summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2016-01-04 12:56:28 -0600
committerMonty Taylor <mordred@inaugust.com>2016-01-13 12:33:50 -0500
commit7e5496763522475bb07a377359d69454f1942e1b (patch)
tree50caed86ff7fd087cb554a81cf67553208ab32ad
parenta9e139088e2754ca354cc2b2d8f3aa44b1c9b9ee (diff)
downloados-client-config-7e5496763522475bb07a377359d69454f1942e1b.tar.gz
Return empty dict instead of None for lack of file
We return None for the file content for non-existent files as a fallback. This is normally fine, but in the case of a person having _only_ a secure.conf file, this means that the dictionary merge fails. Change-Id: I61cc0a8c709ea3510428fc3dfce63dc254c07c83
-rw-r--r--os_client_config/config.py2
-rw-r--r--os_client_config/tests/test_config.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index d490006..d366307 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -315,7 +315,7 @@ class OpenStackConfig(object):
return path, json.load(f)
else:
return path, yaml.safe_load(f)
- return (None, None)
+ return (None, {})
def _normalize_keys(self, config):
new_config = {}
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index 4440ac8..dce436a 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -171,6 +171,13 @@ class TestConfig(base.TestCase):
self.assertEqual('user', cc.auth['username'])
self.assertEqual('testpass', cc.auth['password'])
+ def test_only_secure_yaml(self):
+ c = config.OpenStackConfig(config_files=['nonexistent'],
+ vendor_files=['nonexistent'],
+ secure_files=[self.secure_yaml])
+ cc = c.get_one_cloud(cloud='_test_cloud_no_vendor')
+ self.assertEqual('testpass', cc.auth['password'])
+
def test_get_cloud_names(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
secure_files=[self.no_yaml])