diff options
author | Monty Taylor <mordred@inaugust.com> | 2015-06-05 10:40:01 -0400 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2015-06-05 10:40:01 -0400 |
commit | 95beafeadd99383fc99dd8aff5bfc9ce8ece7030 (patch) | |
tree | 949cc4014c19b9f6eb5a96f5055848d906438270 | |
parent | a0df67704ace186b18fd1ecdc220a7e56409bc6f (diff) | |
download | os-client-config-95beafeadd99383fc99dd8aff5bfc9ce8ece7030.tar.gz |
Stringify project details
There are some clouds that have things like integer project names.
That's no fun when they are interperted at int, so stringify them.
Stringifying integer project ids is apparently less important, but does
not hurt.
Change-Id: Ife9ecaa28c552d589dbea9a065da0dfa483592eb
-rw-r--r-- | os_client_config/config.py | 4 | ||||
-rw-r--r-- | os_client_config/tests/base.py | 8 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 14 |
3 files changed, 22 insertions, 4 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index b323e70..432d1b4 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -251,10 +251,10 @@ class OpenStackConfig(object): target = None for key in possible_values: if key in cloud: - target = cloud[key] + target = str(cloud[key]) del cloud[key] if key in cloud['auth']: - target = cloud['auth'][key] + target = str(cloud['auth'][key]) del cloud['auth'][key] if target: cloud['auth'][target_key] = target diff --git a/os_client_config/tests/base.py b/os_client_config/tests/base.py index 6a412bf..967f119 100644 --- a/os_client_config/tests/base.py +++ b/os_client_config/tests/base.py @@ -56,6 +56,14 @@ USER_CONF = { }, 'region-name': 'test-region', }, + '_test-cloud-int-project_': { + 'auth': { + 'username': 'testuser', + 'password': 'testpass', + 'project_id': 12345, + }, + 'region_name': 'test-region', + }, }, 'cache': {'max_age': 1}, } diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 25e1cc1..562e408 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -73,6 +73,12 @@ class TestConfig(base.TestCase): cc = c.get_one_cloud('_test_cloud_no_vendor') self._assert_cloud_details(cc) + def test_get_one_cloud_with_int_project_id(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + cc = c.get_one_cloud('_test-cloud-int-project_') + self.assertEqual('12345', cc.auth['project_name']) + def test_no_environ(self): c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml]) @@ -95,8 +101,12 @@ class TestConfig(base.TestCase): def test_get_cloud_names(self): c = config.OpenStackConfig(config_files=[self.cloud_yaml]) - self.assertEqual(['_test-cloud_', '_test_cloud_no_vendor'], - sorted(c.get_cloud_names())) + self.assertEqual( + ['_test-cloud-int-project_', + '_test-cloud_', + '_test_cloud_no_vendor', + ], + sorted(c.get_cloud_names())) c = config.OpenStackConfig(config_files=[self.no_yaml], vendor_files=[self.no_yaml]) for k in os.environ.keys(): |