diff options
author | Nikolas Hermanns <nikolas.hermanns@ericsson.com> | 2016-12-05 17:12:46 -0500 |
---|---|---|
committer | Fatih Degirmenci <fatih.degirmenci@ericsson.com> | 2017-02-01 23:07:42 +0100 |
commit | 2590b3c452a5b8e6bd95dbd3f6daecc12a9fc20d (patch) | |
tree | e2a56a0d980ffd92cd9e115b8b36f8c8c4ffa428 /jjb/apex/apex-snapshot-create.sh | |
parent | 690ce5838508a651d5cf06c89533d5b69ac999ec (diff) |
Apex: Create promotion and verify job for Apex CSIT snapshots
Changes Include:
- Adds a daily job to create Apex snapshot tarball if functest passes
- snapshot artifact uploaded to artifacts.opnfv.org
- snapshot artifcat info is stored in snapshot.properties
- 3rd party job updated to deploy from snapshot
- 3rd party install netvirt job updated to use updated sdnvpn tools
JIRA: APEX-364
Depends-On: I792db0fac3f4e81969fe85c05fc298fe5af02537
Change-Id: I8a875c081d756d098173c0baf11c0b4e4956b9fd
Signed-off-by: Tim Rozet <trozet@redhat.com>
Signed-off-by: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
Diffstat (limited to 'jjb/apex/apex-snapshot-create.sh')
-rw-r--r-- | jjb/apex/apex-snapshot-create.sh | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/jjb/apex/apex-snapshot-create.sh b/jjb/apex/apex-snapshot-create.sh new file mode 100644 index 000000000..09c6a1197 --- /dev/null +++ b/jjb/apex/apex-snapshot-create.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +############################################################################## +# Copyright (c) 2016 Tim Rozet (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 +############################################################################## + +set -o errexit +set -o nounset +set -o pipefail + +SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) + +echo "Creating Apex snapshot..." +echo "-------------------------" +echo + +# create tmp directory +tmp_dir=$(pwd)/.tmp +mkdir -p ${tmp_dir} + +# TODO(trozet) remove this after fix goes in for tripleo_inspector to copy these +pushd ${tmp_dir} > /dev/null +echo "Copying overcloudrc and ssh key from Undercloud..." +# Store overcloudrc +UNDERCLOUD=$(sudo virsh domifaddr undercloud | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]') +scp ${SSH_OPTIONS[@]} stack@${UNDERCLOUD}:overcloudrc ./ +# Copy out ssh key of stack from undercloud +scp ${SSH_OPTIONS[@]} stack@${UNDERCLOUD}:.ssh/id_rsa ./ +popd > /dev/null + +echo "Gathering introspection information" +git clone https://gerrit.opnfv.org/gerrit/sdnvpn.git +pushd sdnvpn/odl-pipeline/lib > /dev/null +./tripleo_introspector.sh --out-file ${tmp_dir}/node.yaml +popd > /dev/null + +echo "Shutting down nodes" +# Shut down nodes +nodes=$(sudo virsh list | grep -Eo "baremetal[0-9]") +for node in $nodes; do + sudo virsh shutdown ${node} --mode acpi +done + +for node in $nodes; do + count=0 + while [ "$count" -lt 10 ]; do + sleep 10 + if sudo virsh list | grep ${node}; then + echo "Waiting for $node to shutdown, try $count" + else + break + fi + count=$((count+1)) + done + + if [ "$count" -ge 10 ]; then + echo "Node $node failed to shutdown" + exit 1 + fi +done + +echo "Gathering virsh definitions" +# copy qcow2s, virsh definitions +for node in $nodes; do + cp -f /var/lib/libvirt/images/${node}.qcow2 ./ + sudo virsh dumpxml ${node} > ${node}.xml +done + +# copy virsh net definitions +for net in admin api external storage tenant; do + sudo virsh net-dumpxml ${net} > ${net}.xml +done + +# tar up artifacts +DATE=`date +%Y-%m-%d` +tar czf ../apex-csit-snap-${DATE}.tar.gz . +popd > /dev/null +rm -rf ./.tmp +echo "Snapshot saved as apex-csit-snap-${DATE}.tar.gz" + +# update opnfv properties file +curl -O -L http://$GS_URL/snapshot.properties +sed -i '/^OPNFV_SNAP_URL=/{h;s#=.*#='${GS_URL}'/apex-csit-snap-'${DATE}'.tar.gz#};${x;/^$/{s##OPNFV_SNAP_URL='${GS_URL}'/apex-csit-snap-'${DATE}'.tar.gz#;H};x}' snapshot.properties +snap_sha=$(sha512sum apex-csit-snap-${DATE}.tar.gz | cut -d' ' -f1) +sed -i '/^OPNFV_SNAP_SHA512SUM=/{h;s/=.*/='${snap_sha}'/};${x;/^$/{s//OPNFV_SNAP_SHA512SUM='${snap_sha}'/;H};x}' snapshot.properties +echo "OPNFV_SNAP_URL=$GS_URL/apex-csit-snap-${DATE}.tar.gz" +echo "OPNFV_SNAP_SHA512SUM=$(sha512sum apex-csit-snap-${DATE}.tar.gz | cut -d' ' -f1)" +echo "Updated properties file: " +cat snapshot.properties |