Hello Dan Kenigsberg, Edward Haas,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/64509

to review the following change.

Change subject: net ifcfg: fix bond rollback
......................................................................

net ifcfg: fix bond rollback

When setupNetworks(NET, BOND) fails on NET configuration, BOND ifcfg
file is removed, but it still exists in the system. We have to remove
it manually like we do in removeBonding().

This must be backported to fix new functional tests on 4.0.

Change-Id: I5cea6ec71c913d74d95317ff7318259d64b40969
Signed-off-by: Petr Horáček <phora...@redhat.com>
Reviewed-on: https://gerrit.ovirt.org/59940
Reviewed-by: Edward Haas <edwa...@redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <dan...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/1374194
---
M lib/vdsm/network/configurators/ifcfg.py
1 file changed, 16 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/64509/1

diff --git a/lib/vdsm/network/configurators/ifcfg.py 
b/lib/vdsm/network/configurators/ifcfg.py
index ea09dc3..93fae0b 100644
--- a/lib/vdsm/network/configurators/ifcfg.py
+++ b/lib/vdsm/network/configurators/ifcfg.py
@@ -723,6 +723,10 @@
         if os.path.exists('/sys/class/net/%s/bridge' % dev):
             # ifdown is not enough to remove nicless bridges
             commands.execCmd([constants.EXT_BRCTL, 'delbr', dev])
+        if _is_bond_name(dev):
+            if _is_running_bond(dev):
+                with open(netinfo_bonding.BONDING_MASTERS, 'w') as f:
+                    f.write("-%s\n" % dev)
 
 
 def start_devices(device_ifcfgs):
@@ -730,10 +734,8 @@
         try:
             # this is an ugly way to check if this is a bond but picking into
             # the ifcfg files is even worse.
-            if dev.startswith('bond') and '.' not in dev:
-                with open(netinfo_bonding.BONDING_MASTERS) as info:
-                    names = info.read().split()
-                if dev not in names:
+            if _is_bond_name(dev):
+                if not _is_running_bond(dev):
                     with open(netinfo_bonding.BONDING_MASTERS, 'w') as masters:
                         masters.write('+%s\n' % dev)
             _exec_ifup_by_name(dev)
@@ -742,6 +744,16 @@
                           exc_info=True)
 
 
+def _is_bond_name(dev):
+    return dev.startswith('bond') and '.' not in dev
+
+
+def _is_running_bond(bond):
+    with open(netinfo_bonding.BONDING_MASTERS) as info:
+        names = info.read().split()
+    return bond in names
+
+
 def _sort_device_ifcfgs(device_ifcfgs):
     devices = {'Bridge': [],
                'Vlan': [],


-- 
To view, visit https://gerrit.ovirt.org/64509
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5cea6ec71c913d74d95317ff7318259d64b40969
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Petr Horáček <phora...@redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com>
Gerrit-Reviewer: Edward Haas <edwa...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to