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
This commit is contained in:
parent
a9e139088e
commit
7e54967635
@ -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 = {}
|
||||
|
@ -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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user