# Enable the creation of Neutron networks for isolated Overcloud
# traffic and configure each role to assign ports (related
# to that role) on these networks.
resource_registry:
  # networks as defined in network_data.yaml
  {%- for network in networks if network.enabled|default(true) %}
  OS::TripleO::Network::{{network.name}}: ../network/{{network.name_lower|default(network.name.lower())}}.yaml
  {%- endfor %}

  # Port assignments for the VIPs
  {%- for network in networks if network.vip and network.enabled|default(true) %}
  {%- if network.external_resource_vip_id|default('') %}
  OS::TripleO::Network::Ports::{{network.name}}VipPort: ../network/ports/external_resource_{{network.name_lower|default(network.name.lower())}}.yaml
  {%- else %}
  OS::TripleO::Network::Ports::{{network.name}}VipPort: ../network/ports/{{network.name_lower|default(network.name.lower())}}.yaml
  {%- endif %}
  {%- endfor %}
  OS::TripleO::Network::Ports::RedisVipPort: ../network/ports/vip.yaml
  OS::TripleO::Network::Ports::OVNDBsVipPort: ../network/ports/vip.yaml

  # Port assignments by role, edit role definition to assign networks to roles.
{%- for role in roles %}
{#-     Convert net map or net list to internal list of networks #}
{#-     NOTE(hjensas): For backward compatibility support role data with both #}
{#-                    networks map (new schema) and network list (old schema). #}
{%-     if role.networks is mapping %}
{%-         set _role_networks = [] %}
{%-         for key, val in role.networks.items() %}
{%-             set _ = _role_networks.append(key) %}
{%-         endfor %}
{%-     else %}
{%-         set _role_networks = role.networks %}
{%-     endif %}
  # Port assignments for the {{role.name}}
{%-     for network in networks %}
{%-         if network.name in _role_networks and network.enabled|default(true) %}
  OS::TripleO::{{role.name}}::Ports::{{network.name}}Port: ../network/ports/{{network.name_lower|default(network.name.lower())}}.yaml
{%-         endif %}
{%-     endfor %}
{%- endfor %}
