Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START======================================================= |
| 4 | # ONAP AAF |
| 5 | # ================================================================================ |
| 6 | # Copyright (C) 2017 AT&T Intellectual Property. All rights |
| 7 | # reserved. |
| 8 | # ================================================================================ |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END============================================ |
| 21 | # =================================================================== |
| 22 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 23 | # |
| 24 | # Place the scripts in run order: |
| 25 | source ${SCRIPTS}/common_functions.sh |
| 26 | |
| 27 | # Clone AAF Authz repo |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 28 | mkdir -p $WORKSPACE/archives/opt |
| 29 | cd $WORKSPACE/archives/opt |
| 30 | |
| 31 | |
| 32 | HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') |
| 33 | export HOST_IP=${HOST_IP} |
| 34 | |
| 35 | CURRENT_DIR=$(pwd) export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) |
| 36 | |
| 37 | NEXUS_USERNAME=anonymous |
| 38 | NEXUS_PASSWD=anonymous |
| 39 | NEXUS_DOCKER_REPO=nexus3.onap.org:10001 |
| 40 | AAF_DOCKER_VERSION=2.1.3-SNAPSHOT |
| 41 | |
| 42 | docker login -u $NEXUS_USERNAME -p "$NEXUS_PASSWD" $NEXUS_DOCKER_REPO |
| 43 | |
| 44 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION |
| 45 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_config:$AAF_DOCKER_VERSION |
| 46 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_cm:$AAF_DOCKER_VERSION |
| 47 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_fs:$AAF_DOCKER_VERSION |
| 48 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_gui:$AAF_DOCKER_VERSION |
| 49 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_hello:$AAF_DOCKER_VERSION |
| 50 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_locate:$AAF_DOCKER_VERSION |
| 51 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_oauth:$AAF_DOCKER_VERSION |
| 52 | docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_service:$AAF_DOCKER_VERSION |
| 53 | |
| 54 | docker tag $NEXUS_DOCKER_REPO/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION nexus3.onap.org:10003/onap/aaf/aaf_cass:$AAF_DOCKER_VERSION |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 55 | git clone --depth 1 http://gerrit.onap.org/r/aaf/authz -b master |
| 56 | git pull |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 57 | chmod -R 777 authz |
| 58 | cd authz |
| 59 | CURRENT_DIR=$(pwd) |
| 60 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 61 | pwd |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 62 | |
| 63 | if [ ! -e auth/csit/d.props ]; then |
| 64 | cp auth/csit/d.props.init auth/csit/d.props |
| 65 | fi |
| 66 | |
| 67 | if [ ! -e auth/docker/d.props ]; then |
| 68 | cp auth/docker/d.props.init auth/docker/d.props |
| 69 | fi |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 70 | |
| 71 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 72 | |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 73 | NEXUS_USERNAME=anonymous |
| 74 | NEXUS_PASSWD=anonymous |
| 75 | NEXUS_DOCKER_REPO=nexus3.onap.org:10001 |
| 76 | sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY=$NEXUS_DOCKER_REPO/" auth/csit/d.props |
| 77 | . auth/csit/d.props |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 78 | |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 79 | sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY=$NEXUS_DOCKER_REPO/" auth/docker/d.props |
| 80 | . auth/docker/d.props |
| 81 | |
| 82 | |
| 83 | HOSTNAME=`hostname` |
| 84 | FQDN=aaf.api.simpledemo.onap.org |
| 85 | HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') |
| 86 | export HOST_IP=${HOST_IP} |
| 87 | |
| 88 | |
| 89 | CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4` |
| 90 | CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP |
| 91 | |
| 92 | cd auth/auth-cass/docker |
| 93 | if [ "`docker container ls | grep aaf_cass`" = "" ]; then |
| 94 | # Cassandra Install |
| 95 | echo Cassandra Install |
| 96 | bash ./dinstall.sh |
| 97 | fi |
| 98 | |
| 99 | CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4` |
| 100 | CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP |
| 101 | if [ ! -e $WORKSPACE/archives/opt/authz/auth/csit/cass.props ]; then |
| 102 | cp $WORKSPACE/archives/opt/authz/auth/csit/cass.props.init $WORKSPACE/archives/opt/authz/auth/csit/cass.props |
| 103 | fi |
| 104 | |
| 105 | sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" $WORKSPACE/archives/opt/authz/auth/csit/cass.props |
| 106 | |
| 107 | if [ ! -e $WORKSPACE/archives/opt/authz/auth/docker/cass.props ]; then |
| 108 | cp $WORKSPACE/archives/opt/authz/auth/docker/cass.props.init $WORKSPACE/archives/opt/authz/auth/docker/cass.props |
| 109 | fi |
| 110 | |
| 111 | sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" $WORKSPACE/archives/opt/authz/auth/docker/cass.props |
| 112 | # TODO Pull from Config Dir |
| 113 | if [ "$LATITUDE" = "" ]; then |
| 114 | LATITUDE=37.781 |
| 115 | LONGITUDE=-122.261 |
| 116 | sed -i "s/LATITUDE=.*/LATITUDE=$LATITUDE/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 117 | sed -i "s/LONGITUDE=.*/LONGITUDE=$LONGITUDE/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 118 | fi |
| 119 | |
| 120 | sed -i "s/VERSION=.*/VERSION=$VERSION/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 121 | sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 122 | sed -i "s/HOST_IP=.*/HOST_IP=$HOST_IP/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 123 | sed -i "s/AAF_REGISTER_AS=.*/AAF_REGISTER_AS=$FQDN/g" $WORKSPACE/archives/opt/authz/auth/csit/d.props |
| 124 | |
| 125 | pwd |
| 126 | |
| 127 | cd ../../ |
| 128 | |
| 129 | pwd |
| 130 | |
| 131 | cd csit |
| 132 | tty |
| 133 | # Need new Deployment system properties |
| 134 | bash ./aaf.sh |
| 135 | |
| 136 | # run it |
| 137 | bash ./drun.sh |
| 138 | |
| 139 | docker images |
| 140 | |
| 141 | docker ps -a |
| 142 | |
| 143 | cat /etc/sudoers |
| 144 | |
| 145 | docker logs aaf_hello |
| 146 | |
| 147 | docker logs aaf_locate |
| 148 | |
| 149 | docker logs aaf_cm |
| 150 | |
| 151 | docker logs aaf_gui |
| 152 | |
| 153 | docker logs aaf_fs |
| 154 | |
| 155 | docker logs aaf_oauth |
| 156 | |
| 157 | docker logs aaf_service |
| 158 | |
| 159 | # Wait for initialization of Docker containers |
| 160 | for i in {1..50}; do |
| 161 | if [ $(docker inspect --format '{{ .State.Running }}' aaf_hello) ] && \ |
| 162 | [ $(docker inspect --format '{{ .State.Running }}' aaf_cm) ] && \ |
| 163 | [ $(docker inspect --format '{{ .State.Running }}' aaf_fs) ] && \ |
| 164 | [ $(docker inspect --format '{{ .State.Running }}' aaf_gui) ] && \ |
| 165 | [ $(docker inspect --format '{{ .State.Running }}' aaf_oauth) ] && \ |
| 166 | [ $(docker inspect --format '{{ .State.Running }}' aaf_locate) ] && \ |
| 167 | [ $(docker inspect --format '{{ .State.Running }}' aaf_service) ] |
| 168 | then |
| 169 | echo "aaf Service Running" |
| 170 | break |
| 171 | else |
| 172 | echo sleep $i |
| 173 | sleep $i |
| 174 | fi |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 175 | done |
| 176 | |
| 177 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 178 | |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 179 | AAF_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_service) |
| 180 | CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_cass) |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 181 | |
| 182 | echo AAF_IP=${AAF_IP} |
| 183 | echo CASSANDRA_IP=${CASSANDRA_IP} |
| 184 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 185 | # Wait for initialization of docker services |
| 186 | for i in {1..12}; do |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 187 | curl -k -u aaf_admin@people.osaaf.org:demo123456! https://${AAF_IP}:8100/authz/nss/org.osaaf.people && break |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 188 | echo sleep $i |
| 189 | sleep $i |
| 190 | done |
| 191 | |
| 192 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
Sai Gandham | 94df0ae | 2018-10-09 16:29:54 -0500 | [diff] [blame^] | 193 | ROBOT_VARIABLES="-v AAF_IP:${AAF_IP}" |