diff --git a/releasenotes/notes/role-config-none-d440bd0dcbb63534.yaml b/releasenotes/notes/role-config-none-d440bd0dcbb63534.yaml new file mode 100644 index 000000000..b1ef49eb0 --- /dev/null +++ b/releasenotes/notes/role-config-none-d440bd0dcbb63534.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - RoleConfig can exist as a stack output, but have a value of None. That case + is now handled with a default value of {} where the value was previously + None. diff --git a/tripleo_common/tests/utils/test_config.py b/tripleo_common/tests/utils/test_config.py index ef9d9e4ed..c072a7ca1 100644 --- a/tripleo_common/tests/utils/test_config.py +++ b/tripleo_common/tests/utils/test_config.py @@ -170,6 +170,13 @@ class TestConfig(base.TestCase): expected = {'2af0a373': 'c1', '8269f736': 'c0', 'c8479674': 'c2'} self.assertEqual(expected, server_names) + def test_get_role_config(self): + heat = mock.MagicMock() + self.config = ooo_config.Config(heat) + self.config.stack_outputs = {'RoleConfig': None} + role_config = self.config.get_role_config() + self.assertEqual({}, role_config) + def test_get_deployment_data(self): heat = mock.MagicMock() self.config = ooo_config.Config(heat) diff --git a/tripleo_common/utils/config.py b/tripleo_common/utils/config.py index 6be2b7da9..2cecf5a9d 100644 --- a/tripleo_common/utils/config.py +++ b/tripleo_common/utils/config.py @@ -95,6 +95,11 @@ class Config(object): env.trim_blocks = True return env, templates_path + def get_role_config(self): + role_config = self.stack_outputs.get('RoleConfig', {}) + # RoleConfig can exist as a stack output but have a value of None + return role_config or {} + @staticmethod def _open_file(path): return os.fdopen(os.open(path, @@ -180,7 +185,7 @@ class Config(object): yaml.safe_dump(data, conf_file, default_flow_style=False) - role_config = self.stack_outputs.get('RoleConfig', {}) + role_config = self.get_role_config() for config_name, config in six.iteritems(role_config): conf_path = os.path.join(tmp_path, config_name + ".yaml") with self._open_file(conf_path) as conf_file: