X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Fdeploy.sh;h=47ab59c1a8a2e98820a899e58d497b25e1fc7060;hb=012f1d08b075ec53d3b1174cfd7a93b246385d08;hp=f7b30a1ef7b936a07ffd102db423dffb7807ed1c;hpb=2dae8a5767161e194a19dc85065b4aa6013a1db2;p=apex.git diff --git a/ci/deploy.sh b/ci/deploy.sh index f7b30a1e..47ab59c1 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -17,17 +17,10 @@ set -e ##VARIABLES -if [ "$TERM" != "unknown" ]; then - reset=$(tput sgr0) - blue=$(tput setaf 4) - red=$(tput setaf 1) - green=$(tput setaf 2) -else - reset="" - blue="" - red="" - green="" -fi +reset=$(tput sgr0 || echo "") +blue=$(tput setaf 4 || echo "") +red=$(tput setaf 1 || echo "") +green=$(tput setaf 2 || echo "") vm_index=4 interactive="FALSE" @@ -44,14 +37,14 @@ declare -A NET_MAP SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) DEPLOY_OPTIONS="" -RESOURCES=/var/opt/opnfv/stack +RESOURCES=/var/opt/opnfv/images CONFIG=/var/opt/opnfv 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" -NET_MAP['private_network']="brbm1" -NET_MAP['public_network']="brbm2" -NET_MAP['storage_network']="brbm3" +NET_MAP['admin_network']="br-admin" +NET_MAP['private_network']="br-private" +NET_MAP['public_network']="br-public" +NET_MAP['storage_network']="br-storage" ##FUNCTIONS ##translates yaml into variables @@ -120,7 +113,7 @@ parse_network_settings() { elif [ "${network}" == 'admin_network' ]; then echo -e "${red}ERROR: You must enable admin_network and configure it explicitly or use auto-detection${reset}" exit 1 - elif [ "${network}" == 'public_network' ]; then + elif [[ "${network}" == 'public_network' && "$net_isolation_enabled" == "TRUE" ]]; then echo -e "${red}ERROR: You must enable public_network and configure it explicitly or use auto-detection${reset}" exit 1 else @@ -194,41 +187,38 @@ 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 \${${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}}" - if [ -z "${setting_value}" ]; then - if [ -n "$nic_value" ]; then - setting_value=$(eval find_${setting} ${nic_value}) + for setting in $(eval echo \${${enabled_network}_optional_settings}); do + eval "setting_value=\${${enabled_network}_${setting}}" + if [ -z "${setting_value}" ]; then + if [ -n "$nic_value" ]; then + setting_value=$(eval find_${setting} ${nic_value}) + else + setting_value='' + echo -e "${blue}INFO: Skipping Auto-detection, NIC not specified for ${enabled_network}. Attempting Auto-generation...${reset}" + fi + if [ -n "$setting_value" ]; then + eval "${enabled_network}_${setting}=${setting_value}" + echo -e "${blue}INFO: Auto-detection: ${enabled_network}_${setting}: ${setting_value}${reset}" + else + eval "cidr=\${${enabled_network}_cidr}" + if [ -n "$cidr" ]; then + setting_value=$(eval generate_${setting} ${cidr}) else setting_value='' - echo -e "${blue}INFO: Skipping Auto-detection, NIC not specified for ${enabled_network}. Attempting Auto-generation...${reset}" + echo -e "${red}ERROR: Auto-generation failed: required parameter CIDR missing for network ${enabled_network}${reset}" fi if [ -n "$setting_value" ]; then eval "${enabled_network}_${setting}=${setting_value}" - echo -e "${blue}INFO: Auto-detection: ${enabled_network}_${setting}: ${setting_value}${reset}" + echo -e "${blue}INFO: Auto-generated: ${enabled_network}_${setting}: ${setting_value}${reset}" else - eval "cidr=\${${enabled_network}_cidr}" - if [ -n "$cidr" ]; then - setting_value=$(eval generate_${setting} ${cidr}) - else - setting_value='' - echo -e "${red}ERROR: Auto-generation failed: required parameter CIDR missing for network ${enabled_network}${reset}" - fi - if [ -n "$setting_value" ]; then - eval "${enabled_network}_${setting}=${setting_value}" - echo -e "${blue}INFO: Auto-generated: ${enabled_network}_${setting}: ${setting_value}${reset}" - else - echo -e "${red}ERROR: Auto-generation failed: ${setting} not found${reset}" - exit 1 - fi + echo -e "${red}ERROR: Auto-generation failed: ${setting} not found${reset}" + exit 1 fi - else - echo -e "${blue}INFO: ${enabled_network}_${setting}: ${setting_value}${reset}" fi - done - fi + else + echo -e "${blue}INFO: ${enabled_network}_${setting}: ${setting_value}${reset}" + fi + done done } ##parses deploy settings yaml into globals and options array @@ -303,9 +293,12 @@ parse_inventory_file() { exit 1 fi - eval $(parse_yaml $INVENTORY_FILE) || echo "${red}Failed to parse inventory.yaml. Aborting.${reset}" && exit 1 + eval $(parse_yaml $INVENTORY_FILE) || { + echo "${red}Failed to parse inventory.yaml. Aborting.${reset}" + exit 1 + } - instack_env_output=" + instackenv_output=" { \"nodes\" : [ @@ -328,23 +321,23 @@ parse_inventory_file() { \"pm_addr\": \"$(eval echo \${${node}ipmi_ip})\", \"capabilities\": \"$(eval echo \${${node}capabilities})\" " - instack_env_output+=${node_output} + instackenv_output+=${node_output} if [ $node_count -lt $node_total ]; then - instack_env_output+=" }," + instackenv_output+=" }," else - instack_env_output+=" }" + instackenv_output+=" }" fi done - instack_env_output+=' + instackenv_output+=' ] } ' #Copy instackenv.json to undercloud for baremetal - echo -e "{blue}Parsed instackenv JSON:\n${instack_env_output}${reset}" + echo -e "{blue}Parsed instackenv JSON:\n${instackenv_output}${reset}" ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" < instackenv.json << EOF -$instack_env_output +$instackenv_output EOF EOI @@ -394,22 +387,38 @@ function configure_deps { # If flat we only use admin network if [[ "$net_isolation_enabled" == "FALSE" ]]; then virsh_enabled_networks="admin_network" - # For baremetal we only need to create/attach instack to admin and public + enabled_network_list="admin_network" + # For baremetal we only need to create/attach Undercloud to admin and public elif [ "$virtual" == "FALSE" ]; then virsh_enabled_networks="admin_network public_network" else 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 + # ensure default network is configured correctly + libvirt_dir="/usr/share/libvirt/networks" + virsh net-list --all | grep default || virsh net-define ${libvirt_dir}/default.xml + 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 ${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]} + 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}" @@ -440,21 +449,8 @@ function configure_deps { fi # ensure storage pool exists and is started - virsh pool-list --all | grep default > /dev/null || virsh pool-create $CONFIG/default-pool.xml - virsh pool-list | grep -Eo "default\s+active" > /dev/null || virsh pool-start default - - if virsh net-list | grep default > /dev/null; then - num_ints_same_subnet=$(ip addr show | grep "inet 192.168.122" | wc -l) - if [ "$num_ints_same_subnet" -gt 1 ]; then - virsh net-destroy default - ##go edit /etc/libvirt/qemu/networks/default.xml - sed -i 's/192.168.122/192.168.123/g' /etc/libvirt/qemu/networks/default.xml - sed -i 's/192.168.122/192.168.123/g' instackenv-virt.json - sleep 5 - virsh net-start default - virsh net-autostart default - fi - fi + 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) if ! egrep '^flags.*(vmx|svm)' /proc/cpuinfo > /dev/null; then echo "${red}virtualization extensions not found, kvm kernel module insertion may fail.\n \ @@ -479,119 +475,106 @@ Are you sure you have enabled vmx in your bios or hypervisor?${reset}" ##verify vm exists, an has a dhcp lease assigned to it ##params: none -function setup_instack_vm { - if ! virsh list --all | grep instack > /dev/null; then - #virsh vol-create default instack.qcow2.xml - virsh define $CONFIG/instack.xml - - #Upload instack image - #virsh vol-create default --file instack.qcow2.xml - virsh vol-create-as default instack.qcow2 30G --format qcow2 +function setup_undercloud_vm { + if ! virsh list --all | grep undercloud > /dev/null; then + undercloud_nets="default admin_network" + if [[ $enabled_network_list =~ "public_network" ]]; then + undercloud_nets+=" public_network" + fi + define_vm undercloud hd 30 "$undercloud_nets" ### this doesn't work for some reason I was getting hangup events so using cp instead - #virsh vol-upload --pool default --vol instack.qcow2 --file $CONFIG/stack/instack.qcow2 + #virsh vol-upload --pool default --vol undercloud.qcow2 --file $CONFIG/stack/undercloud.qcow2 #2015-12-05 12:57:20.569+0000: 8755: info : libvirt version: 1.2.8, package: 16.el7_1.5 (CentOS BuildSystem , 2015-11-03-13:56:46, worker1.bsys.centos.org) #2015-12-05 12:57:20.569+0000: 8755: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds #2015-12-05 12:57:20.569+0000: 8756: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds - #error: cannot close volume instack.qcow2 + #error: cannot close volume undercloud.qcow2 #error: internal error: received hangup / error event on socket #error: Reconnected to the hypervisor - local instack_dst=/var/lib/libvirt/images/instack.qcow2 - cp -f $RESOURCES/instack.qcow2 $instack_dst - - # resize instack machine - echo "Checking if instack needs to be resized..." - 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' - 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') + local undercloud_dst=/var/lib/libvirt/images/undercloud.qcow2 + cp -f $RESOURCES/undercloud.qcow2 $undercloud_dst + + # resize Undercloud machine + echo "Checking if Undercloud needs to be resized..." + undercloud_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $undercloud_dst |grep device | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p') + if [ "$undercloud_size" -lt 30 ]; then + qemu-img resize /var/lib/libvirt/images/undercloud.qcow2 +25G + LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/undercloud.qcow2 $undercloud_dst + LIBGUESTFS_BACKEND=direct virt-customize -a $undercloud_dst --run-command 'xfs_growfs -d /dev/sda1 || true' + new_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $undercloud_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}" + echo "Error resizing Undercloud machine, disk size is ${new_size}" exit 1 else - echo "instack successfully resized" + echo "Undercloud successfully resized" fi else - echo "skipped instack resize, upstream is large enough" + echo "Skipped Undercloud resize, upstream is large enough" fi else - echo "Found Instack VM, using existing VM" + echo "Found Undercloud VM, using existing VM" fi # 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" - LIBGUESTFS_BACKEND=direct virt-customize -a $instack_dst --run-command "mkdir -p /root/.ssh/" \ + if ! virsh list | grep undercloud > /dev/null; then + echo "Injecting ssh key to Undercloud VM" + LIBGUESTFS_BACKEND=direct virt-customize -a $undercloud_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/" \ --run-command "chown stack:stack /home/stack/.ssh/authorized_keys && chmod 600 /home/stack/.ssh/authorized_keys" - virsh start instack + virsh start undercloud fi - sleep 3 # let DHCP happen + sleep 10 # let undercloud get started up + # get the undercloud VM IP CNT=10 - echo -n "${blue}Waiting for instack's dhcp address${reset}" - while ! grep instack /var/lib/libvirt/dnsmasq/default.leases > /dev/null && [ $CNT -gt 0 ]; do + echo -n "${blue}Waiting for Undercloud's dhcp address${reset}" + undercloud_mac=$(virsh domiflist undercloud | grep default | awk '{ print $5 }') + while ! $(arp -e | grep ${undercloud_mac} > /dev/null) && [ $CNT -gt 0 ]; do echo -n "." - sleep 3 - CNT=CNT-1 + sleep 10 + CNT=$((CNT-1)) done + UNDERCLOUD=$(arp -e | grep ${undercloud_mac} | awk {'print $1'}) - # get the instack VM IP - UNDERCLOUD=$(grep instack /var/lib/libvirt/dnsmasq/default.leases | awk '{print $3}' | head -n 1) if [ -z "$UNDERCLOUD" ]; then - #if not found then dnsmasq may be using leasefile-ro - instack_mac=$(virsh domiflist instack | grep default | \ - grep -Eo "[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+") - UNDERCLOUD=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'}) - - if [ -z "$UNDERCLOUD" ]; then - echo "\n\nNever got IP for Instack. Can Not Continue." - exit 1 - else - echo -e "${blue}\rInstack VM has IP $UNDERCLOUD${reset}" - fi + echo "\n\nCan't get IP for Undercloud. Can Not Continue." + exit 1 else - echo -e "${blue}\rInstack VM has IP $UNDERCLOUD${reset}" + echo -e "${blue}\rUndercloud VM has IP $UNDERCLOUD${reset}" fi CNT=10 - echo -en "${blue}\rValidating instack VM connectivity${reset}" + echo -en "${blue}\rValidating Undercloud VM connectivity${reset}" while ! ping -c 1 $UNDERCLOUD > /dev/null && [ $CNT -gt 0 ]; do echo -n "." sleep 3 - CNT=$CNT-1 + CNT=$((CNT-1)) done if [ "$CNT" -eq 0 ]; then - echo "Failed to contact Instack. Can Not Continue" + echo "Failed to contact Undercloud. Can Not Continue" exit 1 fi CNT=10 while ! ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "echo ''" 2>&1> /dev/null && [ $CNT -gt 0 ]; do echo -n "." sleep 3 - CNT=$CNT-1 + CNT=$((CNT-1)) done if [ "$CNT" -eq 0 ]; then - echo "Failed to connect to Instack. Can Not Continue" + echo "Failed to connect to Undercloud. Can Not Continue" exit 1 fi # extra space to overwrite the previous connectivity output echo -e "${blue}\r ${reset}" + sleep 1 + ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2; ip link set up dev eth2; fi" - #add the instack public interface if net isolation is enabled (more than just admin network) - if [[ "$net_isolation_enabled" == "TRUE" ]]; then - virsh attach-interface --domain instack --type network --source ${NET_MAP['public_network']} --model rtl8139 --config --live - sleep 1 - ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2; ip link set up dev eth2; fi" - fi # ssh key fix for stack user ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "restorecon -r /home/stack" } @@ -599,24 +582,93 @@ function setup_instack_vm { ##Create virtual nodes in virsh ##params: none function setup_virtual_baremetal { + #start by generating the opening json for instackenv.json + cat > $CONFIG/instackenv-virt.json << EOF +{ + "nodes": [ +EOF + + # next create the virtual machines and add their definitions to the file for i in $(seq 0 $vm_index); do - if ! virsh list --all | grep baremetalbrbm_brbm1_brbm2_brbm3_${i} > /dev/null; then - if [ ! -e $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml ]; then - define_virtual_node baremetalbrbm_brbm1_brbm2_brbm3_${i} - fi - # Fix for ramdisk using wrong pxeboot interface - # TODO: revisit this and see if there's a more proper fix - sed -i "/^\s*/{ - N - s/^\(.*\)virtio\(.*\)$/\1rtl8139\2/ - }" $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml - virsh define $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml + if ! virsh list --all | grep baremetal${i} > /dev/null; then + define_vm baremetal${i} network 41 'admin_network' + for n in private_network public_network storage_network; do + if [[ $enabled_network_list =~ $n ]]; then + echo -n "$n " + virsh attach-interface --domain baremetal${i} --type network --source $n --model rtl8139 --config + fi + done else echo "Found Baremetal ${i} VM, using existing VM" fi - virsh vol-list default | grep baremetalbrbm_brbm1_brbm2_brbm3_${i} 2>&1> /dev/null || virsh vol-create-as default baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 40G --format qcow2 + #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2 + mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }') + + cat >> $CONFIG/instackenv-virt.json << EOF + { + "pm_addr": "192.168.122.1", + "pm_user": "root", + "pm_password": "INSERT_STACK_USER_PRIV_KEY", + "pm_type": "pxe_ssh", + "mac": [ + "$mac" + ], + "cpu": "2", + "memory": "8192", + "disk": "41", + "arch": "x86_64" + }, +EOF done + #truncate the last line to remove the comma behind the bracket + tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{} + + #finally reclose the bracket and close the instackenv.json file + cat >> $CONFIG/instackenv-virt.json << EOF + } + ], + "arch": "x86_64", + "host-ip": "192.168.122.1", + "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager", + "seed-ip": "", + "ssh-key": "INSERT_STACK_USER_PRIV_KEY", + "ssh-user": "root" +} +EOF +} + +##Create virtual nodes in virsh +##params: name - String: libvirt name for VM +## bootdev - String: boot device for the VM +## disksize - Number: size of the disk in GB +## ovs_bridges: - List: list of ovs bridges +function define_vm () { + # Create the libvirt storage volume + if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then + volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2") + echo "Volume ${1} exists. Deleting Existing Volume $volume_path" + virsh vol-dumpxml ${1}.qcow2 --pool default + touch $volume_path + virsh vol-delete ${1}.qcow2 --pool default + fi + virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2 + volume_path=$(virsh vol-path --pool default ${1}.qcow2) + if [ ! -f $volume_path ]; then + echo "$volume_path Not created successfully... Aborting" + exit 1 + fi + + # create the VM + /usr/libexec/openstack-tripleo/configure-vm --name $1 \ + --bootdev $2 \ + --image "$volume_path" \ + --diskbus sata \ + --arch x86_64 \ + --cpus 2 \ + --memory 8388608 \ + --libvirt-nic-driver virtio \ + --baremetal-interface $4 } ##Set network-environment settings @@ -665,23 +717,19 @@ function configure_network_environment { # 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 + nic_ext+=_br-ex_no-public-ip fi # set nics appropriately sed -i 's#^.*Compute::Net::SoftwareConfig:.*$# OS::TripleO::Compute::Net::SoftwareConfig: nics/compute'${nic_ext}'.yaml#' $1 } -##Copy over the glance images and instack json file +##Copy over the glance images and instackenv json file ##params: none function configure_undercloud { echo - echo "Copying configuration files to instack" + echo "Copying configuration files to Undercloud" if [[ "$net_isolation_enabled" == "TRUE" ]]; then configure_network_environment $CONFIG/network-environment.yaml echo -e "${blue}Network Environment set for Deployment: ${reset}" @@ -690,35 +738,20 @@ function configure_undercloud { fi scp ${SSH_OPTIONS[@]} -r $CONFIG/nics/ "stack@$UNDERCLOUD": - # ensure stack user on instack machine has an ssh key + # ensure stack user on Undercloud machine has an ssh key ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "if [ ! -e ~/.ssh/id_rsa.pub ]; then ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa; fi" if [ "$virtual" == "TRUE" ]; then - # copy the instack vm's stack user's pub key to - # root's auth keys so that instack can control + # copy the Undercloud VM's stack user's pub key to + # root's auth keys so that Undercloud can control # vm power on the hypervisor ssh ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> /root/.ssh/authorized_keys - # fix MACs to match new setup - for i in $(seq 0 $vm_index); do - pyscript="import json -data = json.load(open('$CONFIG/instackenv-virt.json')) -print data['nodes'][$i]['mac'][0]" - - old_mac=$(python -c "$pyscript") - new_mac=$(virsh dumpxml baremetalbrbm_brbm1_brbm2_brbm3_$i | grep "mac address" | cut -d = -f2 | grep -Eo "[0-9a-f:]+") - # this doesn't work with multiple vnics on the vms - #if [ "$old_mac" != "$new_mac" ]; then - # echo "${blue}Modifying MAC for node from $old_mac to ${new_mac}${reset}" - # sed -i 's/'"$old_mac"'/'"$new_mac"'/' $CONFIG/instackenv-virt.json - #fi - done - DEPLOY_OPTIONS+=" --libvirt-type qemu" INSTACKENV=$CONFIG/instackenv-virt.json - # upload instackenv file to Instack for virtual deployment + # upload instackenv file to Undercloud for virtual deployment scp ${SSH_OPTIONS[@]} $INSTACKENV "stack@$UNDERCLOUD":instackenv.json fi @@ -742,7 +775,7 @@ EOI # configure undercloud on Undercloud VM echo "Running undercloud configuration." - echo "Logging undercloud configuration to instack:/home/stack/apex-undercloud-install.log" + echo "Logging undercloud configuration to undercloud:/home/stack/apex-undercloud-install.log" ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI if [[ "$net_isolation_enabled" == "TRUE" ]]; then sed -i 's/#local_ip/local_ip/' undercloud.conf @@ -776,7 +809,13 @@ cat << 'EOF' | sudo tee /usr/share/diskimage-builder/elements/yum/bin/install-pa exit 0 EOF -openstack undercloud install &> apex-undercloud-install.log +openstack undercloud install &> apex-undercloud-install.log || { + # cat the undercloud install log incase it fails + echo "ERROR: openstack undercloud install has failed. Dumping Log:" + cat apex-undercloud-install.log + exit 1 +} + sleep 30 sudo systemctl restart openstack-glance-api sudo systemctl restart openstack-nova-conductor @@ -798,6 +837,8 @@ function undercloud_prep_overcloud_deploy { 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" else DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml" fi @@ -815,7 +856,7 @@ function undercloud_prep_overcloud_deploy { 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=opendaylight + SDN_IMAGE=onos elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}" exit 1 @@ -836,7 +877,7 @@ function undercloud_prep_overcloud_deploy { exit 1 fi - echo "Copying overcloud image to instack" + echo "Copying overcloud image to Undercloud" scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2 # make sure ceph is installed @@ -851,7 +892,7 @@ function undercloud_prep_overcloud_deploy { compute_nodes=$((total_nodes - 3)) DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml" else - compute_nodes=1 + compute_nodes=$((total_nodes - 1)) fi if [ "$compute_nodes" -le 0 ]; then @@ -881,6 +922,7 @@ function undercloud_prep_overcloud_deploy { if [ "$debug" == 'TRUE' ]; then LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex fi + source stackrc set -o errexit echo "Uploading overcloud glance images" @@ -981,13 +1023,13 @@ EOI fi done - # for virtual, we NAT public network through instack + # for virtual, we NAT public network through Undercloud 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}" + echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud public network${reset}" fi fi @@ -1106,6 +1148,7 @@ parse_cmdline() { ;; --no-ha ) ha_enabled="FALSE" + vm_index=1 echo "HA Deployment Disabled" shift 1 ;; @@ -1137,9 +1180,9 @@ parse_cmdline() { done if [[ ! -z "$NETSETS" && "$net_isolation_enabled" == "FALSE" ]]; then - echo -e "${red}INFO: Single flat network requested. Ignoring any network settings!${reset}" - elif [[ -z "$NETSETS" && "$net_isolation_enabled" == "TRUE" ]]; then - echo -e "${red}ERROR: You must provide a network_settings file with -n or use --flat to force a single flat network${reset}" + echo -e "${red}INFO: Single flat network requested. Only admin_network settings will be used!${reset}" + elif [[ -z "$NETSETS" ]]; then + echo -e "${red}ERROR: You must provide a network_settings file with -n.${reset}" exit 1 fi @@ -1184,10 +1227,8 @@ parse_cmdline() { main() { parse_cmdline "$@" - if [[ "$net_isolation_enabled" == "TRUE" ]]; then - echo -e "${blue}INFO: Parsing network settings file...${reset}" - parse_network_settings - fi + echo -e "${blue}INFO: Parsing network settings file...${reset}" + parse_network_settings if ! configure_deps; then echo -e "${red}Dependency Validation Failed, Exiting.${reset}" exit 1 @@ -1195,7 +1236,7 @@ main() { if [ -n "$DEPLOY_SETTINGS_FILE" ]; then parse_deploy_settings fi - setup_instack_vm + setup_undercloud_vm if [ "$virtual" == "TRUE" ]; then setup_virtual_baremetal elif [ -n "$INVENTORY_FILE" ]; then