Harald Jensås 53027484ae Skip templating disabled networks
Ignore disabled networks when rendering templates.

Add's the ctlplane network to maps to ensure we don't
end up with no keys/values in map_replace functions.

Also some Jinja cleanup:
 - Reduce the number of times we iterate over networks
   where we can.
 - Add's indentation to make the code easier to read.

Related-Bug: #1809313
Depends-On: I2e8135bc9389d3bf1a6ef01e273515af5c488a9a
Change-Id: Ifeb2d2d1acb43c16a5bf29e95965776494d61fef
2019-01-21 19:35:37 +01:00

35 lines
1.1 KiB
YAML

heat_template_version: rocky
description: Create networks to split out Overcloud traffic
parameters:
CtlplaneNetworkCidrs:
type: json
description: Cidrs for the ctlplane network.
resources:
{%- for network in networks if network.enabled|default(true) %}
{%- set network_name = network.compat_name|default(network.name) %}
{{network_name}}Network:
type: OS::TripleO::Network::{{network.name}}
{%- endfor %}
NetworkExtraConfig:
type: OS::TripleO::Network::ExtraConfig
outputs:
net_cidr_map:
value:
# NOTE(hjensas): If a network does not have any network_cidrs, fall back
# to the ctlplane (provisioning) network.
{%- for network in networks if network.enabled|default(true) %}
{%- set network_name = network.compat_name|default(network.name) %}
{{network.name_lower}}:
yaql:
data:
network_cidrs: {get_attr: [{{network_name}}Network, network_cidrs]}
ctlplane_cidrs: {get_param: CtlplaneNetworkCidrs}
expression: switch(not isList($.data.network_cidrs) => $.data.ctlplane_cidrs, $.data.network_cidrs => $.data.network_cidrs)
{%- endfor %}