[node-patches] Change in ovirt-node[ovirt-3.6]: Sometimes BridgedNIC gets called with a bridge. Be smarter
dougsland at redhat.com
dougsland at redhat.com
Tue Jan 12 15:46:45 UTC 2016
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: Sometimes BridgedNIC gets called with a bridge. Be smarter
......................................................................
Sometimes BridgedNIC gets called with a bridge. Be smarter
Previously, if BridgedNIC was called with an actual bridge as the
argument (ovirtmgmt, for example), it set null values for some
fields, such as the bridge nic, which caused the network to show
unconfigured when it actually was.
Add a method to Bridges() to find slaves.
Add BridgeNIC (essentially BridgedNIC but setting the ifname to
the bridge instead of the slave)
Called BridgedNIC only if it's a slave. If it's a bridge, call
BridgeNIC, and set the ifname appropriately.
Check /sys to find the actual slave nic
Change-Id: I8e99a015ff5904bfccd4c0d1655d5489776a28dd
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1280241
Signed-off-by: Ryan Barry <rbarry at redhat.com>
(cherry picked from commit 053b216d788964875c73bd8430a74f9742d17bfa)
---
M src/ovirt/node/utils/network.py
1 file changed, 21 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/42/51742/1
diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py
index fa742d0..0cde2fe 100755
--- a/src/ovirt/node/utils/network.py
+++ b/src/ovirt/node/utils/network.py
@@ -584,12 +584,19 @@
self.logger.debug(" Has tag")
nic = TaggedNIC(nic, vlanid)
- if layout == "bridged":
+ if layout == "bridged" and not nic.typ == "bridge":
self.logger.debug(" Is bridged")
nic = BridgedNIC(nic)
if nic.typ == "bridge":
- nic = BridgedNIC(nic)
+ try:
+ sifname = Bridges().first_slave_for_bridge(nic.ifname)
+ except IndexError:
+ # There are no slaves. ;vdsmdummy; ?
+ # Leave it with the old behavior so we don't introduce
+ # any regressions
+ sifname = nic.ifname
+ nic = BridgedNIC(sifname)
if nic.is_configured() and filter_configured:
# Don not return configured NICs
@@ -870,6 +877,18 @@
process.call(["ip", "link", "set", "dev", ifname, "down"])
process.call(["brctl", "delbr", ifname])
+ def first_slave_for_bridge(self, ifname):
+ try:
+ slaves = sorted(os.listdir("/sys/class/net/%s/brif" % ifname))
+ slave = slaves[0]
+ except IndexError:
+ # No slaves. ;vdsmdummy; ?
+ # leave snic as it is with the old behavior
+ self.logger.info("Couldn't find a slave for BridgedNIC %s" %
+ ifname)
+ raise
+ return slave
+
class Bonds(base.Base):
"""Convenience API to access some bonding related stuff
--
To view, visit https://gerrit.ovirt.org/51742
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e99a015ff5904bfccd4c0d1655d5489776a28dd
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>
More information about the node-patches
mailing list