summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/config_handler.py
diff options
context:
space:
mode:
authorERIMROB <robertas.rimkus@est.tech>2020-02-12 11:35:20 +0000
committerERIMROB <robertas.rimkus@est.tech>2020-02-20 16:03:48 +0000
commit26b76c02052269ea850d8d4efd6deb536115a0af (patch)
treef7485d7ccd0e7d95c000b9c05bce2c371c34581a /components/pm-subscription-handler/pmsh_service/mod/config_handler.py
parentd42ac06c733c43e19a01b4203c1b987b4973ccfd (diff)
Add Support for Activation and Deactivation
* Add support for reconfiguration of the administrativeState field * Add support for policy feedback handling * Fix network function filter applying to non active network functions Signed-off-by: ERIMROB <robertas.rimkus@est.tech> Change-Id: Ic1cfc3207b2495c1d8d10acd0ed1c40114cf4643 Issue-ID: DCAEGEN2-1830
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/config_handler.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/config_handler.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/config_handler.py b/components/pm-subscription-handler/pmsh_service/mod/config_handler.py
index 1ce4b701..acf5b76f 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/config_handler.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/config_handler.py
@@ -15,12 +15,10 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
-
-import json
from os import environ
import requests
-from tenacity import retry, wait_fixed, stop_after_attempt
+from tenacity import retry, wait_fixed, stop_after_attempt, retry_if_exception_type
import mod.pmsh_logging as logger
@@ -45,7 +43,7 @@ class ConfigHandler:
def hostname(self):
return _get_environment_variable('HOSTNAME')
- @retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
+ @retry(wait=wait_fixed(2), stop=stop_after_attempt(5), retry=retry_if_exception_type(Exception))
def get_config(self):
""" Retrieves PMSH's configuration from Configbinding service. If a non-2xx response
is received, it retries after 2 seconds for 5 times before raising an exception.
@@ -56,18 +54,15 @@ class ConfigHandler:
Raises:
Exception: If any error occurred pulling configuration from Configbinding service.
"""
- if self._config is None:
- logger.debug('No configuration found, pulling from Configbinding Service.')
- try:
- response = requests.get(self.cbs_url)
- response.raise_for_status()
- self._config = response.json()
- logger.debug(f'PMSH Configuration from Configbinding Service: {self._config}')
- return json.loads(self._config)
- except Exception as err:
- raise Exception(f'Error retrieving configuration from CBS: {err}')
- else:
+
+ try:
+ response = requests.get(self.cbs_url)
+ response.raise_for_status()
+ self._config = response.json()
+ logger.debug(f'PMSH Configuration from Configbinding Service: {self._config}')
return self._config
+ except Exception as err:
+ raise Exception(f'Error retrieving configuration from CBS: {err}')
def _get_environment_variable(env_var_key):