Skip bonding if /sys/class/net/bonding_masters doesn't exist (Shigeki Sakamoto)

This commit is contained in:
Daniel P. Berrange
2008-02-21 07:37:22 -05:00
parent dca8fccef5
commit 90c524259d
+18 -14
View File
@@ -151,12 +151,13 @@ class vmmConnection(gobject.GObject):
# find all bonding master devices and register them # find all bonding master devices and register them
# XXX bonding stuff is linux specific # XXX bonding stuff is linux specific
bondMasters = self._net_get_bonding_masters() bondMasters = self._net_get_bonding_masters()
for bond in bondMasters: if bondMasters is not None:
sysfspath = "/sys/class/net/" + bond for bond in bondMasters:
mac = self._net_get_mac_address(bond, sysfspath) sysfspath = "/sys/class/net/" + bond
self._net_device_added(bond, mac, sysfspath) mac = self._net_get_mac_address(bond, sysfspath)
# Add any associated VLANs self._net_device_added(bond, mac, sysfspath)
self._net_tag_device_added(bond, sysfspath) # Add any associated VLANs
self._net_tag_device_added(bond, sysfspath)
# Find info about all current present physical net devices # Find info about all current present physical net devices
# This is OS portable... # This is OS portable...
@@ -896,14 +897,17 @@ class vmmConnection(gobject.GObject):
def _net_get_bonding_masters(self): def _net_get_bonding_masters(self):
masters = [] masters = []
f = open("/sys/class/net/bonding_masters") if os.path.exists("/sys/class/net/bonding_masters"):
while True: f = open("/sys/class/net/bonding_masters")
rline = f.readline() while True:
if not rline: break rline = f.readline()
if rline == "\x00": continue if not rline: break
rline = rline.strip("\n\t") if rline == "\x00": continue
masters = rline[:-1].split(' ') rline = rline.strip("\n\t")
return masters masters = rline[:-1].split(' ')
return masters
else:
return None
def _net_is_bonding_slave(self, name, sysfspath): def _net_is_bonding_slave(self, name, sysfspath):
masterpath = sysfspath + "/master" masterpath = sysfspath + "/master"