Change in vdsm[ovirt-3.5]: network: models: tag non-VDSM devices used by VDSM

phoracek at redhat.com phoracek at redhat.com
Mon Mar 16 14:06:30 UTC 2015


Hello Dan Kenigsberg,

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

    https://gerrit.ovirt.org/38771

to review the following change.

Change subject: network: models: tag non-VDSM devices used by VDSM
......................................................................

network: models: tag non-VDSM devices used by VDSM

When we setup network over pre-existing vlaned bond, models.py skip
configuration of pre-existing devices under a vlan (because they are not
to be changed) in order to not ifdown possibly used devices. Due to this
behaviour we don't persist mentioned networks and therefore we are not
able to restore them.

Now we check if device is a part of vdsm, if not, we configure and
persist it.

Change-Id: I4d3ed2b45d618d404bb340100ca07bc57b2f1136
Signed-off-by: Petr Horáček <phoracek at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/38572
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1154399
---
M tests/functional/networkTests.py
M vdsm/network/models.py
2 files changed, 55 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/38771/1

diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 3b3f474..8af47e4 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -40,10 +40,11 @@
                             ruleExists, Route, Rule, addrFlush, LinkType,
                             getLinks, routeShowTable)
 
-from vdsm.constants import EXT_BRCTL
+from vdsm.constants import EXT_BRCTL, EXT_IFUP
 from vdsm.utils import RollbackContext, execCmd
 from vdsm.netinfo import (bridges, operstate, prefix2netmask, getRouteDeviceTo,
-                          getDhclientIfaces, BONDING_SLAVES, BONDING_MASTERS)
+                          getDhclientIfaces, BONDING_SLAVES, BONDING_MASTERS,
+                          NET_CONF_PREF)
 from vdsm import ipwrapper
 from vdsm.utils import pgrep
 
@@ -2184,3 +2185,54 @@
             self.assertNetworkDoesntExist(NETWORK_NAME)
             self.assertBondDoesntExist(BONDING_NAME, [nic])
             self.vdsm_net.save_config()
+
+    @cleanupNet
+    @ValidateRunningAsRoot
+    def test_setupNetworks_on_external_vlaned_bond(self):
+        with dummyIf(1) as (nic, ):
+            with open(NET_CONF_PREF + nic, 'w') as f:
+                f.write("""DEVICE=%s
+MASTER=%s
+SLAVE=yes
+ONBOOT=yes
+MTU=1500
+NM_CONTROLLED=no""" % (nic, BONDING_NAME))
+            with open(NET_CONF_PREF + BONDING_NAME, 'w') as f:
+                f.write("""DEVICE=%s
+BONDING_OPTS='mode=802.3ad miimon=150'
+ONBOOT=yes
+BOOTPROTO=none
+DEFROUTE=yes
+NM_CONTROLLED=no
+HOTPLUG=no""" % BONDING_NAME)
+            with open(NET_CONF_PREF + BONDING_NAME + '.' + VLAN_ID, 'w') as f:
+                f.write("""DEVICE=%s.%s
+VLAN=yes
+ONBOOT=yes
+BOOTPROTO=static
+NM_CONTROLLED=no
+HOTPLUG=no""" % (BONDING_NAME, VLAN_ID))
+
+            rc, _, _ = execCmd([EXT_IFUP, BONDING_NAME])
+            rc, _, _ = execCmd([EXT_IFUP, BONDING_NAME + '.' + VLAN_ID])
+
+            status, msg = self.vdsm_net.setupNetworks(
+                {NETWORK_NAME: {'bonding': BONDING_NAME, 'bridged': True,
+                                'vlan': VLAN_ID}}, {}, NOCHK)
+            self.assertEqual(status, SUCCESS, msg)
+            self.assertNetworkExists(NETWORK_NAME)
+
+            self.vdsm_net.save_config()
+            self.vdsm_net.restoreNetConfig()
+
+            self.assertNetworkExists(NETWORK_NAME)
+            self.assertBondExists(BONDING_NAME, [nic])
+            self.assertVlanExists(BONDING_NAME + '.' + VLAN_ID)
+
+            status, msg = self.vdsm_net.setupNetworks(
+                {NETWORK_NAME: {'remove': True}},
+                {BONDING_NAME: {'remove': True}}, NOCHK)
+            self.assertEqual(status, SUCCESS, msg)
+            self.assertNetworkDoesntExist(NETWORK_NAME)
+            self.assertBondDoesntExist(BONDING_NAME, [nic])
+            self.vdsm_net.save_config()
diff --git a/vdsm/network/models.py b/vdsm/network/models.py
index 2d13409..11666a0 100644
--- a/vdsm/network/models.py
+++ b/vdsm/network/models.py
@@ -204,6 +204,7 @@
         # is already applied in any way, we can skip the configuring.
         if (self.vlan and
             self.name in netinfo.bondings() and
+            self.name in self.configurator.runningConfig.bonds and
             netinfo.operstate(self.name) == netinfo.OPERSTATE_UP and
             netinfo.ifaceUsed(self.name) and
             self.mtu <= netinfo.getMtu(self.name) and


-- 
To view, visit https://gerrit.ovirt.org/38771
To unsubscribe, visit https://gerrit.ovirt.org/settings

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


More information about the vdsm-patches mailing list