Mark Wu has uploaded a new change for review. Change subject: Improve the checking of mulitple direct users on an interface. ......................................................................
Improve the checking of mulitple direct users on an interface. Change-Id: I1e8bc4d8ee8709f72a5746edc2d61f320ef1a2ab Signed-off-by: Mark Wu <wu...@linux.vnet.ibm.com> --- M lib/vdsm/netinfo.py M vdsm/configNetwork.py 2 files changed, 14 insertions(+), 33 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/14872/1 diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py index 8c06c2a..1e406da 100644 --- a/lib/vdsm/netinfo.py +++ b/lib/vdsm/netinfo.py @@ -606,32 +606,13 @@ users.add(v) return users - def nicOtherUsers(self, bridge, vlan, bonding, nic): + def ifaceHasMultiUsers(self, iface): """ - Returns a list of interfaces using a nic, - other than the specified one. + Checks if the interface has multiple direct users. + The two possible cases of mulitple users are multiple bridged or + bridgeless networks via vlans and one direct bridgeless network + with multiple network users via vlan. + The interface can't have multiple direct users if it's enslaved + to bonding or bridge directly. """ - if bonding: - owner = bonding - elif vlan: - owner = nic + '.' + vlan - else: - owner = bridge - users = self.ifaceUsers(nic) - if bonding: - users.update(self.bondingOtherUsers(bridge, vlan, bonding)) - users.discard(owner) - return users - - def bondingOtherUsers(self, bridge, vlan, bonding): - """ - Return a list of nics/interfaces using a bonding, - other than the specified one. - """ - if vlan: - owner = bonding + '.' + vlan - else: - owner = bridge - users = self.ifaceUsers(bonding) - users.discard(owner) - return users + return len(list(self.getNetworksAndVlansForIface(iface))) > 1 diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py index 2543055..ef6c66f 100755 --- a/vdsm/configNetwork.py +++ b/vdsm/configNetwork.py @@ -270,10 +270,10 @@ print "Bondings:", _netinfo.bondings.keys() -def _removeUnusedNics(network, vlan, bonding, nics, configWriter): +def _removeUnusedNics(nics, configWriter): _netinfo = netinfo.NetInfo() for nic in nics: - if not _netinfo.nicOtherUsers(network, vlan, bonding, nic): + if not _netinfo.ifaceHasMultiUsers(nic): ifdown(nic) configWriter.removeNic(nic) ifup(nic) @@ -368,14 +368,14 @@ # The (relatively) new setupNetwork verb allows to remove a network # defined on top of an bonding device without break the bond itself. if implicitBonding: - if bonding and not _netinfo.bondingOtherUsers(network, vlan, bonding): + if bonding and not _netinfo.ifaceHasMultiUsers(bonding): ifdown(bonding) configWriter.removeBonding(bonding) - _removeUnusedNics(network, vlan, bonding, nics, configWriter) + _removeUnusedNics(nics, configWriter) elif not bonding: - _removeUnusedNics(network, vlan, bonding, nics, configWriter) - elif not _netinfo.bondingOtherUsers(network, vlan, bonding): + _removeUnusedNics(nics, configWriter) + elif not _netinfo.ifaceHasMultiUsers(bonding): ifdown(bonding) configWriter.setBondingMtu(bonding, DEFAULT_MTU) ifup(bonding) -- To view, visit http://gerrit.ovirt.org/14872 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e8bc4d8ee8709f72a5746edc2d61f320ef1a2ab Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Mark Wu <wu...@linux.vnet.ibm.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches