Antoni Segura Puimedon has uploaded a new change for review.

Change subject: network cleanup scripts
......................................................................

network cleanup scripts

This scripts help with cleaning up after failed network functional
tests.

Change-Id: Ib2d300af57d78f1dc39cc971dc5abbd3607a3a80
Signed-off-by: Antoni S. Puimedon <asegu...@redhat.com>
---
A scripts/net_cleanup.sh
A scripts/vdsm_test_net_remover.py
2 files changed, 42 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/jenkins refs/changes/64/20364/1

diff --git a/scripts/net_cleanup.sh b/scripts/net_cleanup.sh
new file mode 100755
index 0000000..2d5f9eb
--- /dev/null
+++ b/scripts/net_cleanup.sh
@@ -0,0 +1,34 @@
+del_dummies() {
+    for nic in `ip l | awk '{print $2;}' | egrep "^dummy"`; do
+        ip link del dev ${nic:0:${#nic}-1}
+    done
+    find /etc/sysconfig/network-scripts/ -iname "ifcfg-dummy*" | xargs 
--no-run-if-empty rm
+}
+
+del_bonds() {
+    for nic in `ip l | awk '{print $2;}' | egrep "^bond"`; do
+        echo "-${nic:0:${#nic}-1}" > /sys/class/net/bonding_masters
+    done
+    find /etc/sysconfig/network-scripts/ -iname "ifcfg-bond*" | xargs 
--no-run-if-empty rm
+}
+
+del_bridges() {
+    for bridge in `brctl show | awk '{print $1;}' | grep test-network`; do
+        ip link set dev $bridge down
+        brctl delbr $bridge
+    done
+}
+
+del_test_nets() {
+    python ./vdsm_test_net_remover.py
+    find /etc/sysconfig/network-scripts/ -iname "ifcfg-test-network*" | xargs 
--no-run-if-empty rm
+}
+
+emergency_net_cleanup() {
+    del_dummies
+    del_bonds
+    del_bridges
+    del_test_nets
+}
+
+emergency_net_cleanup
diff --git a/scripts/vdsm_test_net_remover.py b/scripts/vdsm_test_net_remover.py
new file mode 100644
index 0000000..ba78a91
--- /dev/null
+++ b/scripts/vdsm_test_net_remover.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+from vdsm import libvirtconnection
+c = libvirtconnection.get()
+nets = c.listAllNetworks(0)
+for net in nets:
+    if net.name().startswith('vdsm-test-network'):
+        net.destroy()
+        net.undefine()


-- 
To view, visit http://gerrit.ovirt.org/20364
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2d300af57d78f1dc39cc971dc5abbd3607a3a80
Gerrit-PatchSet: 1
Gerrit-Project: jenkins
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegu...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to