277206dc7086089a81c8ba81b5078f1ef4d80c10
[releng.git] / prototypes / xci / xci-deploy.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5 set -o xtrace
6
7 # This script must run as root
8 if [[ $(whoami) != "root" ]]; then
9     echo "Error: This script must be run as root!"
10     exit 1
11 fi
12
13 # find where are we
14 XCI_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
15
16 # source user vars
17 source $XCI_PATH/config/user-vars
18
19 # source pinned versions
20 source $XCI_PATH/config/pinned-versions
21
22 # source flavor configuration
23 source "$XCI_PATH/flavors/${XCI_FLAVOR}-vars"
24
25 # source xci configuration
26 source $XCI_PATH/config/env-vars
27
28 # log info to console
29 echo "Info: Starting XCI Deployment"
30 echo "Info: Deployment parameters"
31 echo "-------------------------------------------------------------------------"
32 echo "xci flavor: $XCI_FLAVOR"
33 echo "opnfv/releng version: $OPNFV_RELENG_VERSION"
34 echo "openstack/bifrost version: $OPENSTACK_BIFROST_VERSION"
35 echo "openstack/openstack-ansible version: $OPENSTACK_OSA_VERSION"
36 echo "-------------------------------------------------------------------------"
37
38 #-------------------------------------------------------------------------------
39 # Cleanup the leftovers from the previous deployment
40 #-------------------------------------------------------------------------------
41 echo "Info: Cleaning up the previous deployment"
42 $XCI_PATH/../bifrost/scripts/destroy-env.sh > /dev/null 2>&1
43 /bin/rm -rf /opt/releng /opt/bifrost /opt/openstack-ansible
44
45 #-------------------------------------------------------------------------------
46 # Clone the repositories and checkout the versions
47 #-------------------------------------------------------------------------------
48 echo "Info: Cloning repositories and checking out versions"
49 git clone --quiet $OPNFV_RELENG_GIT_URL $OPNFV_RELENG_PATH && \
50     cd $OPNFV_RELENG_PATH
51 echo "Info: Cloned opnfv/releng. HEAD currently points at"
52 echo "      $(git show --oneline -s --pretty=format:'%h - %s (%cr) <%an>')"
53 git clone --quiet $OPENSTACK_BIFROST_GIT_URL $OPENSTACK_BIFROST_PATH && \
54     cd $OPENSTACK_BIFROST_PATH
55 echo "Info: Cloned openstack/bifrost. HEAD currently points at"
56 echo "      $(git show --oneline -s --pretty=format:'%h - %s (%cr) <%an>')"
57
58 #-------------------------------------------------------------------------------
59 # Combine opnfv and upstream scripts/playbooks
60 #-------------------------------------------------------------------------------
61 echo "Info: Combining opnfv/releng and opestack/bifrost scripts/playbooks"
62 /bin/cp -rf $OPNFV_RELENG_PATH/prototypes/bifrost/* $OPENSTACK_BIFROST_PATH/
63
64 #-------------------------------------------------------------------------------
65 # Start provisioning VM nodes
66 #-------------------------------------------------------------------------------
67 echo "Info: Starting provisining VM nodes using openstack/bifrost"
68 echo "      This might take between 10 to 20 minutes depending on the flavor and the host"
69 echo "-------------------------------------------------------------------------"
70 cd $OPENSTACK_BIFROST_PATH
71 STARTTIME=$(date +%s)
72 ./scripts/bifrost-provision.sh
73 ENDTIME=$(date +%s)
74 echo "-----------------------------------------------------------------------"
75 echo "Info: VM nodes are provisioned!"
76 echo "Info: It took $(($ENDTIME - $STARTTIME)) seconds to provising the VM nodes"