diff options
author | Alex Shatov <alexs@att.com> | 2018-06-21 09:19:07 -0400 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2018-06-21 09:19:07 -0400 |
commit | d444b320dea07248dc69c81d0ce9ea5fc353e701 (patch) | |
tree | cacd244c5e2424faca5e088dc3ca3baf9afd8511 /policyhandler/config.py | |
parent | c9ec231483d905f3a391c3985c2c2762344ed5c1 (diff) |
3.0.1 policy-handler - cleaning sonar smells
- no change of functionality or API
- removed the unused enum34>=1.1.6 from requirements.txt and setup.py
- refactored run_policy.sh to redirect the stdout+stderr only once
- refactoring to remove smells+vulnerability reported by sonar
-- renamed Config.config to Config.settings
-- removed the commented out code in customizer.py
-- renamed StepTimer.NEXT to StepTimer.STATE_NEXT to avoid the
naming confusion with the method StepTimer.next.
Also renamed the related StepTimer.STATE_* constants
-- refactored several functions by extracting methods to eliminate
4 out of 5 "brain-overload" smells reported by sonar
-- moved the literal string for the socket_host "0.0.0.0" to a
constant on the web-server to avoid the reported vulnerability
Change-Id: I4c7d47d41c6ecd7cb28f6704f5dad2053c1ca7d6
Signed-off-by: Alex Shatov <alexs@att.com>
Issue-ID: DCAEGEN2-515
Diffstat (limited to 'policyhandler/config.py')
-rw-r--r-- | policyhandler/config.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/policyhandler/config.py b/policyhandler/config.py index 39d528b..8e6edf9 100644 --- a/policyhandler/config.py +++ b/policyhandler/config.py @@ -42,7 +42,7 @@ class Config(object): FIELD_POLICY_ENGINE = "policy_engine" wservice_port = 25577 _logger = logging.getLogger("policy_handler.config") - config = None + settings = None @staticmethod def merge(new_config): @@ -50,19 +50,19 @@ class Config(object): if not new_config: return - if not Config.config: - Config.config = new_config + if not Config.settings: + Config.settings = new_config return new_config = copy.deepcopy(new_config) - Config.config.update(new_config) + Config.settings.update(new_config) @staticmethod def get_system_name(): """find the name of the policy-handler system to be used as the key in consul-kv for config of policy-handler """ - return (Config.config or {}).get(Config.FIELD_SYSTEM, Config.SERVICE_NAME_POLICY_HANDLER) + return (Config.settings or {}).get(Config.FIELD_SYSTEM, Config.SERVICE_NAME_POLICY_HANDLER) @staticmethod def discover(): @@ -76,9 +76,9 @@ class Config(object): Config._logger.debug("loaded config from discovery(%s): %s", \ discovery_key, json.dumps(new_config)) - Config._logger.debug("config before merge from discovery: %s", json.dumps(Config.config)) + Config._logger.debug("config before merge from discovery: %s", json.dumps(Config.settings)) Config.merge(new_config.get(Config.SERVICE_NAME_POLICY_HANDLER)) - Config._logger.info("merged config from discovery: %s", json.dumps(Config.config)) + Config._logger.info("merged config from discovery: %s", json.dumps(Config.settings)) @staticmethod def load_from_file(file_path=None): @@ -102,5 +102,5 @@ class Config(object): Config.wservice_port = loaded_config.get(Config.FIELD_WSERVICE_PORT, Config.wservice_port) Config.merge(loaded_config.get(Config.SERVICE_NAME_POLICY_HANDLER)) - Config._logger.info("config loaded from file: %s", json.dumps(Config.config)) + Config._logger.info("config loaded from file: %s", json.dumps(Config.settings)) return True |