Add get api v1 to registration API 08/94408/1
authorBin Yang <bin.yang@windriver.com>
Tue, 27 Aug 2019 10:26:21 +0000 (10:26 +0000)
committerBin Yang <bin.yang@windriver.com>
Wed, 28 Aug 2019 07:31:32 +0000 (07:31 +0000)
Fix error of cache set with object

Change-Id: Ie397fefa4e19be2a7257ecd5adaa8dd63472b355
Issue-ID: MULTICLOUD-792
Signed-off-by: Bin Yang <bin.yang@windriver.com>
(cherry picked from commit 24f743142abe736e88fe7f4bf69511d2de823ab6)

share/common/msapi/helper.py
share/starlingx_base/registration/registration.py

index d45a729..da730d0 100644 (file)
@@ -354,6 +354,7 @@ class MultiCloudThreadHelper(object):
                         "id": item["id"],
                         "status": item["status"]
                     }
+                    cache_item_for_query_str = json.dumps(cache_item_for_query)
                     if item.get("repeat", 0) == 0:
                         self.owner.expire(backlog_id)
                         # keep only the id and status
@@ -361,7 +362,7 @@ class MultiCloudThreadHelper(object):
 
                         #update cache
                         try:
-                            cache.set(self.owner.cache_expired_prefix + cache_item_for_query["id"], cache_item_for_query, 3600*24)
+                            cache.set(self.owner.cache_expired_prefix + cache_item_for_query["id"], cache_item_for_query_str, 3600*24)
                             cache.delete(self.owner.cache_prefix + cache_item_for_query["id"])
                         except Exception as e:
                             logger.error(e.message)
@@ -369,7 +370,7 @@ class MultiCloudThreadHelper(object):
                         item["timestamp"] = now
                         #update cache
                         try:
-                            cache.set(self.owner.cache_prefix + cache_item_for_query["id"], cache_item_for_query, 3600*24) 
+                            cache.set(self.owner.cache_prefix + cache_item_for_query["id"], cache_item_for_query_str, 3600*24)
                         except Exception as e:
                             logger.error(e.message)
                 pass
index b6ed925..ebd2109 100644 (file)
@@ -83,6 +83,13 @@ class APIv1Registry(newton_registration.Registry):
         super(APIv1Registry, self).__init__()
         # self._logger = logger
 
+    def get(self, request, cloud_owner="", cloud_region_id=""):
+        self._logger.debug("get cloud region: %s, %s"
+                           % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Registry, self).get(request, vimid)
+
     def post(self, request, cloud_owner="", cloud_region_id=""):
         self._logger.info("registration with : %s, %s"
                           % (cloud_owner, cloud_region_id))