Ryan Barry 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. Parameterize BridgedNIC so we can let it know whether it's a slave or not, and if it isn't, check /sys to find the actual slave nic, then assign that to snic so the rest of the logic stays the same, and networking resolves properly. Change-Id: I8e99a015ff5904bfccd4c0d1655d5489776a28dd Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1280241 Signed-off-by: Ryan Barry <[email protected]> --- M src/ovirt/node/utils/network.py 1 file changed, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/60/51560/1 diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py index fa742d0..c96b9fc 100755 --- a/src/ovirt/node/utils/network.py +++ b/src/ovirt/node/utils/network.py @@ -356,8 +356,17 @@ bridge_nic = None slave_nic = None - def __init__(self, snic): + def __init__(self, snic, master=False): super(BridgedNIC, self).__init__(snic.ifname) + if master: + try: + slave = os.listdir("/sys/class/net/%s/brif" % snic.ifname)[0] + snic = NIC(slave) + 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" % + snic.ifname) self.slave_nic = snic self.bridge_nic = NIC(snic.config.bridge) self.config = self.bridge_nic.config @@ -584,12 +593,12 @@ 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) + nic = BridgedNIC(nic, master=True) if nic.is_configured() and filter_configured: # Don not return configured NICs -- To view, visit https://gerrit.ovirt.org/51560 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e99a015ff5904bfccd4c0d1655d5489776a28dd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Ryan Barry <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
