diff --git a/snap_openstack/base.py b/snap_openstack/base.py index 3cb8f61..9d788a0 100644 --- a/snap_openstack/base.py +++ b/snap_openstack/base.py @@ -165,7 +165,7 @@ class OpenStackSnap(object): snap environment, we'll clobber the keys in the environment. ''' snap_config = utils.snap_config( - keys=setup.get('snap-config-keys', [])) + keys=setup.get('snap-config-keys', {})) for key in snap_config.keys(): utils.snap_env[key] = snap_config[key] diff --git a/snap_openstack/tests/test_snap_openstack.py b/snap_openstack/tests/test_snap_openstack.py index d7b65b6..b47a7de 100644 --- a/snap_openstack/tests/test_snap_openstack.py +++ b/snap_openstack/tests/test_snap_openstack.py @@ -361,7 +361,17 @@ class TestSnapUtils(test_base.TestCase): @patch.object(utils, 'os') def test_snap_config(self, mock_os, mock_subprocess): '''snap_config fetch snapctl vals from the environment.''' - faux_config = {'foo': 'bar', 'baz': 'qux', 'quux': ''} + faux_config = { + 'foo': 'questions.foo', + 'baz': 'questions.baz', + 'quux': 'questions.quux', + + } + faux_snap_config = { + 'questions.foo': 'bar', + 'questions.baz': 'qux', + 'questions.quux': '', + } def faux_check_output(commands): '''Replacement for check output. @@ -369,11 +379,11 @@ class TestSnapUtils(test_base.TestCase): We expect this to be called with a list of commands, the last of which is the key that we're looking for. ''' - return faux_config[commands[-1]].encode('utf-8') + return faux_snap_config[commands[-1]].encode('utf-8') mock_subprocess.check_output = faux_check_output - keys = faux_config.keys() + keys = faux_config snap_utils = utils.SnapUtils() snap_config = snap_utils.snap_config(keys) diff --git a/snap_openstack/utils.py b/snap_openstack/utils.py index 4c5eb02..5e2e603 100644 --- a/snap_openstack/utils.py +++ b/snap_openstack/utils.py @@ -69,7 +69,7 @@ class SnapUtils(object): ''' snap_config = {} - for key in keys: + for our_key, snap_key in keys.items(): # Iterating through the keys is a little slow, as we make # a lot of snapctl calls. OTOH, I'm not sure that we want # to take responsibilty for parsing the return of "snap @@ -77,8 +77,8 @@ class SnapUtils(object): # option, or any other way of ensuring a consistently # formatted return. ret = subprocess.check_output( - ['snapctl', 'get', key]).decode('utf-8').strip() - snap_config[key] = ret or None + ['snapctl', 'get', snap_key]).decode('utf-8').strip() + snap_config[our_key] = ret or None return snap_config