Change in vdsm[master]: netinfo: use a Link object in vlanSpeed
osvoboda at redhat.com
osvoboda at redhat.com
Mon Sep 28 22:58:32 UTC 2015
Ondřej Svoboda has uploaded a new change for review.
Change subject: netinfo: use a Link object in vlanSpeed
......................................................................
netinfo: use a Link object in vlanSpeed
This means one less getLink call. _vlan_device can now be
removed.
Change-Id: I347fbc6b361cf95a8115c32cdec364c6c7b53692
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M lib/vdsm/netinfo.py
M vdsm/virt/sampling.py
2 files changed, 8 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/46770/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 772493f..683eb36 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -255,14 +255,13 @@
return operstateFile.read().strip()
-def vlanSpeed(vlanName):
- """Returns the vlan's underlying device speed."""
- vlanDevName = _vlan_device(vlanName)
- vlanDev = getLink(vlanDevName)
- if vlanDev.isNIC():
- speed = nicSpeed(vlanDevName)
- elif vlanDev.isBOND():
- speed = bondSpeed(vlanDevName)
+def vlanSpeed(vlan):
+ """Return the VLAN's underlying device speed."""
+ nic_or_bond = getLink(vlan.device)
+ if nic_or_bond.isNIC():
+ speed = nicSpeed(vlan.device)
+ elif nic_or_bond.isBOND():
+ speed = bondSpeed(vlan.device)
else:
speed = 0
return speed
@@ -788,12 +787,6 @@
def isVlanned(dev):
return any(vlan.startswith(dev + '.') for vlan in vlans())
-
-
-def _vlan_device(vlan):
- """ Return the device of the given VLAN. """
- vlanLink = getLink(vlan)
- return vlanLink.device
def getIpAddresses():
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 1ad9d46..e7f1a51 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -772,7 +772,7 @@
elif dev.isBOND():
speed = netinfo.bondSpeed(dev.name)
elif dev.isVLAN():
- speed = netinfo.vlanSpeed(dev.name)
+ speed = netinfo.vlanSpeed(dev)
else:
speed = 0
return speed
--
To view, visit https://gerrit.ovirt.org/46770
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I347fbc6b361cf95a8115c32cdec364c6c7b53692
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
More information about the vdsm-patches
mailing list