Fabian Deutsch has uploaded a new change for review. Change subject: network: Move slaves to Bonds class ......................................................................
network: Move slaves to Bonds class Change-Id: I14a396647885ee441ce63a5fba67550d9bc95429 Signed-off-by: Fabian Deutsch <[email protected]> --- M src/ovirt/node/utils/network.py 1 file changed, 12 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/77/27777/1 diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py index 084924c..9221693 100644 --- a/src/ovirt/node/utils/network.py +++ b/src/ovirt/node/utils/network.py @@ -496,11 +496,7 @@ @property def slaves(self): - path = "/sys/class/net/%s/bonding/slaves" % self.ifname - if os.path.isfile(path): - return File(path).read().split() - else: - return [] + return Bonds().slaves(self.ifname) def __str__(self): return self.build_str(["ifname", "slave_nics"]) @@ -885,6 +881,7 @@ """Convenience API to access some bonding related stuff """ bonding_masters_filename = "/sys/class/net/bonding_masters" + bond_slaves_path = "/sys/class/net/%s/bonding/slaves" def is_enabled(self): """If bonding is enabled @@ -902,7 +899,16 @@ def is_bond(self, ifname): """Determins if ifname is a bond device """ - return ifname in self.ifnames() + return File(self.bond_slaves_path % ifname).exists() + + def slaves(self, ifname): + """Find all slaves of the bond master ifname + """ + path = self.bond_slaves_path % ifname + slaves = [] + if self.is_bond(ifname): + slaves = File(path).read().split() + return slaves def delete_all(self): """Deletes all bond devices -- To view, visit http://gerrit.ovirt.org/27777 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I14a396647885ee441ce63a5fba67550d9bc95429 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Fabian Deutsch <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
