From 8585e350132b2e25b07d5d327708420590ac30c8 Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Mon, 26 Mar 2018 16:44:58 +0800 Subject: Enhance logging coverage for API capacity_check Change-Id: I0272053bb3bc072548c28e1649939c92998685fe Issue-ID: MULTICLOUD-177 Signed-off-by: Yun Huang --- windriver/titanium_cloud/resource/views/capacity.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'windriver/titanium_cloud/resource/views/capacity.py') 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())) -- cgit 1.2.3-korg