2 # Licensed to the Apache Software Foundation (ASF) under one *
3 # or more contributor license agreements. See the NOTICE file *
4 # distributed with this work for additional information *
5 # regarding copyright ownership. The ASF licenses this file *
6 # to you under the Apache License, Version 2.0 (the *
7 # "License"); you may not use this file except in compliance *
8 # with the License. You may obtain a copy of the License at *
10 # http://www.apache.org/licenses/LICENSE-2.0 *
12 # Unless required by applicable law or agreed to in writing, *
13 # software distributed under the License is distributed on an *
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 # KIND, either express or implied. See the License for the *
16 # specific language governing permissions and limitations *
17 # under the License. *
28 cmd=`curl -s --head --request GET ${url} | grep '200 OK' > /dev/null`
41 echo "Getting contianer Id of the currently running one"
42 contId=$(sudo docker ps | grep "opnfv/${module}:latest" | awk '{print $1}')
46 echo "Pulling the latest image"
47 sudo docker pull opnfv/${module}:latest
49 echo "Deleting old containers of opnfv/${module}:old"
50 sudo docker ps -a | grep "opnfv/${module}" | grep "old" | awk '{print $1}' | xargs -r sudo docker rm -f
52 echo "Deleting old images of opnfv/${module}:latest"
53 sudo docker images | grep "opnfv/${module}" | grep "old" | awk '{print $3}' | xargs -r sudo docker rmi -f
58 echo "No running ${module} container"
60 echo "Removing stopped ${module} containers in the previous iterations"
61 sudo docker ps -f status=exited | grep "opnfv_${module}" | awk '{print $1}' | xargs -r sudo docker rm -f
65 echo "Get the image id of the currently running conatiner"
66 currImgId=$(sudo docker ps | grep "$contId" | awk '{print $2}')
69 if [[ -z "$currImgId" ]]
71 echo "No image id found for the container id"
75 echo "Changing current image tag to old"
76 sudo docker tag "$currImgId" opnfv/${module}:old
78 echo "Removing stopped ${module} containers in the previous iteration"
79 sudo docker ps -f status=exited | grep "opnfv_${module}" | awk '{print $1}' | xargs -r sudo docker rm -f
81 echo "Renaming the running container name to opnfv_${module} as to identify it."
82 sudo docker rename $contId opnfv_${module}
84 echo "Stop the currently running container"
85 sudo docker stop $contId
88 echo "Running a container with the new image"
92 echo "TestResults Module Hosted."
94 echo "TestResults Module Failed"
95 if [[ $(sudo docker images | grep "opnfv/${module}" | grep "old" | awk '{print $3}') ]]; then
96 echo "Running old Image"
102 # Echo Images and Containers