aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2013-07-10 10:58:05 -0700
committerClint Byrum <clint@fewbar.com>2013-07-10 14:11:40 -0700
commit4a43e6395db90c0e2a7bfd9a256fc312365da54c (patch)
tree7b24b8fc208a309db6db6ae4a863c008afc12f9e
parentaebad8ce24f08042fa4814dd11761a9d15fae0a9 (diff)
Add handling of parameter replacements.
We will need to replace the use of Parameters in the included template with actual values in many cases. Change-Id: I95fc9116dc2bba74c31d5570851c5c4eb476291a
-rw-r--r--merge.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/merge.py b/merge.py
index 64cb00ab..768ae420 100644
--- a/merge.py
+++ b/merge.py
@@ -29,6 +29,22 @@ def translate_role(role):
raise Exception('%s -> %r' % (role, r))
return r
+def resolve_params(item, param, value):
+ if item == {'Ref': param}:
+ return value
+ if isinstance(item, dict):
+ copy_item = dict(item)
+ for k, v in iter(copy_item.items()):
+ item[k] = resolve_params(v, param, value)
+ elif isinstance(item, list):
+ copy_item = list(item)
+ new_item = []
+ for v in copy_item:
+ new_item.append(resolve_params(v, param, value))
+ item = new_item
+ return item
+
+
errors = []
end_template={'HeatTemplateFormatVersion': '2012-12-12',
'Description': []}
@@ -93,6 +109,11 @@ for template_path in templates:
subkeys = rbody.get('SubKey','').split('.')
while len(subkeys) and subkeys[0]:
include_content = include_content[subkeys.pop(0)]
+ for replace_param, replace_value in iter(rbody.get('Parameters',
+ {}).items()):
+ include_content = resolve_params(include_content,
+ replace_param,
+ replace_value)
end_template['Resources'][r] = include_content
else:
if r in end_template.get('Resources', {}):