Only top-level some deployment configs

Only config which contains os-apply-config data should be written
to the top level config structure. This change will only top-level
configs which are in the group os-apply-config or the default group
Heat::Ungrouped.

This tripleo-heat-templates change will specify a group for all
config resources https://review.openstack.org/#/c/91731/ however
the expected top-levels will still be written out without this
change.

This change is to fix heat software config when the config is not
json.

Change-Id: I16e42825121cf4968d4b0f0d266f4f6daa962921
Closes-Bug: #1299109
This commit is contained in:
Steve Baker 2014-05-08 12:32:25 +12:00
parent 08a3237484
commit b066d4cc85
3 changed files with 51 additions and 6 deletions

View File

@ -149,7 +149,9 @@ class Collector(object):
'No name found for a deployment under %s.' %
(depkey,))
continue
final_list.append((deployment['name'],
deployment['config']))
if deployment.get('group', 'Heat::Ungrouped') in (
'os-apply-config', 'Heat::Ungrouped'):
final_list.append((deployment['name'],
deployment['config']))
final_list.insert(0, ('cfn', final_content))
return final_list

View File

@ -56,6 +56,45 @@ SOFTWARE_CONFIG_DATA = {
u'config': {
u'config1': 'value1'
}
},
{
u'inputs': [
{
u'type': u'String',
u'name': u'input1',
u'value': u'value1'
}
],
u'group': 'os-apply-config',
u'name': 'dep-name2',
u'outputs': None,
u'options': None,
u'config': {
u'config2': 'value2'
}
},
{
u'inputs': [
{
u'type': u'String',
u'name': u'input1',
u'value': u'value1'
}
],
u'name': 'dep-name3',
u'outputs': None,
u'options': None,
u'config': {
u'config3': 'value3'
}
},
{
u'inputs': [],
u'group': 'ignore_me',
u'name': 'ignore_me_name',
u'outputs': None,
u'options': None,
u'config': 'ignore_me_config'
}
]
}
@ -240,14 +279,15 @@ class TestCfnSoftwareConfig(TestCfnBase):
set(cfn_config.keys()))
self.assertIn('deployments', cfn_config)
self.assertThat(cfn_config['deployments'], matchers.IsInstance(list))
self.assertEqual(1, len(cfn_config['deployments']))
self.assertEqual(4, len(cfn_config['deployments']))
deployment = cfn_config['deployments'][0]
self.assertIn('inputs', deployment)
self.assertThat(deployment['inputs'], matchers.IsInstance(list))
self.assertEqual(1, len(deployment['inputs']))
self.assertEqual('dep-name1', cfn_md[1][0])
config = cfn_md[1][1]
self.assertEqual('value1', config['config1'])
self.assertEqual('value1', cfn_md[1][1]['config1'])
self.assertEqual('dep-name2', cfn_md[2][0])
self.assertEqual('value2', cfn_md[2][1]['config2'])
def test_collect_cfn_deployments_not_list(self):
cfn_md = cfn.Collector(

View File

@ -368,7 +368,8 @@ class TestCollectAll(testtools.TestCase):
}
}
expected_changed = set((
'heat_local', 'ec2', 'cfn', 'heat', 'dep-name1'))
'heat_local', 'ec2', 'cfn', 'heat',
'dep-name1', 'dep-name2', 'dep-name3'))
self._test_collect_all_store(collector_kwargs_map=soft_config_map,
expected_changed=expected_changed)
@ -408,6 +409,8 @@ class TestCollectAll(testtools.TestCase):
store=True, collector_kwargs_map=soft_config_map)
expected_changed = set(cfg.CONF.collectors)
expected_changed.add('dep-name1')
expected_changed.add('dep-name2')
expected_changed.add('dep-name3')
self.assertEqual(expected_changed, changed_keys)
# Commit
for changed in changed_keys: