diff options
author | emartin <ephraim.martin@est.tech> | 2020-03-27 16:31:48 +0000 |
---|---|---|
committer | emartin <ephraim.martin@est.tech> | 2020-03-27 16:46:55 +0000 |
commit | 01dfa52c169aa902e2cd8f58b65daaaf3af5e8e8 (patch) | |
tree | c4bb0a8146026cee8d0f14695e047b314935ba84 /components/pm-subscription-handler/pmsh_service/mod | |
parent | 551cc5be912bb377931d3e38d41af11d53bf0e63 (diff) |
Fix bug where PMSH pushes config to non-active pnf
Issue-ID: DCAEGEN2-2173
Signed-off-by: emartin <ephraim.martin@est.tech>
Change-Id: Ib93a71e825f621721b5acda059cadcb7824f997d
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod')
3 files changed, 14 insertions, 10 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 489d035b..86cecb50 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py +++ b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py @@ -120,8 +120,8 @@ def _filter_nf_data(nf_data, nf_filter): for nf in nf_data['results']: name_identifier = 'pnf-name' if nf['node-type'] == 'pnf' else 'vnf-name' orchestration_status = nf['properties'].get('orchestration-status') - if nf_filter.is_nf_in_filter(nf['properties'].get(name_identifier)) \ - and orchestration_status == 'Active': + if nf_filter.is_nf_in_filter(nf['properties'].get(name_identifier), + orchestration_status): nf_set.add(NetworkFunction( nf_name=nf['properties'].get(name_identifier), orchestration_status=orchestration_status)) 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 ee75fbf5..e40060f0 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 @@ -33,11 +33,6 @@ class AAIEvent(Enum): UPDATE = 'UPDATE' -class OrchestrationStatus(Enum): - ACTIVE = 'Active' - INVENTORIED = 'Inventoried' - - def process_aai_events(mr_sub, subscription, mr_pub, app, app_conf): """ Processes AAI UPDATE events for each filtered xNFs where orchestration status is set to Active. @@ -64,7 +59,7 @@ def process_aai_events(mr_sub, subscription, mr_pub, app, app_conf): 'vnf-name'] new_status = aai_xnf['orchestration-status'] - if NetworkFunctionFilter(**subscription.nfFilter).is_nf_in_filter(xnf_name): + if NetworkFunctionFilter(**subscription.nfFilter).is_nf_in_filter(xnf_name, new_status): _process_event(action, new_status, xnf_name, subscription, mr_pub, app_conf) diff --git a/components/pm-subscription-handler/pmsh_service/mod/network_function.py b/components/pm-subscription-handler/pmsh_service/mod/network_function.py index 1cdf57a0..bf223184 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py +++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py @@ -17,6 +17,8 @@ # ============LICENSE_END===================================================== import re +from enum import Enum + from mod import pmsh_logging as logger, db from mod.db_models import NetworkFunctionModel @@ -95,13 +97,20 @@ class NetworkFunctionFilter: self.nf_names = kwargs.get('nfNames') self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names)) - def is_nf_in_filter(self, nf_name): + def is_nf_in_filter(self, nf_name, orchestration_status): """Match the nf name against regex values in Subscription.nfFilter.nfNames Args: nf_name: the AAI nf name. + orchestration_status: orchestration status of the nf Returns: bool: True if matched, else False. """ - return self.regex_matcher.search(nf_name) + return self.regex_matcher.search(nf_name) and \ + orchestration_status == OrchestrationStatus.ACTIVE.value + + +class OrchestrationStatus(Enum): + ACTIVE = 'Active' + INVENTORIED = 'Inventoried' |