#!/bin/bash # Deploy script to install provisioning server for OPNFV Apex # author: Dan Radez (dradez@redhat.com) # author: Tim Rozet (trozet@redhat.com) # # Based on RDO Manager http://www.rdoproject.org # # Pre-requisties: # - Supports 3 or 4 network interface configuration # - Target system must be RPM based # - Provisioned nodes expected to have following order of network connections (note: not all have to exist, but order is maintained): # eth0- admin network # eth1- private network (+storage network in 3 NIC config) # eth2- public network # eth3- storage network # - script assumes /24 subnet mask set -e ##VARIABLES declare -i CNT declare UNDERCLOUD ##FUNCTIONS ##verify vm exists, an has a dhcp lease assigned to it ##params: none function setup_instack_vm { if ! virsh list | grep instack > /dev/null; then #virsh vol-create default instack.qcow2.xml virsh define instack.xml #Copy instack machine cp instack.qcow2 /var/lib/libvirt/images restorecon /var/lib/libvirt/images/instack.qcow2 sleep 1 virsh start instack else echo "Found Instack VM, using existing VM" fi sleep 3 # let DHCP happen CNT=10 echo -n "Waiting for instack's dhcp address" while ! virsh net-dhcp-leases default | grep instack > /dev/null && [ $CNT -gt 0 ]; do echo -n "." sleep 3 CNT=CNT-1 done # get the instack VM IP UNDERCLOUD=$(virsh net-dhcp-leases default | grep instack | awk '{print $5}' | awk -F '/' '{print $1}') CNT=10 echo -en "\rValidating instack VM connectivity" while ! ping -c 1 $UNDERCLOUD > /dev/null && [ $CNT -gt 0 ]; do echo -n "." sleep 3 CNT=CNT-1 done CNT=10 while ! ssh -T -o "StrictHostKeyChecking no" root@$UNDERCLOUD "echo ''" 1>&2> /dev/null && [ $CNT -gt 0 ]; do echo -n "." sleep 3 CNT=CNT-1 done # extra space to overwrite the previous connectivity output echo -e "\rInstack VM has IP $UNDERCLOUD " #ssh -T -o "StrictHostKeyChecking no" root@$UNDERCLOUD "systemctl stop openstack-nova-compute.service" ssh -T -o "StrictHostKeyChecking no" root@$UNDERCLOUD "ip a a 192.0.2.1/24 dev eth1" } ##Copy over the glance images and instack json file ##params: none function copy_materials { scp stack/deploy-ramdisk-ironic.initramfs stack@$UNDERCLOUD: scp stack/deploy-ramdisk-ironic.kernel stack@$UNDERCLOUD: scp stack/discovery-ramdisk.initramfs stack@$UNDERCLOUD: scp stack/discovery-ramdisk.kernel stack@$UNDERCLOUD: scp stack/fedora-user.qcow2 stack@$UNDERCLOUD: scp stack/overcloud-full.initrd stack@$UNDERCLOUD: scp stack/overcloud-full.qcow2 stack@$UNDERCLOUD: scp stack/overcloud-full.vmlinuz stack@$UNDERCLOUD: scp instackenv.json stack@$UNDERCLOUD: } ##Seed the undercloud openstack installation ##preping it for deployment and launch the deploy ##params: none function undercloud_prep_overcloud_deploy { ssh -T -o "StrictHostKeyChecking no" stack@$UNDERCLOUD <