diff options
author | 2013-09-13 08:42:01 -0700 | |
---|---|---|
committer | 2013-09-13 09:08:53 -0700 | |
commit | a8d5dc5a23bf8a681ab5695b421f04a17547d65c (patch) | |
tree | b765d2cb97e24314bb3f1e715e112c550795681a /merge.py | |
parent | a5320b8f49d17e4ad6790ecafe5797382ba381a1 (diff) |
Add support for merging OS::Nova::Server
Change-Id: Id6a801ee36ae73d8c2133b455e9a850c1a7b6a4d
Diffstat (limited to 'merge.py')
-rw-r--r-- | merge.py | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -44,6 +44,11 @@ def resolve_params(item, param, value): item = new_item return item +MERGABLE_TYPES = {'OS::Nova::Server': + {'image': 'image'}, + 'AWS::EC2::Instance': + {'image': 'ImageId'}, + } errors = [] end_template={'HeatTemplateFormatVersion': '2012-12-12', @@ -77,10 +82,11 @@ for template_path in templates: new_resources = template.get('Resources', {}) for r, rbody in sorted(new_resources.items()): - if rbody['Type'] == 'AWS::EC2::Instance': + if rbody['Type'] in MERGABLE_TYPES: + image_key = MERGABLE_TYPES[rbody['Type']]['image'] # XXX Assuming ImageId is always a Ref - ikey_val = end_template['Parameters'][rbody['Properties']['ImageId']['Ref']] - del end_template['Parameters'][rbody['Properties']['ImageId']['Ref']] + ikey_val = end_template['Parameters'][rbody['Properties'][image_key]['Ref']] + del end_template['Parameters'][rbody['Properties'][image_key]['Ref']] role = rbody.get('Metadata', {}).get('OpenStack::Role', r) role = translate_role(role) if role != r: @@ -102,7 +108,7 @@ for template_path in templates: end_template['Resources'] = {} end_template['Resources'][role] = rbody ikey = '%sImage' % (role) - end_template['Resources'][role]['Properties']['ImageId'] = {'Ref': ikey} + end_template['Resources'][role]['Properties'][image_key] = {'Ref': ikey} end_template['Parameters'][ikey] = ikey_val elif rbody['Type'] == 'FileInclude': with open(rbody['Path']) as rfile: |