Ondřej Svoboda has uploaded a new change for review.

Change subject: networkTests: normalize dict keys and values to str (from 
unicode)
......................................................................

networkTests: normalize dict keys and values to str (from unicode)

Change-Id: I6362e04189f134ad27ee4e3c1991020b2eee91aa
Signed-off-by: Ondřej Svoboda <[email protected]>
---
M lib/vdsm/netconfpersistence.py
M tests/functional/networkTests.py
2 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/45201/1

diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index b5c3f14..b4598fa 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -428,6 +428,15 @@
         return dict(
             (k, v) for k, v in opts.iteritems() if v != defaults.get(k))
 
+    def _normalize_unicode(self, config_copy):
+        for network, netdict in config_copy.networks.iteritems():
+            for attr, value in dict(netdict).iteritems():
+                if isinstance(attr, unicode):
+                    if isinstance(value, unicode):
+                        value = str(value)
+                    netdict.pop(attr)
+                    netdict[str(attr)] = value
+
 
 class RunningConfig(Config):
     def __init__(self):
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 056f3e9..a62881a 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -386,6 +386,8 @@
         # do not use KernelConfig.__eq__ to get better exception if something
         # breaks here
         normalized_config = kernel_config.normalize(running_config)
+        kernel_config._normalize_unicode(normalized_config)
+
         self.assertEqual(normalized_config.networks, kernel_config.networks)
         self.assertEqual(normalized_config.bonds, kernel_config.bonds)
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6362e04189f134ad27ee4e3c1991020b2eee91aa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to