diff options
author | 2020-06-19 13:09:44 +0100 | |
---|---|---|
committer | 2020-06-30 02:15:21 +0100 | |
commit | b80449b81a2deb3b6e2510a655de02f9375ef636 (patch) | |
tree | ee022a88ee287645c72f6716eb9c501b9cf06484 /components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py | |
parent | 20637908b156aeff53d7607f88d655d0becc1f11 (diff) |
[PMSH] Improve Failure Handling
Signed-off-by: ERIMROB <robertas.rimkus@est.tech>
Change-Id: I15d338321957a293e9f444a10cf3bb06f4212f3e
Issue-ID: DCAEGEN2-2157
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): |