diff options
-rw-r--r-- | lcm/ns_pnfs/views/pnf_view.py | 6 | ||||
-rw-r--r-- | lcm/pub/utils/restcall.py | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lcm/ns_pnfs/views/pnf_view.py b/lcm/ns_pnfs/views/pnf_view.py index 0e1ae6fe..c6f2694d 100644 --- a/lcm/ns_pnfs/views/pnf_view.py +++ b/lcm/ns_pnfs/views/pnf_view.py @@ -54,7 +54,7 @@ class PnfView(APIView): return Response(data=resp_serializer.data, status=status.HTTP_201_CREATED) @swagger_auto_schema( - request_body="None", + request_body=None, responses={ status.HTTP_200_OK: PnfInstancesSerializer(help_text="Pnf instances", many=True), status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error" @@ -77,7 +77,7 @@ class PnfView(APIView): class IndividualPnfView(APIView): @swagger_auto_schema( - request_body="None", + request_body=None, responses={ status.HTTP_204_NO_CONTENT: 'successful', status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error" @@ -94,7 +94,7 @@ class IndividualPnfView(APIView): return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) @swagger_auto_schema( - request_body="None", + request_body=None, responses={ status.HTTP_200_OK: PnfInstanceSerializer(help_text="Pnf instance", many=True), status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error", diff --git a/lcm/pub/utils/restcall.py b/lcm/pub/utils/restcall.py index 848b9bad..171e7265 100644 --- a/lcm/pub/utils/restcall.py +++ b/lcm/pub/utils/restcall.py @@ -18,6 +18,7 @@ import logging import urllib2 import uuid import httplib2 +import requests from lcm.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT @@ -87,12 +88,11 @@ def req_by_msb(resource, method, content=''): return call_req(base_url, "", "", rest_no_auth, resource, method, content) -def upload_by_msb(resource, method, file_data={}): - headers = {'Content-Type': 'application/octet-stream'} +def upload_by_msb(resource, method, file_data): + headers = {'accept': 'application/json'} full_url = "http://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, resource) - http = httplib2.Http() - resp, resp_content = http.request(full_url, method=method.upper(), body=file_data, headers=headers) - resp_status, resp_body = resp['status'], resp_content.decode('UTF-8') + r = requests.post(full_url, files=file_data, headers=headers) + resp_status, resp_body = str(r.status_code), r.text if resp_status not in status_ok_list: logger.error("Status code is %s, detail is %s.", resp_status, resp_body) return [1, "Failed to upload file.", resp_status] |