From 2e3c407d0fcf8c73c5fd6714d6013e37930c92cb Mon Sep 17 00:00:00 2001 From: egernug Date: Wed, 19 Aug 2020 14:57:36 +0100 Subject: [PMSH] Enhance Filtering Mechanism Issue-ID: DCAEGEN2-2151 Signed-off-by: egernug Change-Id: Ib6c207ac08a54dea06346596ff11c980fa4cf5e8 --- .../pmsh_service/mod/network_function.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'components/pm-subscription-handler/pmsh_service/mod/network_function.py') 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 191e9512..62cd546f 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py +++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py @@ -90,21 +90,33 @@ class NetworkFunction: db.session.commit() + class NetworkFunctionFilter: def __init__(self, **kwargs): - self.nf_sw_version = kwargs.get('swVersions') self.nf_names = kwargs.get('nfNames') + self.model_invariant_ids = kwargs.get('modelInvariantUUIDs') + self.model_version_ids = kwargs.get('modelVersionIDs') self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names)) - def is_nf_in_filter(self, nf_name, orchestration_status): + def is_nf_in_filter(self, nf_name, model_invariant_id, model_version_id, orchestration_status): """Match the nf name against regex values in Subscription.nfFilter.nfNames Args: nf_name (str): the AAI nf name. + invariant_uuid (str): the AAI model-invariant-id + uuid (str): the AAI model-version-id orchestration_status (str): orchestration status of the nf Returns: bool: True if matched, else False. """ - return self.regex_matcher.search(nf_name) and \ - orchestration_status == 'Active' + match = True + if orchestration_status != 'Active': + match = False + if self.nf_names and self.regex_matcher.search(nf_name) is None: + match = False + if self.model_invariant_ids and not model_invariant_id in self.model_invariant_ids: + match = False + if self.model_version_ids and not model_version_id in self.model_version_ids: + match = False + return match -- cgit 1.2.3-korg