From 42d7a0189ad5c138f79b5a522bfda0d75b7977c4 Mon Sep 17 00:00:00 2001 From: Dan Radez Date: Wed, 6 Jul 2016 09:35:07 -0400 Subject: Splitting out overcloud functions to lib files trying to reduce the monolith deploy.sh to smaller parts Change-Id: Iceeda2be0539563163bceaacbb54c6cc2d07b87b Signed-off-by: Dan Radez --- build/opnfv-apex-common.spec | 2 + ci/deploy.sh | 274 +------------------------------------ lib/overcloud-deploy-functions.sh | 280 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 272 deletions(-) create mode 100755 lib/overcloud-deploy-functions.sh diff --git a/build/opnfv-apex-common.spec b/build/opnfv-apex-common.spec index 43e357cd..231b4801 100644 --- a/build/opnfv-apex-common.spec +++ b/build/opnfv-apex-common.spec @@ -56,6 +56,7 @@ install lib/configure-deps-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ install lib/parse-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ install lib/virtual-setup-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ install lib/undercloud-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ +install lib/overcloud-deploy-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ install lib/utility-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/ install lib/python/apex_python_utils.py %{buildroot}%{_var}/opt/opnfv/lib/python/ mkdir -p %{buildroot}%{python3_sitelib}/apex/ @@ -92,6 +93,7 @@ install config/inventory/pod_example_settings.yaml %{buildroot}%{_docdir}/opnfv/ %{_var}/opt/opnfv/lib/parse-functions.sh %{_var}/opt/opnfv/lib/virtual-setup-functions.sh %{_var}/opt/opnfv/lib/undercloud-functions.sh +%{_var}/opt/opnfv/lib/overcloud-deploy-functions.sh %{_var}/opt/opnfv/lib/utility-functions.sh %{_var}/opt/opnfv/lib/python/ %{python3_sitelib}/apex/ diff --git a/ci/deploy.sh b/ci/deploy.sh index abe07e48..c00b2c5c 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -62,6 +62,7 @@ $LIB/configure-deps-functions.sh $LIB/parse-functions.sh $LIB/virtual-setup-functions.sh $LIB/undercloud-functions.sh +$LIB/overcloud-deploy-functions.sh $LIB/utility-functions.sh $LIB/installer/onos/onos_gw_mac_update.sh ) @@ -103,277 +104,6 @@ function verify_internet { fi } -##preping it for deployment and launch the deploy -##params: none -function undercloud_prep_overcloud_deploy { - if [[ "${#deploy_options_array[@]}" -eq 0 || "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then - if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_l3.yaml" - elif [ "${deploy_options_array['sfc']}" == 'True' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml" - elif [ "${deploy_options_array['vpn']}" == 'True' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml" - elif [ "${deploy_options_array['vpp']}" == 'True' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_fdio.yaml" - else - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml" - fi - SDN_IMAGE=opendaylight - if [ "${deploy_options_array['sfc']}" == 'True' ]; then - SDN_IMAGE+=-sfc - if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then - echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute an SFC deployment." - echo "Please install the opnfv-apex-opendaylight-sfc package to provide this overcloud image for deployment.${reset}" - exit 1 - fi - fi - elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml" - SDN_IMAGE=opendaylight - elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml" - SDN_IMAGE=onos - elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then - echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}" - exit 1 - elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then - echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}" - SDN_IMAGE=opendaylight - else - echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}" - echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}" - exit 1 - fi - - - - # Make sure the correct overcloud image is available - if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then - echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment." - echo "Both ONOS and OpenDaylight are currently deployed from this image." - echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}" - exit 1 - fi - - echo "Copying overcloud image to Undercloud" - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2" - scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2 - - # Install ovs-dpdk inside the overcloud image if it is enabled. - if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then - # install dpdk packages before ovs - echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}" - - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < vfio_pci.modules -#!/bin/bash -exec /sbin/modprobe vfio_pci >/dev/null 2>&1 -EOF - - cat << EOF > uio_pci_generic.modules -#!/bin/bash -exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1 -EOF - - LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \ - --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \ - --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \ - --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \ - --run-command "yum install -y /root/dpdk_rpms/*" \ - -a overcloud-full.qcow2 -EOI - elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then - echo "${red}${deploy_options_array['dataplane']} not supported${reset}" - exit 1 - fi - - # Set ODL version accordingly - if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < /home/stack/Compute-ironic-python-agent.initramfs -chown stack /home/stack/Compute-ironic-python-agent.initramfs -if [ ! -f /home/stack/Controller-kernel_params.txt ]; then - touch /home/stack/Controller-kernel_params.txt - chown stack /home/stack/Controller-kernel_params.txt -fi -/bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt -echo "Controller params set: " -cat tmp/kernel_params.txt -find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs -chown stack /home/stack/Controller-ironic-python-agent.initramfs -popd -/bin/rm -rf ipa/ -EOI - - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml" - fi - - # make sure ceph is installed - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" - - # scale compute nodes according to inventory - total_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/instackenv.json | grep -c memory") - - # check if HA is enabled - if [[ "$ha_enabled" == "True" ]]; then - DEPLOY_OPTIONS+=" --control-scale 3" - compute_nodes=$((total_nodes - 3)) - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml" - else - compute_nodes=$((total_nodes - 1)) - fi - - if [ "$compute_nodes" -le 0 ]; then - echo -e "${red}ERROR: Invalid number of compute nodes: ${compute_nodes}. Check your inventory file.${reset}" - exit 1 - else - echo -e "${blue}INFO: Number of compute nodes set for deployment: ${compute_nodes}${reset}" - DEPLOY_OPTIONS+=" --compute-scale ${compute_nodes}" - fi - - if [[ "$net_isolation_enabled" == "TRUE" ]]; then - #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml" - DEPLOY_OPTIONS+=" -e network-environment.yaml" - fi - - if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then - DEPLOY_OPTIONS+=" --ntp-server $ntp_server" - fi - - if [[ ! "$virtual" == "TRUE" ]]; then - DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute" - else - DEPLOY_OPTIONS+=" -e virtual-environment.yaml" - fi - - DEPLOY_OPTIONS+=" -e opnfv-environment.yaml" - - echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}" - - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < deploy_command << EOF -openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90 -EOF -EOI - - if [ "$interactive" == "TRUE" ]; then - if ! prompt_user "Overcloud Deployment"; then - echo -e "${blue}INFO: User requests exit${reset}" - exit 0 - fi - fi - - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" </dev/null; then - $(typeset -f debug_stack) - debug_stack - exit 1 -fi -EOI - - # Configure DPDK - if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then - ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < vfio_pci.modules +#!/bin/bash +exec /sbin/modprobe vfio_pci >/dev/null 2>&1 +EOF + + cat << EOF > uio_pci_generic.modules +#!/bin/bash +exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1 +EOF + + LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \ + --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \ + --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \ + --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \ + --run-command "yum install -y /root/dpdk_rpms/*" \ + -a overcloud-full.qcow2 +EOI + elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then + echo "${red}${deploy_options_array['dataplane']} not supported${reset}" + exit 1 + fi + + # Set ODL version accordingly + if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < /home/stack/Compute-ironic-python-agent.initramfs +chown stack /home/stack/Compute-ironic-python-agent.initramfs +if [ ! -f /home/stack/Controller-kernel_params.txt ]; then + touch /home/stack/Controller-kernel_params.txt + chown stack /home/stack/Controller-kernel_params.txt +fi +/bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt +echo "Controller params set: " +cat tmp/kernel_params.txt +find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs +chown stack /home/stack/Controller-ironic-python-agent.initramfs +popd +/bin/rm -rf ipa/ +EOI + + DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml" + fi + + # make sure ceph is installed + DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" + + # scale compute nodes according to inventory + total_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/instackenv.json | grep -c memory") + + # check if HA is enabled + if [[ "$ha_enabled" == "True" ]]; then + DEPLOY_OPTIONS+=" --control-scale 3" + compute_nodes=$((total_nodes - 3)) + DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml" + else + compute_nodes=$((total_nodes - 1)) + fi + + if [ "$compute_nodes" -le 0 ]; then + echo -e "${red}ERROR: Invalid number of compute nodes: ${compute_nodes}. Check your inventory file.${reset}" + exit 1 + else + echo -e "${blue}INFO: Number of compute nodes set for deployment: ${compute_nodes}${reset}" + DEPLOY_OPTIONS+=" --compute-scale ${compute_nodes}" + fi + + if [[ "$net_isolation_enabled" == "TRUE" ]]; then + #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml" + DEPLOY_OPTIONS+=" -e network-environment.yaml" + fi + + if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then + DEPLOY_OPTIONS+=" --ntp-server $ntp_server" + fi + + if [[ ! "$virtual" == "TRUE" ]]; then + DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute" + else + DEPLOY_OPTIONS+=" -e virtual-environment.yaml" + fi + + DEPLOY_OPTIONS+=" -e opnfv-environment.yaml" + + echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}" + + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < deploy_command << EOF +openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90 +EOF +EOI + + if [ "$interactive" == "TRUE" ]; then + if ! prompt_user "Overcloud Deployment"; then + echo -e "${blue}INFO: User requests exit${reset}" + exit 0 + fi + fi + + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" </dev/null; then + $(typeset -f debug_stack) + debug_stack + exit 1 +fi +EOI + + # Configure DPDK + if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <