Adds declaring disk device to use on overcloud nodes
[apex.git] / lib / undercloud-functions.sh
index 3c91850..6f7addb 100755 (executable)
@@ -62,6 +62,7 @@ function setup_undercloud_vm {
         --run-command "cp /root/.ssh/authorized_keys /home/stack/.ssh/" \
         --run-command "chown stack:stack /home/stack/.ssh/authorized_keys && chmod 600 /home/stack/.ssh/authorized_keys"
     virsh start undercloud
+    virsh autostart undercloud
   fi
 
   sleep 10 # let undercloud get started up
@@ -70,12 +71,12 @@ function setup_undercloud_vm {
   CNT=10
   echo -n "${blue}Waiting for Undercloud's dhcp address${reset}"
   undercloud_mac=$(virsh domiflist undercloud | grep default | awk '{ print $5 }')
-  while ! $(arp -e | grep ${undercloud_mac} > /dev/null) && [ $CNT -gt 0 ]; do
+  while ! $(arp -en | grep ${undercloud_mac} > /dev/null) && [ $CNT -gt 0 ]; do
       echo -n "."
       sleep 10
       CNT=$((CNT-1))
   done
-  UNDERCLOUD=$(arp -e | grep ${undercloud_mac} | awk {'print $1'})
+  UNDERCLOUD=$(arp -en | grep ${undercloud_mac} | awk {'print $1'})
 
   if [ -z "$UNDERCLOUD" ]; then
     echo "\n\nCan't get IP for Undercloud. Can Not Continue."
@@ -120,32 +121,31 @@ function configure_undercloud {
   local controller_nic_template compute_nic_template
   echo
   echo "Copying configuration files to Undercloud"
-  if [[ "$net_isolation_enabled" == "TRUE" ]]; then
-    echo -e "${blue}Network Environment set for Deployment: ${reset}"
-    cat $APEX_TMP_DIR/network-environment.yaml
-    scp ${SSH_OPTIONS[@]} $APEX_TMP_DIR/network-environment.yaml "stack@$UNDERCLOUD":
-
-    # check for ODL L3/ONOS
-    if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
-      ext_net_type=br-ex
-    fi
-
-    if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
-      ovs_dpdk_bridge='br-phy'
-    else
-      ovs_dpdk_bridge=''
-    fi
-
-    if ! controller_nic_template=$(python3 -B $LIB/python/apex_python_utils.py nic-template -r controller -s $NETSETS $net_isolation_arg -t $CONFIG/nics-template.yaml.jinja2 -e "br-ex"); then
-      echo -e "${red}ERROR: Failed to generate controller NIC heat template ${reset}"
-      exit 1
-    fi
+  echo -e "${blue}Network Environment set for Deployment: ${reset}"
+  cat $APEX_TMP_DIR/network-environment.yaml
+  scp ${SSH_OPTIONS[@]} $APEX_TMP_DIR/network-environment.yaml "stack@$UNDERCLOUD":
 
-    if ! compute_nic_template=$(python3 -B $LIB/python/apex_python_utils.py nic-template -r compute -s $NETSETS $net_isolation_arg -t $CONFIG/nics-template.yaml.jinja2 -e $ext_net_type -d "$ovs_dpdk_bridge"); then
-      echo -e "${red}ERROR: Failed to generate compute NIC heat template ${reset}"
-      exit 1
-    fi
-    ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
+  # check for ODL L3/ONOS
+  if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
+    ext_net_type=br-ex
+  fi
+
+  if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
+    ovs_dpdk_bridge='br-phy'
+  else
+    ovs_dpdk_bridge=''
+  fi
+
+  if ! controller_nic_template=$(python3 -B $LIB/python/apex_python_utils.py nic-template -r controller -s $NETSETS -t $CONFIG/nics-template.yaml.jinja2 -e "br-ex"); then
+    echo -e "${red}ERROR: Failed to generate controller NIC heat template ${reset}"
+    exit 1
+  fi
+
+  if ! compute_nic_template=$(python3 -B $LIB/python/apex_python_utils.py nic-template -r compute -s $NETSETS -t $CONFIG/nics-template.yaml.jinja2 -e $ext_net_type -d "$ovs_dpdk_bridge"); then
+    echo -e "${red}ERROR: Failed to generate compute NIC heat template ${reset}"
+    exit 1
+  fi
+  ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
 mkdir nics/
 cat > nics/controller.yaml << EOF
 $controller_nic_template
@@ -154,7 +154,6 @@ cat > nics/compute.yaml << EOF
 $compute_nic_template
 EOF
 EOI
-  fi
 
   # ensure stack user on Undercloud machine has an ssh key
   ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "if [ ! -e ~/.ssh/id_rsa.pub ]; then ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa; fi"
@@ -189,26 +188,27 @@ EOI
   echo "Running undercloud configuration."
   echo "Logging undercloud configuration to undercloud:/home/stack/apex-undercloud-install.log"
   ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
-if [[ "$net_isolation_enabled" == "TRUE" ]]; then
-  sed -i 's/#local_ip/local_ip/' undercloud.conf
-  sed -i 's/#network_gateway/network_gateway/' undercloud.conf
-  sed -i 's/#network_cidr/network_cidr/' undercloud.conf
-  sed -i 's/#dhcp_start/dhcp_start/' undercloud.conf
-  sed -i 's/#dhcp_end/dhcp_end/' undercloud.conf
-  sed -i 's/#inspection_iprange/inspection_iprange/' undercloud.conf
-  sed -i 's/#undercloud_debug/undercloud_debug/' undercloud.conf
-
-  openstack-config --set undercloud.conf DEFAULT local_ip ${admin_installer_vm_ip}/${admin_cidr##*/}
-  openstack-config --set undercloud.conf DEFAULT network_gateway ${admin_installer_vm_ip}
-  openstack-config --set undercloud.conf DEFAULT network_cidr ${admin_cidr}
-  openstack-config --set undercloud.conf DEFAULT dhcp_start ${admin_dhcp_range%%,*}
-  openstack-config --set undercloud.conf DEFAULT dhcp_end ${admin_dhcp_range##*,}
-  openstack-config --set undercloud.conf DEFAULT inspection_iprange ${admin_introspection_range}
-  openstack-config --set undercloud.conf DEFAULT undercloud_debug false
-  openstack-config --set undercloud.conf DEFAULT undercloud_hostname "undercloud.${domain_name}"
-  sudo openstack-config --set /etc/ironic/ironic.conf disk_utils iscsi_verify_attempts 30
-  sudo openstack-config --set /etc/ironic/ironic.conf disk_partitioner check_device_max_retries 40
-
+sed -i 's/#local_ip/local_ip/' undercloud.conf
+sed -i 's/#network_gateway/network_gateway/' undercloud.conf
+sed -i 's/#network_cidr/network_cidr/' undercloud.conf
+sed -i 's/#dhcp_start/dhcp_start/' undercloud.conf
+sed -i 's/#dhcp_end/dhcp_end/' undercloud.conf
+sed -i 's/#inspection_iprange/inspection_iprange/' undercloud.conf
+sed -i 's/#undercloud_debug/undercloud_debug/' undercloud.conf
+
+openstack-config --set undercloud.conf DEFAULT local_ip ${admin_installer_vm_ip}/${admin_cidr##*/}
+openstack-config --set undercloud.conf DEFAULT network_gateway ${admin_installer_vm_ip}
+openstack-config --set undercloud.conf DEFAULT network_cidr ${admin_cidr}
+openstack-config --set undercloud.conf DEFAULT dhcp_start ${admin_dhcp_range%%,*}
+openstack-config --set undercloud.conf DEFAULT dhcp_end ${admin_dhcp_range##*,}
+openstack-config --set undercloud.conf DEFAULT inspection_iprange ${admin_introspection_range}
+openstack-config --set undercloud.conf DEFAULT undercloud_debug false
+openstack-config --set undercloud.conf DEFAULT undercloud_hostname "undercloud.${domain_name}"
+sudo openstack-config --set /etc/ironic/ironic.conf disk_utils iscsi_verify_attempts 30
+sudo openstack-config --set /etc/ironic/ironic.conf disk_partitioner check_device_max_retries 40
+
+if [[ -n "${deploy_options_array['ceph_device']}" ]]; then
+    sed -i '/ExtraConfig/a\\    ceph::profile::params::osds: {\\x27${deploy_options_array['ceph_device']}\\x27: {}}' ${ENV_FILE}
 fi
 
 sudo sed -i '/CephClusterFSID:/c\\  CephClusterFSID: \\x27$(cat /proc/sys/kernel/random/uuid)\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
@@ -253,6 +253,7 @@ sudo systemctl restart openstack-heat-api
 EOI
 
 # configure external network
+if [[ "$enabled_network_list" =~ "external" ]]; then
   ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" << EOI
 if [[ "$external_installer_vm_vlan" != "native" ]]; then
   cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-vlan${external_installer_vm_vlan}
@@ -274,6 +275,7 @@ else
   fi
 fi
 EOI
+fi
 
 # WORKAROUND: must restart the above services to fix sync problem with nova compute manager
 # TODO: revisit and file a bug if necessary. This should eventually be removed