2 ##############################################################################
3 # Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others.
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 ##############################################################################
11 ##preping it for deployment and launch the deploy
13 function overcloud_deploy {
14 local num_compute_nodes
15 local num_control_nodes
17 if [[ "${#deploy_options_array[@]}" -eq 0 || "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
18 if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
19 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_l3.yaml"
20 elif [ "${deploy_options_array['sfc']}" == 'True' ]; then
21 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml"
22 elif [ "${deploy_options_array['vpn']}" == 'True' ]; then
23 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml"
24 elif [ "${deploy_options_array['vpp']}" == 'True' ]; then
25 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_fdio.yaml"
26 elif [ "${deploy_options_array['vpn']}" == 'true' ]; then
27 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml"
29 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml"
31 SDN_IMAGE=opendaylight
32 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
34 if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
35 echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute an SFC deployment."
36 echo "Please install the opnfv-apex-opendaylight-sfc package to provide this overcloud image for deployment.${reset}"
40 elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
41 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
42 SDN_IMAGE=opendaylight
43 elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
44 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
45 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos_sfc.yaml"
47 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
50 elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
51 echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
53 elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
54 echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}"
55 SDN_IMAGE=opendaylight
57 echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
58 echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
64 # Make sure the correct overcloud image is available
65 if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
66 echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
67 echo "Both ONOS and OpenDaylight are currently deployed from this image."
68 echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
72 echo "Copying overcloud image to Undercloud"
73 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
74 scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
76 # Install ovs-dpdk inside the overcloud image if it is enabled.
77 if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' || "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
78 # install dpdk packages before ovs
79 echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
81 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
82 cat << EOF > vfio_pci.modules
84 exec /sbin/modprobe vfio_pci >/dev/null 2>&1
87 cat << EOF > uio_pci_generic.modules
89 exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
92 LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
93 --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
94 --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
95 --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
96 -a overcloud-full.qcow2
98 if [ "${deploy_options_array['dataplane']}" == 'fdio' ]; then
99 sudo sed -i '/FdioEnabled:/c\ FdioEnabled: true' /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml
100 if [ "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]; then
101 LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /root/ && tar zxvf networking-odl.tar.gz" \
102 --run-command "cd /root/networking-odl && git init && pip install -r requirements.txt" \
103 --run-command "cd /root/networking-odl && python setup.py build && python setup.py install" \
104 -a overcloud-full.qcow2
107 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/dpdk_rpms/*" \
108 -a overcloud-full.qcow2
112 elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
113 echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
117 if [ "$debug" == 'TRUE' ]; then
118 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex"
121 # Set ODL version accordingly
122 if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then
123 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
124 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
125 --run-command "yum -y install /root/boron/*" \
126 -a overcloud-full.qcow2
130 # Add performance deploy options if they have been set
131 if [ ! -z "${deploy_options_array['performance']}" ]; then
133 # Remove previous kernel args files per role
134 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Compute-kernel_params.txt"
135 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Controller-kernel_params.txt"
137 # Push performance options to subscript to modify per-role images as needed
138 for option in "${performance_options[@]}" ; do
139 echo -e "${blue}Setting performance option $option${reset}"
140 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "bash build_perf_image.sh $option"
143 # Build IPA kernel option ramdisks
144 ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" <<EOI
145 /bin/cp -f /home/stack/ironic-python-agent.initramfs /root/
148 gunzip -c ../ironic-python-agent.initramfs | cpio -i
149 if [ ! -f /home/stack/Compute-kernel_params.txt ]; then
150 touch /home/stack/Compute-kernel_params.txt
151 chown stack /home/stack/Compute-kernel_params.txt
153 /bin/cp -f /home/stack/Compute-kernel_params.txt tmp/kernel_params.txt
154 echo "Compute params set: "
155 cat tmp/kernel_params.txt
156 /bin/cp -f /root/image.py usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.py
157 /bin/cp -f /root/image.pyc usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.pyc
158 find . | cpio -o -H newc | gzip > /home/stack/Compute-ironic-python-agent.initramfs
159 chown stack /home/stack/Compute-ironic-python-agent.initramfs
160 if [ ! -f /home/stack/Controller-kernel_params.txt ]; then
161 touch /home/stack/Controller-kernel_params.txt
162 chown stack /home/stack/Controller-kernel_params.txt
164 /bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt
165 echo "Controller params set: "
166 cat tmp/kernel_params.txt
167 find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs
168 chown stack /home/stack/Controller-ironic-python-agent.initramfs
173 # set NIC heat params and resource registry
174 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
175 sed -i '/TenantNIC:/c\ TenantNIC: '${private_network_compute_interface} opnfv-environment.yaml
176 sed -i '/PublicNIC:/c\ PublicNIC: '${public_network_compute_interface} opnfv-environment.yaml
179 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml"
182 # make sure ceph is installed
183 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
185 # get number of nodes available in inventory
186 num_control_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:control /home/stack/instackenv.json")
187 num_compute_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:compute /home/stack/instackenv.json")
189 # check if HA is enabled
190 if [[ "$ha_enabled" == "True" ]]; then
191 if [ "$num_control_nodes" -lt 3 ]; then
192 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}"
195 DEPLOY_OPTIONS+=" --control-scale ${num_control_nodes}"
196 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
197 echo -e "${blue}INFO: Number of control nodes set for deployment: ${num_control_nodes}${reset}"
200 if [ "$num_control_nodes" -lt 1 ]; then
201 echo -e "${red}ERROR: Number of control nodes in inventory is less than 1: ${num_control_nodes}. Check your inventory file.${reset}"
206 if [ "$num_compute_nodes" -le 0 ]; then
207 echo -e "${red}ERROR: Invalid number of compute nodes: ${num_compute_nodes}. Check your inventory file.${reset}"
210 echo -e "${blue}INFO: Number of compute nodes set for deployment: ${num_compute_nodes}${reset}"
211 DEPLOY_OPTIONS+=" --compute-scale ${num_compute_nodes}"
214 if [[ "$net_isolation_enabled" == "TRUE" ]]; then
215 #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml"
216 DEPLOY_OPTIONS+=" -e network-environment.yaml"
219 if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then
220 DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
223 DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
224 if [[ "$virtual" == "TRUE" ]]; then
225 DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
228 DEPLOY_OPTIONS+=" -e opnfv-environment.yaml"
230 echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
232 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
233 if [ "${deploy_options_array['tacker']}" == 'False' ]; then
234 sed -i '/EnableTacker:/c\ EnableTacker: false' opnfv-environment.yaml
237 # Create a key for use by nova for live migration
238 echo "Creating nova SSH key for nova resize support"
239 ssh-keygen -f nova_id_rsa -b 1024 -P ""
240 public_key=\'\$(cat nova_id_rsa.pub | cut -d ' ' -f 2)\'
241 sed -i "s#replace_public_key:#key: \$public_key#g" opnfv-environment.yaml
242 python -c 'open("opnfv-environment-new.yaml", "w").write((open("opnfv-environment.yaml").read().replace("replace_private_key:", "key: \"" + "".join(open("nova_id_rsa").readlines()).replace("\\n","\\\n") + "\"")))'
243 mv -f opnfv-environment-new.yaml opnfv-environment.yaml
247 # Workaround for APEX-207 where sometimes swift proxy is down
248 if ! sudo systemctl status openstack-swift-proxy > /dev/null; then
249 sudo systemctl restart openstack-swift-proxy
251 echo "Uploading overcloud glance images"
252 openstack overcloud image upload
254 echo "Configuring undercloud and discovering nodes"
255 openstack baremetal import --json instackenv.json
256 openstack baremetal configure boot
257 bash -x set_perf_images.sh ${performance_roles[@]}
258 #if [[ -z "$virtual" ]]; then
259 # openstack baremetal introspection bulk start
261 echo "Configuring flavors"
262 for flavor in baremetal control compute; do
263 echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
264 if openstack flavor list | grep \${flavor}; then
265 openstack flavor delete \${flavor}
267 openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
268 if ! openstack flavor list | grep \${flavor}; then
269 echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
272 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
273 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
274 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
275 echo "Configuring nameserver on ctlplane network"
277 for dns_server in ${dns_servers}; do
278 dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
280 neutron subnet-update \$(neutron subnet-list | grep -Ev "id|tenant|external|storage" | grep -v \\\\-\\\\- | awk {'print \$2'}) \${dns_server_ext}
281 sed -i '/CloudDomain:/c\ CloudDomain: '${domain_name} opnfv-environment.yaml
282 echo "Executing overcloud deployment, this should run for an extended period without output."
283 sleep 60 #wait for Hypervisor stats to check-in to nova
284 # save deploy command so it can be used for debugging
285 cat > deploy_command << EOF
286 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
290 if [ "$interactive" == "TRUE" ]; then
291 if ! prompt_user "Overcloud Deployment"; then
292 echo -e "${blue}INFO: User requests exit${reset}"
297 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
299 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
300 if ! heat stack-list | grep CREATE_COMPLETE 1>/dev/null; then
301 $(typeset -f debug_stack)
308 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
309 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI || (echo "DPDK config failed, exiting..."; exit 1)
312 for node in \$(nova list | grep novacompute | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
313 echo "Running DPDK test app on \$node"
314 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
316 sudo dpdk_helloworld --no-pci
317 sudo dpdk_nic_bind -s
323 if [ "$debug" == 'TRUE' ]; then
324 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
326 echo "Keystone Endpoint List:"
327 openstack endpoint list
328 echo "Keystone Service List"
329 openstack service list
330 cinder quota-show \$(openstack project list | grep admin | awk {'print \$2'})