summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py
diff options
context:
space:
mode:
authorshivasubedi <shiva.subedi@est.tech>2021-01-18 13:59:18 +0000
committershivasubedi <shiva.subedi@est.tech>2021-02-09 10:57:23 +0000
commit9aa0b665b1d8ad6105ea783e176eacc58b26a804 (patch)
tree2cbb03f5a23a465062f4d3a1940018de3a2f7585 /components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py
parentf7be006e7cc638788164fb1028d03898138b8c16 (diff)
[PMSH] Validate schema of PMSH monitoring policy
Change-Id: I42b002f855a03b39ab85cfcb20d7857d30447e40 Signed-off-by: shivasubedi <shiva.subedi@est.tech> Issue-ID: DCAEGEN2-2152
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py')
-rw-r--r--components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py b/components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py
index f50f5ab2..6238a298 100644
--- a/components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/subscription_handler.py
@@ -15,9 +15,11 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
+from jsonschema import ValidationError
from mod import logger, aai_client
from mod.aai_event_handler import process_aai_events
+from mod.network_function import NetworkFunctionFilter
from mod.pmsh_utils import PeriodicTask
from mod.subscription import AdministrativeState
@@ -42,12 +44,16 @@ class SubscriptionHandler:
self._check_for_failed_nfs()
else:
self.app_conf.refresh_config()
+ self.app_conf.validate_sub_schema()
new_administrative_state = self.app_conf.subscription.administrativeState
if local_admin_state == new_administrative_state:
logger.info(f'Administrative State did not change in the app config: '
f'{new_administrative_state}')
else:
self._check_state_change(local_admin_state, new_administrative_state)
+ except (ValidationError, TypeError) as err:
+ logger.error(f'Error occurred during validation of subscription schema {err}',
+ exc_info=True)
except Exception as err:
logger.error(f'Error occurred during the activation/deactivation process {err}',
exc_info=True)
@@ -65,6 +71,8 @@ class SubscriptionHandler:
raise Exception(f'Invalid AdministrativeState: {new_administrative_state}')
def _activate(self, new_administrative_state):
+ if not self.app_conf.nf_filter:
+ self.app_conf.nf_filter = NetworkFunctionFilter(**self.app_conf.subscription.nfFilter)
self._start_aai_event_thread()
self.app_conf.subscription.update_sub_params(new_administrative_state,
self.app_conf.subscription.fileBasedGP,