X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Fpub%2Futils%2Frestcall.py;h=c7386dc64f81ce267222152b3643846e78abafab;hb=refs%2Fchanges%2F04%2F101004%2F3;hp=62dd301e432e5b0c75280e1e0d19ac40fddd77be;hpb=7c194de2d67a1c71b741345a74ed9a493936fdb0;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/pub/utils/restcall.py b/multivimbroker/multivimbroker/pub/utils/restcall.py index 62dd301..c7386dc 100644 --- a/multivimbroker/multivimbroker/pub/utils/restcall.py +++ b/multivimbroker/multivimbroker/pub/utils/restcall.py @@ -20,11 +20,13 @@ import urllib.error import uuid import httplib2 import base64 +import codecs from multivimbroker.pub.config.config import AAI_SCHEMA_VERSION from multivimbroker.pub.config.config import AAI_SERVICE_URL from multivimbroker.pub.config.config import AAI_USERNAME from multivimbroker.pub.config.config import AAI_PASSWORD +from multivimbroker.pub.config.config import MSB_SERVICE_PROTOCOL from multivimbroker.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2 @@ -98,7 +100,8 @@ def call_req(base_url, user, passwd, auth_type, resource, method, resp, resp_content = http.request( full_url, method=method.upper(), body=content, headers=headers) - resp_status, resp_body = resp['status'], resp_content + resp_status, resp_body = resp['status'], codecs.decode( + resp_content, 'UTF-8') if resp_content else None if resp_status in status_ok_list: ret = [0, resp_body, resp_status, resp] @@ -128,13 +131,15 @@ def call_req(base_url, user, passwd, auth_type, resource, method, def req_by_msb(resource, method, content='', headers=None): - base_url = "http://%s:%s/" % (MSB_SERVICE_IP, MSB_SERVICE_PORT) + base_url = "%s://%s:%s/" % ( + MSB_SERVICE_PROTOCOL, MSB_SERVICE_IP, MSB_SERVICE_PORT) return call_req(base_url, "", "", rest_no_auth, resource, method, content, headers) def req_by_msb_multipart(resource, method, content, headers=None): - base_url = "http://%s:%s/" % (MSB_SERVICE_IP, MSB_SERVICE_PORT) + base_url = "%s://%s:%s/" % ( + MSB_SERVICE_PROTOCOL, MSB_SERVICE_IP, MSB_SERVICE_PORT) return call_multipart_req(base_url, "", "", rest_no_auth, resource, method, content, headers)