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 snapshot cache exists, find the checksum
45 if [ -d "$SNAP_CACHE" ]; then
46 latest_snap=$(ls ${SNAP_CACHE} | grep tar.gz | tail -n 1)
47 if [ -n "$latest_snap" ]; then
48 local_snap_checksum=$(sha512sum ${SNAP_CACHE}/${latest_snap} | cut -d' ' -f1)
51 mkdir -p ${SNAP_CACHE}
54 # compare check sum and download latest snap if not up to date
55 if [ "$local_snap_checksum" != "$latest_snap_checksum" ]; then
56 snap_url=$(cat opnfv.properties | grep OPNFV_SNAP_URL | awk -F "=" '{print $2}')
57 if [ -z "$snap_url" ]; then
58 echo "ERROR: Snap URL from snapshot.properties is null!"
61 echo "INFO: SHA mismatch, will download latest snapshot"
63 rm -rf ${SNAP_CACHE}/*
64 wget --directory-prefix=${SNAP_CACHE}/ ${snap_url}
65 snap_tar=$(basename ${snap_url})
67 snap_tar=${latest_snap}
70 echo "INFO: Snapshot to be used is ${snap_tar}"
72 # move to snap cache dir and unpack
73 pushd ${SNAP_CACHE} > /dev/null
77 virsh_networks=$(ls *.xml | grep -v baremetal)
79 if [ -z "$virsh_networks" ]; then
80 echo "ERROR: no virsh networks found in snapshot unpack"
84 for network_def in ${virsh_networks}; do
85 sudo virsh net-create ${network_def}
86 network=$(echo ${network_def} | awk -F '.' '{print $1}')
87 if ! sudo virsh net-list | grep ${network}; then
88 sudo virsh net-start ${network}
90 echo "Checking if OVS bridge is missing for network: ${network}"
91 if ! sudo ovs-vsctl show | grep "br-${network}"; then
92 sudo ovs-vsctl add-br br-${network}
93 echo "OVS Bridge created: br-${network}"
94 if [ "br-${network}" == 'br-admin' ]; then
95 echo "Configuring IP 192.0.2.99 on br-admin"
96 sudo ip addr add 192.0.2.99/24 dev br-admin
97 sudo ip link set up dev br-admin
98 elif [ "br-${network}" == 'br-external' ]; then
99 echo "Configuring IP 192.168.37.1 on br-external"
100 sudo ip addr add 192.168.37.1/24 dev br-external
101 sudo ip link set up dev br-external
106 echo "Virsh networks up: $(sudo virsh net-list)"
107 echo "Bringing up Overcloud VMs..."
108 virsh_vm_defs=$(ls baremetal*.xml)
110 if [ -z "$virsh_vm_defs" ]; then
111 echo "ERROR: no virsh VMs found in snapshot unpack"
115 for node_def in ${virsh_vm_defs}; do
116 sudo virsh define ${node_def}
117 node=$(echo ${node_def} | awk -F '.' '{print $1}')
118 sudo cp -f ${node}.qcow2 /var/lib/libvirt/images/
119 sudo virsh start ${node}
120 echo "Node: ${node} started"
123 echo "Checking overcloudrc"
124 if ! stat overcloudrc; then
125 echo "ERROR: overcloudrc does not exist in snap unpack"
129 # copy overcloudrc for functest
130 mkdir -p $HOME/cloner-info
131 cp -f overcloudrc $HOME/cloner-info/
133 admin_controller_ip=$(cat overcloudrc | grep -Eo "192.0.2.[0-9]+")
134 netvirt_url="http://${admin_controller_ip}:8081/restconf/operational/network-topology:network-topology/topology/netvirt:1"
138 while [ "$counter" -le 10 ]; do
139 if curl --fail --silent ${admin_controller_ip}:80 > /dev/null; then
140 echo "Overcloud Horizon is up...Checking if OpenDaylight NetVirt is up..."
141 if curl --fail --silent -u admin:admin ${netvirt_url} > /dev/null; then
142 echo "OpenDaylight is up. Overcloud deployment complete"
145 echo "OpenDaylight not yet up, try ${counter}"
148 echo "Horizon/Apache not yet up, try ${counter}"
150 counter=$((counter+1))
154 echo "ERROR: Deployment not up after 10 minutes...exiting."