summaryrefslogtreecommitdiffstats
path: root/share/common
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-04-27 18:16:12 +0800
committerYun Huang <yun.huang@windriver.com>2018-04-27 18:16:12 +0800
commite1d221000f6aaa52312c4138eac239a93593ba32 (patch)
tree8dc19a420c7fbd5a8c07edf4ece20b287c53bbb0 /share/common
parent8c129a5264fc69fafc8f307a65f98153cfe2d4b3 (diff)
Add logging for rest calls to ONAP services
Change-Id: I9372f303790241a2ba580e212d5dea5a7d1844e0 Issue-ID: MULTICLOUD-178 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'share/common')
-rw-r--r--share/common/utils/restcall.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/share/common/utils/restcall.py b/share/common/utils/restcall.py
index f19ea838..05788bc9 100644
--- a/share/common/utils/restcall.py
+++ b/share/common/utils/restcall.py
@@ -63,6 +63,10 @@ def _call_req(base_url, user, passwd, auth_type,
headers['Authorization'] = 'Basic ' + \
base64.b64encode(tmpauthsource).decode('utf-8')
+ logger.info("Making rest call with uri,method, header = %s, %s, %s" % (full_url, method.upper(), headers))
+ if content:
+ logger.debug("with content = %s" % (content))
+
ca_certs = None
for retry_times in range(MAX_RETRY_TIME):
http = httplib2.Http(
@@ -89,7 +93,10 @@ def _call_req(base_url, user, passwd, auth_type,
ret = [1, "Unable to connect to %s" % full_url, resp_status]
continue
raise ex
+ logger.info("Rest call finished with status = %s", resp_status)
+ logger.debug("with response content = %s" % resp_body)
except urllib.error.URLError as err:
+ logger.error("status=%s, error message=%s" % (resp_status, str(err)))
ret = [2, str(err), resp_status]
except Exception:
logger.error(traceback.format_exc())
@@ -99,7 +106,10 @@ def _call_req(base_url, user, passwd, auth_type,
ret = [3, str(sys.exc_info()), resp_status]
except:
logger.error(traceback.format_exc())
+ if not resp_status:
+ resp_status = status.HTTP_500_INTERNAL_SERVER_ERROR
ret = [4, str(sys.exc_info()), resp_status]
+
return ret
@@ -123,8 +133,6 @@ def req_to_aai(resource, method, content='', appid=settings.MULTICLOUD_APP_ID):
'accept': 'application/json'
}
- logger.debug("req_to_aai--%s::> %s, %s" %
- (tmp_trasaction_id, method, _combine_url(settings.AAI_BASE_URL,resource)))
return _call_req(settings.AAI_BASE_URL, settings.AAI_USERNAME, settings.AAI_PASSWORD, rest_no_auth,
resource, method, content=json.dumps(content), extra_headers=headers)