From 80ff14860e3b8a7a2c29272c2c10c1e830c2141d Mon Sep 17 00:00:00 2001 From: efiacor Date: Tue, 9 Jun 2020 19:20:22 +0100 Subject: [PMSH] Improve CBS data handling # AppConfog object fetch priodically # AAI client to only fetch AAI data Signed-off-by: efiacor Change-Id: I78315f141c3bb7e8b0d9efa818d294415fa79918 Issue-ID: DCAEGEN2-2146 --- .../pmsh_service/mod/policy_response_handler.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py') diff --git a/components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py b/components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py index 5ce03691..2b917cec 100644 --- a/components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py +++ b/components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py @@ -37,9 +37,9 @@ policy_response_handle_functions = { class PolicyResponseHandler: - def __init__(self, mr_sub, subscription_name, app): + def __init__(self, mr_sub, app_conf, app): self.mr_sub = mr_sub - self.subscription_name = subscription_name + self.app_conf = app_conf self.app = app @retry(wait=wait_fixed(5), retry=retry_if_exception_type(Exception)) @@ -48,18 +48,19 @@ class PolicyResponseHandler: This method polls MR for response from policy. It checks whether the message is for the relevant subscription and then handles the response """ - logger.info('Polling MR started for XNF activation/deactivation policy response events.') self.app.app_context().push() - administrative_state = Subscription.get(self.subscription_name).status + administrative_state = self.app_conf.subscription.administrativeState + logger.info('Polling MR started for XNF activation/deactivation policy response events.') try: response_data = self.mr_sub.get_from_topic('policy_response_consumer') for data in response_data: data = json.loads(data) - if data['status']['subscriptionName'] == self.subscription_name: + if data['status']['subscriptionName'] \ + == self.app_conf.subscription.subscriptionName: nf_name = data['status']['nfName'] response_message = data['status']['message'] - self._handle_response(self.subscription_name, administrative_state, - nf_name, response_message) + self._handle_response(self.app_conf.subscription.subscriptionName, + administrative_state, nf_name, response_message) except Exception as err: raise Exception(f'Error trying to poll policy response topic on MR: {err}') -- cgit 1.2.3-korg