summaryrefslogtreecommitdiffstats
path: root/vio/vio/pub/utils/syscomm.py
diff options
context:
space:
mode:
Diffstat (limited to 'vio/vio/pub/utils/syscomm.py')
-rw-r--r--vio/vio/pub/utils/syscomm.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/vio/vio/pub/utils/syscomm.py b/vio/vio/pub/utils/syscomm.py
index 833a290..fd99ac6 100644
--- a/vio/vio/pub/utils/syscomm.py
+++ b/vio/vio/pub/utils/syscomm.py
@@ -11,7 +11,38 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import inspect
-
+import json
+from collections import defaultdict
def fun_name():
return inspect.stack()[1][3]
+
+
+def jsonResponse(data,encoding='utf-8'):
+
+ content_type = "application/json"
+ try:
+ res = json.loads(data,encoding=encoding)
+ except Exception as e:
+ res = data
+ content_type = "text/plain"
+ return (res,content_type)
+
+
+class Catalogs(object):
+
+ def __init__(self):
+ self.ct=defaultdict(dict)
+
+
+ def storeEndpoint(self,vimid,endpoints):
+ self.ct.setdefault(vimid,endpoints)
+
+ def getEndpointBy(self,vimid,serverType,interface='public'):
+
+ vim = self.ct.get(vimid)
+ return vim.get(serverType).get(interface,"") if vim else ""
+
+
+
+catalog = Catalogs()