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
16 local dpdk_cores pmd_cores socket_mem ovs_dpdk_perf_flag ovs_option_heat_arr
17 declare -A ovs_option_heat_arr
19 ovs_option_heat_arr['dpdk_cores']=OvsDpdkCoreList
20 ovs_option_heat_arr['pmd_cores']=PmdCoreList
21 ovs_option_heat_arr['socket_memory']=OvsDpdkSocketMemory
23 # OPNFV Default Environment and Network settings
24 DEPLOY_OPTIONS+=" -e ${ENV_FILE}"
25 DEPLOY_OPTIONS+=" -e network-environment.yaml"
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-bgpvpn-opendaylight.yaml"
33 if [ "${deploy_options_array['gluon']}" == 'True' ]; then
34 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/services/gluon.yaml"
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"
40 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb.yaml"
43 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight.yaml"
45 SDN_IMAGE=opendaylight
46 elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
47 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
48 SDN_IMAGE=opendaylight
49 elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
50 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
51 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-onos-sfc.yaml"
53 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-onos.yaml"
56 elif [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
57 if [[ "$ha_enabled" == "True" ]]; then
58 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn-ha.yaml"
59 echo "${red}OVN HA support is not not supported... exiting.${reset}"
62 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn.yaml"
64 SDN_IMAGE=opendaylight
65 elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
66 echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
68 elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
69 echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}"
70 if [ "${deploy_options_array['vpp']}" == 'True' ]; then
71 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-vpp.yaml"
72 elif [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
73 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ovs-dpdk.yaml"
75 SDN_IMAGE=opendaylight
77 echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
78 echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
83 if [ "${deploy_options_array['tacker']}" == 'True' ]; then
84 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/enable_tacker.yaml"
88 if [ "${deploy_options_array['congress']}" == 'True' ]; then
89 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/enable_congress.yaml"
92 # Enable Real Time Kernel (kvm4nfv)
93 if [ "${deploy_options_array['rt_kvm']}" == 'True' ]; then
94 DEPLOY_OPTIONS+=" -e /home/stack/enable_rt_kvm.yaml"
97 # Make sure the correct overcloud image is available
98 if [ ! -f $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
99 echo "${red} $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
100 echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
104 echo "Copying overcloud image to Undercloud"
105 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
106 scp ${SSH_OPTIONS[@]} $IMAGES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
108 # disable neutron openvswitch agent from starting
109 if [[ -n "${deploy_options_array['sdn_controller']}" && "${deploy_options_array['sdn_controller']}" != 'False' ]]; then
110 echo -e "${blue}INFO: Disabling neutron-openvswitch-agent from systemd${reset}"
111 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
112 LIBGUESTFS_BACKEND=direct virt-customize --run-command "rm -f /etc/systemd/system/multi-user.target.wants/neutron-openvswitch-agent.service" \
113 --run-command "rm -f /usr/lib/systemd/system/neutron-openvswitch-agent.service" \
114 -a overcloud-full.qcow2
118 if [ "${deploy_options_array['vpn']}" == 'True' ]; then
119 echo -e "${blue}INFO: Enabling ZRPC and Quagga${reset}"
120 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
121 LIBGUESTFS_BACKEND=direct virt-customize \
122 --run-command "systemctl enable zrpcd" \
123 -a overcloud-full.qcow2
127 # Install ovs-dpdk inside the overcloud image if it is enabled.
128 if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' || "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
129 # install dpdk packages before ovs
130 echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
132 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
133 cat << EOF > vfio_pci.modules
135 exec /sbin/modprobe vfio_pci >/dev/null 2>&1
138 cat << EOF > uio_pci_generic.modules
140 exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
143 LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
144 --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
145 --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
146 --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
147 -a overcloud-full.qcow2
149 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
150 sed -i "/OS::TripleO::ComputeExtraConfigPre:/c\ OS::TripleO::ComputeExtraConfigPre: ./ovs-dpdk-preconfig.yaml" network-environment.yaml
155 elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
156 echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
160 if [ "$debug" == 'TRUE' ]; then
161 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex"
164 # upgrade ovs into ovs 2.5.90 with NSH function if SFC is enabled
165 if [[ "${deploy_options_array['sfc']}" == 'True' && "${deploy_options_array['dataplane']}" == 'ovs' ]]; then
166 echo "ONOS SFC is currently unavailable. JIRA: APEX-417"
168 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
169 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_kmod_rpm_name}" \
170 --run-command "yum upgrade -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_rpm_name}" \
171 -a overcloud-full.qcow2
175 # Patch neutron with using OVS external interface for router and add generic linux NS interface driver
176 if [[ "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
177 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
178 LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /usr/lib/python2.7/site-packages/ && patch -p1 < neutron-patch-NSDriver.patch" \
179 -a overcloud-full.qcow2
182 # Configure routing node and interface role mapping for odl-fdio
183 if [[ "${deploy_options_array['sdn_l3']}" == 'True' ]]; then
184 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
185 sed -i "/opendaylight::vpp_routing_node:/c\ opendaylight::vpp_routing_node: ${deploy_options_array['odl_vpp_routing_node']}.${domain_name}" ${ENV_FILE}
186 sed -i "/ControllerExtraConfig:/ c\ ControllerExtraConfig:\n tripleo::profile::base::neutron::agents::honeycomb::interface_role_mapping: \"['${tenant_nic_mapping_controller_members}:tenant-interface']\"" ${ENV_FILE}
187 sed -i "/NovaComputeExtraConfig:/ c\ NovaComputeExtraConfig:\n tripleo::profile::base::neutron::agents::honeycomb::interface_role_mapping: \"['${tenant_nic_mapping_compute_members}:tenant-interface','${external_nic_mapping_compute_members}:public-interface']\"" ${ENV_FILE}
192 if [ -n "${deploy_options_array['performance']}" ]; then
193 ovs_dpdk_perf_flag="False"
194 for option in "${performance_options[@]}" ; do
195 if [ "${arr[1]}" == "vpp" ]; then
196 if [ "${arr[0]}" == "Compute" ]; then
201 if [ "${arr[2]}" == "main-core" ]; then
202 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
203 sed -i "/${role}ExtraConfig:/ c\ ${role}ExtraConfig:\n fdio::vpp_cpu_main_core: \"'${arr[3]}'\"" ${ENV_FILE}
205 elif [ "${arr[2]}" == "corelist-workers" ]; then
206 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
207 sed -i "/${role}ExtraConfig:/ c\ ${role}ExtraConfig:\n fdio::vpp_cpu_corelist_workers: \"'${arr[3]}'\"" ${ENV_FILE}
212 # use compute's kernel settings for all nodes for now.
213 if [ "${arr[0]}" == "Compute" ] && [ "${arr[1]}" == "kernel" ]; then
214 kernel_args+=" ${arr[2]}=${arr[3]}"
216 if [ "${arr[0]}" == "Compute" ] && [ "${arr[1]}" == "ovs" ]; then
217 eval "${arr[2]}=${arr[3]}"
218 ovs_dpdk_perf_flag="True"
222 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
223 sed -i "/ComputeKernelArgs:/c\ ComputeKernelArgs: '$kernel_args'" ${ENV_FILE}
224 sed -i "$ a\resource_registry:\n OS::TripleO::NodeUserData: first-boot.yaml" ${ENV_FILE}
225 sed -i "/NovaSchedulerDefaultFilters:/c\ NovaSchedulerDefaultFilters: 'RamFilter,ComputeFilter,AvailabilityZoneFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,NUMATopologyFilter'" ${ENV_FILE}
228 if [[ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' && "$ovs_dpdk_perf_flag" == "True" ]]; then
229 for ovs_option in ${!ovs_option_heat_arr[@]}; do
230 if [ -n "${!ovs_option}" ]; then
231 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
232 sed -i "/${ovs_option_heat_arr[$ovs_option]}:/c\ ${ovs_option_heat_arr[$ovs_option]}: ${!ovs_option}" ${ENV_FILE}
239 if [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
240 if [ "${deploy_options_array['dataplane']}" == "fdio" ]; then
241 if [ "$tenant_nic_mapping_controller_members" == "$tenant_nic_mapping_compute_members" ]; then
242 echo -e "${blue}INFO: nosdn fdio deployment...installing correct vpp packages...${reset}"
243 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
244 sed -i "/NeutronVPPAgentPhysnets:/c\ NeutronVPPAgentPhysnets: 'datacentre:${tenant_nic_mapping_controller_members}'" ${ENV_FILE}
247 echo -e "${red}Compute and Controller must use the same tenant nic name, please modify network setting file.${reset}"
253 # Set ODL version accordingly
254 if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && -n "${deploy_options_array['odl_version']}" ]]; then
255 case "${deploy_options_array['odl_version']}" in
256 carbon) odl_version=''
258 *) echo -e "${red}Invalid ODL version ${deploy_options_array['odl_version']}. Please use 'carbon'.${reset}"
263 if [[ -n "$odl_version" ]]; then
264 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
265 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
266 --run-command "yum -y install /root/${odl_version}/*" \
267 -a overcloud-full.qcow2
271 # Overwrite puppet-opendaylight with carbon. By default we install boron branch.
272 if [ "${deploy_options_array['odl_version']}" == 'carbon' ]; then
273 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
274 LIBGUESTFS_BACKEND=direct virt-customize --run-command "rm -rf /etc/puppet/modules/opendaylight" \
275 --run-command "cd /etc/puppet/modules/ && tar xzf /root/puppet-opendaylight-carbon.tar.gz" \
276 -a overcloud-full.qcow2
281 # Override ODL if we enable netvirt for fdio
282 if [[ "${deploy_options_array['odl_vpp_netvirt']}" == 'True' && "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
283 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
284 LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
285 --run-command "yum -y install /root/opendaylight-7.0.0-0.1.20170531snap665.el7.noarch.rpm" \
286 -a overcloud-full.qcow2
290 # check if ceph should be enabled
291 if [ "${deploy_options_array['ceph']}" == 'True' ]; then
292 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
295 if [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
296 # The epoch in deloran's ovs is 1: and in leif's is 0:
297 # so we have to execute a downgrade instead of an update
298 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
299 LIBGUESTFS_BACKEND=direct virt-customize \
300 --run-command "cd /root/ovs27 && yum update -y *openvswitch*" \
301 --run-command "cd /root/ovs27 && yum downgrade -y *openvswitch*" \
302 -a overcloud-full.qcow2
306 # get number of nodes available in inventory
307 num_control_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:control /home/stack/instackenv.json")
308 num_compute_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:compute /home/stack/instackenv.json")
310 # check if HA is enabled
311 if [[ "$ha_enabled" == "True" ]]; then
312 if [ "$num_control_nodes" -lt 3 ]; then
313 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}"
316 DEPLOY_OPTIONS+=" --control-scale ${num_control_nodes}"
317 DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
318 echo -e "${blue}INFO: Number of control nodes set for deployment: ${num_control_nodes}${reset}"
321 if [ "$num_control_nodes" -lt 1 ]; then
322 echo -e "${red}ERROR: Number of control nodes in inventory is less than 1: ${num_control_nodes}. Check your inventory file.${reset}"
327 if [ "$num_compute_nodes" -le 0 ]; then
328 echo -e "${red}ERROR: Invalid number of compute nodes: ${num_compute_nodes}. Check your inventory file.${reset}"
331 echo -e "${blue}INFO: Number of compute nodes set for deployment: ${num_compute_nodes}${reset}"
332 DEPLOY_OPTIONS+=" --compute-scale ${num_compute_nodes}"
335 DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
337 DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
338 if [[ "$virtual" == "TRUE" ]]; then
339 DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
340 echo 'Ensuring Virtual BMC device status'
341 for i in $(vbmc list | grep down | awk '{ print $2}'); do
348 echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
350 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
351 # Create a key for use by nova for live migration
352 echo "Creating nova SSH key for nova resize support"
353 ssh-keygen -f nova_id_rsa -b 1024 -P ""
354 public_key=\'\$(cat nova_id_rsa.pub | cut -d ' ' -f 2)\'
355 sed -i "s#replace_public_key:#key: \$public_key#g" ${ENV_FILE}
356 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") + "\"")))'
357 mv -f opnfv-environment-new.yaml ${ENV_FILE}
361 # Workaround for APEX-207 where sometimes swift proxy is down
362 if ! sudo systemctl status openstack-swift-proxy > /dev/null; then
363 sudo systemctl restart openstack-swift-proxy
365 echo "Uploading overcloud glance images"
366 openstack overcloud image upload
368 echo "Configuring undercloud and discovering nodes"
371 if [[ -z "$virtual" ]]; then
372 openstack overcloud node import instackenv.json
373 openstack overcloud node introspect --all-manageable --provide
374 #if [[ -n "$root_disk_list" ]]; then
375 # TODO: replace node configure boot with ironic node-update
376 # TODO: configure boot is not used in ocata here anymore
377 #openstack overcloud node configure boot --root-device=${root_disk_list}
378 #https://github.com/openstack/tripleo-quickstart-extras/blob/master/roles/overcloud-prep-images/templates/overcloud-prep-images.sh.j2#L73-L130
379 #ironic node-update $ironic_node add properties/root_device='{"{{ node['key'] }}": "{{ node['value'] }}"}'
382 openstack overcloud node import --provide instackenv.json
385 openstack flavor set --property "cpu_arch"="x86_64" baremetal
386 openstack flavor set --property "cpu_arch"="x86_64" control
387 openstack flavor set --property "cpu_arch"="x86_64" compute
388 echo "Configuring nameserver on ctlplane network"
390 for dns_server in ${dns_servers}; do
391 dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
393 openstack subnet set ctlplane-subnet \${dns_server_ext}
394 sed -i '/CloudDomain:/c\ CloudDomain: '${domain_name} ${ENV_FILE}
395 echo "Executing overcloud deployment, this could run for an extended period without output."
396 sleep 60 #wait for Hypervisor stats to check-in to nova
397 # save deploy command so it can be used for debugging
398 cat > deploy_command << EOF
399 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
403 if [ "$interactive" == "TRUE" ]; then
404 if ! prompt_user "Overcloud Deployment"; then
405 echo -e "${blue}INFO: User requests exit${reset}"
410 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
412 openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
413 if ! openstack stack list | grep CREATE_COMPLETE 1>/dev/null; then
414 $(typeset -f debug_stack)
420 # Configure DPDK and restart ovs agent after bringing up br-phy
421 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
422 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI || (echo "DPDK config failed, exiting..."; exit 1)
425 for node in \$(nova list | grep novacompute | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
426 echo "Checking DPDK status and bringing up br-phy on \$node"
427 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
431 if [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
432 echo "Restarting openvswitch agent to pick up VXLAN tunneling"
433 sudo systemctl restart neutron-openvswitch-agent
440 if [ "$debug" == 'TRUE' ]; then
441 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
443 echo "Keystone Endpoint List:"
444 openstack endpoint list
445 echo "Keystone Service List"
446 openstack service list