Allow overriding InterfaceDefaultRoute with ips_from_pool template

Currently InterfaceDefaultRoute doesn't affect when ips_from_pool
template is used, and gateway_ip in network_data is always picked up.
This patch allows operators to override default route by the parameter
even when ips_from_pool template is used.

Note that this patch also fixes incorrect handling about subnet in
ips_from_pool template when ipv6 is enabled.

Closes-Bug: #1881768
Change-Id: I2f0f60052c1acfc971fe3d5195f9499e45068396
(cherry picked from commit 396b26fe9b)
This commit is contained in:
Takashi Kajinami 2020-06-03 01:09:32 +09:00
parent 8712190046
commit 454a0e6520
1 changed files with 23 additions and 4 deletions

View File

@ -53,9 +53,24 @@ parameters:
default: 0
type: number
{{network.name}}NetCidr:
default: {{network.ip_subnet}}
{%- if network.ipv6 or ipv6_override %}
default: "{{network.ipv6_subnet|default(network.ip_subnet|default(""))}}"
{%- else %}
default: "{{network.ip_subnet|default("")}}"
{%- endif %}
description: Cidr for the {{network.name_lower}} network.
type: string
{{network.name}}InterfaceDefaultRoute:
default: ''
description: default route for the {{network.name_lower}} network
type: string
conditions:
{{network.name_lower}}_interface_default_route_set:
not:
equals:
- {get_param: {{network.name}}InterfaceDefaultRoute}
- ''
outputs:
ip_address:
@ -86,9 +101,13 @@ outputs:
value: {{network.mtu|default('1500')}}
gateway_ip:
description: Gateway IP of the ports subnet
value:
if:
- {{network.name_lower}}_interface_default_route_set
- {get_param: {{network.name}}InterfaceDefaultRoute}
-
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
value: {{network.gateway_ipv6|default('')}}
{{network.gateway_ipv6|default('')}}
{%- else %}
value: {{network.gateway_ip|default('')}}
{{network.gateway_ip|default('')}}
{%- endif %}