FIX for bringing down pxebr in clean.sh 77/1577/2
authorSzilard Cserey <szilard.cserey@ericsson.com>
Tue, 15 Sep 2015 12:26:38 +0000 (14:26 +0200)
committerSzilard Cserey <szilard.cserey@ericsson.com>
Tue, 15 Sep 2015 14:17:12 +0000 (16:17 +0200)
Wait for 5 seconds after pxebr has been brought down

Change-Id: Ic9e64a484eeab6be63df3c7c4b9b98bed1cd2ed4
Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
common/ci/clean.sh

index da75205..caaf88f 100755 (executable)
@@ -239,8 +239,15 @@ done
 echo "${blue}Checking whether PXE bridge ${pxe_bridge} exists${reset}"
 if ! brctl show ${pxe_bridge} 2>&1 | grep -i 'No such device'; then
   echo "${blue}PXE bridge detected. Removing...${reset}"
-  if ifconfig | grep ${pxe_bridge}; then
-    ifdown ${pxe_bridge}
+  link_state=$(ip link show ${pxe_bridge} | grep -oP 'state \K[^ ]+')
+  if [[ ${link_state} != 'DOWN' ]]; then
+    ip link set dev ${pxe_bridge} down
+    sleep 5
+    link_state=$(ip link show ${pxe_bridge} | grep -oP 'state \K[^ ]+')
+    if [[ ${link_state} != 'DOWN' ]]; then
+      echo "${red}Could not bring DOWN bridge ${pxe_bridge} link state is ${link_state}${reset}"
+      exit 1
+    fi
   fi
   brctl delbr ${pxe_bridge}
   if ifconfig | grep ${pxe_bridge} || brctl show | grep ${pxe_bridge}; then