Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Use get_attr to set %network%InterfaceDefaultRoute
Browse files Browse the repository at this point in the history
For networks in role.default_route_networks use get_attr
to fetch the gateway_ip of the port's subnet and pass
it to the nic-config template.

Changes the default in nic-config templates to ''.

Closes-Bug: #1821046
Change-Id: Ic07a3166fafba3aa307a9e1953b3e3be2594a6f5
  • Loading branch information
hjensas committed Mar 20, 2019
1 parent e4854d6 commit ce9a83c
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 116 deletions.
9 changes: 2 additions & 7 deletions network/config/2-linux-bonds-vlans/role.role.j2.yaml
Expand Up @@ -59,14 +59,9 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
default: ''
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
Expand Down
15 changes: 4 additions & 11 deletions network/config/bond-with-vlans/controller-no-external.j2.yaml
Expand Up @@ -50,17 +50,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -70,6 +59,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
15 changes: 4 additions & 11 deletions network/config/bond-with-vlans/controller-v6.j2.yaml
Expand Up @@ -48,17 +48,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -68,6 +57,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
11 changes: 3 additions & 8 deletions network/config/bond-with-vlans/role.role.j2.yaml
Expand Up @@ -57,17 +57,12 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
default: ''
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand Down
19 changes: 8 additions & 11 deletions network/config/multiple-nics/compute-dvr.j2.yaml
Expand Up @@ -48,17 +48,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -68,6 +57,14 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
# Uncomment when including environments/network-management.yaml and setting
# default route on the Management interface. Also comment out the default
# route on the Control Plane and add the Management network to the roles
# default_route_networks in roles data.
# ManagementInterfaceDefaultRoute:
# default: ''
# description: default route for the management network
# type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
15 changes: 4 additions & 11 deletions network/config/multiple-nics/controller-v6.j2.yaml
Expand Up @@ -47,17 +47,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -67,6 +56,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
11 changes: 3 additions & 8 deletions network/config/multiple-nics/role.role.j2.yaml
Expand Up @@ -57,17 +57,12 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
default: ''
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand Down
15 changes: 4 additions & 11 deletions network/config/single-nic-linux-bridge-vlans/controller-v6.j2.yaml
Expand Up @@ -47,17 +47,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -67,6 +56,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
11 changes: 3 additions & 8 deletions network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml
Expand Up @@ -57,17 +57,12 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
default: ''
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand Down
15 changes: 4 additions & 11 deletions network/config/single-nic-vlans/controller-no-external.j2.yaml
Expand Up @@ -50,17 +50,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -70,6 +59,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
15 changes: 4 additions & 11 deletions network/config/single-nic-vlans/controller-v6.j2.yaml
Expand Up @@ -47,17 +47,6 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand All @@ -67,6 +56,10 @@ parameters:
from the subnet host_routes attribute.
type: json
{%- endfor %}
ExternalInterfaceDefaultRoute:
default: ''
description: default route for the external network
type: string
DnsServers: # Override this via parameter_defaults
default: []
description: >
Expand Down
11 changes: 3 additions & 8 deletions network/config/single-nic-vlans/role.role.j2.yaml
Expand Up @@ -57,17 +57,12 @@ parameters:
guaranteed to pass through the data path of the segments in the
{{network.name}} network.
type: number
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ipv6}}'
description: default route for the {{network.name_lower}} network
type: string
{%- elif network.gateway_ip|default(false) %}
{{network.name}}InterfaceDefaultRoute:
default: '{{network.gateway_ip}}'
default: ''
description: default route for the {{network.name_lower}} network
type: string
{%- endif %}
{%- endif %}
{{network.name}}InterfaceRoutes:
default: []
description: >
Expand Down
3 changes: 3 additions & 0 deletions network/ports/noop.yaml
Expand Up @@ -76,3 +76,6 @@ outputs:
description: The maximum transmission unit (MTU)
value:
get_param: ControlPlaneMtu
gateway_ip: # Here for compatibility
description: Gateway IP of the ports subnet
value: ''
4 changes: 4 additions & 0 deletions network/ports/port.j2
Expand Up @@ -107,3 +107,7 @@ outputs:
description: The maximum transmission unit (MTU)
value:
get_attr: [{{network.name}}Port, network, mtu]
gateway_ip:
description: Gateway IP of the ports subnet
value:
get_attr: [{{network.name}}Port, subnets, 0, gateway_ip]
7 changes: 7 additions & 0 deletions network/ports/port_from_pool.j2
Expand Up @@ -84,4 +84,11 @@ outputs:
mtu:
description: The maximum transmission unit (MTU)
value: {{network.mtu|default('1500')}}
gateway_ip:
description: Gateway IP of the ports subnet
{%- if network.ipv6|default(false) and network.gateway_ipv6|default(false) %}
value: {{network.gateway_ipv6|default('')}}
{%- else %}
value: {{network.gateway_ip|default('')}}
{%- endif %}

3 changes: 3 additions & 0 deletions puppet/role.role.j2.yaml
Expand Up @@ -539,6 +539,9 @@ resources:
- {get_param: {{network.name}}InterfaceRoutes}
- {get_attr: [{{network.name}}Port, host_routes]}
{{network.name}}Mtu: {get_attr: [{{network.name}}Port, mtu]}
{%- if network.name in role.default_route_networks %}
{{network.name}}InterfaceDefaultRoute: {get_attr: [{{network.name}}Port, gateway_ip]}
{%- endif %}
{%- endif %}
{%- endfor %}

Expand Down
@@ -0,0 +1,9 @@
---
features:
- |
The *get_attr* function is now used to read the ``gateway_ip`` of a ports
subnet. The gateway_ip value is passed to nic config templates using the
``%network%InterfaceDefaultRoute`` parameter. (This parameter is only used
if the network is present in the roles ``default_route_networks``.) Using
*get_attr* ensures that the correct gateway ip address is used when
networks have multiple subnets.

0 comments on commit ce9a83c

Please sign in to comment.