From ba7c8ff52b1fa9246ef39d9a291e620af9b095da Mon Sep 17 00:00:00 2001
From: Alexander Lutay <alutay@sipwise.com>
Date: Thu, 26 Jan 2017 12:52:00 +0100
Subject: [PATCH] TT#7473 Ask user confirmation to use 'unsupported' disk

It is impossible to install puppet node on plain SSD drive:
> Error: /dev/sdc does not look like a VirtIO, ServeRAID, LSILOGIC or PowerEdge disk/controller. Exiting to avoid possible data damage.

Lets ask the user confirmation here, as restart installation
is very slow way in case of manual bonding configuration and
slow IBM hardware POST.

The boot option TARGET_DISK can be used to bypass any checks here.

Change-Id: I6ace2c0225b7e66896a00459594901d06ae7bf0c
---
 deployment.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/deployment.sh b/deployment.sh
index 43783b6..afdf99e 100755
--- a/deployment.sh
+++ b/deployment.sh
@@ -1049,6 +1049,27 @@ check_for_supported_disk() {
     return 0
   fi
 
+  local disk_model
+  disk_model=$(cat "/sys/block/${DISK}/device/model") || true
+  local disk_vendor
+  disk_vendor=$(cat "/sys/block/${DISK}/device/vendor") || true
+
+  echo "WARNING: Cannot detect supported device vendor/model." >&2
+  echo "(Disk: ${DISK}  Vendor: ${disk_vendor}  Model: ${disk_model})" >&2
+  echo "Would you like to continue anyway? (yes/NO)" >&2
+  read a
+  case "$a" in
+    y|Y|yes|YES)
+      echo "Continue anyway as requested."
+      return 0
+      ;;
+    *)
+      echo "Aborting installation using disk '${DISK}'" >&2
+      return 1
+      ;;
+  esac
+  unset a
+
   # no match so far?
   return 1
 }