Change in vdsm[ovirt-3.5]: Veth devices are shown as NICs + test

phoracek at redhat.com phoracek at redhat.com
Tue Aug 26 19:13:21 UTC 2014


Hello Antoni Segura Puimedon, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/32016

to review the following change.

Change subject: Veth devices are shown as NICs + test
......................................................................

Veth devices are shown as NICs + test

Veth LinkType was not listed in tuple, therefore veths were
evaluated as NICs.

New test adds dummies and veths with _fakeNics prefix and with
non _fakeNics prefix and then verify if fake nics are shown in
netinfo.nics() and the others are not.

Bug-Url: https://bugzilla.redhat.com/1125177
Change-Id: Ide618510b46eee28d939c32e8188bbd38349d660
Signed-off-by: Petr Horáček <phoracek at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/31166
Reviewed-by: Antoni Segura Puimedon <asegurap at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Tested-by: Dan Kenigsberg <danken at redhat.com>
---
M lib/vdsm/ipwrapper.py
M tests/netinfoTests.py
2 files changed, 25 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/32016/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index cd4b7d4..ff081ed 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -181,7 +181,7 @@
             else:
                 raise  # Reraise other errors like ENODEV
         if driver in (LinkType.BRIDGE, LinkType.MACVLAN, LinkType.TUN,
-                      LinkType.OVS, LinkType.TEAM):
+                      LinkType.OVS, LinkType.TEAM, LinkType.VETH):
             detectedType = driver
         elif driver == 'bonding':
             detectedType = LinkType.BOND
diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py
index dd90613..a3a1e64 100644
--- a/tests/netinfoTests.py
+++ b/tests/netinfoTests.py
@@ -32,6 +32,7 @@
 from vdsm.netinfo import (getBootProtocol, getDhclientIfaces, BONDING_MASTERS,
                           BONDING_OPT, _randomIfaceName, _getBondingOptions)
 
+from functional import dummy, veth
 from ipwrapperTests import _fakeTypeDetection
 from monkeypatch import MonkeyPatch, MonkeyPatchScope
 from testrunner import VdsmTestCase as TestCaseBase, namedTemporaryDir
@@ -191,6 +192,29 @@
             self.assertEqual(set(netinfo.nics()),
                              set(['em', 'me', 'fake', 'fake0']))
 
+    @ValidateRunningAsRoot
+    def testFakeNics(self):
+        with MonkeyPatchScope([(ipwrapper.Link, '_fakeNics', ['veth_*',
+                                                              'dummy_*'])]):
+            d1 = dummy.create()
+            d2 = dummy.create(prefix='mehd_')
+            v1a, v1b = veth.create()
+            v2a, v2b = veth.create(prefix='mehv_')
+
+            fakes = set([d1, v1a, v1b])
+            hiddens = set([d2, v2a, v2b])
+            nics = netinfo.nics()
+            dummy.remove(d1)
+            dummy.remove(d2)
+            veth.remove(v1a)
+            veth.remove(v2a)
+
+            self.assertTrue(fakes.issubset(nics), 'Fake devices %s are not '
+                            'listed in nics %s' % (fakes, nics))
+            self.assertFalse(hiddens.intersection(nics), 'Some of hidden '
+                             'devices %s is shown in nics %s' % (hiddens,
+                                                                 nics))
+
     def testGetBandwidthQos(self):
         notEmptyDoc = minidom.parseString("""<bandwidth>
                             <inbound average='4500' burst='5400' />


-- 
To view, visit http://gerrit.ovirt.org/32016
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide618510b46eee28d939c32e8188bbd38349d660
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list