2 ##############################################################################
3 # Copyright (c) 2016 Tim Rozet (Red Hat) and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error)
16 SNAP_CACHE=$HOME/snap_cache
19 echo "Deploying Apex snapshot..."
20 echo "--------------------------"
23 echo "Cleaning server"
25 sudo CONFIG=../build/ LIB=../lib ./clean.sh
28 echo "Downloading latest snapshot properties file"
29 if ! wget -O $WORKSPACE/opnfv.properties http://$GS_URL/snapshot.properties; then
30 echo "ERROR: Unable to find snapshot.properties at ${GS_URL}...exiting"
34 # find latest check sum
35 latest_snap_checksum=$(cat opnfv.properties | grep OPNFV_SNAP_SHA512SUM | awk -F "=" '{print $2}')
36 if [ -z "$latest_snap_checksum" ]; then
37 echo "ERROR: checksum of latest snapshot from snapshot.properties is null!"
41 local_snap_checksum=""
43 # check snap cache directory exists
44 if [ -d "$SNAP_CACHE" ]; then
45 latest_snap=$(ls -Art | grep tar.gz | tail -n 1)
46 if [ -n "$latest_snap" ]; then
47 local_snap_checksum=$(sha512sum ${latest_snap} | cut -d' ' -f1)
50 mkdir -p ${SNAP_CACHE}
53 # compare check sum and download latest snap if not up to date
54 if [ "$local_snap_checksum" -ne "$latest_snap_checksum" ]; then
55 snap_url=$(cat opnfv.properties | grep OPNFV_SNAP_URL | awk -F "=" '{print $2}')
56 if [ -z "$snap_url" ]; then
57 echo "ERROR: Snap URL from snapshot.properties is null!"
60 echo "INFO: SHA mismatch, will download latest snapshot"
61 wget --directory-prefix=${SNAP_CACHE}/ ${snap_url}
62 snap_tar=$(basename ${snap_url})
64 snap_tar=${latest_snap}
67 echo "INFO: Snapshot to be used is ${snap_tar}"
69 # create tmp directory and unpack snap
71 pushd ./tmp > /dev/null
75 virsh_networks=$(ls *.xml | grep -v baremetal)
77 if [ -z "$virsh_networks" ]; then
78 echo "ERROR: no virsh networks found in snapshot unpack"
82 for network_def in ${virsh_networks}; do
83 sudo virsh net-create ${network_def}
84 network=$(echo ${network_def} | awk -F '.' '{print $1}')
85 if ! sudo virsh net-list | grep ${network}; then
86 sudo virsh net-start ${network}
88 echo "Checking if OVS bridge is missing for network: ${network}"
89 if ! ovs-vsctl show | grep "br-${network}"; then
90 ovs-vsctl add-br br-${network}
91 echo "OVS Bridge created: br-${network}"
92 if [ "br-${network}" == 'br-admin' ]; then
93 echo "Configuring IP 192.0.2.99 on br-admin"
94 sudo ip addr add 192.0.2.99/24 dev br-admin
95 sudo ip link set up dev br-admin
96 elif [ "br-${network}" == 'br-external' ]; then
97 echo "Configuring IP 192.168.37.99 on br-external"
98 sudo ip addr add 192.168.37.99/24 dev br-external
99 sudo ip link set up dev br-external
104 echo "Virsh networks up: $(virsh net-list)"
105 echo "Bringing up Overcloud VMs..."
106 virsh_vm_defs=$(ls baremetal*.xml)
108 if [ -z "$virsh_vm_defs" ]; then
109 echo "ERROR: no virsh VMs found in snapshot unpack"
113 for node_def in ${virsh_vm_defs}; do
114 sudo virsh define ${node_def}
115 node=$(echo ${node_def} | awk -F '.' '{print $1}')
116 sudo cp -f ${node}.qcow2 /var/lib/libvirt/images/
117 sudo virsh start ${node}
118 echo "Node: ${node} started"
121 echo "Checking overcloudrc"
122 if ! stat overcloudrc; then
123 echo "ERROR: overcloudrc does not exist in snap unpack"
127 # copy overcloudrc for functest
128 mkdir -p $HOME/cloner-info
129 cp -f overcloudrc $HOME/cloner-info/
131 admin_controller_ip=$(cat overcloudrc | grep -Eo "192.0.2.[0-9]+")
132 netvirt_url="http://${admin_controller_ip}:8081/restconf/operational/network-topology:network-topology/topology/netvirt:1"
136 while [ "$counter" -le 10 ]; do
137 if curl --fail ${admin_controller_ip}:80; then
138 echo "Overcloud Horizon is up...Checking if OpenDaylight NetVirt is up..."
139 if curl --fail ${netvirt_url} > /dev/null; then
140 echo "OpenDaylight is up. Overcloud deployment complete"
143 echo "OpenDaylight not yet up, try ${counter}"
146 echo "Horizon/Apache not yet up, try ${counter}"
148 counter=$((counter+1))
152 echo "ERROR: Deployment not up after 10 minutes...exiting."