Various fixes and improvements 55/8355/1
authorTim Rozet <trozet@redhat.com>
Thu, 28 Jan 2016 20:03:51 +0000 (15:03 -0500)
committerTim Rozet <trozet@redhat.com>
Thu, 28 Jan 2016 20:11:16 +0000 (15:11 -0500)
Changes Include:
 - New Interactive mode.  Allows you to pause deployments in order to
make changes before continuing (or exit and deploy manually).  Useful
when needing to modify NIC order for baremetal deployments.
 - deploy_settings -d is now required.
 - ha_enabled no longer defaults to true.  It can be specified in
deploy_settings or overridden with via command line.
 - compute nodes now scale correctly with what is defined by inventory

JIRA: APEX-70 APEX-71 APEX-72

Change-Id: Id45808f4d0435d66f12c020bd4455faaa43da191
Signed-off-by: Tim Rozet <trozet@redhat.com>
ci/deploy.sh
lib/common-functions.sh

index d0b8338..a2c9c43 100755 (executable)
@@ -30,7 +30,8 @@ else
 fi
 
 vm_index=4
-ha_enabled="TRUE"
+#ha_enabled="TRUE"
+interactive="FALSE"
 ping_site="8.8.8.8"
 ntp_server="pool.ntp.org"
 net_isolation_enabled="TRUE"
@@ -811,10 +812,24 @@ function undercloud_prep_overcloud_deploy {
   # make sure ceph is installed
   DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
 
+  # scale compute nodes according to inventory
+  total_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/instackenv.json | grep -c memory")
+
   # check if HA is enabled
   if [[ "$ha_enabled" == "TRUE" ]]; then
-     DEPLOY_OPTIONS+=" --control-scale 3 --compute-scale 2"
+     DEPLOY_OPTIONS+=" --control-scale 3"
+     compute_nodes=$((total_nodes - 3))
      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
+  else
+     compute_nodes=$((total_nodes - 1))
+  fi
+
+  if [ "$compute_nodes" -le 0 ]; then
+    echo -e "${red}ERROR: Invalid number of compute nodes: ${compute_nodes}. Check your inventory file.${reset}"
+    exit 1
+  else
+    echo -e "${blue}INFO: Number of compute nodes set for deployment: ${compute_nodes}${reset}"
+    DEPLOY_OPTIONS+=" --compute-scale ${compute_nodes}"
   fi
 
   if [[ "$net_isolation_enabled" == "TRUE" ]]; then
@@ -865,6 +880,18 @@ sleep 60 #wait for Hypervisor stats to check-in to nova
 cat > deploy_command << EOF
 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
 EOF
+EOI
+
+  if [ "$interactive" == "TRUE" ]; then
+    if ! prompt_user "Overcloud Deployment"; then
+      echo -e "${blue}INFO: User requests exit${reset}"
+      exit 0
+    fi
+  fi
+
+  ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+source stackrc
+set -o errexit
 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
 EOI
 
@@ -944,6 +971,7 @@ display_usage() {
   echo -e "   --flat : disable Network Isolation and use a single flat network for the underlay network.\n"
   echo -e "   --no-post-config : disable Post Install configuration."
   echo -e "   --debug : enable debug output."
+  echo -e "   --interactive : enable interactive deployment mode which requires user to confirm steps of deployment."
 }
 
 ##translates the command line parameters into variables
@@ -1015,6 +1043,11 @@ parse_cmdline() {
                 echo "Enable debug output"
                 shift 1
             ;;
+        --interactive )
+                interactive="TRUE"
+                echo "Interactive mode enabled"
+                shift 1
+            ;;
         *)
                 display_usage
                 exit 1
@@ -1034,18 +1067,18 @@ parse_cmdline() {
     exit 1
   fi
 
-  if [[ ! -z "$DEPLOY_SETTINGS_FILE" && ! -f "$DEPLOY_SETTINGS_FILE" ]]; then
-    echo -e "${red}ERROR: ${DEPLOY_SETTINGS_FILE} does not exist! Exiting...${reset}"
+  if [[ -z "$DEPLOY_SETTINGS_FILE" || ! -f "$DEPLOY_SETTINGS_FILE" ]]; then
+    echo -e "${red}ERROR: Deploy Settings: ${DEPLOY_SETTINGS_FILE} does not exist! Exiting...${reset}"
     exit 1
   fi
 
   if [[ ! -z "$NETSETS" && ! -f "$NETSETS" ]]; then
-    echo -e "${red}ERROR: ${NETSETS} does not exist! Exiting...${reset}"
+    echo -e "${red}ERROR: Network Settings: ${NETSETS} does not exist! Exiting...${reset}"
     exit 1
   fi
 
   if [[ ! -z "$INVENTORY_FILE" && ! -f "$INVENTORY_FILE" ]]; then
-    echo -e "{$red}ERROR: ${DEPLOY_SETTINGS_FILE} does not exist! Exiting...${reset}"
+    echo -e "{$red}ERROR: Inventory File: ${INVENTORY_FILE} does not exist! Exiting...${reset}"
     exit 1
   fi
 
index 7435411..0b1eb7d 100644 (file)
@@ -544,3 +544,19 @@ iptables -A FORWARD -s ${external_cidr} -m state --state ESTABLISHED,RELATED -j
 service iptables save
 EOI
 }
+
+# Interactive prompt handler
+# params: step stage, ex. deploy, undercloud install, etc
+function prompt_user {
+  while [ 1 ]; do
+    echo -n "Would you like to proceed with ${1}? (y/n) "
+    read response
+    if [ "$response" == 'y' ]; then
+      return 0
+    elif [ "$response" == 'n' ]; then
+      return 1
+    else
+      continue
+    fi
+  done
+}