Revise deployment tools to better reflect the repo structure.

Signed-off-by: Zhe Huang <zhehuang@research.att.com>
Change-Id: I7273d520aa3b1b6260ea5872411263ab2e0dc0e0
diff --git a/bin/deploy-nonrtric b/bin/deploy-nonrtric
index fd7b85e..eab4dc2 100755
--- a/bin/deploy-nonrtric
+++ b/bin/deploy-nonrtric
@@ -56,11 +56,7 @@
     nohup helm serve >& /dev/null &
 fi
 
-# Package nonrtric-common and serve it using Helm local repo
-HELM_HOME=$(helm home)
-COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
-cp /tmp/nonrtric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+$ROOT_DIR/prepare-common-templates
 
 COMPONENTS=${LIST_OF_COMPONENTS:-"controlpanel a1controller a1simulator policymanagementservice"}
 echo "Packaging NONRTRIC components [$COMPONENTS]"
diff --git a/bin/deploy-ric-aux b/bin/deploy-ric-aux
index 3816f7e..d0ddeee 100755
--- a/bin/deploy-ric-aux
+++ b/bin/deploy-ric-aux
@@ -51,28 +51,6 @@
 
 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
 
-# Start Helm local repo if there isn't one
-HELM_REPO_PID=$(ps -x | grep  "helm serve" | grep -v "grep" | awk '{print $1}')
-if [ -z "$HELM_REPO_PID" ]; then
-    nohup helm serve >& /dev/null &
-fi
-
-# Package ric-common and serve it using Helm local repo
-HELM_HOME=$(helm home)
-COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
-cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
-
-AUX_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/aux-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/aux-common
-cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
-
-helm repo index $HELM_HOME/repository/local/
-
-
-# Make sure that helm local repo is added
-helm repo remove local
-helm repo add local http://127.0.0.1:8879/charts
-
+$ROOT_DIR/prepare-common-templates
 
 $ROOT_DIR/../ric-aux/bin/install -f $OVERRIDEYAML
diff --git a/bin/deploy-ric-platform b/bin/deploy-ric-platform
index 1d2f837..a16b67c 100755
--- a/bin/deploy-ric-platform
+++ b/bin/deploy-ric-platform
@@ -58,19 +58,7 @@
     nohup helm serve >& /dev/null &
 fi
 
-# Package ric-common and serve it using Helm local repo
-HELM_HOME=$(helm home)
-COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
-cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
-helm repo index $HELM_HOME/repository/local/
-
-
-# Make sure that helm local repo is added
-helm repo remove local
-helm repo add local http://127.0.0.1:8879/charts
-
-
+$ROOT_DIR/prepare-common-templates
 
 $ROOT_DIR/../ric-dep/bin/install -f $OVERRIDEYAML
 
diff --git a/bin/gen-image-list b/bin/gen-image-list
deleted file mode 100755
index 34df424..0000000
--- a/bin/gen-image-list
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/bash
-##############################################################################
-#
-#   Copyright (c) 2019 AT&T Intellectual Property.
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-##############################################################################
-
-# Installs well-known RIC charts then verifies specified helm chart
-# Requires chart tgz archives in /tmp
-
-
-while [ -n "$1" ]; do # while loop starts
-
-    case "$1" in
-
-    -f) OVERRIDEYAML=$2
-        shift
-        ;; 
-    *) echo "Option $1 not recognized. Please use -f to specify the recipe path." ;; # In case you typed a different option other than a,b,c
-
-    esac
-
-    shift
-
-done
-
-if [ -z $OVERRIDEYAML ]; then
-   echo "Deploy recipe is missing. Please use -f to specify the recipe path."
-   exit 1
-fi
-
-
-ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
-
-
-# Start Helm local repo if there isn't one
-HELM_REPO_PID=$(ps -x | grep  "helm serve" | grep -v "grep" | awk '{print $1}')
-if [ -z "$HELM_REPO_PID" ]; then
-    nohup helm serve >& /dev/null &
-fi
-
-# Package ric-common and serve it using Helm local repo
-HELM_HOME=$(helm home)
-COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
-cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
-helm repo index $HELM_HOME/repository/local/
-
-
-# Make sure that helm local repo is added
-helm repo remove local
-helm repo add local http://127.0.0.1:8879/charts
-
-
-
-
-TEMP_DIR=/tmp
-rm -rf $TEMP_DIR/imagelist
-touch $TEMP_DIR/imagelist
-CHART_ARRAY=()
-while IFS= read -r -d $'\0'; do
-    CHART_ARRAY+=("$REPLY")
-done < <(find $ROOT_DIR/../ -name Chart.yaml -printf '%h\0')
-
-
-echo "***************************************"
-
-
-
-for dir in "${CHART_ARRAY[@]}"
-do
-  
-    echo "Analyzing Chart $(echo $dir | awk '{n=split($0, a, "/"); print a[n]}')"    
-    echo $dir 
-
-    #helm dep up $dir > /dev/null 2>&1
-    helm dep up $dir 
-    
-    IMAGE_ARRAY=$(helm template -f $OVERRIDEYAML $dir | grep "image:" | awk '{ gsub(/.*image: /, "", $0); gsub(/"/, "", $0); print $0}' )
-    
-
-    for f in $IMAGE_ARRAY; do
-	if [ ! -z $f ]; then
-	    FOUND=$(grep $f $TEMP_DIR/imagelist)
-	    if [ -z $FOUND ]; then
-		echo "Found unique docker image $f."
-                echo $f >> $TEMP_DIR/imagelist
-	    fi
-	fi
-    done
-
-    echo "***************************************"
-done
-
-
-
-echo "Your image list is available here: $TEMP_DIR/imagelist"
diff --git a/bin/preload-images b/bin/preload-images
deleted file mode 100755
index a8b6a4f..0000000
--- a/bin/preload-images
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-##############################################################################
-#
-#   Copyright (c) 2019 AT&T Intellectual Property.
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-##############################################################################
-
-# Installs well-known RIC charts then verifies specified helm chart
-# Requires chart tgz archives in /tmp
-
-
-while [ -n "$1" ]; do # while loop starts
-
-    case "$1" in
-
-    -d) DOCKER_REGISTRY=$2
-        shift
-        ;;
-
-    -p) IMAGE_DIRECTORY_PATH=$2
-	shift
-	;;
-
-    *) echo "Option $1 not recognized. Please specify the docker registry path with the -d option and specify the directory path of the images with the -p option."
-	;; # In case you typed a different option other than -d or -p
-
-    esac
-
-    shift
-
-done
-
-if [ -z $DOCKER_REGISTRY ]; then
-   echo "Please specify the docker registry path with the -d option."
-   exit 1
-fi
-
-if [ -z $IMAGE_DIRECTORY_PATH ]; then
-   echo "Please specify the directory path of the images with the -p option."
-   exit 1
-fi
-
-
-
-
-for image in $IMAGE_DIRECTORY_PATH/*; do
-	OUTPUT=$(docker load -i $image)
-	IMAGE_PATH_ORIGINAL=$(echo $OUTPUT | grep image: | awk '{print $3}' )
-	IMAGENAME=$(echo $IMAGE_PATH_ORIGINAL | awk '{ n=split($0, a, "/"); print a[n] }')
-	echo "************************************************************"
-	echo "Loading image $IMAGENAME"
-        docker tag $IMAGE_PATH_ORIGINAL $DOCKER_REGISTRY/$IMAGENAME
-	RESULT=$(docker push $DOCKER_REGISTRY/$IMAGENAME 2>&1)
-        LOGIN_ERROR=$(echo $RESULT |& grep "no basic auth credentials" )
-	if [ ! -z "$LOGIN_ERROR" ]; then
-            echo "You are not logined to $DOCKER_REGISTRY. Please login by running \"docker login $DOCKER_REGISTRY\""
-	    exit 1
-	fi
-        ACCESS_ERROR=$(echo $RESULT |& grep "denied: requested access to the resource is denied" )
-	if [ ! -z "$ACCESS_ERROR" ]; then
-            echo "Failed to push image to docker registry: <$DOCKER_REGISTRY>. Please check if it is a typo."
-	    exit 1
-	fi
-done
diff --git a/bin/prepare-common-templates b/bin/prepare-common-templates
new file mode 100755
index 0000000..d791e22
--- /dev/null
+++ b/bin/prepare-common-templates
@@ -0,0 +1,52 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #
+#   Copyright (c) 2019 Nokia.                                                  #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+
+# Start Helm local repo if there isn't one
+HELM_REPO_PID=$(ps -x | grep  "helm serve" | grep -v "grep" | awk '{print $1}')
+if [ -z "$HELM_REPO_PID" ]; then
+    nohup helm serve >& /dev/null &
+fi
+
+
+
+# Package common templates and serve it using Helm local repo
+HELM_HOME=$(helm home)
+COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
+helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
+cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+
+AUX_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/aux-common/Chart.yaml | grep version | awk '{print $2}')
+helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/aux-common
+cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+
+NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
+helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
+cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+
+helm repo index $HELM_HOME/repository/local/
+
+
+# Make sure that helm local repo is added
+helm repo remove local
+helm repo add local http://127.0.0.1:8879/charts
+
+
+
diff --git a/bin/prepull-images b/bin/prepull-images
deleted file mode 100755
index 119d76d..0000000
--- a/bin/prepull-images
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/bash
-##############################################################################
-#
-#   Copyright (c) 2019 AT&T Intellectual Property.
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-##############################################################################
-
-# Installs well-known RIC charts then verifies specified helm chart
-# Requires chart tgz archives in /tmp
-
-
-while [ -n "$1" ]; do # while loop starts
-
-    case "$1" in
-
-    -f) IMAGELISTFILE=$2
-        shift
-        ;; 
-
-
-    -d) IMAGE_DIRECTORY_PATH=$2
-        shift
-        ;;
-
-
-    *) echo "Option $1 not recognized. Please use -f to specify the recipe path." ;; # In case you typed a different option other than a,b,c
-
-    esac
-
-    shift
-
-done
-
-if [ -z "$IMAGELISTFILE" ]; then
-   echo "Image list file is missing. Please use -f to specify the path."
-   exit 1
-fi
-
-if [ -z "$IMAGE_DIRECTORY_PATH" ]; then
-    IMAGE_DIRECTORY_PATH=/tmp/ric_image
-fi
-
-
-rm -rf $IMAGE_DIRECTORY_PATH
-mkdir -p $IMAGE_DIRECTORY_PATH
-
-
-while IFS= read -r image
-do
-    if [[ $image == "#"* ]]; then
-        # supporting comment lines
-        continue
-    fi
-
-    IMAGENAME=$(echo $image | awk '{ n=split($0, a, "/"); print a[n] }')
-
-    echo "Pulling image $image"
-    RESULT=$(docker pull $image |& grep "no basic auth credentials" )
-    if [ ! -z "$RESULT" ]; then
-        echo "You are not logined to docker registry. Please login by running \"docker login DOCKER_REGISTRY\""
-	exit 1
-    fi
-
-    echo "Saving image $image"
-    docker save $image -o $IMAGE_DIRECTORY_PATH/$IMAGENAME
-
-    echo "************************************************************"
-
-
-done < "$IMAGELISTFILE"
-
-
-echo "RIC Images are downloaded to: $IMAGE_DIRECTORY_PATH"
diff --git a/ric-aux/bin/install b/ric-aux/bin/install
index da9bc36..917c942 100755
--- a/ric-aux/bin/install
+++ b/ric-aux/bin/install
@@ -165,11 +165,6 @@
     kubectl create ns onap
 fi
 
-HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"jobs.batch \"ricaux-portal-db-config\" is forbidden: User \"system:serviceaccount:ricaux:default\" cannot get resource \"jobs/status\" in API group \"batch\" in the namespace \"ricaux\"","reason":"Forbidden","details":{"name":"ricaux-portal-db-config","group":"batch","kind":"jobs"},"code":403}
-
-
-HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods is forbidden: User \"system:serviceaccount:onap:default\" cannot list resource \"pods\" in API group \"\" in the namespace \"onap\"","reason":"Forbidden","details":{"kind":"pods"},"code":403}
-
 
 
 echo Add cluster roles