Update aaf csit plans latest images

Adjust teardown.sh

Issue-ID: AAF-388
Change-Id: Iaa9c384f38877e158309e4c25d96b2fed5ae61b9
Signed-off-by: Sai Gandham <sg481n@att.com>
diff --git a/plans/aaf/aafapi/setup.sh b/plans/aaf/aafapi/setup.sh
index dd6cb29..d561ee0 100644
--- a/plans/aaf/aafapi/setup.sh
+++ b/plans/aaf/aafapi/setup.sh
@@ -25,52 +25,169 @@
 source ${SCRIPTS}/common_functions.sh
 
 # Clone AAF Authz repo
-mkdir -p $WORKSPACE/archives/aafcsit
-cd $WORKSPACE/archives/aafcsit
-#unset http_proxy https_proxy
+mkdir -p $WORKSPACE/archives/opt
+cd $WORKSPACE/archives/opt
+
+
+HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
+export HOST_IP=${HOST_IP}
+
+CURRENT_DIR=$(pwd) export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
+
+NEXUS_USERNAME=anonymous
+NEXUS_PASSWD=anonymous
+NEXUS_DOCKER_REPO=nexus3.onap.org:10001
+AAF_DOCKER_VERSION=2.1.3-SNAPSHOT
+
+docker login -u $NEXUS_USERNAME -p "$NEXUS_PASSWD" $NEXUS_DOCKER_REPO
+
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_config:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_cm:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_fs:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_gui:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_hello:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_locate:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_oauth:$AAF_DOCKER_VERSION
+docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_service:$AAF_DOCKER_VERSION
+
+docker tag $NEXUS_DOCKER_REPO/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION nexus3.onap.org:10003/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION
 git clone --depth 1 http://gerrit.onap.org/r/aaf/authz -b master
 git pull
-cd $WORKSPACE/archives/aafcsit/authz/auth/auth-service/src/main/resources/docker-compose
+chmod -R 777 authz
+cd authz
+CURRENT_DIR=$(pwd)
+
 pwd
-chmod -R 777 $WORKSPACE/archives/aafcsit/authz/auth/auth-service/src/main/resources/docker-compose
+
+if [ ! -e auth/csit/d.props ]; then
+  cp auth/csit/d.props.init auth/csit/d.props
+fi
+
+if [ ! -e auth/docker/d.props ]; then
+  cp auth/docker/d.props.init auth/docker/d.props
+fi
 
 
-# start aaf containers with docker compose and configuration from docker-compose.yml
-docker-compose up -d
-export aaf_service=$(get_docker_compose_service aaf_container)
-export cassandra_service=$(get_docker_compose_service cassandra_container)
 
-# Wait for initialization of Docker container for AAF & Cassandra
-for i in {1..12}; do
+NEXUS_USERNAME=anonymous
+NEXUS_PASSWD=anonymous
+NEXUS_DOCKER_REPO=nexus3.onap.org:10001
+sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY=$NEXUS_DOCKER_REPO/" auth/csit/d.props
+. auth/csit/d.props
 
-	if [ $(docker inspect --format '{{ .State.Running }}' $aaf_service) ] && \
-		[ $(docker inspect --format '{{ .State.Running }}' $cassandra_service) ]
-	then
-		echo "AAF Service Running"
-		break
-	else
-		echo sleep $i
-		sleep $i
-	fi
+sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY=$NEXUS_DOCKER_REPO/" auth/docker/d.props
+. auth/docker/d.props
+
+
+HOSTNAME=`hostname`
+FQDN=aaf.api.simpledemo.onap.org
+HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
+export HOST_IP=${HOST_IP}
+
+
+CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4`
+CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP
+
+cd auth/auth-cass/docker
+if [ "`docker container ls | grep aaf_cass`" = "" ]; then
+  # Cassandra Install
+  echo Cassandra Install
+  bash ./dinstall.sh
+fi
+
+CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4`
+CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP
+if [ ! -e $WORKSPACE/archives/opt/authz/auth/csit/cass.props ]; then
+  cp $WORKSPACE/archives/opt/authz/auth/csit/cass.props.init $WORKSPACE/archives/opt/authz/auth/csit/cass.props
+fi
+
+sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" $WORKSPACE/archives/opt/authz/auth/csit/cass.props
+
+if [ ! -e $WORKSPACE/archives/opt/authz/auth/docker/cass.props ]; then
+  cp $WORKSPACE/archives/opt/authz/auth/docker/cass.props.init $WORKSPACE/archives/opt/authz/auth/docker/cass.props
+fi
+
+sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" $WORKSPACE/archives/opt/authz/auth/docker/cass.props
+# TODO Pull from Config Dir
+if [ "$LATITUDE" = "" ]; then
+  LATITUDE=37.781
+  LONGITUDE=-122.261
+  sed -i "s/LATITUDE=.*/LATITUDE=$LATITUDE/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+  sed -i "s/LONGITUDE=.*/LONGITUDE=$LONGITUDE/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+fi
+
+sed -i "s/VERSION=.*/VERSION=$VERSION/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+sed -i "s/HOST_IP=.*/HOST_IP=$HOST_IP/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+sed -i "s/AAF_REGISTER_AS=.*/AAF_REGISTER_AS=$FQDN/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props
+
+pwd
+
+cd ../../
+
+pwd
+
+cd csit
+tty
+# Need new Deployment system properties
+bash ./aaf.sh
+
+# run it
+bash ./drun.sh
+
+docker images
+
+docker ps -a
+
+cat /etc/sudoers
+
+docker logs aaf_hello
+
+docker logs aaf_locate
+
+docker logs aaf_cm
+
+docker logs aaf_gui
+
+docker logs aaf_fs
+
+docker logs aaf_oauth
+
+docker logs aaf_service
+
+# Wait for initialization of Docker containers
+for i in {1..50}; do
+        if [ $(docker inspect --format '{{ .State.Running }}' aaf_hello) ] && \
+                [ $(docker inspect --format '{{ .State.Running }}' aaf_cm) ] && \
+				[ $(docker inspect --format '{{ .State.Running }}' aaf_fs) ] && \
+				[ $(docker inspect --format '{{ .State.Running }}' aaf_gui) ] && \
+				[ $(docker inspect --format '{{ .State.Running }}' aaf_oauth) ] && \
+				[ $(docker inspect --format '{{ .State.Running }}' aaf_locate) ] && \
+                [ $(docker inspect --format '{{ .State.Running }}' aaf_service) ]
+        then
+                echo "aaf Service Running"
+                break
+        else
+                echo sleep $i
+                sleep $i
+        fi
 done
 
 
-AAF_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $aaf_service)
-CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cassandra_service)
 
-bypass_ip_adress $AAF_IP
-bypass_ip_adress $CASSANDRA_IP
+AAF_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_service)
+CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_cass)
 
 echo AAF_IP=${AAF_IP}
 echo CASSANDRA_IP=${CASSANDRA_IP}
 
-
 # Wait for initialization of docker services
 for i in {1..12}; do
-    curl -sS -m 1 ${AAF_IP}:8101 && break
+   curl -k -u aaf_admin@people.osaaf.org:demo123456! https://${AAF_IP}:8100/authz/nss/org.osaaf.people && break
     echo sleep $i
     sleep $i
 done
 
 #Pass any variables required by Robot test suites in ROBOT_VARIABLES
-ROBOT_VARIABLES="-v AAF_IP:${AAF_IP}"
+ROBOT_VARIABLES="-v AAF_IP:${AAF_IP}"
\ No newline at end of file
diff --git a/plans/aaf/aafapi/teardown.sh b/plans/aaf/aafapi/teardown.sh
index 41e0b00..742a1b3 100644
--- a/plans/aaf/aafapi/teardown.sh
+++ b/plans/aaf/aafapi/teardown.sh
@@ -17,8 +17,12 @@
 # Modifications copyright (c) 2017 AT&T Intellectual Property
 #
 
-kill-instance.sh $aaf_service
-kill-instance.sh $cassandra_service
 
-unset aaf_service
-unset cassandra_service
+kill-instance.sh aaf_service
+kill-instance.sh aaf_locate
+kill-instance.sh aaf_hello
+kill-instance.sh aaf_cm
+kill-instance.sh aaf_gui
+kill-instance.sh aaf_fs
+kill-instance.sh aaf_oauth
+kill-instance.sh aaf_cass