Compass4NFV CI verify support centos7
[releng.git] / jjb / infra / bifrost-verify.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson AB 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 ##############################################################################
10 set -o errexit
11 set -o nounset
12 set -o pipefail
13
14 trap fix_ownership EXIT
15
16 function fix_ownership() {
17     if [ -z "${JOB_URL+x}" ]; then
18         echo "Not running as part of Jenkins. Handle the logs manually."
19     else
20         # Make sure cache exists
21         [[ ! -d ${HOME}/.cache ]] && mkdir ${HOME}/.cache
22
23         sudo chown -R jenkins:jenkins $WORKSPACE
24         sudo chown -R jenkins:jenkins ${HOME}/.cache
25     fi
26 }
27
28 # check distro to see if we support it
29 if [[ ! "$DISTRO" =~ (trusty|centos7|suse) ]]; then
30     echo "Distro $DISTRO is not supported!"
31     exit 1
32 fi
33
34 # remove previously cloned repos
35 sudo /bin/rm -rf /opt/bifrost /opt/puppet-infracloud /opt/stack /opt/releng
36
37 # Fix up permissions
38 fix_ownership
39
40 # clone all the repos first and checkout the patch afterwards
41 sudo git clone https://git.openstack.org/openstack/bifrost /opt/bifrost
42 sudo git clone https://git.openstack.org/openstack-infra/puppet-infracloud /opt/puppet-infracloud
43 sudo git clone https://gerrit.opnfv.org/gerrit/releng /opt/releng
44
45 # checkout the patch
46 cd $CLONE_LOCATION
47 sudo git fetch $PROJECT_REPO $GERRIT_REFSPEC && sudo git checkout FETCH_HEAD
48
49 # combine opnfv and upstream scripts/playbooks
50 sudo /bin/cp -rf /opt/releng/prototypes/bifrost/* /opt/bifrost/
51
52 # place bridge creation file on the right path
53 sudo mkdir -p /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt
54 sudo cp /opt/puppet-infracloud/templates/bifrost/create_bridge.py.erb /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt/create_bridge.py
55
56 # replace bridge name
57 sudo sed -i s/"<%= @bridge_name -%>"/br_opnfv/g /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt/create_bridge.py
58
59 # cleanup remnants of previous deployment
60 cd /opt/bifrost
61 sudo -E ./scripts/destroy-env.sh
62
63 # provision 3 VMs; jumphost, controller, and compute
64 cd /opt/bifrost
65 sudo -E ./scripts/test-bifrost-deployment.sh
66
67 # list the provisioned VMs
68 cd /opt/bifrost
69 source env-vars
70 ironic node-list
71 virsh list