Change in vdsm[master]: net: ignore pass through ifcfg parameters for selective rest...

ibarkan at redhat.com ibarkan at redhat.com
Wed Jul 29 14:45:53 UTC 2015


Ido Barkan has uploaded a new change for review.

Change subject: net: ignore pass through ifcfg parameters for selective restoration
......................................................................

net: ignore pass through ifcfg parameters for selective restoration

Ignore keys in persisted networks that might originate from vdsm-reg.
these might be a result of calling setupNetworks with ifcfg values
that come from the original interface that is serving the management
network. for 3.5, VDSM still supports passing arbitrary values
directly to the ifcfg files, e.g. 'IPV6_AUTOCONF=no'. we filter them
out here since kernelConfig will never report them.

Change-Id: Ib1525f7b0238aaa5eb82eedb9ad6f41154c2c29f
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M lib/vdsm/netconfpersistence.py
M tests/functional/networkTests.py
2 files changed, 41 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/44152/1

diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index c3fbda8..b5c3f14 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -25,6 +25,7 @@
 import logging
 import netaddr
 import os
+import string
 
 from .config import config
 from .tool.restore_nets import restore
@@ -319,6 +320,7 @@
         self._normalize_bonding_opts(config_copy)
         self._normalize_bonding_nics(config_copy)
         self._normalize_address(config_copy)
+        self._normalize_ifcfg_keys(config_copy)
 
         return config_copy
 
@@ -391,6 +393,23 @@
             if 'defaultRoute' not in net_attr:
                 net_attr['defaultRoute'] = False
 
+    def _normalize_ifcfg_keys(self, config_copy):
+        # ignore keys in persisted networks that might originate from vdsm-reg.
+        # these might be a result of calling setupNetworks with ifcfg values
+        # that come from the original interface that is serving the management
+        # network. for 3.5, VDSM still supports passing arbitrary values
+        # directly to the ifcfg files, e.g. 'IPV6_AUTOCONF=no'. we filter them
+        # out here since kernelConfig will never report them.
+        # TODO: remove when 3.5 is unsupported.
+        def unsupported(key):
+            return set(key) <= set(
+                string.ascii_uppercase + string.digits + '_')
+
+        for net_attr in config_copy.networks.itervalues():
+            for k in net_attr.keys():
+                if unsupported(k):
+                    net_attr.pop(k)
+
     def _parse_bond_options(self, opts):
         if not opts:
             return {}
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index ce532bb..bec3372 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -1744,6 +1744,28 @@
                 self.assertBondDoesntExist(BOND_UNCHANGED, [nic_a])
 
     @cleanupNet
+    def testSelectiveRestoreIgnoresVdsmRegParams(self):
+        if vdsm.config.config.get('vars', 'net_persistence') == 'ifcfg':
+            raise SkipTest(
+                "with ifcfg persistence, vdsm-restore-net-config selective"
+                "restoration is not supported")
+
+        with dummyIf(1) as nics:
+            nic,  = nics
+            # let _assert_kernel_config_matches_running_config do the job
+            status, msg = self.setupNetworks(
+                {NETWORK_NAME: {'nic': nic, 'IPV6_AUTOCONF': 'no',
+                                'PEERNTP': 'yes', 'IPV6INIT': 'no'}},
+                {}, NOCHK)
+            self.assertEquals(status, SUCCESS, msg)
+            self.assertNetworkExists(NETWORK_NAME)
+            status, msg = self.setupNetworks(
+                {NETWORK_NAME: {'remove': True}}, {}, NOCHK)
+            self.assertEquals(status, SUCCESS, msg)
+            self.assertNetworkDoesntExist(NETWORK_NAME)
+
+
+    @cleanupNet
     @permutations([[True], [False]])
     def testVolatileConfig(self, bridged):
         """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1525f7b0238aaa5eb82eedb9ad6f41154c2c29f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>


More information about the vdsm-patches mailing list