diff options
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py')
-rwxr-xr-x | components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py | 36 |
1 files changed, 21 insertions, 15 deletions
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 96f51431..b3957bc5 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,6 +19,8 @@ import json from enum import Enum +from requests import HTTPError + from mod import logger from mod.network_function import NetworkFunction @@ -44,22 +46,26 @@ def process_aai_events(mr_sub, mr_pub, app, app_conf): app_conf (AppConfig): the application configuration. """ app.app_context().push() - aai_events = mr_sub.get_from_topic('AAI-EVENT') - - if aai_events is not None and len(aai_events) != 0: - for entry in aai_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'] + try: + aai_events = mr_sub.get_from_topic('AAI-EVENT') + if len(aai_events) != 0: + for entry in aai_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'] - if app_conf.nf_filter.is_nf_in_filter(xnf_name, new_status): - _process_event(action, new_status, xnf_name, mr_pub, app_conf) + 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}') def _process_event(action, new_status, xnf_name, mr_pub, app_conf): |