Logging enhancement for openo hypervisor API 85/44285/2
authorYun Huang <yun.huang@windriver.com>
Tue, 24 Apr 2018 03:09:41 +0000 (11:09 +0800)
committerYun Huang <yun.huang@windriver.com>
Tue, 24 Apr 2018 03:09:41 +0000 (11:09 +0800)
Change-Id: I567557ee4c70083d366c1c614dae2b953d2a18d7
Issue-ID: MULTICLOUD-178
Signed-off-by: Yun Huang <yun.huang@windriver.com>
share/newton_base/openoapi/flavor.py
share/newton_base/openoapi/hypervisor.py

index d922be8..1124aec 100644 (file)
@@ -138,7 +138,7 @@ class Flavors(APIView):
 
             logger.info("request returns with status %s" % resp.status_code)
             if resp.status_code == status.HTTP_200_OK:
-                logger.debug("with content:%s" % req_resouce)
+                logger.debug("with content:%s" % resp.json())
                 pass
 
             return resp
@@ -163,7 +163,7 @@ class Flavors(APIView):
 
             logger.info("request returns with status %s" % resp.status_code)
             if resp.status_code == status.HTTP_200_OK:
-                logger.debug("with content:%s" % req_resouce)
+                logger.debug("with content:%s" % resp.json())
                 pass
 
             return resp
index 147fbc4..e920130 100755 (executable)
@@ -37,14 +37,22 @@ class Hypervisors(APIView):
         ("container_format", "containerFormat")\r
     ]\r
 \r
-       \r
+\r
     def get(self, request, vimid="", tenantid="", hypervisorid=""):\r
-        logger.debug("hypervisors--get::> %s" % request.data)\r
+        logger.info("vimid, tenantid, hypervisorid = %s,%s,%s" % (vimid, tenantid, hypervisorid))\r
+        if request.data:\r
+            logger.debug("With data = %s" % request.data)\r
+            pass\r
+\r
         try:\r
             query = VimDriverUtils.get_query_part(request)\r
             content, status_code = self.get_hypervisors(query, vimid, tenantid, hypervisorid)\r
+\r
+            logger.info("response with status = %s" % resp.status_code)\r
+\r
             return Response(data=content, status=status_code)\r
         except VimDriverNewtonException as e:\r
+            logger.error("response with status = %s" % e.status_code)\r
             return Response(data={'error': e.content}, status=e.status_code)\r
         except HttpError as e:\r
             logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))\r
@@ -54,16 +62,24 @@ class Hypervisors(APIView):
             return Response(data={'error': str(e)},\r
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)\r
 \r
-                                                       \r
+\r
     def get_hypervisors(self, query="", vimid="", tenantid="", hypervisorid=""):\r
-        logger.debug("hypervisors--get::> %s" % hypervisorid)\r
 \r
         req_resource = "/os-hypervisors"\r
 \r
         vim = VimDriverUtils.get_vim_info(vimid)\r
         vim["domain"] = "Default"\r
         sess = VimDriverUtils.get_session(vim, tenantid)\r
+\r
+        logger.info("making request with URI:%s" % req_resouce)\r
+\r
         resp = sess.get(req_resource, endpoint_filter = self.service)\r
+\r
+        logger.info("request returns with status %s" % resp.status_code)\r
+        if resp.status_code == status.HTTP_200_OK:\r
+            logger.debug("with content:%s" % resp.json())\r
+            pass\r
+\r
         content = resp.json()\r
 \r
         return content, resp.status_code\r