diff options
author | 2020-05-12 12:56:56 +0100 | |
---|---|---|
committer | 2020-06-05 10:11:06 +0100 | |
commit | 2760519436f78975f16f26c412e842e34b28d624 (patch) | |
tree | 3fb616398002bd4525c10ff8b510bbf5ebadc26f /components/pm-subscription-handler/pmsh_service/mod/aai_client.py | |
parent | 5ed9b7d3cad56c6438bca305b6d2931bd320352b (diff) |
[PMSH] Replace own logging implementation with pylog
Signed-off-by: ERIMROB <robertas.rimkus@est.tech>
Issue-ID: DCAEGEN2-2155
Change-Id: I670c4fff8029a73075b651c2afe6237c08cf907c
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/aai_client.py')
-rwxr-xr-x | components/pm-subscription-handler/pmsh_service/mod/aai_client.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py index 5e71da4d..371fdb06 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py +++ b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py @@ -16,13 +16,13 @@ # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END===================================================== import json -import uuid from os import environ import requests from requests.auth import HTTPBasicAuth -import mod.pmsh_logging as logger +from mod import logger +from mod.pmsh_utils import mdc_handler from mod.network_function import NetworkFunction, NetworkFunctionFilter from mod.subscription import Subscription @@ -50,7 +50,8 @@ def get_pmsh_subscription_data(cbs_data): return sub, nfs -def _get_all_aai_nf_data(): +@mdc_handler +def _get_all_aai_nf_data(**kwargs): """ Return queried nf data from the AAI service. @@ -61,10 +62,14 @@ def _get_all_aai_nf_data(): try: session = requests.Session() aai_endpoint = f'{_get_aai_service_url()}{"/aai/v16/query"}' + logger.info('Fetching XNFs from AAI.') headers = {'accept': 'application/json', 'content-type': 'application/json', 'x-fromappid': 'dcae-pmsh', - 'x-transactionid': str(uuid.uuid1())} + 'x-transactionid': kwargs['request_id'], + 'InvocationID': kwargs['invocation_id'], + 'RequestID': kwargs['request_id'] + } json_data = """ {'start': ['network/pnfs', @@ -77,8 +82,10 @@ def _get_all_aai_nf_data(): response.raise_for_status() if response.ok: nf_data = json.loads(response.text) + logger.info('Successfully fetched XNFs from AAI') + logger.debug(f'XNFs from AAI: {nf_data}') except Exception as e: - logger.debug(e) + logger.error(f'Failed to get XNFs from AAI: {e}') return nf_data @@ -97,7 +104,7 @@ def _get_aai_service_url(): aai_ssl_port = environ['AAI_SERVICE_PORT'] return f'https://{aai_service}:{aai_ssl_port}' except KeyError as e: - logger.debug(f'Failed to get AAI env vars: {e}') + logger.error(f'Failed to get AAI env vars: {e}') raise @@ -126,6 +133,6 @@ def _filter_nf_data(nf_data, nf_filter): nf_name=nf['properties'].get(name_identifier), orchestration_status=orchestration_status)) except KeyError as e: - logger.debug(f'Failed to parse AAI data: {e}') + logger.error(f'Failed to parse AAI data: {e}') raise return nf_set |