X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Fdeploy.sh;h=ad7d0d1b9e7b1b7bb36dcc1e22b7362c6a8f0cf1;hb=9a1ad598d448df0e1cf4523f55eed28716ad2468;hp=232d8251a3dd85b47eec6a66768b3372da00fb07;hpb=266eaa1148a529e829c322320d27842bad280157;p=apex.git diff --git a/ci/deploy.sh b/ci/deploy.sh index 232d8251..ad7d0d1b 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -1,4 +1,12 @@ #!/bin/bash +############################################################################## +# Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## # Deploy script to install provisioning server for OPNFV Apex # author: Dan Radez (dradez@redhat.com) @@ -22,11 +30,12 @@ else fi vm_index=4 -ha_enabled="TRUE" +interactive="FALSE" ping_site="8.8.8.8" ntp_server="pool.ntp.org" net_isolation_enabled="TRUE" post_config="TRUE" +debug="FALSE" declare -i CNT declare UNDERCLOUD @@ -37,7 +46,6 @@ SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o Us DEPLOY_OPTIONS="" RESOURCES=/var/opt/opnfv/stack CONFIG=/var/opt/opnfv -INSTACKENV=$CONFIG/instackenv.json OPNFV_NETWORK_TYPES="admin_network private_network public_network storage_network" # Netmap used to map networks to OVS bridge names NET_MAP['admin_network']="brbm" @@ -45,9 +53,6 @@ NET_MAP['private_network']="brbm1" NET_MAP['public_network']="brbm2" NET_MAP['storage_network']="brbm3" -##LIBRARIES -source $CONFIG/lib/common-functions.sh - ##FUNCTIONS ##translates yaml into variables ##params: filename, prefix (ex. "config_") @@ -276,7 +281,7 @@ parse_inventory_file() { for entry in $inventory; do if echo $entry | grep -Eo "^nodes_node[0-9]+_" > /dev/null; then this_node=$(echo $entry | grep -Eo "^nodes_node[0-9]+_") - if [[ $inventory_list != *"$this_node"* ]]; then + if [[ "$inventory_list" != *"$this_node"* ]]; then inventory_list+="$this_node " fi fi @@ -290,7 +295,7 @@ parse_inventory_file() { node_total=$node_count - if [[ "$node_total" -lt 5 && ha_enabled == "TRUE" ]]; then + if [[ "$node_total" -lt 5 && ( ha_enabled == "TRUE" || "$ha_enabled" == "true" ) ]]; then echo -e "${red}ERROR: You must provide at least 5 nodes for HA baremetal deployment${reset}" exit 1 elif [[ "$node_total" -lt 2 ]]; then @@ -397,7 +402,7 @@ function configure_deps { for network in ${OPNFV_NETWORK_TYPES}; do ovs-vsctl list-br | grep ${NET_MAP[$network]} > /dev/null || ovs-vsctl add-br ${NET_MAP[$network]} - virsh net-list --all | grep ${NET_MAP[$network]} > /dev/null || virsh net-create $CONFIG/${NET_MAP[$network]}-net.xml + virsh net-list --all | grep ${NET_MAP[$network]} > /dev/null || virsh net-define $CONFIG/${NET_MAP[$network]}-net.xml virsh net-list | grep -E "${NET_MAP[$network]}\s+active" > /dev/null || virsh net-start ${NET_MAP[$network]} done @@ -650,17 +655,27 @@ function configure_network_environment { sed -i 's#^.*Compute::Ports::StoragePort:.*$# OS::TripleO::Compute::Ports::StoragePort: '${tht_dir}'/ports/noop.yaml#' $1 fi + sed -i 's#^.*Controller::Net::SoftwareConfig:.*$# OS::TripleO::Controller::Net::SoftwareConfig: nics/controller'${nic_ext}'.yaml#' $1 + + # check for ODL L3 + if [ "${deploy_options_array['sdn_l3']}" == 'true' ]; then + nic_ext+=_br-ex + fi + + if [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then + nic_ext+=_no-public-ip + fi + # set nics appropriately sed -i 's#^.*Compute::Net::SoftwareConfig:.*$# OS::TripleO::Compute::Net::SoftwareConfig: nics/compute'${nic_ext}'.yaml#' $1 - sed -i 's#^.*Controller::Net::SoftwareConfig:.*$# OS::TripleO::Controller::Net::SoftwareConfig: nics/controller'${nic_ext}'.yaml#' $1 + } ##Copy over the glance images and instack json file ##params: none function configure_undercloud { echo - echo "Copying configuration file and disk images to instack" - scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full.qcow2 "stack@$UNDERCLOUD": + echo "Copying configuration files to instack" if [[ "$net_isolation_enabled" == "TRUE" ]]; then configure_network_environment $CONFIG/network-environment.yaml echo -e "${blue}Network Environment set for Deployment: ${reset}" @@ -746,6 +761,15 @@ sudo sed -i '/CephClusterFSID:/c\\ CephClusterFSID: \\x27$(cat /proc/sys/kernel sudo sed -i '/CephMonKey:/c\\ CephMonKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml sudo sed -i '/CephAdminKey:/c\\ CephAdminKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml +# we assume that packages will not need to be updated with undercloud install +# and that it will be used only to configure the undercloud +# packages updates would need to be handled manually with yum update +sudo cp -f /usr/share/diskimage-builder/elements/yum/bin/install-packages /usr/share/diskimage-builder/elements/yum/bin/install-packages.bak +cat << 'EOF' | sudo tee /usr/share/diskimage-builder/elements/yum/bin/install-packages > /dev/null +#!/bin/sh +exit 0 +EOF + openstack undercloud install &> apex-undercloud-install.log sleep 30 sudo systemctl restart openstack-glance-api @@ -763,25 +787,60 @@ sleep 15 ##preping it for deployment and launch the deploy ##params: none function undercloud_prep_overcloud_deploy { - # TODO ADD ODL L3 logic here - if [[ ${#deploy_options_array[@]} -eq 0 || ${deploy_options_array['sdn_controller']} == 'opendaylight' ]]; then - DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml" - elif [ ${deploy_options_array['sdn_controller']} == 'opendaylight-external' ]; then + 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" + 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 + fi + elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml" - elif [ ${deploy_options_array['sdn_controller']} == 'onos' ]; then + SDN_IMAGE=opendaylight + elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml" - elif [ ${deploy_options_array['sdn_controller']} == 'opencontrail' ]; then + SDN_IMAGE=opendaylight + 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 + echo "Copying overcloud image to instack" + scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2 + # 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-scale 2" + if [[ "$ha_enabled" == "TRUE" || "$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=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 @@ -789,7 +848,7 @@ function undercloud_prep_overcloud_deploy { DEPLOY_OPTIONS+=" -e network-environment.yaml" fi - if [[ "$ha_enabled" == "TRUE" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then + if [[ "$ha_enabled" == "TRUE" || "$ha_enabled" == "true" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then DEPLOY_OPTIONS+=" --ntp-server $ntp_server" fi @@ -797,7 +856,12 @@ function undercloud_prep_overcloud_deploy { DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute" fi + 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 +openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90 EOF -openstack overcloud deploy --templates $DEPLOY_OPTIONS 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 | grep id | cut -d '|' -f 3) echo "Configuring Neutron external network" -neutron net-create external --router:external=True -neutron subnet-create --name external-net --disable-dhcp external --gateway ${public_network_gateway} --allocation-pool start=${public_network_floating_ip_range%%,*},end=${public_network_floating_ip_range##*,} ${public_network_cidr} +neutron net-create external --router:external=True --tenant-id $service_tenant_id +neutron subnet-create --name external-net --tenant-id $service_tenant_id --disable-dhcp external --gateway ${public_network_gateway} --allocation-pool start=${public_network_floating_ip_range%%,*},end=${public_network_floating_ip_range##*,} ${public_network_cidr} EOI echo -e "${blue}INFO: Checking if OVS bridges have IP addresses...${reset}" @@ -873,6 +962,64 @@ EOI fi fi done + + # for virtual, we NAT public network through instack + if [ "$virtual" == "TRUE" ]; then + if ! configure_undercloud_nat ${public_network_cidr}; then + echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${public_network_cidr}${reset}" + exit 1 + else + echo -e "${blue}INFO: Undercloud (instack VM) has been setup to NAT Overcloud public network${reset}" + fi + fi + + # for sfc deployments we need the vxlan workaround + if [ "${deploy_options_array['sfc']}" == 'true' ]; then + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <