From 0464347539f931847ab578ff935994aef0102352 Mon Sep 17 00:00:00 2001 From: efiacor Date: Mon, 22 Jun 2020 18:51:43 +0100 Subject: [PMSH] Add enable_tls boolean flag to config Signed-off-by: efiacor Change-Id: I19f71b690f743980eaa149c9b2c76fecb98a0120 Issue-ID: DCAEGEN2-2146 --- .../pmsh_service/mod/aai_event_handler.py | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py') diff --git a/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py b/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py index b3957bc5..f1e8cf27 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py +++ b/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py @@ -19,8 +19,6 @@ import json from enum import Enum -from requests import HTTPError - from mod import logger from mod.network_function import NetworkFunction @@ -46,26 +44,26 @@ def process_aai_events(mr_sub, mr_pub, app, app_conf): app_conf (AppConfig): the application configuration. """ app.app_context().push() + logger.info('Polling MR for XNF AAI events.') try: - aai_events = mr_sub.get_from_topic('AAI-EVENT') - if len(aai_events) != 0: - for entry in aai_events: + aai_events = mr_sub.get_from_topic('dcae_pmsh_aai_event') + if aai_events is not None and len(aai_events) != 0: + aai_events = [json.loads(e) for e in aai_events] + xnf_events = [e for e in aai_events if e['event-header']['entity-type'] == ( + XNFType.PNF.value or XNFType.VNF.value)] + for entry in xnf_events: logger.debug(f'AAI-EVENT entry: {entry}') - entry = json.loads(entry) - event_header = entry['event-header'] - aai_xnf = entry['entity'] - action = event_header['action'] - entity_type = event_header['entity-type'] - xnf_name = aai_xnf['pnf-name'] if entity_type == XNFType.PNF.value else aai_xnf[ - 'vnf-name'] - new_status = aai_xnf['orchestration-status'] + aai_entity = entry['entity'] + action = entry['event-header']['action'] + entity_type = entry['event-header']['entity-type'] + xnf_name = aai_entity['pnf-name'] if entity_type == XNFType.PNF.value \ + else aai_entity['vnf-name'] + new_status = aai_entity['orchestration-status'] if app_conf.nf_filter.is_nf_in_filter(xnf_name, new_status): _process_event(action, new_status, xnf_name, mr_pub, app_conf) - except HTTPError as e: - logger.debug(f'Failed to fetch AAI-EVENT messages from MR {e}') except Exception as e: - logger.debug(f'Exception trying to process AAI events {e}') + logger.error(f'Failed to process AAI event: {e}', exc_info=True) def _process_event(action, new_status, xnf_name, mr_pub, app_conf): -- cgit 1.2.3-korg