From 64c540bd168c463f1bb1ba08b7c1a803eee24fcb Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Wed, 9 May 2018 15:04:32 -0700 Subject: Add script to sync heat template from manifest Also clean up other helper scripts Change-Id: Icae9cac8c6e9e3cef5e52e66bf79d6c30d23d235 Issue-ID: INT-495 Signed-off-by: Gary Wu --- .../src/main/scripts/add-images-from-oom.sh | 39 ++++++++++++++++++++++ version-manifest/src/main/scripts/check-sorted.sh | 7 ++++ .../src/main/scripts/merge-oom-images.sh | 39 ---------------------- .../src/main/scripts/update-heat-image-versions.sh | 20 +++++++++++ .../src/main/scripts/update-oom-image-versions.sh | 8 +---- 5 files changed, 67 insertions(+), 46 deletions(-) create mode 100755 version-manifest/src/main/scripts/add-images-from-oom.sh delete mode 100755 version-manifest/src/main/scripts/merge-oom-images.sh create mode 100755 version-manifest/src/main/scripts/update-heat-image-versions.sh (limited to 'version-manifest/src/main') diff --git a/version-manifest/src/main/scripts/add-images-from-oom.sh b/version-manifest/src/main/scripts/add-images-from-oom.sh new file mode 100755 index 000000000..f7207701f --- /dev/null +++ b/version-manifest/src/main/scripts/add-images-from-oom.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo This script adds new docker images from OOM helm charts into docker-manifest.csv + echo "$0 " + exit 1 +fi + +# expected parameters +MANIFEST=$(realpath $1) +OOM_DIR=$(realpath $2) + +if [ -z "$WORKSPACE" ]; then + export WORKSPACE=`git rev-parse --show-toplevel` +fi + +DIR=$(dirname $(readlink -f "$0")) +TARGET_DIR=$DIR/target +rm -rf $TARGET_DIR +mkdir -p $TARGET_DIR +cd $TARGET_DIR + +cd $OOM_DIR +rgrep "image: .*" --include=values.yaml -h | cut -d ' ' -f 2 | tr -d '"'| grep -v '<' | grep -e "^onap" -e "^openecomp" | LC_ALL=C sort -u > $TARGET_DIR/oom-manifest.txt +touch $TARGET_DIR/docker-manifest-new-entries.txt + +for line in $(cat $TARGET_DIR/oom-manifest.txt); do + image=$(echo $line | cut -d : -f 1) + tag=$(echo $line | cut -s -d : -f 2) + if [ -z "$tag" ]; then + tag="latest" + fi + if ! grep -q "$image" $MANIFEST; then + echo $image,$tag >> $TARGET_DIR/docker-manifest-new-entries.txt + fi +done + +cat $MANIFEST $TARGET_DIR/docker-manifest-new-entries.txt | LC_ALL=C sort -u > $MANIFEST.tmp +mv $MANIFEST.tmp $MANIFEST diff --git a/version-manifest/src/main/scripts/check-sorted.sh b/version-manifest/src/main/scripts/check-sorted.sh index fa120f399..70ca5ac04 100755 --- a/version-manifest/src/main/scripts/check-sorted.sh +++ b/version-manifest/src/main/scripts/check-sorted.sh @@ -1,4 +1,11 @@ #!/bin/bash + +if [ "$#" -ne 1 ]; then + echo This script checks the input file to verify that it is sorted + echo "$0 " + exit 1 +fi + LC_ALL=C sort -c $1 retval=$? if [ $retval -ne 0 ]; then diff --git a/version-manifest/src/main/scripts/merge-oom-images.sh b/version-manifest/src/main/scripts/merge-oom-images.sh deleted file mode 100755 index 248bc331c..000000000 --- a/version-manifest/src/main/scripts/merge-oom-images.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -if [ "$#" -ne 2 ]; then - echo This script adds docker images that exist in OOM helm charts into docker-manifest.csv - echo "$0 " - exit 1 -fi - -# expected parameters -MANIFEST=$(realpath $1) -OOM_DIR=$(realpath $2) - -if [ -z "$WORKSPACE" ]; then - export WORKSPACE=`git rev-parse --show-toplevel` -fi - -DIR=$(dirname $(readlink -f "$0")) -TARGET_DIR=$DIR/target -rm -rf $TARGET_DIR -mkdir -p $TARGET_DIR -cd $TARGET_DIR - -cd $OOM_DIR -rgrep "image: .*" --include=values.yaml -h | cut -d ' ' -f 2 | tr -d '"'| grep -v '<' | grep -e "^onap" -e "^openecomp" | LC_ALL=C sort -u > $TARGET_DIR/oom-manifest.txt -touch $TARGET_DIR/docker-manifest-new-entries.txt - -for line in $(cat $TARGET_DIR/oom-manifest.txt); do - image=$(echo $line | cut -d : -f 1) - tag=$(echo $line | cut -s -d : -f 2) - if [ -z "$tag" ]; then - tag="latest" - fi - if ! grep -q "$image" $MANIFEST; then - echo $image,$tag >> $TARGET_DIR/docker-manifest-new-entries.txt - fi -done - -cat $MANIFEST $TARGET_DIR/docker-manifest-new-entries.txt | LC_ALL=C sort -u > $MANIFEST.tmp -mv $MANIFEST.tmp $MANIFEST diff --git a/version-manifest/src/main/scripts/update-heat-image-versions.sh b/version-manifest/src/main/scripts/update-heat-image-versions.sh new file mode 100755 index 000000000..19415bb12 --- /dev/null +++ b/version-manifest/src/main/scripts/update-heat-image-versions.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo This script updates HEAT docker versions to use versions in docker-manifest.csv + echo "$0 " + exit 1 +fi + +# expected parameters +MANIFEST=$(realpath $1) +DEMO_DIR=$(realpath $2) + +if [ -z "$WORKSPACE" ]; then + export WORKSPACE=`git rev-parse --show-toplevel` +fi + +cd $DEMO_DIR/heat/ONAP + +source <(./manifest-to-env.sh < $MANIFEST) +envsubst < onap_openstack_template.env > onap_openstack.env diff --git a/version-manifest/src/main/scripts/update-oom-image-versions.sh b/version-manifest/src/main/scripts/update-oom-image-versions.sh index eba847841..1a82b490d 100755 --- a/version-manifest/src/main/scripts/update-oom-image-versions.sh +++ b/version-manifest/src/main/scripts/update-oom-image-versions.sh @@ -2,7 +2,7 @@ if [ "$#" -ne 2 ]; then echo This script updates OOM helm charts to use versions in docker-manifest.csv - echo "$0 " + echo "$0 " exit 1 fi @@ -14,12 +14,6 @@ if [ -z "$WORKSPACE" ]; then export WORKSPACE=`git rev-parse --show-toplevel` fi -DIR=$(dirname $(readlink -f "$0")) -TARGET_DIR=$DIR/target -rm -rf $TARGET_DIR -mkdir -p $TARGET_DIR -cd $TARGET_DIR - cd $OOM_DIR/kubernetes for line in $(tail -n +2 $MANIFEST); do -- cgit 1.2.3-korg