3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 ############################################################################
13 # BEGIN of Exit handlers
20 # End of Exit handlers
21 ############################################################################
23 ############################################################################
24 # BEGIN of usage description
29 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
30 `basename $0`: Deploys the Fuel@OPNFV stack
32 usage: `basename $0` -b base-uri [-B PXE Bridge] [-f] [-F] [-H] -l lab-name -p pod-name -s deploy-scenario [-S image-dir] -i iso
33 -s deployment-scenario [-S optional Deploy-scenario path URI]
34 [-R optional local relen repo (containing deployment Scenarios]
37 -b Base-uri for the stack-configuration structure
38 -B PXE Bridge for booting of Fuel master
40 -f Deploy on existing Fuel master
41 -e Do not launch environment deployment
42 -F Do only create a Fuel master
43 -h Print this message and exit
46 -L Deployment log path and file name
48 -s Deploy-scenario short-name/base-file-name
49 -S Storage dir for VM images
53 Deploys the Fuel@OPNFV stack on the indicated lab resource
55 This script provides the Fuel@OPNFV deployment abstraction
56 It depends on the OPNFV official configuration directory/file structure
57 and provides a fairly simple mechanism to execute a deployment.
58 Input parameters to the build script is:
59 -b Base URI to the configuration directory (needs to be provided in a URI
60 style, it can be a local resource: file:// or a remote resource http(s)://)
61 -B PXE Bridge for booting of Fuel master, default is pxebr
62 -d Dry-run - Produces deploy config files (config/dea.yaml and
63 config/dha.yaml), but does not execute deploy
64 -f Deploy on existing Fuel master
65 -e Do not launch environment deployment
66 -F Do only create a Fuel master
67 -h Print this message and exit
68 -H Do not run fuel built in health-check after successfull deployment
69 -l Lab name as defined in the configuration directory, e.g. lf
70 -L Deployment log path and name, eg. -L /home/jenkins/logs/job888.log.tar.gz
71 -p POD name as defined in the configuration directory, e.g. pod-1
72 -s Deployment-scenario, this points to a deployment/test scenario file as
73 defined in the configuration directory:
74 e.g fuel-ocl-heat-ceilometer_scenario_0.0.1.yaml
75 or a deployment short-name as defined by scenario.yaml in the deployment
77 -S Storage dir for VM images, default is fuel/deploy/images
78 -i .iso image to be deployed (needs to be provided in a URI
79 style, it can be a local resource: file:// or a remote resource http(s)://)
81 NOTE: Root priviledges are needed for this script to run
85 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
90 # END of usage description
91 ############################################################################
93 ############################################################################
94 # BEGIN of deployment clean-up
97 echo "Cleaning up deploy tmp directories"
98 rm -rf ${SCRIPT_PATH}/ISO
101 # END of deployment clean-up
102 ############################################################################
104 ############################################################################
105 # BEGIN of shorthand variables for internal use
107 SCRIPT_PATH=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
108 DEPLOY_DIR=$(cd ${SCRIPT_PATH}/../deploy; pwd)
112 FUEL_CREATION_ONLY=''
113 NO_DEPLOY_ENVIRONMENT=''
117 # END of variables to customize
118 ############################################################################
120 ############################################################################
123 while getopts "b:B:dfFHl:L:p:s:S:i:he" OPTION
127 BASE_CONFIG_URI=${OPTARG}
128 if [[ ! $BASE_CONFIG_URI == file://* ]] && \
129 [[ ! $BASE_CONFIG_URI == http://* ]] && \
130 [[ ! $BASE_CONFIG_URI == https://* ]] && \
131 [[ ! $BASE_CONFIG_URI == ftp://* ]]; then
132 echo "-b $BASE_CONFIG_URI - Not given in URI style"
138 if [[ ${OPTARG} ]]; then
139 PXE_BRIDGE="-b ${OPTARG}"
146 USE_EXISTING_FUEL='-nf'
149 FUEL_CREATION_ONLY='-fo'
152 NO_DEPLOY_ENVIRONMENT='-nde'
155 NO_HEALTH_CHECK='-nh'
161 DEPLOY_LOG="-log ${OPTARG}"
167 DEPLOY_SCENARIO=${OPTARG}
170 if [[ ${OPTARG} ]]; then
171 STORAGE_DIR="-s ${OPTARG}"
176 if [[ ! $ISO == file://* ]] && \
177 [[ ! $ISO == http://* ]] && \
178 [[ ! $ISO == https://* ]] && \
179 [[ ! $ISO == ftp://* ]]; then
180 echo "-i $ISO - Not given in URI style"
190 echo "${OPTION} is not a valid argument"
191 echo "Arguments not according to new argument style"
192 echo "Trying old-style compatibility mode"
193 pushd ${DEPLOY_DIR} > /dev/null
194 python deploy.py "$@"
201 if [[ $EUID -ne 0 ]]; then
202 echo "This script must be run as root" 1>&2
206 if [ -z $BASE_CONFIG_URI ] || [ -z $TARGET_LAB ] || \
207 [ -z $TARGET_POD ] || [ -z $DEPLOY_SCENARIO ] || \
209 echo "Arguments not according to new argument style"
210 echo "Trying old-style compatibility mode"
211 pushd ${DEPLOY_DIR} > /dev/null
212 python deploy.py "$@"
217 # Enable the automatic exit trap
218 trap do_exit SIGINT SIGTERM EXIT
220 # Set no restrictive umask so that Jenkins can removeeee any residuals
225 pushd ${DEPLOY_DIR} > /dev/null
226 # Prepare the deploy config files based on lab/pod information, deployment
229 echo "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"
231 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
233 if [ $DRY_RUN -eq 0 ]; then
234 # Download iso if it doesn't already exists locally
235 if [[ $ISO == file://* ]]; then
238 mkdir -p ${SCRIPT_PATH}/ISO
239 curl -o ${SCRIPT_PATH}/ISO/image.iso $ISO
240 ISO=${SCRIPT_PATH}/ISO/image.iso
243 echo "python deploy.py $DEPLOY_LOG $STORAGE_DIR $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK $NO_DEPLOY_ENVIRONMENT -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
244 python deploy.py $DEPLOY_LOG $STORAGE_DIR $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK $NO_DEPLOY_ENVIRONMENT -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
250 ############################################################################