X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Fdeploy.sh;h=31b5d2f560e9a776612187a8c7a294a0f56e5870;hb=6eaef72d9b3de5a7c17a6a03529bbd735890b830;hp=5118aea186ff7e8c9ec6721c43108deed115df83;hpb=ed90b347e4228477f419a1b483f3997639665fef;p=apex.git diff --git a/ci/deploy.sh b/ci/deploy.sh index 5118aea1..31b5d2f5 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 @@ -185,7 +194,7 @@ for Auto-detection${reset}" done echo -e "${blue}INFO: Detecting Network Specific settings for: ${enabled_network}${reset}" # detect network specific settings - if [ -n $(eval echo \${${network}_optional_settings}) ]; then + if [ -n $(eval echo \${${enabled_network}_optional_settings}) ]; then eval "network_specific_settings=\${${enabled_network}_optional_settings}" for setting in ${network_specific_settings}; do eval "setting_value=\${${enabled_network}_${setting}}" @@ -272,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 @@ -286,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 @@ -294,7 +303,7 @@ parse_inventory_file() { exit 1 fi - eval $(parse_yaml $INVENTORY_FILE) + eval $(parse_yaml $INVENTORY_FILE) || echo "${red}Failed to parse inventory.yaml. Aborting.${reset}" && exit 1 instack_env_output=" { @@ -307,7 +316,7 @@ parse_inventory_file() { node_output=" { \"pm_password\": \"$(eval echo \${${node}ipmi_pass})\", - \"pm_type\": \"pxe_ipmitool\", + \"pm_type\": \"$(eval echo \${${node}pm_type})\", \"mac\": [ \"$(eval echo \${${node}mac_address})\" ], @@ -379,7 +388,8 @@ function configure_deps { fi # ensure networks are configured - systemctl start openvswitch + systemctl status libvirtd || systemctl start libvirtd + systemctl status openvswitch || systemctl start openvswitch # If flat we only use admin network if [[ "$net_isolation_enabled" == "FALSE" ]]; then @@ -391,10 +401,15 @@ function configure_deps { virsh_enabled_networks=$enabled_network_list fi + virsh net-list | grep default || virsh net-define /usr/share/libvirt/networks/default.xml + virsh net-list | grep -E "default\s+active" > /dev/null || virsh net-start default + virsh net-list | grep -E "default\s+active\s+yes" > /dev/null || virsh net-autostart --network default + 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]} + virsh net-list | grep -E "${NET_MAP[$network]}\s+active\s+yes" > /dev/null || virsh net-autostart --network ${NET_MAP[$network]} done echo -e "${blue}INFO: Bridges set: ${reset}" @@ -482,7 +497,7 @@ function setup_instack_vm { #error: internal error: received hangup / error event on socket #error: Reconnected to the hypervisor - instack_dst=/var/lib/libvirt/images/instack.qcow2 + local instack_dst=/var/lib/libvirt/images/instack.qcow2 cp -f $RESOURCES/instack.qcow2 $instack_dst # resize instack machine @@ -490,8 +505,8 @@ function setup_instack_vm { instack_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $instack_dst |grep device | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p') if [ "$instack_size" -lt 30 ]; then qemu-img resize /var/lib/libvirt/images/instack.qcow2 +25G - LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/instack.qcow2 $instack_dst - LIBGUESTFS_BACKEND=direct virt-customize -a $instack_dst --run-command 'xfs_growfs -d /dev/sda1 || true' + LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/instack.qcow2 $instack_dst + LIBGUESTFS_BACKEND=direct virt-customize -a $instack_dst --run-command 'xfs_growfs -d /dev/sda1 || true' new_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $instack_dst |grep filesystem | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p') if [ "$new_size" -lt 30 ]; then echo "Error resizing instack machine, disk size is ${new_size}" @@ -510,7 +525,7 @@ function setup_instack_vm { # if the VM is not running update the authkeys and start it if ! virsh list | grep instack > /dev/null; then echo "Injecting ssh key to instack VM" - virt-customize -c qemu:///system -d instack --run-command "mkdir -p /root/.ssh/" \ + LIBGUESTFS_BACKEND=direct virt-customize -a $instack_dst --run-command "mkdir -p /root/.ssh/" \ --upload ~/.ssh/id_rsa.pub:/root/.ssh/authorized_keys \ --run-command "chmod 600 /root/.ssh/authorized_keys && restorecon /root/.ssh/authorized_keys" \ --run-command "cp /root/.ssh/authorized_keys /home/stack/.ssh/" \ @@ -649,10 +664,14 @@ function configure_network_environment { 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 + 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 @@ -748,6 +767,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 @@ -765,40 +793,73 @@ sleep 15 ##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 + 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 + 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 + 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 + elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml" SDN_IMAGE=opendaylight - elif [ ${deploy_options_array['sdn_controller']} == 'opencontrail' ]; then + 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${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 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 @@ -806,7 +867,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 @@ -817,6 +878,9 @@ function undercloud_prep_overcloud_deploy { 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" <