diff options
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) |