summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py
diff options
context:
space:
mode:
authorJoseph O'Leary <joseph.o.leary@est.tech>2020-06-17 16:04:53 +0000
committerGerrit Code Review <gerrit@onap.org>2020-06-17 16:04:53 +0000
commit20637908b156aeff53d7607f88d655d0becc1f11 (patch)
tree32977480c45d99c5be4668c176ddb2069e438fe7 /components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py
parenta878f684dc8f906e0800dc1598e5214f8da2ba33 (diff)
parent80ff14860e3b8a7a2c29272c2c10c1e830c2141d (diff)
Merge "[PMSH] Improve CBS data handling"
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py')
-rw-r--r--components/pm-subscription-handler/pmsh_service/mod/policy_response_handler.py15
1 files changed, 8 insertions, 7 deletions
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}')