From b074a929a43629a5d4ced09f1ebe4106241d776f Mon Sep 17 00:00:00 2001 From: ERIMROB Date: Thu, 27 Feb 2020 10:05:37 +0000 Subject: [PMSH] Refactor subscription processor and policy response handler Signed-off-by: ERIMROB Change-Id: I91964848df8f7455169650b138b46d8dfc326b6f Issue-ID: DCAEGEN2-1820 --- .../pmsh_service/mod/subscription.py | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'components/pm-subscription-handler/pmsh_service/mod/subscription.py') 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) -- cgit 1.2.3-korg