2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # jonas.bjurel@ericsson.com
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 ##############################################################################
11 ############################################################################
12 # BEGIN of Exit handlers
19 # End of Exit handlers
20 ############################################################################
22 ############################################################################
23 # BEGIN of usage description
28 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
29 `basename $0`: Deploys the Fuel@OPNFV stack
31 usage: `basename $0` -b base-uri -l lab-name -p pod-name -i iso
32 -s deployment-scenario [-S optional Deploy-scenario path URI]
33 [-R optional local relen repo (containing deployment Scenarios]
36 -b Base-uri for the stack-configuration structure
39 -s Deploy-scenario short-name/base-file-name
43 Deploys the Fuel@OPNFV stack on the indicated lab resource
45 This script provides the Fuel@OPNFV deployment abstraction
46 It depends on the OPNFV official configuration directory/file structure
47 and provides a fairly simple mechanism to execute a deployment.
48 Input parameters to the build script is:
49 -b Base URI to the configuration directory (needs to be provided in a URI
50 style, it can be a local resource: file:// or a remote resource http(s)://)
51 -l Lab name as defined in the configuration directory, e.g. lf
52 -p POD name as defined in the configuration directory, e.g. pod-1
53 -s Deployment-scenario, this points to a deployment/test scenario file as
54 defined in the configuration directory:
55 e.g fuel-ocl-heat-ceilometer_scenario_0.0.1.yaml
56 or a deployment short-name as defined by scenario.yaml in the deployment
58 -i .iso image to be deployed (needs to be provided in a URI
59 style, it can be a local resource: file:// or a remote resource http(s)://)
61 NOTE: Root priviledges are needed for this script to run
64 sudo `basename $0` -b file:///home/jenkins/lab-config -l lf -p pod1 -s ha_odl-l3_heat_ceilometer -i file:///home/jenkins/myiso.iso
69 # END of usage description
70 ############################################################################
72 ############################################################################
73 # BEGIN of deployment clean-up
76 echo "Cleaning up deploy tmp directories"
77 rm -rf ${SCRIPT_PATH}/config
78 rm -rf ${SCRIPT_PATH}/ISO
79 rm -rf ${SCRIPT_PATH}/releng
82 # END of deployment clean-up
83 ############################################################################
85 ############################################################################
86 # BEGIN of shorthand variables for internal use
88 SCRIPT_PATH=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
89 DEPLOY_DIR=$(cd ${SCRIPT_PATH}/../deploy; pwd)
90 RELENG_REPO=https://jonasbjurel@gerrit.opnfv.org/gerrit/releng
92 # END of variables to customize
93 ############################################################################
95 ############################################################################
98 while getopts "b:l:p:s:i:h" OPTION
102 BASE_CONFIG_URI=${OPTARG}
111 DEPLOY_SCENARIO=${OPTARG}
121 echo "${OPTION} is not a valid argument"
122 echo "Arguments not according to new argument style"
123 echo "Trying old-style compatibility mode"
124 pushd ${DEPLOY_DIR} > /dev/null
125 python deploy.py "$@"
132 if [[ $EUID -ne 0 ]]; then
133 echo "This script must be run as root" 1>&2
137 if [ -z $BASE_CONFIG_URI ] || [ -z $TARGET_LAB ] || \
138 [ -z $TARGET_POD ] || [ -z $DEPLOY_SCENARIO ] || \
140 echo "Arguments not according to new argument style"
141 echo "Trying old-style compatibility mode"
142 pushd ${DEPLOY_DIR} > /dev/null
143 python deploy.py "$@"
148 # Enable the automatic exit trap
150 trap do_exit SIGINT SIGTERM EXIT
154 pushd ${DEPLOY_DIR} > /dev/null
155 # Prepare the deploy config files based on lab/pod information, deployment
158 echo "python deploy-config.py -dha ${BASE_CONFIG_URI}/labs/${TARGET_LAB}/${TARGET_POD}/fuel/config/dha.yaml -deab ${DEPLOY_DIR}/config/dea_base.yaml -deao ${BASE_CONFIG_URI}/labs/${TARGET_LAB}/${TARGET_POD}/fuel/config/dea-pod-override.yaml -scenario-base-uri ${DEPLOY_DIR}/scenario -scenario ${DEPLOY_SCENARIO} -plugins ${DEPLOY_DIR}/config/plugins -output ${SCRIPT_PATH}/config"
160 python deploy-config.py -dha ${BASE_CONFIG_URI}/labs/${TARGET_LAB}/${TARGET_POD}/fuel/config/dha.yaml -deab file://${DEPLOY_DIR}/config/dea_base.yaml -deao ${BASE_CONFIG_URI}/labs/${TARGET_LAB}/${TARGET_POD}/fuel/config/dea-pod-override.yaml -scenario-base-uri file://${DEPLOY_DIR}/scenario -scenario ${DEPLOY_SCENARIO} -plugins file://${DEPLOY_DIR}/config/plugins -output ${SCRIPT_PATH}/config
162 # Download iso if it doesn't already exists locally
163 if [[ $ISO == file://* ]]; then
166 mkdir -p ${SCRIPT_PATH}/ISO
167 curl -o ${SCRIPT_PATH}/ISO/image.iso $ISO
168 ISO=${SCRIPT_PATH}/ISO/image.iso
171 echo "python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
172 python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
175 # TBD: Upload the test-section of the scenario yaml file to the fuel master:
180 ############################################################################