summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Haynes <greg@greghaynes.net>2015-09-16 17:22:39 -0700
committerGregory Haynes <greg@greghaynes.net>2015-09-16 17:51:29 -0700
commit0339a9a7f8c004b7e6df5c3d9dc49a69fcc3b357 (patch)
tree74ae9e9c3bc3dddc4d0adc2cc999d278ae19f724
parent4287c75c5795665e2a7dfdbab826adbc1a106df4 (diff)
downloados-client-config-0339a9a7f8c004b7e6df5c3d9dc49a69fcc3b357.tar.gz
Convert auth kwargs '-' to '_'
When passing in kwargs to _get_one_cloud we do not dive into the auth dict to convert '-' to '_'. Change-Id: I8ce12370b5fd4444ba17d724e7f8036a7b0d2784
-rw-r--r--os_client_config/config.py5
-rw-r--r--os_client_config/tests/test_config.py15
2 files changed, 20 insertions, 0 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index e8e76a5..100cf73 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -382,6 +382,11 @@ class OpenStackConfig(object):
os_args = dict()
new_args = dict()
for (key, val) in iter(args.items()):
+ if type(args[key]) == dict:
+ # dive into the auth dict
+ new_args[key] = self._fix_args(args[key])
+ continue
+
key = key.replace('-', '_')
if key.startswith('os'):
os_args[key[3:]] = val
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index 36fe15d..9c9451d 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -106,6 +106,21 @@ class TestConfig(base.TestCase):
cc = c.get_one_cloud('_test_cloud_hyphenated')
self.assertEqual('12345', cc.auth['project_id'])
+ def test_get_one_cloud_with_hyphenated_kwargs(self):
+ c = config.OpenStackConfig(config_files=[self.cloud_yaml],
+ vendor_files=[self.vendor_yaml])
+ args = {
+ 'auth': {
+ 'username': 'testuser',
+ 'password': 'testpass',
+ 'project-id': '12345',
+ 'auth-url': 'http://example.com/v2',
+ },
+ 'region_name': 'test-region',
+ }
+ cc = c.get_one_cloud(**args)
+ self.assertEqual('http://example.com/v2', cc.auth['auth_url'])
+
def test_no_environ(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])