Fixing zrpcd is not starting
[apex.git] / lib / overcloud-deploy-functions.sh
1 #!/usr/bin/env bash
2 ##############################################################################
3 # Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 ##preping it for deployment and launch the deploy
12 ##params: none
13 function overcloud_deploy {
14   local num_compute_nodes
15   local num_control_nodes
16   local dpdk_cores pmd_cores socket_mem ovs_dpdk_perf_flag ovs_option_heat_arr
17   declare -A ovs_option_heat_arr
18
19   ovs_option_heat_arr['dpdk_cores']=OvsDpdkCoreList
20   ovs_option_heat_arr['pmd_cores']=PmdCoreList
21   ovs_option_heat_arr['socket_memory']=OvsDpdkSocketMemory
22
23   # OPNFV Default Environment and Network settings
24   DEPLOY_OPTIONS+=" -e ${ENV_FILE}"
25   DEPLOY_OPTIONS+=" -e network-environment.yaml"
26
27   # Custom Deploy Environment Templates
28   if [[ "${#deploy_options_array[@]}" -eq 0 || "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
29     if [ "${deploy_options_array['sfc']}" == 'True' ]; then
30       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml"
31     elif [ "${deploy_options_array['vpn']}" == 'True' ]; then
32       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-bgpvpn.yaml"
33       if [ "${deploy_options_array['gluon']}" == 'True' ]; then
34         DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/services/gluon.yaml"
35       fi
36     elif [ "${deploy_options_array['vpp']}" == 'True' ]; then
37       if [ "${deploy_options_array['odl_vpp_netvirt']}" == "True" ]; then
38         DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-netvirt-vpp.yaml"
39       elif [ "${deploy_options_array['sdn_l3']}" == "True" ]; then
40         DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb.yaml"
41       else
42         DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb-l2.yaml"
43       fi
44     else
45       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-l3.yaml"
46     fi
47     SDN_IMAGE=opendaylight
48   elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
49     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
50     SDN_IMAGE=opendaylight
51   elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
52     echo -e "${red}ERROR: ONOS is unsupported in Danube...exiting${reset}"
53     exit 1
54     #if [ "${deploy_options_array['sfc']}" == 'True' ]; then
55     #  DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos_sfc.yaml"
56     #else
57     #  DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
58     #fi
59     #SDN_IMAGE=onos
60   elif [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
61     if [[ "$ha_enabled" == "True" ]]; then
62       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn-ha.yaml"
63       echo "${red}OVN HA support is not not supported... exiting.${reset}"
64       exit 1
65     else
66       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn.yaml"
67     fi
68     SDN_IMAGE=opendaylight
69   elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
70     echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
71     exit 1
72   elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
73     echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}"
74     if [ "${deploy_options_array['vpp']}" == 'True' ]; then
75       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-vpp.yaml"
76     elif [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
77       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ovs-dpdk.yaml"
78     fi
79     SDN_IMAGE=opendaylight
80   else
81     echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
82     echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
83     exit 1
84   fi
85
86   # Enable Tacker
87   if [ "${deploy_options_array['tacker']}" == 'True' ]; then
88     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/enable_tacker.yaml"
89   fi
90
91   # Enable Congress
92   if [ "${deploy_options_array['congress']}" == 'True' ]; then
93     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/enable_congress.yaml"
94   fi
95
96   # Enable Real Time Kernel (kvm4nfv)
97   if [ "${deploy_options_array['rt_kvm']}" == 'True' ]; then
98     DEPLOY_OPTIONS+=" -e /home/stack/enable_rt_kvm.yaml"
99   fi
100
101   # Make sure the correct overcloud image is available
102   if [ ! -f $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
103       echo "${red} $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
104       echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
105       exit 1
106   fi
107
108   echo "Copying overcloud image to Undercloud"
109   ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
110   scp ${SSH_OPTIONS[@]} $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
111
112   # disable neutron openvswitch agent from starting
113   if [[ -n "${deploy_options_array['sdn_controller']}" && "${deploy_options_array['sdn_controller']}" != 'False' ]]; then
114       echo -e "${blue}INFO: Disabling neutron-openvswitch-agent from systemd${reset}"
115       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
116       LIBGUESTFS_BACKEND=direct virt-customize --run-command "rm -f /etc/systemd/system/multi-user.target.wants/neutron-openvswitch-agent.service" \
117                                                --run-command "rm -f /usr/lib/systemd/system/neutron-openvswitch-agent.service" \
118                                                -a overcloud-full.qcow2
119 EOI
120   fi
121
122   if [ "${deploy_options_array['vpn']}" == 'True' ]; then
123       echo -e "${blue}INFO: Enabling ZRPC and Quagga${reset}"
124       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
125       LIBGUESTFS_BACKEND=direct virt-customize \
126          --run-command "cd /root/quagga; packages=\\\$(ls |grep -vE 'debuginfo|devel|contrib'); yum -y install \\\$packages" \
127          --run-command "sudo usermod -a -G quaggavt quagga" \
128          --run-command "systemctl enable zrpcd" \
129          -a overcloud-full.qcow2
130 EOI
131   fi
132
133   # Install ovs-dpdk inside the overcloud image if it is enabled.
134   if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' || "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
135     # install dpdk packages before ovs
136     echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
137
138     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
139       cat << EOF > vfio_pci.modules
140 #!/bin/bash
141 exec /sbin/modprobe vfio_pci >/dev/null 2>&1
142 EOF
143
144       cat << EOF > uio_pci_generic.modules
145 #!/bin/bash
146 exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
147 EOF
148
149       LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
150                                                --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
151                                                --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
152                                                --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
153                                                -a overcloud-full.qcow2
154
155       if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
156         sed -i "/OS::TripleO::ComputeExtraConfigPre:/c\  OS::TripleO::ComputeExtraConfigPre: ./ovs-dpdk-preconfig.yaml" network-environment.yaml
157       fi
158
159 EOI
160
161   elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
162     echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
163     exit 1
164   fi
165
166   if [ "$debug" == 'TRUE' ]; then
167     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex"
168   fi
169
170   # upgrade ovs into ovs 2.5.90 with NSH function if SFC is enabled
171   if [[ "${deploy_options_array['sfc']}" == 'True' && "${deploy_options_array['dataplane']}" == 'ovs' ]]; then
172     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
173          LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_kmod_rpm_name}" \
174                                                   --run-command "yum upgrade -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_rpm_name}" \
175                                                   -a overcloud-full.qcow2
176 EOI
177   fi
178
179   # Patch neutron with using OVS external interface for router and add generic linux NS interface driver
180   if [[ "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
181     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
182       LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /usr/lib/python2.7/site-packages/ && patch -p1 < neutron-patch-NSDriver.patch" \
183                                                -a overcloud-full.qcow2
184 EOI
185
186     # Disable clustering for ODL FDIO HA scenarios
187     if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
188       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
189       LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /etc/puppet/modules/tripleo/ && patch -p1 < disable_odl_clustering.patch" \
190                                                -a overcloud-full.qcow2
191 EOI
192     fi
193
194     # Configure routing node for odl-fdio
195     if [[ "${deploy_options_array['sdn_l3']}" == 'True' ]]; then
196       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
197         sed -i "/opendaylight::vpp_routing_node:/c\    opendaylight::vpp_routing_node: ${deploy_options_array['odl_vpp_routing_node']}.${domain_name}" ${ENV_FILE}
198 EOI
199     fi
200   fi
201
202   if [ -n "${deploy_options_array['performance']}" ]; then
203     ovs_dpdk_perf_flag="False"
204     for option in "${performance_options[@]}" ; do
205       if [ "${arr[1]}" == "vpp" ]; then
206         if [ "${arr[0]}" == "Compute" ]; then
207           role='NovaCompute'
208         else
209           role=${arr[0]}
210         fi
211         if [ "${arr[2]}" == "main-core" ]; then
212           ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
213             sed -i "/${role}ExtraConfig:/ c\  ${role}ExtraConfig:\n    fdio::vpp_cpu_main_core: \"'${arr[3]}'\"" ${ENV_FILE}
214 EOI
215         elif [ "${arr[2]}" == "corelist-workers" ]; then
216           ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
217             sed -i "/${role}ExtraConfig:/ c\  ${role}ExtraConfig:\n    fdio::vpp_cpu_corelist_workers: \"'${arr[3]}'\"" ${ENV_FILE}
218 EOI
219         fi
220       fi
221       arr=($option)
222       # use compute's kernel settings for all nodes for now.
223       if [ "${arr[0]}" == "Compute" ] && [ "${arr[1]}" == "kernel" ]; then
224         kernel_args+=" ${arr[2]}=${arr[3]}"
225       fi
226       if [ "${arr[0]}" == "Compute" ] && [ "${arr[1]}" == "ovs" ]; then
227          eval "${arr[2]}=${arr[3]}"
228          ovs_dpdk_perf_flag="True"
229       fi
230     done
231
232     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
233       sed -i "/ComputeKernelArgs:/c\  ComputeKernelArgs: '$kernel_args'" ${ENV_FILE}
234       sed -i "$ a\resource_registry:\n  OS::TripleO::NodeUserData: first-boot.yaml" ${ENV_FILE}
235       sed -i "/NovaSchedulerDefaultFilters:/c\  NovaSchedulerDefaultFilters: 'RamFilter,ComputeFilter,AvailabilityZoneFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,NUMATopologyFilter'" ${ENV_FILE}
236 EOI
237
238     if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' && "$ovs_dpdk_perf_flag" == "True" ]]; then
239       for ovs_option in ${!ovs_option_heat_arr[@]}; do
240         if [ -n "${!ovs_option}" ]; then
241           ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
242             sed -i "/${ovs_option_heat_arr[$ovs_option]}:/c\  ${ovs_option_heat_arr[$ovs_option]}: ${!ovs_option}" ${ENV_FILE}
243 EOI
244         fi
245       done
246     fi
247   fi
248
249   if [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
250     if [ "${deploy_options_array['dataplane']}" == "fdio" ]; then
251       if [ "$tenant_nic_mapping_controller_members" == "$tenant_nic_mapping_compute_members" ]; then
252         echo -e "${blue}INFO: nosdn fdio deployment...installing correct vpp packages...${reset}"
253         ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
254           sed -i "/NeutronVPPAgentPhysnets:/c\  NeutronVPPAgentPhysnets: 'datacentre:${tenant_nic_mapping_controller_members}'" ${ENV_FILE}
255           LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum remove -y vpp vpp-api-python vpp-lib vpp-plugins" \
256                                                    --run-command "yum install -y /root/fdio_nosdn/*.rpm" \
257                                                    --run-command "rm -f /etc/sysctl.d/80-vpp.conf" \
258                                                    -a overcloud-full.qcow2
259 EOI
260       else
261         echo -e "${red}Compute and Controller must use the same tenant nic name, please modify network setting file.${reset}"
262         exit 1
263       fi
264     fi
265   fi
266
267   # Set ODL version accordingly
268   if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && -n "${deploy_options_array['odl_version']}" ]]; then
269     case "${deploy_options_array['odl_version']}" in
270       beryllium) odl_version=''
271               ;;
272       boron)  odl_version='boron'
273               ;;
274       carbon) odl_version='master'
275               ;;
276       *) echo -e "${red}Invalid ODL version ${deploy_options_array['odl_version']}.  Please use 'carbon' or 'boron' values.${reset}"
277          exit 1
278          ;;
279     esac
280
281     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
282       LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
283                                                --run-command "yum -y install /root/${odl_version}/*" \
284                                                -a overcloud-full.qcow2
285 EOI
286   fi
287
288   # Override ODL if FDIO and ODL L2
289   if [[ "${deploy_options_array['vpp']}" == 'True' && "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
290     if [ "${deploy_options_array['sdn_l3']}" == "False" ]; then
291       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
292          LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
293                                                   --run-command "yum -y install /root/fdio_l2/opendaylight*.rpm" \
294                                                   -a overcloud-full.qcow2
295 EOI
296     else
297       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
298          LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum remove -y vpp vpp-api-python vpp-lib vpp-plugins honeycomb" \
299                                                   --run-command "yum -y install /root/fdio_l3/*.rpm" \
300                                                   --run-command "rm -f /etc/sysctl.d/80-vpp.conf" \
301                                                   -a overcloud-full.qcow2
302 EOI
303     fi
304     if [ "${deploy_options_array['odl_vpp_netvirt']}" == "True" ]; then
305       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
306         LIBGUESTFS_BACKEND=direct virt-customize --run-command "rm -rf /opt/opendaylight/*" \
307                                                  --run-command "tar zxvf /root/odl-netvirt-vpp-distribution.tar.gz -C /opt/opendaylight/" \
308                                                  -a overcloud-full.qcow2
309 EOI
310     fi
311   fi
312
313   # check if ceph should be enabled
314   if [ "${deploy_options_array['ceph']}" == 'True' ]; then
315     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
316   fi
317
318   if [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
319     # The epoch in deloran's ovs is 1: and in leif's is 0:
320     # so we have to execute a downgrade instead of an update
321     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
322       LIBGUESTFS_BACKEND=direct virt-customize \
323         --run-command "cd /root/ovs27 && yum update -y *openvswitch*" \
324         --run-command "cd /root/ovs27 && yum downgrade -y *openvswitch*" \
325         -a overcloud-full.qcow2
326 EOI
327   fi
328
329   # get number of nodes available in inventory
330   num_control_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:control /home/stack/instackenv.json")
331   num_compute_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:compute /home/stack/instackenv.json")
332
333   # check if HA is enabled
334   if [[ "$ha_enabled" == "True" ]]; then
335     if [ "$num_control_nodes" -lt 3 ]; then
336       echo -e "${red}ERROR: Number of control nodes in inventory is less than 3 and HA is enabled: ${num_control_nodes}. Check your inventory file.${reset}"
337       exit 1
338     else
339      DEPLOY_OPTIONS+=" --control-scale ${num_control_nodes}"
340      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
341      echo -e "${blue}INFO: Number of control nodes set for deployment: ${num_control_nodes}${reset}"
342     fi
343   else
344     if [ "$num_control_nodes" -lt 1 ]; then
345       echo -e "${red}ERROR: Number of control nodes in inventory is less than 1: ${num_control_nodes}. Check your inventory file.${reset}"
346       exit 1
347     fi
348   fi
349
350   if [ "$num_compute_nodes" -le 0 ]; then
351     echo -e "${red}ERROR: Invalid number of compute nodes: ${num_compute_nodes}. Check your inventory file.${reset}"
352     exit 1
353   else
354     echo -e "${blue}INFO: Number of compute nodes set for deployment: ${num_compute_nodes}${reset}"
355     DEPLOY_OPTIONS+=" --compute-scale ${num_compute_nodes}"
356   fi
357
358   DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
359
360   DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
361   if [[ "$virtual" == "TRUE" ]]; then
362      DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
363   fi
364
365   echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
366
367   ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
368 # Create a key for use by nova for live migration
369 echo "Creating nova SSH key for nova resize support"
370 ssh-keygen -f nova_id_rsa -b 1024 -P ""
371 public_key=\'\$(cat nova_id_rsa.pub | cut -d ' ' -f 2)\'
372 sed -i "s#replace_public_key:#key: \$public_key#g" ${ENV_FILE}
373 python -c 'open("opnfv-environment-new.yaml", "w").write((open("${ENV_FILE}").read().replace("replace_private_key:", "key: \"" + "".join(open("nova_id_rsa").readlines()).replace("\\n","\\\n") + "\"")))'
374 mv -f opnfv-environment-new.yaml ${ENV_FILE}
375
376 source stackrc
377 set -o errexit
378 # Workaround for APEX-207 where sometimes swift proxy is down
379 if ! sudo systemctl status openstack-swift-proxy > /dev/null; then
380   sudo systemctl restart openstack-swift-proxy
381 fi
382 echo "Uploading overcloud glance images"
383 openstack overcloud image upload
384
385 echo "Configuring undercloud and discovering nodes"
386 openstack baremetal import --json instackenv.json
387
388 if [[ -z "$virtual" ]]; then
389   openstack baremetal introspection bulk start
390   if [[ -n "$root_disk_list" ]]; then
391     openstack baremetal configure boot --root-device=${root_disk_list}
392   else
393     openstack baremetal configure boot
394   fi
395 else
396   openstack baremetal configure boot
397 fi
398
399 echo "Configuring flavors"
400 for flavor in baremetal control compute; do
401   echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
402   if openstack flavor list | grep \${flavor}; then
403     openstack flavor delete \${flavor}
404   fi
405   openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
406   if ! openstack flavor list | grep \${flavor}; then
407     echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
408   fi
409 done
410 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
411 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
412 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
413 echo "Configuring nameserver on ctlplane network"
414 dns_server_ext=''
415 for dns_server in ${dns_servers}; do
416   dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
417 done
418 neutron subnet-update \$(neutron subnet-list | grep -Ev "id|tenant|external|storage" | grep -v \\\\-\\\\- | awk {'print \$2'}) \${dns_server_ext}
419 sed -i '/CloudDomain:/c\  CloudDomain: '${domain_name} ${ENV_FILE}
420 echo "Executing overcloud deployment, this should run for an extended period without output."
421 sleep 60 #wait for Hypervisor stats to check-in to nova
422 # save deploy command so it can be used for debugging
423 cat > deploy_command << EOF
424 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
425 EOF
426 EOI
427
428   if [ "$interactive" == "TRUE" ]; then
429     if ! prompt_user "Overcloud Deployment"; then
430       echo -e "${blue}INFO: User requests exit${reset}"
431       exit 0
432     fi
433   fi
434
435   ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
436 source stackrc
437 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
438 if ! openstack stack list | grep CREATE_COMPLETE 1>/dev/null; then
439   $(typeset -f debug_stack)
440   debug_stack
441   exit 1
442 fi
443 EOI
444
445   # Configure DPDK and restart ovs agent after bringing up br-phy
446   if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
447     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI || (echo "DPDK config failed, exiting..."; exit 1)
448 source stackrc
449 set -o errexit
450 for node in \$(nova list | grep novacompute | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
451 echo "Checking DPDK status and bringing up br-phy on \$node"
452 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
453 set -o errexit
454 sudo dpdk-devbind -s
455 sudo ifup br-phy
456 if [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
457   echo "Restarting openvswitch agent to pick up VXLAN tunneling"
458   sudo systemctl restart neutron-openvswitch-agent
459 fi
460 EOF
461 done
462 EOI
463   fi
464
465   if [ "$debug" == 'TRUE' ]; then
466       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
467 source overcloudrc
468 echo "Keystone Endpoint List:"
469 openstack endpoint list
470 echo "Keystone Service List"
471 openstack service list
472 EOI
473   fi
474 }