[node-patches] Change in ovirt-node[master]: network: Don't remov bonding module on cleanup

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Aug 8 16:12:23 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: network: Don't remov bonding module on cleanup
......................................................................

network: Don't remov bonding module on cleanup

Previously the bonding module got unloaded to remove all bonds on the
system, but this conflicted with other parts of Node, namely vdsm.
Therefor now the bonds are removed by bringing down each device on it's
own.

Change-Id: I184d3ce6318a4086528ae33fe67dfb6ce4aeed43
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/utils/network.py
1 file changed, 13 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/49/17849/1

diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py
index edbe870..bdadea9 100644
--- a/src/ovirt/node/utils/network.py
+++ b/src/ovirt/node/utils/network.py
@@ -20,6 +20,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import base, utils, config, valid
 from ovirt.node.config.network import NicConfig
+from ovirt.node.utils import fs
 from ovirt.node.utils.fs import File
 import glob
 import gudev
@@ -807,18 +808,17 @@
 class Bonds(base.Base):
     """Convenience API to access some bonding related stuff
     """
-    basepath = "/proc/net/bonding"
+    bonding_masters_filename = "/sys/class/net/bonding_masters"
 
     def is_enabled(self):
         """If bonding is enabled
         """
-        return os.path.exists(self.basepath)
+        return fs.File(self.bonding_masters_filename).exists()
 
     def ifnames(self):
         """Return the ifnames of all bond devices
         """
-        return [os.path.basename(b)
-                for b in os.listdir(self.basepath)]
+        return fs.File(self.bonding_masters_filename).read().split()
 
     def is_bond(self, ifname):
         """Determins if ifname is a bond device
@@ -828,10 +828,13 @@
     def delete_all(self):
         """Deletes all bond devices
         """
-        process.call("rmmod bonding 2> /dev/null", shell=True)
+        for master in self.ifnames():
+            self.delete(master)
 
-    def delete(self, ifname):
-        if not self.is_bond(ifname):
-            raise RuntimeError("Can no delete '%s', is no bond" % ifname)
-        process.call(["ip", "link", "set", "dev", ifname, "down"])
-        process.call(["ip", "link", "delete", ifname, "type", "bond"])
+    def delete(self, mifname):
+        """Delete a bond master
+        """
+        if not self.is_bond(mifname):
+            raise RuntimeError("Can no delete '%s', is no bond" % mifname)
+        process.call(["ip", "link", "set", "dev", mifname, "down"])
+        process.call(["ip", "link", "delete", mifname, "type", "bond"])


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I184d3ce6318a4086528ae33fe67dfb6ce4aeed43
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list