X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=tools%2Fgenerate_yamls.sh;h=9187e85dfd888047949b6bb4b43fc9d805a51867;hb=fbb206730195c6f03ded7658d08f1ef708ebf88b;hp=45284423b58d776e66b7329dd2b7a74050074b8f;hpb=8ca1343f22312d9711b92fed95ad52655842451a;p=yaml_builds.git diff --git a/tools/generate_yamls.sh b/tools/generate_yamls.sh old mode 100644 new mode 100755 index 4528442..9187e85 --- a/tools/generate_yamls.sh +++ b/tools/generate_yamls.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright © 2018 AT&T Intellectual Property. All rights reserved. # +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. # @@ -15,24 +15,13 @@ # limitations under the License. # ############################################################################## +set -x source $(dirname $0)/setenv.sh -if [ -z "$AIC_CLCP_MANIFESTS" ] -then - echo "Please follow https://codecloud.web.att.com/projects/ST_CCP/repos/aic-clcp-manifests/browse/docs/source/deployment_blueprint.md to clone aic-clcp-manifests. Also export AIC_CLCP_MANIFESTS to it." - exit -1 -fi - -if [ -z "$AIC_CLCP_SECURITY_MANIFESTS" ] -then - echo "Please follow https://codecloud.web.att.com/projects/ST_CCP/repos/aic-clcp-manifests/browse/docs/source/deployment_blueprint.md to clone aic-clcp-security-manifests. Also export AIC_CLCP_SECURITY_MANIFESTS to it." - exit -1 -fi - if [ -z "$1" ] then - echo "Plese pass site name as command line argument" + echo "Please pass site name as command line argument" exit -2 else SITE=${SITE:-$1} @@ -40,7 +29,54 @@ else fi cd $YAML_BUILDS -python ./scripts/jcopy.py $SITE.yaml ./templates/aic-clcp-manifests $AIC_CLCP_MANIFESTS/site/$SITE -python ./scripts/jcopy.py $SITE.yaml ./templates/aic-clcp-security-manifests $AIC_CLCP_SECURITY_MANIFESTS/site/$SITE -python ./scripts/jcopy.py $SITE.yaml ./templates/yaml_builds/set_site_env.sh ./tools/ -mv ./tools/set_site_env.sh ./tools/env_$SITE.sh + +# ECHO INPUT FILE TO LOGS FOR TROUBLESHOOTING +echo "#######################################" +echo "# USING INPUT FILE [${YAML_BUILDS}/${SITE}.yaml]" +echo "#######################################" +sed -E 's/(^.*password:).*/\1 ###PASSWORD REMOVED####/g' ${YAML_BUILDS}/${SITE}.yaml +echo "#######################################" + +python ./scripts/jcopy.py $SITE.yaml ./tools/j2/set_site_env.sh ./tools/env_$SITE.sh +source ./tools/env_$SITE.sh + +if [ ! -d "$AIRSHIP_TREASUREMAP" ] && [ -f "${AIRSHIP_TREASUREMAP}.tgz" ]; then + echo "Expanding [${AIRSHIP_TREASUREMAP}.tgz] to directory [$AIRSHIP_TREASUREMAP]." + mkdir -p "$AIRSHIP_TREASUREMAP" + tar xzvf "${AIRSHIP_TREASUREMAP}.tgz" --strip-components=1 -C "$AIRSHIP_TREASUREMAP" +fi + +if [ ! -d "$AIRSHIP_TREASUREMAP" ]; then + echo "ERROR: Missing AIRSHIP_TREASUREMAP directory [$AIRSHIP_TREASUREMAP]." + exit -1 +fi + +if [ ! -d "$AIRSHIP_TEMPLATES" ]; then + echo "ERROR: Missing AIRSHIP_TEMPLATES directory [$AIRSHIP_TEMPLATES]." + exit -1 +fi + +echo "# Generating templates to $YAML_BUILDS/site/$SITE" +rm -rf $YAML_BUILDS/site/$SITE +mkdir -p $YAML_BUILDS/site/$SITE +python ./scripts/jcopy.py $SITE.yaml $AIRSHIP_TEMPLATES $YAML_BUILDS/site/$SITE + +echo "# Merging config files to $AIRSHIP_TREASUREMAP/site/$SITE" +rm -rf $AIRSHIP_TREASUREMAP/site/$SITE +mkdir -p $AIRSHIP_TREASUREMAP/site/$SITE + +cp -r $AIRSHIP_TREASUREMAP/site/seaworthy/* $AIRSHIP_TREASUREMAP/site/$SITE +cp -r $YAML_BUILDS/site/$SITE/* $AIRSHIP_TREASUREMAP/site/$SITE + +CONFIG_COUNT=`find $AIRSHIP_TREASUREMAP/site/$SITE -type f | wc -l` +echo "#######################################" +echo "# Created site $AIRSHIP_TREASUREMAP/site/$SITE with $CONFIG_COUNT config files" +echo "#######################################" + +( +echo "# Linting config files in $AIRSHIP_TREASUREMAP/site/$SITE" +cd $AIRSHIP_TREASUREMAP +$AIRSHIP_TREASUREMAP/tools/airship pegleg site -r /target lint $SITE -x P001 -x P005 || true +) + +echo "#######################################"