[NEW PATCH] BZ#726359 Use ethtool to get interface state (via gerrit-bot)
Federico Simoncelli
fsimonce at redhat.com
Thu Jul 28 13:02:28 UTC 2011
New patch submitted by Federico Simoncelli (fsimonce at redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/759
commit fcadfb9010a6c91127b02a3014c6e2bc3e8505ec
Author: Federico Simoncelli <fsimonce at redhat.com>
Date: Thu Jul 28 13:01:12 2011 +0000
BZ#726359 Use ethtool to get interface state
Change-Id: Ide8773361c3eec26297eae4d413e9d259d2000ec
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 1d3f058..58a5604 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -120,13 +120,11 @@ class InterfaceSample:
:returns: ``'up'`` if interface is up. ``'down'`` or ``0`` id it's down.
"""
- f = '/sys/class/net/%s/operstate' % (ifid,)
try:
- s = file(f).readline().strip()
- except:
- logging.debug(traceback.format_exc())
+ flags = ethtool.get_flags(ifid)
+ except IOError:
return '0'
- return s
+ return 'up' if flags & ethtool.IFF_UP else 'down'
def __init__(self, ifid):
self.rx = self.readIfaceStat(ifid, 'rx_bytes')
More information about the vdsm-patches
mailing list