Create on boarding docker

Add BE and Cassandra init docker images

Change-Id: Id9d767c73fc946819cec821b4634ce650cbb22fd
Issue-ID: SDC-781
Signed-off-by: Michael Lando <ml636r@att.com>
diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh
index b7d96d5..2c12fff 100755
--- a/sdc-os-chef/scripts/docker_run.sh
+++ b/sdc-os-chef/scripts/docker_run.sh
@@ -6,6 +6,7 @@
 JETTY_BASE="/var/lib/jetty"
 BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
 FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
+ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
 SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m"
 API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
 UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
@@ -38,6 +39,7 @@
     mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
     mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
     mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
+    mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
 	mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
 	mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
 	mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
@@ -69,19 +71,31 @@
 be_stat=false
 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
 rc=$?
-if [[ $rc == 200 ]]; then
+if [[ $rc == 0 ]]; then
   echo DOCKER start finished in $2 seconds
   be_stat=true
 fi
 
 }
 
+function probe_sdc_onboard_be {
+
+sdc_onboard_be_stat=false
+docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
+rc=$?
+if [[ $rc == 0 ]]; then
+  echo DOCKER start finished in $2 seconds
+  sdc_onboard_be_stat=true
+fi
+
+}
+
 function probe_fe {
 
 fe_stat=false
 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
 rc=$?
-if [[ $rc == 200 ]]; then
+if [[ $rc == 0 ]]; then
   echo DOCKER start finished in $2 seconds
   fe_stat=true
 fi
@@ -144,6 +158,10 @@
 		elif [ "$1" == "sdc-FE" ]; then
 		    probe_fe $1 $TIME
 			if [[ $fe_stat == true ]]; then break; fi
+        elif [ "$1" == "sdc-onboard-BE" ]; then
+             probe_sdc_onboard_be $1 $TIME
+             if [[ $sdc_onboard_be_stat == true ]]; then break; fi
+
         else
             probe_docker $1 $TIME
             if [[ $match_result == true ]]; then break; fi
@@ -189,6 +207,7 @@
 LOCAL=false
 RUNTESTS=false
 DEBUG_PORT="--publish 4000:4000"
+ONBOARD_DEBUG_PORT="--publish 4001:4000"
 
 while [ $# -gt 0 ]; do
     case $1 in
@@ -319,6 +338,18 @@
 if [[ $rc != 0 ]]; then exit $rc; fi
 }
 
+#Onboard Cassandra-init
+function sdc-cs-onboard-init {
+echo "docker run sdc-cs-onboard-init..."
+if [ ${LOCAL} = false ]; then
+        docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
+fi
+docker run --name sdc-cs-onboard-init --env RELEASE="${RELEASE}" --env CS_HOST_IP=${IP}  --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
+rc=$?
+docker_logs sdc-onboard-cs-init
+if [[ $rc != 0 ]]; then exit $rc; fi
+}
+
 #Kibana
 function sdc-kbn {
 echo "docker run sdc-kibana..."
@@ -355,6 +386,23 @@
 if [[ $rc != 0 ]]; then exit $rc; fi
 }
 
+# Onboard Back-End
+function sdc-onboard-BE {
+
+dir_perms
+# Back-End
+echo "docker run  sdc-onboard-BE ..."
+if [ ${LOCAL} = false ]; then
+        docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
+else
+        ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
+fi
+docker run --detach --name sdc-onboard-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env SDC_CLUSTER_NAME="SDC-CS-${DEP_ENV}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env JAVA_OPTIONS="${ONBOARD_BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/ONBOARD:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8445:8445 --publish 8081:8081 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-onboard-backend:${RELEASE}
+
+echo "please wait while sdc-onboard-BE is starting..."
+monitor_docker sdc-onboard-BE
+}
+
 
 # Front-End
 function sdc-FE {
@@ -431,6 +479,8 @@
 	sdc-cs
 	sdc-cs-init
 #	sdc-kbn
+	sdc-cs-onboard-init
+	sdc-onboard-BE
 	sdc-BE
 	sdc-BE-init
 	sdc-FE
diff --git a/sdc-os-chef/scripts/k8s/bin_nsenter b/sdc-os-chef/scripts/k8s/bin_nsenter
new file mode 100755
index 0000000..9137f71
--- /dev/null
+++ b/sdc-os-chef/scripts/k8s/bin_nsenter
Binary files differ
diff --git a/sdc-os-chef/scripts/k8s/etc/bash_completion.d/nsenter b/sdc-os-chef/scripts/k8s/etc_nsenter
similarity index 100%
rename from sdc-os-chef/scripts/k8s/etc/bash_completion.d/nsenter
rename to sdc-os-chef/scripts/k8s/etc_nsenter
diff --git a/sdc-os-chef/scripts/k8s/kubernetes_run.sh b/sdc-os-chef/scripts/k8s/kubernetes_run.sh
index fd9de2e..7a73c2a 100644
--- a/sdc-os-chef/scripts/k8s/kubernetes_run.sh
+++ b/sdc-os-chef/scripts/k8s/kubernetes_run.sh
@@ -52,8 +52,18 @@
 print_header "Dependency - Install ..."
 echo "[INFO]   Install - nsenter"
 # Use pre compiled nsenter:
-sudo cp bin/nsenter /usr/local/bin/nsenter
-sudo cp etc/bash_completion.d/nsenter /etc/bash_completion.d/nsenter
+if [ -f bin_nsenter ]; then
+    sudo cp bin_nsenter /usr/local/bin/nsenter
+else
+  echo "[ERROR] File [bin_nsenter] is missing"
+fi
+
+if [ -f etc_nsenter ]; then
+    sudo cp etc_nsenter /etc/bash_completion.d/nsenter
+else
+  echo "[ERROR] File [etc_nsenter] is missing"
+fi
+
 
 ## In order to build the nsenter use the below instructions:
 ##./build_nsenter_exec.sh
@@ -75,3 +85,12 @@
 sh ./deploy_k8s_sdc.sh
 status $?
 
+
+####################
+# SDC LOGS Tree    #
+####################
+print_header "SDC - Deploy Pods ..."
+mkdir -p /dockerdata-nfs/onap/sdc/logs//BE/SDC/SDC-BE
+mkdir -p /dockerdata-nfs/onap/sdc/logs/FE/SDC/SDC-FE
+mkdir -p /dockerdata-nfs/onap/sdc/logs/ONBOARD/SDC/ONBOARD-BE
+chmod -R 777 /dockerdata-nfs/onap/sdc/logs/*