summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/network_function.py
diff options
context:
space:
mode:
authoregernug <gerard.nugent@est.tech>2020-08-19 14:57:36 +0100
committeregernug <gerard.nugent@est.tech>2020-09-08 09:28:01 +0100
commit2e3c407d0fcf8c73c5fd6714d6013e37930c92cb (patch)
treec9cac72011779bcd6ffdb7658653a08958fa524c /components/pm-subscription-handler/pmsh_service/mod/network_function.py
parente783ede93e1c0f2f76a332fc82f6e6a7f40f04fc (diff)
[PMSH] Enhance Filtering Mechanism
Issue-ID: DCAEGEN2-2151 Signed-off-by: egernug <gerard.nugent@est.tech> Change-Id: Ib6c207ac08a54dea06346596ff11c980fa4cf5e8
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/network_function.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/network_function.py20
1 files changed, 16 insertions, 4 deletions
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