summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/subscription.py
diff options
context:
space:
mode:
authorERIMROB <robertas.rimkus@est.tech>2020-02-27 10:05:37 +0000
committerERIMROB <robertas.rimkus@est.tech>2020-03-23 14:17:18 +0000
commitb074a929a43629a5d4ced09f1ebe4106241d776f (patch)
treeed2477888b4b5091736be7209b332ee2c43ab58b /components/pm-subscription-handler/pmsh_service/mod/subscription.py
parent06ab83c7455d6474548d63a146754748f830922c (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/subscription.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/subscription.py35
1 files changed, 15 insertions, 20 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/subscription.py b/components/pm-subscription-handler/pmsh_service/mod/subscription.py
index 5449f420..99a787da 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/subscription.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/subscription.py
@@ -15,13 +15,14 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
-import re
+
from enum import Enum
+from tenacity import retry, retry_if_exception_type, wait_exponential, stop_after_attempt
+
import mod.pmsh_logging as logger
from mod import db
from mod.db_models import SubscriptionModel, NfSubRelationalModel
-from tenacity import retry, retry_if_exception_type, wait_exponential, stop_after_attempt
class SubNfState(Enum):
@@ -37,6 +38,18 @@ class AdministrativeState(Enum):
LOCKED = 'LOCKED'
+subscription_nf_states = {
+ AdministrativeState.LOCKED.value: {
+ 'success': SubNfState.CREATED,
+ 'failed': SubNfState.DELETE_FAILED
+ },
+ AdministrativeState.UNLOCKED.value: {
+ 'success': SubNfState.CREATED,
+ 'failed': SubNfState.CREATE_FAILED
+ }
+}
+
+
class Subscription:
def __init__(self, **kwargs):
self.subscriptionName = kwargs.get('subscriptionName')
@@ -205,21 +218,3 @@ class Subscription:
update({NfSubRelationalModel.nf_sub_status: status}, synchronize_session='evaluate')
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)