summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/aai_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/aai_client.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/aai_client.py21
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