3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Modifications copyright (c) 2018 AT&T Intellectual Property
20 if [[ -z $WORKSPACE ]]; then
21 CUR_PATH="`dirname \"$0\"`" # relative path
22 CUR_PATH="`( cd \"$CUR_PATH\" && pwd )`" # absolutized and normalized
23 if [ -z "$CUR_PATH" ] ; then
24 echo "Permission error!"
28 # define location of workpsace based on where the current script is
29 WORKSPACE=$(cd $CUR_PATH/../../ && pwd)
32 if [[ -z $SCRIPTS ]]; then
33 SCRIPTS=$(cd $WORKSPACE/scripts && pwd)
36 source ${SCRIPTS}/sdnr/sdnrEnv_Common.sh
37 env_file="--env-file ${SCRIPTS}/sdnr/docker-compose/.env"
39 function sdnr_teardown() {
40 running_containers=$(docker ps -aq)
41 if [ -z "$running_containers" ]
43 echo "No containers to get logs from!"
45 echo "Getting logs from containers!"
46 running_containers_array=($(echo "$running_containers" | tr ' ' '\n'))
47 mkdir -p ${WORKSPACE}/archives/getallinfo
48 for i in "${running_containers_array[@]}"
50 echo "Getting logs from container $i"
51 docker logs $i >> ${WORKSPACE}/archives/getallinfo/$i.log 2>&1
54 echo "Starting teardown!"
55 # removes sdnrdb, sdnr AND all of the rest of the containers (--remove-orphans)
56 docker rm -f $(docker ps -aq -f name=ntsim*)
57 docker rm -f $(docker ps -aq -f name=nts-*)
58 docker rm -f $(docker ps -aq -f name=NTS_Manager*)
59 docker rm -f $(docker ps -aq -f name=NTS-Manager*)
60 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr.yaml down --remove-orphans
61 docker network rm integration