X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Fdeploy.sh;h=bb4c1f81806296d0cd6351c32ca897bd1df94874;hb=374c0788c83a8384223dc75333422fc6d4a20b14;hp=2853f188f6f0ace232e0b97993a228b2c2f3d02d;hpb=e4de3789bc5d9f3af141f9c822adf7dde94bde58;p=apex.git diff --git a/ci/deploy.sh b/ci/deploy.sh index 2853f188..bb4c1f81 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -22,7 +22,6 @@ blue=$(tput setaf 4 || echo "") red=$(tput setaf 1 || echo "") green=$(tput setaf 2 || echo "") -vm_index=4 interactive="FALSE" ping_site="8.8.8.8" ntp_server="pool.ntp.org" @@ -33,15 +32,20 @@ debug="FALSE" declare -i CNT declare UNDERCLOUD declare -A deploy_options_array +declare -a performance_options declare -A NET_MAP SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) DEPLOY_OPTIONS="" -RESOURCES=${RESOURCES:-'/var/opt/opnfv/images'} CONFIG=${CONFIG:-'/var/opt/opnfv'} +RESOURCES=${RESOURCES:-"$CONFIG/images"} +LIB=${LIB:-"$CONFIG/lib"} OPNFV_NETWORK_TYPES="admin_network private_network public_network storage_network" + VM_CPUS=4 VM_RAM=8 +VM_COMPUTES=2 + # Netmap used to map networks to OVS bridge names NET_MAP['admin_network']="br-admin" NET_MAP['private_network']="br-private" @@ -50,6 +54,11 @@ NET_MAP['storage_network']="br-storage" ext_net_type="interface" ip_address_family=4 +# Libraries +source $LIB/common-functions.sh +source $LIB/utility-functions.sh +source $LIB/installer/onos/onos_gw_mac_update.sh + ##FUNCTIONS ##translates yaml into variables ##params: filename, prefix (ex. "config_") @@ -102,50 +111,31 @@ parse_setting_value() { local mystr=$1 echo $(echo $mystr | grep -Eo "\=.*$" | tr -d '=') } + ##parses network settings yaml into globals parse_network_settings() { - if output=$(python3.4 -B $CONFIG/lib/python/apex-python-utils.py parse_net_settings -n $NETSETS -i $net_isolation_enabled); then - eval "$output" + local output + if output=$(python3.4 -B $LIB/python/apex-python-utils.py parse-net-settings -f $NETSETS -i $net_isolation_enabled); then echo -e "${blue}${output}${reset}" + eval "$output" else + echo -e "${red}ERROR: Failed to parse network settings file $NETSETS ${reset}" exit 1 fi - } -##parses deploy settings yaml into globals and options array -##params: none -##usage: parse_deploy_settings + +##parses deploy settings yaml into globals parse_deploy_settings() { - local global_prefix="deploy_global_params_" - local options_prefix="deploy_deploy_options_" - local myvar myvalue - local settings=$(parse_yaml $DEPLOY_SETTINGS_FILE "deploy_") - - for this_setting in $settings; do - if contains_prefix $this_setting $global_prefix; then - myvar=$(parse_setting_var $this_setting $global_prefix) - if [ -z "$myvar" ]; then - echo -e "${red}ERROR: while parsing ${DEPLOY_SETTINGS_FILE} for setting: ${this_setting}${reset}" - fi - myvalue=$(parse_setting_value $this_setting) - # Do not override variables set by cmdline - if [ -z "$(eval echo \$$myvar)" ]; then - eval "$myvar=\$myvalue" - echo -e "${blue}Global parameter set: ${myvar}:${myvalue}${reset}" - else - echo -e "${blue}Global parameter already set: ${myvar}${reset}" - fi - elif contains_prefix $this_setting $options_prefix; then - myvar=$(parse_setting_var $this_setting $options_prefix) - if [ -z "$myvar" ]; then - echo -e "${red}ERROR: while parsing ${DEPLOY_SETTINGS_FILE} for setting: ${this_setting}${reset}" - fi - myvalue=$(parse_setting_value $this_setting) - deploy_options_array[$myvar]=$myvalue - echo -e "${blue}Deploy option set: ${myvar}:${myvalue}${reset}" - fi - done + local output + if output=$(python3.4 -B $LIB/python/apex-python-utils.py parse-deploy-settings -f $DEPLOY_SETTINGS_FILE); then + echo -e "${blue}${output}${reset}" + eval "$output" + else + echo -e "${red}ERROR: Failed to parse deploy settings file $DEPLOY_SETTINGS_FILE ${reset}" + exit 1 + fi } + ##parses baremetal yaml settings into compatible json ##writes the json to $CONFIG/instackenv_tmp.json ##params: none @@ -176,7 +166,7 @@ parse_inventory_file() { node_total=$node_count - if [[ "$node_total" -lt 5 && ( ha_enabled == "TRUE" || "$ha_enabled" == "true" ) ]]; then + if [[ "$node_total" -lt 5 && "$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 @@ -292,10 +282,11 @@ function configure_deps { virsh net-list --all | grep -E "default\s+active" > /dev/null || virsh net-start default virsh net-list --all | grep -E "default\s+active\s+yes" > /dev/null || virsh net-autostart --network default - for network in ${OPNFV_NETWORK_TYPES}; do - echo "${blue}INFO: Creating Virsh Network: $network & OVS Bridge: ${NET_MAP[$network]}${reset}" - ovs-vsctl list-br | grep "^${NET_MAP[$network]}$" > /dev/null || ovs-vsctl add-br ${NET_MAP[$network]} - virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF + if [[ -z "$virtual" || "$virtual" == "FALSE" ]]; then + for network in ${OPNFV_NETWORK_TYPES}; do + echo "${blue}INFO: Creating Virsh Network: $network & OVS Bridge: ${NET_MAP[$network]}${reset}" + ovs-vsctl list-br | grep "^${NET_MAP[$network]}$" > /dev/null || ovs-vsctl add-br ${NET_MAP[$network]} + virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF $network @@ -303,21 +294,18 @@ function configure_deps { EOF - if ! (virsh net-list --all | grep $network > /dev/null); then - echo "${red}ERROR: unable to create network: ${network}${reset}" - exit 1; - fi - rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null; - virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network - virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network - done + if ! (virsh net-list --all | grep $network > /dev/null); then + echo "${red}ERROR: unable to create network: ${network}${reset}" + exit 1; + fi + rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null; + virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network + virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network + done - echo -e "${blue}INFO: Bridges set: ${reset}" - ovs-vsctl list-br - echo -e "${blue}INFO: virsh networks set: ${reset}" - virsh net-list + echo -e "${blue}INFO: Bridges set: ${reset}" + ovs-vsctl list-br - if [[ -z "$virtual" || "$virtual" == "FALSE" ]]; then # bridge interfaces to correct OVS instances for baremetal deployment for network in ${enabled_network_list}; do if [[ "$network" != "admin_network" && "$network" != "public_network" ]]; then @@ -337,8 +325,31 @@ EOF exit 1 fi done + else + for network in ${OPNFV_NETWORK_TYPES}; do + echo "${blue}INFO: Creating Virsh Network: $network${reset}" + virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF + +$network + + +EOF + if ! (virsh net-list --all | grep $network > /dev/null); then + echo "${red}ERROR: unable to create network: ${network}${reset}" + exit 1; + fi + rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null; + virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network + virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network + done + + echo -e "${blue}INFO: Bridges set: ${reset}" + brctl show fi + echo -e "${blue}INFO: virsh networks set: ${reset}" + virsh net-list + # ensure storage pool exists and is started virsh pool-list --all | grep default > /dev/null || virsh pool-define-as --name default dir --target /var/lib/libvirt/images virsh pool-list | grep -Eo "default\s+active" > /dev/null || (virsh pool-autostart default; virsh pool-start default) @@ -491,6 +502,16 @@ function setup_virtual_baremetal { EOF # next create the virtual machines and add their definitions to the file + if [ ha_enabled == "False" ]; then + # 1 controller + computes + # zero based so just pass compute count + vm_index=$VM_COMPUTES + else + # 3 controller + computes + # zero based so add 2 to compute count + vm_index=$((2+$VM_COMPUTES)) + fi + for i in $(seq 0 $vm_index); do if ! virsh list --all | grep baremetal${i} > /dev/null; then define_vm baremetal${i} network 41 'admin_network' $vcpus $ramsize @@ -630,7 +651,7 @@ function configure_network_environment { fi # check for ODL L3 - if [ "${deploy_options_array['sdn_l3']}" == 'true' ]; then + if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then ext_net_type=br-ex fi @@ -638,7 +659,7 @@ function configure_network_environment { ##Copy over the glance images and instackenv json file ##params: none function configure_undercloud { - + local controller_nic_template compute_nic_template echo echo "Copying configuration files to Undercloud" if [[ "$net_isolation_enabled" == "TRUE" ]]; then @@ -646,13 +667,22 @@ function configure_undercloud { echo -e "${blue}Network Environment set for Deployment: ${reset}" cat $CONFIG/network-environment.yaml scp ${SSH_OPTIONS[@]} $CONFIG/network-environment.yaml "stack@$UNDERCLOUD": + if ! controller_nic_template=$(python3.4 -B $LIB/python/apex-python-utils.py nic-template -t $CONFIG/nics-controller.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family); then + echo -e "${red}ERROR: Failed to generate controller NIC heat template ${reset}" + exit 1 + fi + + if ! compute_nic_template=$(python3.4 -B $LIB/python/apex-python-utils.py nic-template -t $CONFIG/nics-compute.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family); then + echo -e "${red}ERROR: Failed to generate compute NIC heat template ${reset}" + exit 1 + fi ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI mkdir nics/ cat > nics/controller.yaml << EOF -$(python3.4 -B $CONFIG/lib/python/apex-python-utils.py nic_template -d $CONFIG -f nics-controller.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family) +$controller_nic_template EOF cat > nics/compute.yaml << EOF -$(python3.4 -B $CONFIG/lib/python/apex-python-utils.py nic_template -d $CONFIG -f nics-compute.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family) +$compute_nic_template EOF EOI fi @@ -759,15 +789,15 @@ 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 + 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 + elif [ "${deploy_options_array['vpn']}" == 'True' ]; then DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.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 + 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." @@ -784,12 +814,12 @@ function undercloud_prep_overcloud_deploy { 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 + 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}" + echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}" exit 1 fi @@ -805,6 +835,17 @@ function undercloud_prep_overcloud_deploy { 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 + # Push performance options to subscript to modify per-role images as needed + for option in "${performance_options[@]}" ; do + echo -e "${blue}Setting performance option $option${reset}" + ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "bash build_perf_image.sh $option" + done + + # Add performance deploy options if they have been set + if [ ! -z "${deploy_options_array['performance']}" ]; then + 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" @@ -812,7 +853,7 @@ function undercloud_prep_overcloud_deploy { 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" || "$ha_enabled" == "true" ]]; then + 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" @@ -833,7 +874,7 @@ function undercloud_prep_overcloud_deploy { DEPLOY_OPTIONS+=" -e network-environment.yaml" fi - if [[ "$ha_enabled" == "TRUE" || "$ha_enabled" == "true" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then + if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then DEPLOY_OPTIONS+=" --ntp-server $ntp_server" fi @@ -856,6 +897,9 @@ source stackrc set -o errexit echo "Uploading overcloud glance images" openstack overcloud image upload + +bash -x set_perf_images.sh ${performance_roles} + echo "Configuring undercloud and discovering nodes" openstack baremetal import --json instackenv.json openstack baremetal configure boot @@ -967,7 +1011,7 @@ EOI fi # for sfc deployments we need the vxlan workaround - if [ "${deploy_options_array['sfc']}" == 'true' ]; then + if [ "${deploy_options_array['sfc']}" == 'True' ]; then ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <