summaryrefslogtreecommitdiffstats
path: root/share/newton_base
diff options
context:
space:
mode:
Diffstat (limited to 'share/newton_base')
-rw-r--r--share/newton_base/openoapi/volume.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/share/newton_base/openoapi/volume.py b/share/newton_base/openoapi/volume.py
index 27bd1ef7..d9d95983 100644
--- a/share/newton_base/openoapi/volume.py
+++ b/share/newton_base/openoapi/volume.py
@@ -41,13 +41,18 @@ class Volumes(APIView):
]
def get(self, request, vimid="", tenantid="", volumeid=""):
- logger.debug("Volumes--get::> %s" % request.data)
+ logger.info("vimid, tenantid, volumeid = %s,%s,%s" % (vimid, tenantid, volumeid))
+ 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_volumes(query, vimid, tenantid, volumeid)
+ logger.info("response 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 Volumes(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_volumes(self, query="", vimid="", tenantid="", volumeid=None):
- logger.debug("Volumes--get_volumes::> %s,%s" % (tenantid, volumeid))
# prepare request resource to vim instance
req_resouce = "volumes"
@@ -71,7 +75,12 @@ class Volumes(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"],
@@ -95,7 +104,10 @@ class Volumes(APIView):
return content, resp.status_code
def post(self, request, vimid="", tenantid="", volumeid=""):
- logger.debug("Volumes--post::> %s" % request.data)
+ logger.info("vimid, tenantid, volumeid = %s,%s,%s" % (vimid, tenantid, volumeid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
#check if created already: check name
query = "name=%s" % request.data["name"]
@@ -122,9 +134,12 @@ class Volumes(APIView):
VimDriverUtils.replace_key_by_mapping(volume,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"volume": volume})
+ 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, headers={"Content-Type": "application/json",
"Accept": "application/json" })
+ logger.info("request returns with status %s" % resp.status_code)
resp_body = resp.json()["volume"]
VimDriverUtils.replace_key_by_mapping(resp_body, self.keys_mapping)
vim_dict = {
@@ -136,6 +151,7 @@ class Volumes(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()))
@@ -146,7 +162,10 @@ class Volumes(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request, vimid="", tenantid="", volumeid=""):
- logger.debug("Volumes--delete::> %s" % request.data)
+ logger.info("vimid, tenantid, volumeid = %s,%s,%s" % (vimid, tenantid, volumeid))
+ if request.data:
+ logger.debug("With data = %s" % request.data)
+ pass
try:
# prepare request resource to vim instance
req_resouce = "volumes"
@@ -155,9 +174,12 @@ class Volumes(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()))