From 30dfb6af2e2cd2cbc1632031202f48c1ef6a876f Mon Sep 17 00:00:00 2001 From: RHE Date: Wed, 27 Dec 2017 09:58:36 +0100 Subject: moon_forming for policy templates Change-Id: I8f19a9c4d791d509a6c0349424252ea24c56ab6b Signed-off-by: RHE --- python_moonclient/Changelog | 10 +++++- python_moonclient/python_moonclient/__init__.py | 2 +- python_moonclient/python_moonclient/config.py | 44 +++++++++++++++++-------- 3 files changed, 40 insertions(+), 16 deletions(-) (limited to 'python_moonclient') diff --git a/python_moonclient/Changelog b/python_moonclient/Changelog index 854200cb..cd099ae3 100644 --- a/python_moonclient/Changelog +++ b/python_moonclient/Changelog @@ -9,4 +9,12 @@ CHANGES 0.1.0 ----- -- First version of the python-moonclient \ No newline at end of file +- First version of the python-moonclient + +1.0.0 +----- +- First public version of the python-moonclient + +1.0.1 +----- +- Fix a bug in configuration diff --git a/python_moonclient/python_moonclient/__init__.py b/python_moonclient/python_moonclient/__init__.py index d7cdd111..2249a1b6 100644 --- a/python_moonclient/python_moonclient/__init__.py +++ b/python_moonclient/python_moonclient/__init__.py @@ -3,4 +3,4 @@ # license which can be found in the file 'LICENSE' in this package distribution # or at 'http://www.apache.org/licenses/LICENSE-2.0'. -__version__ = "0.0.1" +__version__ = "1.0.1" diff --git a/python_moonclient/python_moonclient/config.py b/python_moonclient/python_moonclient/config.py index d6317820..300ebf1a 100644 --- a/python_moonclient/python_moonclient/config.py +++ b/python_moonclient/python_moonclient/config.py @@ -21,17 +21,36 @@ def get_configuration(consul_host, consul_port, key): def get_config_data(consul_host, consul_port): conf_data = dict() - conf_data['manager_host'] = get_configuration(consul_host, consul_port, - 'components/manager')['components/manager']['external']['hostname'] - conf_data['manager_port'] = get_configuration(consul_host, consul_port, - 'components/manager')['components/manager']['external']['port'] - # conf_data['authz_host'] = get_configuration(consul_host, consul_port, - # 'components/interface')['components/interface']['external']['hostname'] - # conf_data['authz_port'] = get_configuration(consul_host, consul_port, - # 'components/interface')['components/interface']['external']['port'] - conf_data['keystone_host'] = get_configuration(consul_host, consul_port, - 'openstack/keystone')['openstack/keystone']['external']['url'] - # conf_data['keystone_port'] = '5000' + conf_data['manager_host'] = get_configuration( + consul_host, consul_port, + 'components/manager')['components/manager']['external']['hostname'] + conf_data['manager_port'] = get_configuration( + consul_host, consul_port, + 'components/manager')['components/manager']['external']['port'] + try: + requests.get("http://{}:{}/".format( + conf_data['manager_host'], + conf_data['manager_port'] + ), + timeout=2) + except requests.exceptions.ConnectionError: + conf_data['manager_host'] = get_configuration(consul_host, consul_port, + 'components/manager')[ + 'components/manager']['hostname'] + conf_data['manager_port'] = get_configuration(consul_host, consul_port, + 'components/manager')[ + 'components/manager']['port'] + + conf_data['keystone_host'] = get_configuration( + consul_host, consul_port, + 'openstack/keystone')['openstack/keystone']['external']['url'] + try: + requests.get(conf_data['keystone_host'], timeout=2) + except requests.exceptions.ConnectionError: + conf_data['keystone_host'] = get_configuration( + consul_host, consul_port, + 'openstack/keystone')['openstack/keystone']['url'] + conf_data['keystone_user'] = get_configuration(consul_host, consul_port, 'openstack/keystone')['openstack/keystone']['user'] conf_data['keystone_password'] = get_configuration(consul_host, consul_port, @@ -39,6 +58,3 @@ def get_config_data(consul_host, consul_port): conf_data['keystone_project'] = get_configuration(consul_host, consul_port, 'openstack/keystone')['openstack/keystone']['project'] return conf_data - -# get_conf_data('88.88.88.2', '30005') -# get_conf_data('127.0.0.1', 8082) -- cgit 1.2.3-korg