Petr Horáček has uploaded a new change for review.

Change subject: net: legacy: split bonds handling to removal and setup
......................................................................

net: legacy: split bonds handling to removal and setup

In order to support multiple switches we have to do network removal,
addition and bond removal, addition in separate steps.

Change-Id: Ib53d04c89a72d514ffcea93981b6782f6eb4a14d
Signed-off-by: Petr Horáček <[email protected]>
---
M lib/vdsm/network/api.py
M lib/vdsm/network/legacy_switch.py
2 files changed, 24 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/54352/1

diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py
index 5513e91..596b125 100644
--- a/lib/vdsm/network/api.py
+++ b/lib/vdsm/network/api.py
@@ -278,8 +278,10 @@
             legacy_switch.remove_networks(networks, bondings, configurator,
                                           _netinfo, libvirt_nets)
 
-            legacy_switch.bonds_setup(bondings, configurator, _netinfo,
-                                      in_rollback)
+            legacy_switch.bonds_removal(bondings, configurator, _netinfo,
+                                        in_rollback)
+
+            legacy_switch.bonds_add(bondings, configurator, _netinfo)
 
             legacy_switch.add_missing_networks(configurator, networks,
                                                bondings, _netinfo)
diff --git a/lib/vdsm/network/legacy_switch.py 
b/lib/vdsm/network/legacy_switch.py
index 340512a..b786740 100644
--- a/lib/vdsm/network/legacy_switch.py
+++ b/lib/vdsm/network/legacy_switch.py
@@ -530,13 +530,20 @@
             ne.ERR_BAD_PARAMS, 'Bond %s does not exist' % bond)
 
 
-def bonds_setup(bonds, configurator, _netinfo, in_rollback):
-    _logger.debug('Starting bondings setup. bonds=%s, in_rollback=%s',
+def bonds_removal(bonds, configurator, _netinfo, in_rollback):
+    _logger.debug('Starting bondings removal. bonds=%s, in_rollback=%s',
                   bonds, in_rollback)
     _netinfo.updateDevices()
-    remove, edit, add = _bonds_classification(bonds, _netinfo)
+    remove, edit, _ = _bonds_classification(bonds, _netinfo)
     _bonds_remove(remove, configurator, _netinfo, in_rollback)
-    _bonds_edit(edit, configurator, _netinfo)
+    _bonds_edit_remove(edit, configurator, _netinfo)
+
+
+def bonds_add(bonds, configurator, _netinfo):
+    _logger.debug('Starting bondings setup. bonds=%s', bonds)
+    _netinfo.updateDevices()
+    _, edit, add = _bonds_classification(bonds, _netinfo)
+    _bonds_edit_add(edit, configurator, _netinfo)
     _bonds_add(add, configurator, _netinfo)
 
 
@@ -590,7 +597,7 @@
     return True
 
 
-def _bonds_edit(bonds, configurator, _netinfo):
+def _bonds_edit_remove(bonds, configurator, _netinfo):
     _netinfo.updateDevices()
 
     for name, attrs in six.iteritems(bonds):
@@ -600,7 +607,14 @@
                       slaves_to_remove)
         _remove_slaves(slaves_to_remove, configurator, _netinfo)
 
-    # we need bonds to be slaveless in _netinfo
+
+def _remove_slaves(slaves_to_remove, configurator, _netinfo):
+    for name in slaves_to_remove:
+        slave = Nic(name, configurator, _netinfo=_netinfo)
+        slave.remove(remove_even_if_used=True)
+
+
+def _bonds_edit_add(bonds, configurator, _netinfo):
     _netinfo.updateDevices()
 
     for name, attrs in six.iteritems(bonds):
@@ -609,12 +623,6 @@
             mtu=None, _netinfo=_netinfo)
         _logger.debug('Editing bond %r with options %s', bond, bond.options)
         configurator.editBonding(bond, _netinfo)
-
-
-def _remove_slaves(slaves_to_remove, configurator, _netinfo):
-    for name in slaves_to_remove:
-        slave = Nic(name, configurator, _netinfo=_netinfo)
-        slave.remove(remove_even_if_used=True)
 
 
 def _bonds_add(bonds, configurator, _netinfo):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib53d04c89a72d514ffcea93981b6782f6eb4a14d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to