Merge R3 into master
[it/dep.git] / ric-aux / bin / install
similarity index 55%
rename from ric-aux/80-Auxiliary-Functions/bin/install
rename to ric-aux/bin/install
index b10b044..360b32b 100755 (executable)
@@ -45,18 +45,45 @@ if [ -z "$OVERRIDEYAML" ];then
     exit 1
 fi
 
+
+HAS_RIC_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common)
+
+if [ -z "$HAS_RIC_COMMON_PACKAGE" ];then
+    echo "****************************************************************************************************************"
+    echo "                                                     ERROR                                                      "
+    echo "****************************************************************************************************************"
+    echo "Can't locate the ric-common helm package in the local repo. Please make sure that it is properly installed."
+    echo "****************************************************************************************************************"
+    exit 1
+fi
+
+HAS_AUX_COMMON_PACKAGE=$(helm search local/aux-common | grep aux-common)
+
+if [ -z "$HAS_AUX_COMMON_PACKAGE" ];then
+    echo "****************************************************************************************************************"
+    echo "                                                     ERROR                                                      "
+    echo "****************************************************************************************************************"
+    echo "Can't locate the aux-common helm package in the local repo. Please make sure that it is properly installed."
+    echo "****************************************************************************************************************"
+    exit 1
+fi
+
+
+
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
-GLOBAL_BLOCK=$(cat $OVERRIDEYAML | awk '/^global:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
+
+COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^  namespace:/{getline; while ($0 ~ /^    .*|^ *$/) {print $0; if (getline == 0) {break}}}')
-NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
-RELEASE_PREFIX=$(echo "$GLOBAL_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
-COMPONENTS=${LIST_OF_COMPONENTS:-"dashboard ves message-router mrsub mc-stack portal aaf"}
+AUXNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
+INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
+RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
+COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure dashboard ves message-router mrsub mc-stack portal aaf"}
 
 
 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
 LABELFOUND=false
 for f in $NODENAME; do
-    LABEL=$(kubectl describe node $f | grep local-storage)
+    LABEL=$(kubectl describe node $f | grep "local-storage=enable")
     if [ ! -z "$LABEL" ]; then
         LABELFOUND=true
     fi
@@ -105,26 +132,51 @@ if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
 
 fi
 
-echo "Deploying RIC infra components [$COMPONENTS]"
 
-COMMON_CHART_VERSION=$(cat $DIR/../../../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $DIR/../../../ric-common/Common-Template/helm/ric-common
+if ! kubectl get ns ${AUXNAMESPACE:-ricaux}> /dev/null 2>&1; then
+    kubectl create ns ${AUXNAMESPACE:-ricaux}
+fi
+if ! kubectl get ns ${INFRANAMESPACE:-ricinfra}> /dev/null 2>&1; then
+    kubectl create ns ${INFRANAMESPACE:-ricinfra}
+fi
+if ! kubectl get ns onap > /dev/null 2>&1; then
+    kubectl create ns onap
+fi
+
+kubectl create configmap -n ${AUXNAMESPACE:-ricaux} aux-recipe --from-file=recipe=$OVERRIDEYAML
+
+
+echo "Deploying AUX components [$COMPONENTS]"
+
 
 
 for component in $COMPONENTS; do
+    helm dep up $DIR/../helm/$component
     case "$component" in
-            dashboard | ves | message-router | mrsub | mc-stack | portal)
-                mkdir -p $DIR/../helm/$component/charts/
-                cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $DIR/../helm/$component/charts/
-                helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
-            ;;
             aaf)
-                mkdir -p $DIR/../helm/$component/charts/
-                cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $DIR/../helm/$component/charts/
-                helm install -f $OVERRIDEYAML --namespace "onap" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
+                NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
+                LABELFOUND=false
+                for f in $NODENAME; do
+                    LABEL=$(kubectl describe node $f | grep "aaf-storage=enable")
+                    if [ ! -z "$LABEL" ]; then
+                        LABELFOUND=true
+                    fi
+                done
+                
+                if  ! $LABELFOUND; then
+                    echo "***********************************************************************************************"
+                    echo "*                                          ERROR!!!!!!!!!!!!!                                 *"
+                    echo "***********************************************************************************************"
+                    echo "* Nodes label \"aaf-storage=enable\" is not found in any of the cluster node.               *"
+                    echo "* Please pick a node and label it using the following command.                                *"
+                    echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> aaf-storage=enable                       *"
+                    echo "***********************************************************************************************"
+                else
+                   helm install -f $OVERRIDEYAML --namespace "onap" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
+                fi
             ;;
             *)
-                helm install --namespace "${NAMESPACE}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
+                helm install -f $OVERRIDEYAML --namespace "${AUXNAMESPACE:-ricaux}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
  
     esac