I think the issue is in the way lists are handled:
def replace_links_in_template(template_part, link_replacement):
"""Replace get_file and type file links in a Heat template
Scan the template for 'get_file' and 'type' occurrences, and
replace the file paths according to link_replacement
dict. (Key/value in link_replacement are from/to, respectively.)
"""
def replaced_dict_value(key, value):
if ((key == 'get_file' or key == 'type') and isinstance(value, six.string_types)):
return link_replacement.get(value, value)
else:
return replace_links_in_template(value, link_replacement)
if isinstance(template_part, dict):
return {k: replaced_dict_value(k, v)
for k, v in six.iteritems(template_part)}
elif isinstance(template_part, list):
return map(replaced_list_value, template_part)
else:
return template_part
both empty and non-empty lists are ending up like:
template_part: []
replaced value: <function replace_links_in_template.<locals>.replaced_list_value at 0x7fea0d31a378>
...
I think the issue is in the way lists are handled:
def replace_ links_in_ template( template_ part, link_replacement):
"""Replace get_file and type file links in a Heat template
Scan the template for 'get_file' and 'type' occurrences, and
replace the file paths according to link_replacement
dict. (Key/value in link_replacement are from/to, respectively.)
"""
def replaced_ dict_value( key, value):
isinstance( value, six.string_types)): t.get(value, value) links_in_ template( value, link_replacement)
if ((key == 'get_file' or key == 'type') and
return link_replacemen
else:
return replace_
def replaced_ list_value( value): links_in_ template( value, link_replacement)
return replace_
if isinstance( template_ part, dict): dict_value( k, v) template_ part)} template_ part, list): list_value, template_part)
return {k: replaced_
for k, v in six.iteritems(
elif isinstance(
return map(replaced_
else:
return template_part
both empty and non-empty lists are ending up like:
template_part: []
replaced value: <function replace_ links_in_ template. <locals> .replaced_ list_value at 0x7fea0d31a378>
...
template_part:
[{'type': 'interface', 'name': 'nic1', 'use_dhcp': False, 'dns_servers': {'get_param': 'DnsServers'}, 'addresses': [{'ip_netmask': {'list_join': ['/', [{'get_param': 'ControlPlaneIp'}, {'get_param': 'ControlPlaneSu bnetCidr' }]]}}], 'routes': [{'ip_netmask': '0.0.0.0/0', 'next_hop': {'get_param': 'ControlPlaneDe faultRoute' }, 'default': True}, {'ip_netmask': '169.254. 169.254/ 32', 'next_hop': {'get_param': 'EC2MetadataIp' }}]}, {'type': 'ovs_bridge', 'name': 'br-isolated', 'use_dhcp': False, 'members': [{'type': 'interface', 'name': 'nic2', 'primary': True}, {'type': 'vlan', 'vlan_id': {'get_param': 'InternalApiNet workVlanID' }, 'addresses': [{'ip_netmask': {'get_param': 'InternalApiIpS ubnet'} }]}, {'type': 'vlan', 'vlan_id': {'get_param': 'StorageNetwork VlanID' }, 'addresses': [{'ip_netmask': {'get_param': 'StorageIpSubne t'}}]}, {'type': 'vlan', 'vlan_id': {'get_param': 'StorageMgmtNet workVlanID' }, 'addresses': [{'ip_netmask': {'get_param': 'StorageMgmtIpS ubnet'} }]}, {'type': 'vlan', 'vlan_id': {'get_param': 'TenantNetworkV lanID'} , 'addresses': [{'ip_netmask': {'get_param': 'TenantIpSubnet '}}]}]} , {'type': 'ovs_bridge', 'name': 'br-ex', 'use_dhcp': False, 'addresses': [{'ip_netmask': {'get_param': 'ExternalIpSubn et'}}], 'routes': [{'ip_netmask': '0.0.0.0/0', 'next_hop': {'get_param': 'ExternalInterf aceDefaultRoute '}}], 'members': [{'type': 'interface', 'name': 'nic3', 'primary': True}]}]
replaced value:
<function replace_ links_in_ template. <locals> .replaced_ list_value at 0x7fea0d31ab70>