aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ovsdb/ovsdbmonitor/OVEConfig.py26
-rw-r--r--ovsdb/ovsdbmonitor/OVEFetch.py4
-rw-r--r--ovsdb/ovsdbmonitor/OVEStandard.py5
3 files changed, 27 insertions, 8 deletions
diff --git a/ovsdb/ovsdbmonitor/OVEConfig.py b/ovsdb/ovsdbmonitor/OVEConfig.py
index 7cc18eb4..4754c67a 100644
--- a/ovsdb/ovsdbmonitor/OVEConfig.py
+++ b/ovsdb/ovsdbmonitor/OVEConfig.py
@@ -1,3 +1,4 @@
+# Copyright (c) 2011 Nicira Networks.
# Copyright (c) 2010 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +15,21 @@
from OVEStandard import *
from OVELogger import *
+import ovs.json
+
+def str_recursive(x):
+ t = type(x)
+ if t == unicode:
+ return str(x)
+ elif t == list:
+ return [str_recursive(_) for _ in x]
+ elif t == dict:
+ out = {}
+ for k,v in x.iteritems():
+ out[str_recursive(k)] = str_recursive(v)
+ return out
+ else:
+ return x
class OVEConfig(QtCore.QObject):
instance = None
@@ -40,21 +56,21 @@ class OVEConfig(QtCore.QObject):
def saveConfig(self):
settings = QtCore.QSettings()
- settings.setValue('config/hosts', QVariant(json.JsonWriter().write(self.hosts)))
+ settings.setValue('config/hosts', QVariant(ovs.json.to_string((self.hosts))))
settings.setValue('config/logTraffic', QVariant(self.logTraffic))
settings.setValue('config/truncateUuids', QVariant(self.truncateUuids))
- settings.setValue('config/ssgList', QVariant(json.JsonWriter().write(self.ssgList)))
+ settings.setValue('config/ssgList', QVariant(ovs.json.to_string(self.ssgList)))
settings.sync()
self.emitUpdated()
-
+
def loadConfig(self):
settings = QtCore.QSettings()
jsonText = unicode(settings.value('config/hosts', QVariant('[]')).toString())
- self.hosts = json.JsonReader().read(str(jsonText))
+ self.hosts = str_recursive(ovs.json.from_string(str(jsonText)))
self.logTraffic = settings.value('config/logTraffic', QVariant(False)).toBool()
self.truncateUuids = settings.value('config/truncateUuids', QVariant(False)).toBool()
jsonText = unicode(settings.value('config/ssgList', QVariant('[]')).toString())
- self.ssgList = json.JsonReader().read(str(jsonText))
+ self.ssgList = ovs.json.from_string(str(jsonText))
if len(self.ssgList) == 0:
self.ssgList = [
r'in_port0000',
diff --git a/ovsdb/ovsdbmonitor/OVEFetch.py b/ovsdb/ovsdbmonitor/OVEFetch.py
index 9dd1118b..8bc5757c 100644
--- a/ovsdb/ovsdbmonitor/OVEFetch.py
+++ b/ovsdb/ovsdbmonitor/OVEFetch.py
@@ -1,3 +1,4 @@
+# Copyright (c) 2011 Nicira Networks.
# Copyright (c) 2010 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +16,7 @@
from OVEStandard import *
from OVEConfig import *
from OVELogger import *
+import ovs.json
# This sequence installs the qt4reactor before twisted gets a chance to install its reactor
import qt4reactor
@@ -166,7 +168,7 @@ class OVECommandChannel(channel.SSHChannel, QtCore.QObject):
if self.commandType == 'JSON':
try:
# Decode the JSON data, to confirm that we have all of the data
- self._jsonValues = json.read(str(self._data)) # FIXME: Should handle unicode
+ self._jsonValues = ovs.json.from_string(str(self._data)) # FIXME: Should handle unicode
self.sendResult()
except:
pass # Wait for more data
diff --git a/ovsdb/ovsdbmonitor/OVEStandard.py b/ovsdb/ovsdbmonitor/OVEStandard.py
index b9bc419c..23b3e665 100644
--- a/ovsdb/ovsdbmonitor/OVEStandard.py
+++ b/ovsdb/ovsdbmonitor/OVEStandard.py
@@ -1,3 +1,4 @@
+# Copyright (c) 2011 Nicira Networks.
# Copyright (c) 2010 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,9 +21,9 @@ from pprint import pprint
globalForcePySide = False
try:
- import json
+ import ovs.json
except Exception, e:
- print('+++ Python JSON module is required\n')
+ print('+++ OVS JSON module is required\n')
raise
try: