Change in vdsm[ovirt-3.5]: network: persistence: skip bonds owned and used by vdsm

phoracek at redhat.com phoracek at redhat.com
Wed Mar 11 15:24:40 UTC 2015


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

Change subject: network: persistence: skip bonds owned and used by vdsm
......................................................................

network: persistence: skip bonds owned and used by vdsm

Change-Id: Idb643a0c3681631db7bd875a03ebdb91fd893e70
Signed-off-by: Petr Horáček <phoracek at redhat.com>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1154399
---
M lib/vdsm/tool/unified_persistence.py
1 file changed, 21 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/97/38597/1

diff --git a/lib/vdsm/tool/unified_persistence.py b/lib/vdsm/tool/unified_persistence.py
index 1733c97..7821685 100644
--- a/lib/vdsm/tool/unified_persistence.py
+++ b/lib/vdsm/tool/unified_persistence.py
@@ -116,7 +116,7 @@
         bondings = {}
         for bonding, bondingParams in netinfo.bondings.iteritems():
             # If the bond is unused, skip it
-            if not bondingParams['slaves'] or not _owned(bonding):
+            if not bondingParams['slaves']:
                 continue
 
             bondings[bonding] = {'nics': bondingParams['slaves']}
@@ -128,6 +128,19 @@
         return bondings
 
     netinfo = NetInfo()
+    networks = _processNetworks(netinfo)
+    bonds = _processBondings(netinfo)
+
+    # Filter out non-owned and non-used bonds
+    for bonding in bonds.keys():
+        if not _owned(bonding) and not _used(networks, bonding):
+            del bonds[bonding]
+
+    # Test if networks' bonds are persited
+    for network, attributes in networks.iteritems():
+        if attributes.get('bonding') not in bonds:
+            raise Exception('Network %s miss its bonds', network)
+
     return _processNetworks(netinfo), _processBondings(netinfo)
 
 
@@ -145,6 +158,13 @@
     runningConfig.store()
 
 
+def _used(networks, bonding):
+    for network, attributes in networks.iteritems():
+        if attributes.get('bonding') == bonding:
+            return True
+    return False
+
+
 def _owned(devname):
     try:
         with open(NET_CONF_PREF + devname) as conf:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb643a0c3681631db7bd875a03ebdb91fd893e70
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>


More information about the vdsm-patches mailing list