diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-09-17 01:58:49 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-09-17 01:58:49 +0000 |
commit | 64d3393a620d87634e2a4bb0afb15eb815641421 (patch) | |
tree | a16f18583dea3353c427f038f7ccaaa3364013ae | |
parent | 2906d1e61fd6e2e1024996993e1c108966fc425f (diff) | |
parent | 0339a9a7f8c004b7e6df5c3d9dc49a69fcc3b357 (diff) | |
download | os-client-config-64d3393a620d87634e2a4bb0afb15eb815641421.tar.gz |
Merge "Convert auth kwargs '-' to '_'"1.7.1
-rw-r--r-- | os_client_config/config.py | 5 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 6531205..387d014 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]) |