diff options
Diffstat (limited to 'python_moonclient/python_moonclient/core/config.py')
-rw-r--r-- | python_moonclient/python_moonclient/core/config.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/python_moonclient/python_moonclient/core/config.py b/python_moonclient/python_moonclient/core/config.py index f8e3fe29..c123499b 100644 --- a/python_moonclient/python_moonclient/core/config.py +++ b/python_moonclient/python_moonclient/core/config.py @@ -14,11 +14,10 @@ def get_configuration(consul_host, consul_port, key): if len(data) == 1: data = data[0] return {data["Key"]: json.loads(base64.b64decode(data["Value"]).decode("utf-8"))} - else: - return [ - {item["Key"]: json.loads(base64.b64decode(item["Value"]).decode("utf-8"))} - for item in data - ] + return [ + {item["Key"]: json.loads(base64.b64decode(item["Value"]).decode("utf-8"))} + for item in data + ] def get_config_data(consul_host, consul_port): @@ -31,9 +30,9 @@ def get_config_data(consul_host, consul_port): 'components/manager')['components/manager']['external']['port'] try: requests.get("http://{}:{}/".format( - conf_data['manager_host'], - conf_data['manager_port'] - ), + conf_data['manager_host'], + conf_data['manager_port'] + ), timeout=2) except requests.exceptions.ConnectionError: conf_data['manager_host'] = get_configuration(consul_host, consul_port, @@ -54,9 +53,12 @@ def get_config_data(consul_host, consul_port): 'openstack/keystone')['openstack/keystone']['url'] conf_data['keystone_user'] = get_configuration(consul_host, consul_port, - 'openstack/keystone')['openstack/keystone']['user'] + 'openstack/keystone')['openstack/keystone'][ + 'user'] conf_data['keystone_password'] = get_configuration(consul_host, consul_port, - 'openstack/keystone')['openstack/keystone']['password'] + 'openstack/keystone')['openstack/keystone'][ + 'password'] conf_data['keystone_project'] = get_configuration(consul_host, consul_port, - 'openstack/keystone')['openstack/keystone']['project'] + 'openstack/keystone')['openstack/keystone'][ + 'project'] return conf_data |