summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-07-04 18:11:32 +0800
committerYun Huang <yun.huang@windriver.com>2018-07-04 18:11:32 +0800
commitf733a2438cc6df26ac9019a401b4fdb32d29f9ee (patch)
treec18e5107e19d49a700ac42123f313ec984089904 /ocata
parent0efdb6a4ee78417040732f72ee4a6223b5f96729 (diff)
Add GET API to retrieve config&backlogs for ocata
Change-Id: I9410ee7ebf10c2b915d42e2cba3c0a03f2427840 Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'ocata')
-rw-r--r--ocata/ocata/vesagent/vesagent_ctrl.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/ocata/ocata/vesagent/vesagent_ctrl.py b/ocata/ocata/vesagent/vesagent_ctrl.py
index daacb4fa..2d5d3238 100644
--- a/ocata/ocata/vesagent/vesagent_ctrl.py
+++ b/ocata/ocata/vesagent/vesagent_ctrl.py
@@ -162,8 +162,23 @@ class VesAgentCtrl(APIView):
'''
self._logger.info("vimid: %s" % vimid)
self._logger.debug("with META: %s" % request.META)
+ try:
+ # get vesagent_config from cloud region
+ viminfo = extsys.get_vim_by_id(vimid)
+ cloud_extra_info_str = viminfo.get('cloud_extra_info', None)
+ cloud_extra_info = json.loads(cloud_extra_info_str) if cloud_extra_info_str is not None else None
+ vesagent_config = cloud_extra_info.get("vesagent_config", None) if cloud_extra_info is not None else None
- pass
+ vesagent_backlogs = self.getBacklogsOneVIM(vimid)
+
+ except Exception as e:
+ self._logger.error("exception:%s" % str(e))
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+ return Response(data={"vesagent_config":vesagent_config,
+ "vesagent_backlogs": vesagent_backlogs},
+ status=status.HTTP_200_OK)
def post(self, request, vimid=""):
@@ -230,6 +245,36 @@ class VesAgentCtrl(APIView):
return Response(status=status.HTTP_200_OK)
+ def getBacklogsOneVIM(self, vimid):
+ '''
+ remove the specified backlogs for a VIM
+ :param vimid:
+ :return:
+ '''
+ self._logger.info("vimid: %s" % vimid)
+
+ vesAgentConfig = None
+ try:
+ # retrive the backlogs
+ vesAgentConfigStr = cache.get("VesAgentBacklogs.config.%s" % (vimid))
+ if vesAgentConfigStr is None:
+ logger.warn("VesAgentBacklogs.config.%s cannot be found in cache" % (vimid))
+ return None
+
+ logger.debug("VesAgentBacklogs.config.%s: %s" % (vimid, vesAgentConfigStr))
+
+ vesAgentConfig = json.loads(vesAgentConfigStr)
+ if vesAgentConfig is None:
+ logger.warn("VesAgentBacklogs.config.%s corrupts" % (vimid))
+ return None
+
+ except Exception as e:
+ self._logger.error("exception:%s" % str(e))
+ vesAgentConfig = {"error": "exception occurs"}
+
+ self._logger.info("return")
+ return vesAgentConfig
+
def buildBacklogsOneVIM(self, vimid, vesagent_config = None):
'''