summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/resource
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-26 16:44:58 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-26 16:46:49 +0800
commit8585e350132b2e25b07d5d327708420590ac30c8 (patch)
tree8f33388b886eb42b4faf2ec4666c3814d4553e96 /windriver/titanium_cloud/resource
parentcab47ee33492d244b3f926e4f71f118b4c1ac7f1 (diff)
Enhance logging coverage for API capacity_check
Change-Id: I0272053bb3bc072548c28e1649939c92998685fe Issue-ID: MULTICLOUD-177 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/resource')
-rw-r--r--windriver/titanium_cloud/resource/views/capacity.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py
index d73cc0fb..0d44d0c4 100644
--- a/windriver/titanium_cloud/resource/views/capacity.py
+++ b/windriver/titanium_cloud/resource/views/capacity.py
@@ -38,8 +38,8 @@ class CapacityCheck(APIView):
self._logger = logger
def post(self, request, vimid=""):
- self._logger.info("CapacityCheck--post::vimid, data> %s, %s" % (vimid, request.data))
- self._logger.debug("CapacityCheck--post::META> %s" % request.META)
+ self._logger.info("vimid, data> %s, %s" % (vimid, request.data))
+ self._logger.debug("META> %s" % request.META)
hasEnoughResource = False
try :
@@ -58,22 +58,31 @@ class CapacityCheck(APIView):
#get limit for this tenant
req_resouce = "/limits"
+ self._logger.info("check limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check limits> status:%s" % resp.status_code)
content = resp.json()
compute_limits = content['limits']['absolute']
+ self._logger.debug("check limits> resp data:%s" % content)
#get total resource of this cloud region
req_resouce = "/os-hypervisors/statistics"
+ self._logger.info("check os-hypervisors statistics> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check os-hypervisors statistics> status:%s" % resp.status_code)
content = resp.json()
hypervisor_statistics = content['hypervisor_statistics']
+ self._logger.debug("check os-hypervisors statistics> resp data:%s" % content)
#get storage limit for this tenant
service['service_type'] = 'volumev2'
req_resouce = "/limits"
+ self._logger.info("check volumev2 limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check volumev2> status:%s" % resp.status_code)
content = resp.json()
storage_limits = content['limits']['absolute']
+ self._logger.debug("check volumev2> resp data:%s" % content)
# compute actual available resource for this tenant
remainVCPU = compute_limits['maxTotalCores'] - compute_limits['totalCoresUsed']
@@ -102,8 +111,11 @@ class CapacityCheck(APIView):
else:
hasEnoughResource = True
+ self._logger.info("RESP with data> result:%s" % hasEnoughResource)
return Response(data={'result': hasEnoughResource}, status=status.HTTP_200_OK)
except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
return Response(data={'result': hasEnoughResource,'error': e.content}, status=e.status_code)
except HttpError as e:
self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))