functest, apex: Add iptable rule check before deleting 45/12545/3
authorFeng Pan <fpan@redhat.com>
Thu, 21 Apr 2016 18:01:15 +0000 (14:01 -0400)
committerFeng Pan <fpan@redhat.com>
Thu, 21 Apr 2016 18:29:42 +0000 (14:29 -0400)
Change-Id: I70955e7ab926b9e6b1a5c9be70a06eba6d8b4d7d
Signed-off-by: Feng Pan <fpan@redhat.com>
jjb/functest/functest-ci-jobs.yml

index 1e16fcf..5e1d972 100644 (file)
                 fi
                 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
                 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
-                sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
-                sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
+                if sudo iptables -C FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
+                    sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
+                fi
+                if sudo iptables -C FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
+                    sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
+                fi
             elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
                 # If production lab then creds may be retrieved dynamically
                 # creds are on the jumphost, always in the same folder