diff options
author | 2020-02-27 10:05:37 +0000 | |
---|---|---|
committer | 2020-03-23 14:17:18 +0000 | |
commit | b074a929a43629a5d4ced09f1ebe4106241d776f (patch) | |
tree | ed2477888b4b5091736be7209b332ee2c43ab58b /components/pm-subscription-handler/pmsh_service/mod/network_function.py | |
parent | 06ab83c7455d6474548d63a146754748f830922c (diff) |
[PMSH] Refactor subscription processor and policy response handler
Signed-off-by: ERIMROB <robertas.rimkus@est.tech>
Change-Id: I91964848df8f7455169650b138b46d8dfc326b6f
Issue-ID: DCAEGEN2-1820
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/network_function.py')
-rwxr-xr-x | components/pm-subscription-handler/pmsh_service/mod/network_function.py | 20 |
1 files changed, 20 insertions, 0 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 2150dc28..1cdf57a0 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py +++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py @@ -15,6 +15,8 @@ # # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END===================================================== + +import re from mod import pmsh_logging as logger, db from mod.db_models import NetworkFunctionModel @@ -85,3 +87,21 @@ class NetworkFunction: if nf: db.session.delete(nf) db.session.commit() + + +class NetworkFunctionFilter: + def __init__(self, **kwargs): + self.nf_sw_version = kwargs.get('swVersions') + 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): + """Match the nf name against regex values in Subscription.nfFilter.nfNames + + Args: + nf_name: the AAI nf name. + + Returns: + bool: True if matched, else False. + """ + return self.regex_matcher.search(nf_name) |