Handle any network name in ServiceNetMap

In commit, I737d5656b113f7e2238fe7bb555cc2d4cb13877c, support was added
to have the services fall back to the ctlplane network if the default
service network wasn't enabled.

The commit only worked for the hardcoded default network names though
(ItnernalApi, Storage, etc). Given that any network names can be used,
and that our spine/leaf examples show using non-default network names
(IternalApi0, Storage0, etc), the code needs to work for any network
name.

This commit updates the jinja2 logic to work for any network name. It
also handles service_net_map_replace in the jinja2 logic instead of
Heat, so that services can be correctly defaulted when the default
networks don't exist at all.

Change-Id: Icd8d49c0cf8c8ac43348813c502861fb0aa7091f
implements: blueprint split-controlplane-templates
Closes-Bug: #1824025
This commit is contained in:
James Slagle 2019-04-09 14:15:55 -04:00
parent e701077c96
commit da5b57c7bb
2 changed files with 9 additions and 21 deletions

View File

@ -1,24 +1,12 @@
{%- set _service_nets = {} -%}
{%- for network in networks if network.enabled|default(true) -%}
{%- if network.name == 'InternalApi' -%}
{%- set _service_nets = _service_nets.update({'internal_api': 'internal_api'}) -%}
{%- endif -%}
{%- if network.name == 'External' -%}
{%- set _service_nets = _service_nets.update({'external': 'external'}) -%}
{%- endif -%}
{%- if network.name == 'Tenant' -%}
{%- set _service_nets = _service_nets.update({'tenant': 'tenant'}) -%}
{%- endif -%}
{%- if network.name == 'Storage' -%}
{%- set _service_nets = _service_nets.update({'storage': 'storage'}) -%}
{%- endif -%}
{%- if network.name == 'StorageMgmt' -%}
{%- set _service_nets = _service_nets.update({'storage_mgmt': 'storage_mgmt'}) -%}
{%- endif -%}
{%- if network.name == 'StorageNFS' -%}
{%- set _service_nets = _service_nets.update({'storage_nfs': 'storage_nfs'}) -%}
{%- if network.service_net_map_replace is defined -%}
{%- set _service_nets = _service_nets.update({network.service_net_map_replace:network.name_lower}) -%}
{%- else -%}
{%- set _service_nets = _service_nets.update({network.name_lower:network.name_lower}) -%}
{%- endif -%}
{%- endfor -%}
heat_template_version: rocky
description: >
@ -173,11 +161,7 @@ resources:
- {get_param: ServiceNetMapDefaults}
- values:
{%- for network in networks if network.enabled|default(true) %}
{%- if network.service_net_map_replace is defined %}
{{network.service_net_map_replace}}: {{network.name_lower}}
{%- else %}
{{network.name_lower}}: {get_param: {{network.name}}NetName}
{%- endif %}
{%- endfor %}
- map_replace:
- {get_param: ServiceNetMap}

View File

@ -0,0 +1,4 @@
---
fixes:
- ServiceNetMap now handles any network name when computing the default
network for each service in ServiceNetMapDefaults.