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 if [[ "${#deploy_options_array[@]}" -eq 0 || "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
15 if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
16 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_l3.yaml"
17 elif [ "${deploy_options_array['sfc']}" == 'True' ]; then
18 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml"
19 elif [ "${deploy_options_array['vpn']}" == 'True' ]; then
20 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml"
21 elif [ "${deploy_options_array['vpp']}" == 'True' ]; then
22 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_fdio.yaml"
23 elif [ "${deploy_options_array['vpn']}" == 'true' ]; then
24 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml"
26 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml"
28 SDN_IMAGE=opendaylight
29 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
31 if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
32 echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute an SFC deployment."
33 echo "Please install the opnfv-apex-opendaylight-sfc package to provide this overcloud image for deployment.${reset}"
37 elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
38 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
39 SDN_IMAGE=opendaylight
40 elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
41 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
42 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos_sfc.yaml"
44 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
47 elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
48 echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
50 elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
51 echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}"
52 SDN_IMAGE=opendaylight
54 echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
55 echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
61 # Make sure the correct overcloud image is available
62 if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
63 echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
64 echo "Both ONOS and OpenDaylight are currently deployed from this image."
65 echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
69 echo "Copying overcloud image to Undercloud"
70 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
71 scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
73 # Install ovs-dpdk inside the overcloud image if it is enabled.
74 if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' || "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
75 # install dpdk packages before ovs
76 echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
78 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
79 cat << EOF > vfio_pci.modules
81 exec /sbin/modprobe vfio_pci >/dev/null 2>&1
84 cat << EOF > uio_pci_generic.modules
86 exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
89 LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
90 --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
91 --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
92 --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
93 -a overcloud-full.qcow2
95 if [ "${deploy_options_array['dataplane']}" == 'fdio' ]; then
96 sudo sed -i '/FdioEnabled:/c\ FdioEnabled: true' /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml
97 if [ "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]; then
98 LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /root/ && tar zxvf networking-odl.tar.gz" \
99 --run-command "cd /root/networking-odl && git init && pip install -r requirements.txt" \
100 --run-command "cd /root/networking-odl && python setup.py build && python setup.py install" \
101 -a overcloud-full.qcow2
104 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/dpdk_rpms/*" \
105 -a overcloud-full.qcow2
109 elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
110 echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
114 if [ "$debug" == 'TRUE' ]; then
115 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex"
118 # Set ODL version accordingly
119 if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then
120 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
121 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
122 --run-command "yum -y install /root/boron/*" \
123 -a overcloud-full.qcow2
127 # Add performance deploy options if they have been set
128 if [ ! -z "${deploy_options_array['performance']}" ]; then
130 # Remove previous kernel args files per role
131 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Compute-kernel_params.txt"
132 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Controller-kernel_params.txt"
134 # Push performance options to subscript to modify per-role images as needed
135 for option in "${performance_options[@]}" ; do
136 echo -e "${blue}Setting performance option $option${reset}"
137 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "bash build_perf_image.sh $option"
140 # Build IPA kernel option ramdisks
141 ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" <<EOI
142 /bin/cp -f /home/stack/ironic-python-agent.initramfs /root/
145 gunzip -c ../ironic-python-agent.initramfs | cpio -i
146 if [ ! -f /home/stack/Compute-kernel_params.txt ]; then
147 touch /home/stack/Compute-kernel_params.txt
148 chown stack /home/stack/Compute-kernel_params.txt
150 /bin/cp -f /home/stack/Compute-kernel_params.txt tmp/kernel_params.txt
151 echo "Compute params set: "
152 cat tmp/kernel_params.txt
153 /bin/cp -f /root/image.py usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.py
154 /bin/cp -f /root/image.pyc usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.pyc
155 find . | cpio -o -H newc | gzip > /home/stack/Compute-ironic-python-agent.initramfs
156 chown stack /home/stack/Compute-ironic-python-agent.initramfs
157 if [ ! -f /home/stack/Controller-kernel_params.txt ]; then
158 touch /home/stack/Controller-kernel_params.txt
159 chown stack /home/stack/Controller-kernel_params.txt
161 /bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt
162 echo "Controller params set: "
163 cat tmp/kernel_params.txt
164 find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs
165 chown stack /home/stack/Controller-ironic-python-agent.initramfs
170 # set NIC heat params and resource registry
171 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
172 sed -i '/TenantNIC:/c\ TenantNIC: '${private_network_compute_interface} opnfv-environment.yaml
173 sed -i '/PublicNIC:/c\ PublicNIC: '${public_network_compute_interface} opnfv-environment.yaml
176 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml"
179 # make sure ceph is installed
180 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
182 # scale compute nodes according to inventory
183 total_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/instackenv.json | grep -c memory")
185 # check if HA is enabled
186 if [[ "$ha_enabled" == "True" ]]; then
187 DEPLOY_OPTIONS+=" --control-scale 3"
188 compute_nodes=$((total_nodes - 3))
189 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
191 compute_nodes=$((total_nodes - 1))
194 if [ "$compute_nodes" -le 0 ]; then
195 echo -e "${red}ERROR: Invalid number of compute nodes: ${compute_nodes}. Check your inventory file.${reset}"
198 echo -e "${blue}INFO: Number of compute nodes set for deployment: ${compute_nodes}${reset}"
199 DEPLOY_OPTIONS+=" --compute-scale ${compute_nodes}"
202 if [[ "$net_isolation_enabled" == "TRUE" ]]; then
203 #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml"
204 DEPLOY_OPTIONS+=" -e network-environment.yaml"
207 if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then
208 DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
211 DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
212 if [[ "$virtual" == "TRUE" ]]; then
213 DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
216 DEPLOY_OPTIONS+=" -e opnfv-environment.yaml"
218 echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
220 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
221 if [ "${deploy_options_array['tacker']}" == 'False' ]; then
222 sed -i '/EnableTacker:/c\ EnableTacker: false' opnfv-environment.yaml
225 # Create a key for use by nova for live migration
226 echo "Creating nova SSH key for nova resize support"
227 ssh-keygen -f nova_id_rsa -b 1024 -P ""
228 public_key=\'\$(cat nova_id_rsa.pub | cut -d ' ' -f 2)\'
229 sed -i "s#replace_public_key:#key: \$public_key#g" opnfv-environment.yaml
230 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") + "\"")))'
231 mv -f opnfv-environment-new.yaml opnfv-environment.yaml
235 # Workaround for APEX-207 where sometimes swift proxy is down
236 if ! sudo systemctl status openstack-swift-proxy > /dev/null; then
237 sudo systemctl restart openstack-swift-proxy
239 echo "Uploading overcloud glance images"
240 openstack overcloud image upload
242 echo "Configuring undercloud and discovering nodes"
243 openstack baremetal import --json instackenv.json
244 openstack baremetal configure boot
245 bash -x set_perf_images.sh ${performance_roles[@]}
246 #if [[ -z "$virtual" ]]; then
247 # openstack baremetal introspection bulk start
249 echo "Configuring flavors"
250 for flavor in baremetal control compute; do
251 echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
252 if openstack flavor list | grep \${flavor}; then
253 openstack flavor delete \${flavor}
255 openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
256 if ! openstack flavor list | grep \${flavor}; then
257 echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
260 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
261 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
262 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
263 echo "Configuring nameserver on ctlplane network"
265 for dns_server in ${dns_servers}; do
266 dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
268 neutron subnet-update \$(neutron subnet-list | grep -Ev "id|tenant|external|storage" | grep -v \\\\-\\\\- | awk {'print \$2'}) \${dns_server_ext}
269 sed -i '/CloudDomain:/c\ CloudDomain: '${domain_name} opnfv-environment.yaml
270 echo "Executing overcloud deployment, this should run for an extended period without output."
271 sleep 60 #wait for Hypervisor stats to check-in to nova
272 # save deploy command so it can be used for debugging
273 cat > deploy_command << EOF
274 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
278 if [ "$interactive" == "TRUE" ]; then
279 if ! prompt_user "Overcloud Deployment"; then
280 echo -e "${blue}INFO: User requests exit${reset}"
285 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
287 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
288 if ! heat stack-list | grep CREATE_COMPLETE 1>/dev/null; then
289 $(typeset -f debug_stack)
296 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
297 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI || (echo "DPDK config failed, exiting..."; exit 1)
300 for node in \$(nova list | grep novacompute | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
301 echo "Running DPDK test app on \$node"
302 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
304 sudo dpdk_helloworld --no-pci
305 sudo dpdk_nic_bind -s
311 if [ "$debug" == 'TRUE' ]; then
312 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
314 echo "Keystone Endpoint List:"
315 openstack endpoint list
316 echo "Keystone Service List"
317 openstack service list
318 cinder quota-show \$(openstack project list | grep admin | awk {'print \$2'})