Change in vdsm[master]: netinfo: added configuration to show dummy NIC's too
hercinger.viktor at gmail.com
hercinger.viktor at gmail.com
Mon Oct 29 20:10:29 UTC 2012
Hercinger Viktor has uploaded a new change for review.
Change subject: netinfo: added configuration to show dummy NIC's too
......................................................................
netinfo: added configuration to show dummy NIC's too
With the vars.fake_nics configuration a list of comma-separated
interfaces can be specified. If a dummy interface matches the
fnmatch pattern, it will be included in the NIC list.
Change-Id: Ica0ad974e6dd0d144a6bb0904fdcd6bbce99ff9f
Signed-off-by: Hercinger Viktor <hercinger.viktor at gmail.com>
---
M tests/netinfoTests.py
M vdsm/netinfo.py
2 files changed, 18 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/17/8917/1
diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py
index f5a4b95..a678fbc 100644
--- a/tests/netinfoTests.py
+++ b/tests/netinfoTests.py
@@ -23,6 +23,7 @@
from testrunner import VdsmTestCase as TestCaseBase
from vdsm import netinfo
+from vdsm import config
from monkeypatch import MonkeyPatch
# speeds defined in ethtool
@@ -66,3 +67,6 @@
# just log a traceback. If it raises an exception the test will fail as
# it should.
netinfo.get()
+
+ def testMatchNicName(self):
+ self.assertTrue(netinfo.match_nic_name('test1', ['test0', 'test1']))
diff --git a/vdsm/netinfo.py b/vdsm/netinfo.py
index c3c5a6f..26ad247 100644
--- a/vdsm/netinfo.py
+++ b/vdsm/netinfo.py
@@ -19,6 +19,7 @@
#
import os
+import os.path
import errno
import glob
import ethtool
@@ -43,13 +44,22 @@
LIBVIRT_NET_PREFIX = 'vdsm-'
+def match_nic_name(nic, patterns):
+ return any(map(lambda p: fnmatch(nic, p), patterns))
+
def nics():
res = []
- for b in glob.glob('/sys/class/net/*/device'):
- nic = b.split('/')[-2]
- if not any(map(lambda p: fnmatch(nic, p),
- config.get('vars', 'hidden_nics').split(','))):
+ hidden_nics = config.get('vars', 'hidden_nics').split(',')
+ fake_nics = config.get('vars', 'fake_nics').split(',')
+
+ for b in glob.glob('/sys/class/net/*'):
+ nic = b.split('/')[-1]
+ if not os.path.exists(os.path.join(b, 'device')):
+ if match_nic_name(nic, fake_nics):
+ res.append(nic)
+ elif not match_nic_name(nic, hidden_nics):
res.append(nic)
+
return res
--
To view, visit http://gerrit.ovirt.org/8917
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica0ad974e6dd0d144a6bb0904fdcd6bbce99ff9f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Hercinger Viktor <hercinger.viktor at gmail.com>
More information about the vdsm-patches
mailing list