summaryrefslogtreecommitdiffstats
path: root/share/newton_base/openoapi
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-04-27 12:13:03 +0800
committerYun Huang <yun.huang@windriver.com>2018-04-27 12:13:03 +0800
commit73333bf28802707d32cb550ac4b16dfe01f1af7d (patch)
tree1c8d70e878c707e7f39000eb19826aab7475084d /share/newton_base/openoapi
parentb5ad6b5f107388a79d145fa42267d0884d575f45 (diff)
Logging enhancement for openo subnet API
Change-Id: I17a0046ae3c279e52b325cb84a94a7efb8291821 Issue-ID: MULTICLOUD-178 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'share/newton_base/openoapi')
-rw-r--r--share/newton_base/openoapi/subnet.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/share/newton_base/openoapi/subnet.py b/share/newton_base/openoapi/subnet.py
index a9b423ac..02f24b4f 100644
--- a/share/newton_base/openoapi/subnet.py
+++ b/share/newton_base/openoapi/subnet.py
@@ -41,13 +41,18 @@ class Subnets(APIView):
]
def get(self, request, vimid="", tenantid="", subnetid=""):
- logger.debug("Subnets--get::> %s" % request.data)
+ logger.info("vimid, tenantid, subnetid = %s,%s,%s" % (vimid, tenantid, subnetid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
# prepare request resource to vim instance
query = VimDriverUtils.get_query_part(request)
content, status_code = self.get_subnets(query, vimid, tenantid, subnetid)
+ logger.info("request returns with status %s" % status_code)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -58,7 +63,6 @@ class Subnets(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_subnets(self, query="", vimid="", tenantid="", subnetid=""):
- logger.debug("Subnets--get_subnets::> %s" % subnetid)
# prepare request resource to vim instance
req_resouce = "v2.0/subnets"
@@ -70,7 +74,12 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
+ if resp.status_code == status.HTTP_200_OK:
+ logger.debug("with content:%s" % resp.json())
+ pass
content = resp.json()
vim_dict = {
"vimName": vim["name"],
@@ -94,7 +103,10 @@ class Subnets(APIView):
return content, resp.status_code
def post(self, request, vimid="", tenantid="", subnetid=""):
- logger.debug("Subnets--post::> %s" % request.data)
+ logger.info("vimid, tenantid, subnetid = %s,%s,%s" % (vimid, tenantid, subnetid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#check if created already: check name
query = "name=%s" % request.data["name"]
@@ -121,8 +133,11 @@ class Subnets(APIView):
VimDriverUtils.replace_key_by_mapping(subnet,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"subnet": subnet})
+ logger.info("making request with URI:%s" % req_resouce)
+ logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
resp_body = resp.json()["subnet"]
VimDriverUtils.replace_key_by_mapping(resp_body, self.keys_mapping)
vim_dict = {
@@ -134,6 +149,7 @@ class Subnets(APIView):
resp_body.update(vim_dict)
return Response(data=resp_body, status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
@@ -144,7 +160,10 @@ class Subnets(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request, vimid="", tenantid="", subnetid=""):
- logger.debug("Subnets--delete::> %s" % request.data)
+ logger.info("vimid, tenantid, subnetid = %s,%s,%s" % (vimid, tenantid, subnetid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
# prepare request resource to vim instance
req_resouce = "v2.0/subnets"
@@ -156,9 +175,12 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
+ logger.info("request returns with status %s" % resp.status_code)
return Response(status=resp.status_code)
except VimDriverNewtonException as e:
+ logger.error("response with status = %s" % e.status_code)
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))