Antoni Segura Puimedon has uploaded a new change for review. Change subject: sampling: remove ethtool dependency ......................................................................
sampling: remove ethtool dependency The flags are already part of the link object. There was no good reason to ask the system again for this data. Change-Id: I9ae5b5a017c954d0c3c2c0b6f3f62c08ee05bd4f Signed-off-by: Antoni S. Puimedon <[email protected]> --- M lib/vdsm/ipwrapper.py M vdsm/virt/sampling.py 2 files changed, 6 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/32360/1 diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py index af31159..5fa874e 100644 --- a/lib/vdsm/ipwrapper.py +++ b/lib/vdsm/ipwrapper.py @@ -115,6 +115,7 @@ _hiddenBonds = config.get('vars', 'hidden_bonds').split(',') _hiddenNics = config.get('vars', 'hidden_nics').split(',') _hiddenVlans = config.get('vars', 'hidden_vlans').split(',') + IFF_RUNNING = 1 << 6 def __init__(self, address, index, linkType, mtu, name, qdisc, state, vlanid=None, vlanprotocol=None, master=None, device=None, @@ -238,6 +239,10 @@ return True return False + @property + def oper_up(self): + return bool(self.flags & self.IFF_RUNNING) + def drv_name(devName): """Returns the driver used by a device. diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py index d6bef32..969f755 100644 --- a/vdsm/virt/sampling.py +++ b/vdsm/virt/sampling.py @@ -31,7 +31,6 @@ import time import logging import errno -import ethtool import re from vdsm import utils @@ -87,19 +86,6 @@ if not tries: raise - def readIfaceOperstate(self, ifid): - """ - Return the operational state of the interface. - - :returns: ``'up'`` if interface is up. ``'down'`` or ``0`` id it's - down. - """ - try: - flags = ethtool.get_flags(ifid) - except IOError: - return '0' - return 'up' if flags & ethtool.IFF_RUNNING else 'down' - def __init__(self, link): ifid = link.name self.rx = self.readIfaceStat(ifid, 'rx_bytes') @@ -108,7 +94,7 @@ self.txDropped = self.readIfaceStat(ifid, 'tx_dropped') self.rxErrors = self.readIfaceStat(ifid, 'rx_errors') self.txErrors = self.readIfaceStat(ifid, 'tx_errors') - self.operstate = self.readIfaceOperstate(ifid) + self.operstate = 'up' if link.oper_up else 'down' self.speed = _getLinkSpeed(link) self.duplex = _getDuplex(ifid) -- To view, visit http://gerrit.ovirt.org/32360 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9ae5b5a017c954d0c3c2c0b6f3f62c08ee05bd4f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Antoni Segura Puimedon <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
