#!/bin/bash
+set -e
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# jonas.bjurel@ericsson.com
OPTIONS:
-b Base-uri for the stack-configuration structure
+ -d Dry-run
+
-l Lab-name
-p Pod-name
-s Deploy-scenario short-name/base-file-name
Input parameters to the build script is:
-b Base URI to the configuration directory (needs to be provided in a URI
style, it can be a local resource: file:// or a remote resource http(s)://)
+-d Dry-run - - Produces deploy config files (config/dea.yaml and
+ config/dha.yaml), but does not execute deploy
-l Lab name as defined in the configuration directory, e.g. lf
-p POD name as defined in the configuration directory, e.g. pod-1
-s Deployment-scenario, this points to a deployment/test scenario file as
NOTE: Root priviledges are needed for this script to run
+
Examples:
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
EOF
#
clean() {
echo "Cleaning up deploy tmp directories"
- rm -rf ${SCRIPT_PATH}/config
rm -rf ${SCRIPT_PATH}/ISO
- rm -rf ${SCRIPT_PATH}/releng
}
#
# END of deployment clean-up
#
SCRIPT_PATH=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
DEPLOY_DIR=$(cd ${SCRIPT_PATH}/../deploy; pwd)
-RELENG_REPO=https://jonasbjurel@gerrit.opnfv.org/gerrit/releng
+DRY_RUN=0
#
# END of variables to customize
############################################################################
############################################################################
# BEGIN of main
#
-while getopts "b:l:p:s:i:h" OPTION
+while getopts "b:dl:p:s:i:h" OPTION
do
case $OPTION in
b)
BASE_CONFIG_URI=${OPTARG}
;;
+ d)
+ DRY_RUN=1
+ ;;
l)
TARGET_LAB=${OPTARG}
;;
fi
# Enable the automatic exit trap
-set -o errexit
trap do_exit SIGINT SIGTERM EXIT
+# Set no restrictive umask so that Jenkins can removeeee any residuals
+umask 0000
+
clean
pushd ${DEPLOY_DIR} > /dev/null
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"
+
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
-# Download iso if it doesn't already exists locally
-if [[ $ISO == file://* ]]; then
- ISO=${ISO#file://}
-else
- mkdir -p ${SCRIPT_PATH}/ISO
- curl -o ${SCRIPT_PATH}/ISO/image.iso $ISO
- ISO=${SCRIPT_PATH}/ISO/image.iso
+if [ $DRY_RUN -eq 0 ]; then
+ # Download iso if it doesn't already exists locally
+ if [[ $ISO == file://* ]]; then
+ ISO=${ISO#file://}
+ else
+ mkdir -p ${SCRIPT_PATH}/ISO
+ curl -o ${SCRIPT_PATH}/ISO/image.iso $ISO
+ ISO=${SCRIPT_PATH}/ISO/image.iso
+ fi
+ # Start deployment
+ echo "python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
+ python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
fi
-# Start deployment
-echo "python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
-python deploy.py -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
popd > /dev/null
-# TBD: Upload the test-section of the scenario yaml file to the fuel master:
-# var/www/test.yaml
-
#
# END of main
############################################################################
final_dha_conf = dha_pod_conf
dha_scenario_override_conf = deploy_scenario_conf["dha-override-config"]
-if dha_scenario_override_conf:
+# Only virtual deploy scenarios can override dha.yaml since there
+# is no way to programatically override a physical environment:
+# wireing, IPMI set-up, etc.
+# For Physical environments, dha.yaml overrides will be silently ignored
+if dha_scenario_override_conf and (final_dha_conf['adapter'] == 'libvirt' or final_dha_conf['adapter'] == 'esxi' or final_dha_conf['adapter'] == 'vbox'):
print 'Merging dha-pod and deployment-scenario override information to final dha.yaml configuration....'
final_dha_conf = dict(mergedicts(final_dha_conf, dha_scenario_override_conf))