get_attr = 'Fn::GetAtt'
+class Hot(object):
+
+ base_template = {
+ 'heat_template_version': '2013-05-23',
+ 'description': []
+ }
+ get_resource = 'get_resource'
+ get_param = 'get_param'
+ description = 'description'
+ parameters = 'parameters'
+ outputs = 'outputs'
+ resources = 'resources'
+ type = 'type'
+ properties = 'properties'
+ metadata = 'metadata'
+ depends_on = 'depends_on'
+ get_attr = 'get_attr'
+
+
lang = Cfn()
in_copies is reset to None when a dict {'Merge::Map': someobject} is
encountered.
+
+ :param scaling: A dict of prefix -> (count, blacklists).
"""
in_copies = dict(in_copies or {})
# Shouldn't be needed but to avoid unexpected side effects/bugs we short
"""Scale out a value.
:param value: The value to scale (not a container).
- :param scaling: The scaling map to use.
+ :param scaling: The scaling map (prefix-> (copies, blacklist) to use.
:param in_copies: What containers we're currently copying.
:return: An iterator of the new values for the value as tuples:
(prefix, copy_num, value). E.g. Compute0, 1, Compute1Foo
- and that prefix is not in in_copies
"""
if isinstance(value, (str, unicode)):
- for prefix, copies in scaling.items():
+ for prefix, (copies, blacklist) in scaling.items():
if not value.startswith(prefix):
continue
suffix = value[len(prefix):]
return
else:
for n in range(copies):
- yield prefix, n, prefix[:-1] + str(n) + suffix
+ if n not in blacklist:
+ yield prefix, n, prefix[:-1] + str(n) + suffix
return
yield None, None, value
else:
scaling_args = scaling_args or []
result = {}
for item in scaling_args:
- key, value = item.split('=')
- value = int(value)
- result[key + '0'] = value
+ key, values = item.split('=')
+ values = values.split(',')
+ value = int(values[0])
+ blacklist = frozenset(int(v) for v in values[1:] if v)
+ result[key + '0'] = value, blacklist
return result
help='File to write output to. - for stdout',
default='-')
parser.add_argument('--scale', action="append",
- help="Names to scale out. Pass Prefix=1 to cause a key Prefix0Foo to "
+ help="Names to scale out. Pass Prefix=2 to cause a key Prefix0Foo to "
"be copied to Prefix1Foo in the output, and value Prefix0Bar to be"
"renamed to Prefix1Bar inside that copy, or copied to Prefix1Bar "
- "outside of any copy.")
+ "outside of any copy. Pass Prefix=3,1 to cause Prefix1* to be elided"
+ "when scaling Prefix out. Prefix=4,1,2 will likewise elide Prefix1 and"
+ "Prefix2.")
parser.add_argument(
'--change-image-params', action='store_true', default=False,
help="Change parameters in templates to match resource names. This was "
" the default at one time but it causes issues when parameter "
" names need to remain stable.")
+ parser.add_argument(
+ '--hot', action='store_true', default=False,
+ help="Assume source templates are in the HOT format, and generate a "
+ "HOT template artifact.")
args = parser.parse_args(argv)
+ if args.hot:
+ global lang
+ lang = Hot()
+
templates = args.templates
scaling = parse_scaling(args.scale)
merged_template = merge(templates, args.master_role, args.slave_roles,
# XXX Assuming ImageId is always a Ref
ikey_val = end_template[lang.parameters][rbody[lang.properties][image_key][lang.get_param]]
del end_template[lang.parameters][rbody[lang.properties][image_key][lang.get_param]]
+ if 'OpenStack::Role' in rbody.get(lang.metadata, {}):
+ sys.stderr.write("WARNING: OpenStack::Role is deprecated"
+ " and will be removed in a later release\n");
role = rbody.get(lang.metadata, {}).get('OpenStack::Role', r)
role = translate_role(role, master_role, slave_roles)
if role != r:
if m in end_template[lang.resources][role].get(lang.metadata, {}):
if m == 'OpenStack::ImageBuilder::Elements':
end_template[lang.resources][role][lang.metadata][m].extend(mbody)
+ sys.stderr.write(
+ "WARNING: OpenStack::ImageBuilder::Elements"
+ " is deprecated and will be removed in a"
+ " later release\n");
continue
if mbody != end_template[lang.resources][role][lang.metadata][m]:
errors.append('Role %s metadata key %s conflicts.' %