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 if [ "${deploy_options_array['vpp']}" == 'True' ]; then
56 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-networking-vpp.yaml"
58 SDN_IMAGE=opendaylight
60 echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
61 echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
67 # Make sure the correct overcloud image is available
68 if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
69 echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
70 echo "Both ONOS and OpenDaylight are currently deployed from this image."
71 echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
75 echo "Copying overcloud image to Undercloud"
76 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
77 scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
79 # Install ovs-dpdk inside the overcloud image if it is enabled.
80 if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' || "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
81 # install dpdk packages before ovs
82 echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
84 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
85 cat << EOF > vfio_pci.modules
87 exec /sbin/modprobe vfio_pci >/dev/null 2>&1
90 cat << EOF > uio_pci_generic.modules
92 exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
95 LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
96 --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
97 --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
98 --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
99 -a overcloud-full.qcow2
101 if [ "${deploy_options_array['dataplane']}" == 'fdio' ]; then
102 sudo sed -i '/FdioEnabled:/c\ FdioEnabled: true' /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml
103 LIBGUESTFS_BACKEND=direct virt-customize --run-command "cp -f /root/fdio_neutron_l3/namespaces.py /usr/lib/python2.7/site-packages/neutron/agent/l3/" \
104 --run-command "cp -f /root/fdio_neutron_l3/router_info.py /usr/lib/python2.7/site-packages/neutron/agent/l3/" \
105 -a overcloud-full.qcow2
106 if [ "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]; then
107 LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /root/ && tar zxvf networking-odl.tar.gz" \
108 --run-command "cd /root/networking-odl && git init && pip install -r requirements.txt" \
109 --run-command "cd /root/networking-odl && python setup.py build && python setup.py install" \
110 -a overcloud-full.qcow2
113 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/dpdk_rpms/*" \
114 -a overcloud-full.qcow2
118 elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
119 echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
123 if [ "$debug" == 'TRUE' ]; then
124 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex"
127 # Set ODL version accordingly
128 if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then
129 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
130 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
131 --run-command "yum -y install /root/boron/*" \
132 -a overcloud-full.qcow2
136 # Add performance deploy options if they have been set
137 if [ ! -z "${deploy_options_array['performance']}" ]; then
139 # Remove previous kernel args files per role
140 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Compute-kernel_params.txt"
141 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Controller-kernel_params.txt"
143 # Push performance options to subscript to modify per-role images as needed
144 for option in "${performance_options[@]}" ; do
145 echo -e "${blue}Setting performance option $option${reset}"
146 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "dataplane=${deploy_options_array['dataplane']} bash build_perf_image.sh $option"
149 # Build IPA kernel option ramdisks
150 ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" <<EOI
151 /bin/cp -f /home/stack/ironic-python-agent.initramfs /root/
154 gunzip -c ../ironic-python-agent.initramfs | cpio -i
155 if [ ! -f /home/stack/Compute-kernel_params.txt ]; then
156 touch /home/stack/Compute-kernel_params.txt
157 chown stack /home/stack/Compute-kernel_params.txt
159 /bin/cp -f /home/stack/Compute-kernel_params.txt tmp/kernel_params.txt
160 echo "Compute params set: "
161 cat tmp/kernel_params.txt
162 /bin/cp -f /root/image.py usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.py
163 /bin/cp -f /root/image.pyc usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.pyc
164 find . | cpio -o -H newc | gzip > /home/stack/Compute-ironic-python-agent.initramfs
165 chown stack /home/stack/Compute-ironic-python-agent.initramfs
166 if [ ! -f /home/stack/Controller-kernel_params.txt ]; then
167 touch /home/stack/Controller-kernel_params.txt
168 chown stack /home/stack/Controller-kernel_params.txt
170 /bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt
171 echo "Controller params set: "
172 cat tmp/kernel_params.txt
173 find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs
174 chown stack /home/stack/Controller-ironic-python-agent.initramfs
179 # set NIC heat params and resource registry
180 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
181 sed -i '/TenantNIC:/c\ TenantNIC: '${private_network_compute_interface} opnfv-environment.yaml
182 sed -i '/PublicNIC:/c\ PublicNIC: '${public_network_compute_interface} opnfv-environment.yaml
185 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml"
188 # make sure ceph is installed
189 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
191 # get number of nodes available in inventory
192 num_control_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:control /home/stack/instackenv.json")
193 num_compute_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:compute /home/stack/instackenv.json")
195 # check if HA is enabled
196 if [[ "$ha_enabled" == "True" ]]; then
197 if [ "$num_control_nodes" -lt 3 ]; then
198 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}"
201 DEPLOY_OPTIONS+=" --control-scale ${num_control_nodes}"
202 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
203 echo -e "${blue}INFO: Number of control nodes set for deployment: ${num_control_nodes}${reset}"
206 if [ "$num_control_nodes" -lt 1 ]; then
207 echo -e "${red}ERROR: Number of control nodes in inventory is less than 1: ${num_control_nodes}. Check your inventory file.${reset}"
212 if [ "$num_compute_nodes" -le 0 ]; then
213 echo -e "${red}ERROR: Invalid number of compute nodes: ${num_compute_nodes}. Check your inventory file.${reset}"
216 echo -e "${blue}INFO: Number of compute nodes set for deployment: ${num_compute_nodes}${reset}"
217 DEPLOY_OPTIONS+=" --compute-scale ${num_compute_nodes}"
220 if [[ "$net_isolation_enabled" == "TRUE" ]]; then
221 #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml"
222 DEPLOY_OPTIONS+=" -e network-environment.yaml"
225 if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then
226 DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
229 DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
230 if [[ "$virtual" == "TRUE" ]]; then
231 DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
234 DEPLOY_OPTIONS+=" -e opnfv-environment.yaml"
236 echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
238 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
239 if [ "${deploy_options_array['tacker']}" == 'False' ]; then
240 sed -i '/EnableTacker:/c\ EnableTacker: false' opnfv-environment.yaml
243 # Create a key for use by nova for live migration
244 echo "Creating nova SSH key for nova resize support"
245 ssh-keygen -f nova_id_rsa -b 1024 -P ""
246 public_key=\'\$(cat nova_id_rsa.pub | cut -d ' ' -f 2)\'
247 sed -i "s#replace_public_key:#key: \$public_key#g" opnfv-environment.yaml
248 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") + "\"")))'
249 mv -f opnfv-environment-new.yaml opnfv-environment.yaml
253 # Workaround for APEX-207 where sometimes swift proxy is down
254 if ! sudo systemctl status openstack-swift-proxy > /dev/null; then
255 sudo systemctl restart openstack-swift-proxy
257 echo "Uploading overcloud glance images"
258 openstack overcloud image upload
260 echo "Configuring undercloud and discovering nodes"
261 openstack baremetal import --json instackenv.json
262 openstack baremetal configure boot
263 bash -x set_perf_images.sh ${performance_roles[@]}
264 #if [[ -z "$virtual" ]]; then
265 # openstack baremetal introspection bulk start
267 echo "Configuring flavors"
268 for flavor in baremetal control compute; do
269 echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
270 if openstack flavor list | grep \${flavor}; then
271 openstack flavor delete \${flavor}
273 openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
274 if ! openstack flavor list | grep \${flavor}; then
275 echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
278 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
279 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
280 openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
281 echo "Configuring nameserver on ctlplane network"
283 for dns_server in ${dns_servers}; do
284 dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
286 neutron subnet-update \$(neutron subnet-list | grep -Ev "id|tenant|external|storage" | grep -v \\\\-\\\\- | awk {'print \$2'}) \${dns_server_ext}
287 sed -i '/CloudDomain:/c\ CloudDomain: '${domain_name} opnfv-environment.yaml
288 echo "Executing overcloud deployment, this should run for an extended period without output."
289 sleep 60 #wait for Hypervisor stats to check-in to nova
290 # save deploy command so it can be used for debugging
291 cat > deploy_command << EOF
292 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
296 if [ "$interactive" == "TRUE" ]; then
297 if ! prompt_user "Overcloud Deployment"; then
298 echo -e "${blue}INFO: User requests exit${reset}"
303 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
305 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
306 if ! heat stack-list | grep CREATE_COMPLETE 1>/dev/null; then
307 $(typeset -f debug_stack)
314 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
315 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI || (echo "DPDK config failed, exiting..."; exit 1)
318 for node in \$(nova list | grep novacompute | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
319 echo "Running DPDK test app on \$node"
320 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
322 sudo dpdk_helloworld --no-pci
323 sudo dpdk_nic_bind -s
329 if [ "$debug" == 'TRUE' ]; then
330 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
332 echo "Keystone Endpoint List:"
333 openstack endpoint list
334 echo "Keystone Service List"
335 openstack service list
336 cinder quota-show \$(openstack project list | grep admin | awk {'print \$2'})