Skip to content

Commit

Permalink
Support subinterfaces as tenant l3_interfaces (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista authored May 18, 2021
1 parent ee5f3a3 commit 0c77ce1
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ vlan 350
| Ethernet7 | test | routed | - | 10.10.10.10/24 | Tenant_A_WAN_Zone | 9000 | false | - | - |
| Ethernet8 | test | routed | - | 10.10.10.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet9 | test | routed | - | 10.10.20.20/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet10.100 | subinterface test | l3dot1q | - | 10.10.11.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet10.200 | subinterface test with vlan override | l3dot1q | - | 10.10.21.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet41 | P2P_LINK_TO_DC1-SPINE1_Ethernet6 | routed | - | 172.31.255.81/31 | default | 1500 | false | - | - |
| Ethernet42 | P2P_LINK_TO_DC1-SPINE2_Ethernet6 | routed | - | 172.31.255.83/31 | default | 1500 | false | - | - |
| Ethernet43 | P2P_LINK_TO_DC1-SPINE3_Ethernet6 | routed | - | 172.31.255.85/31 | default | 1500 | false | - | - |
Expand Down Expand Up @@ -329,6 +331,26 @@ interface Ethernet9
vrf Tenant_L3_VRF_Zone
ip address 10.10.20.20/24
!
interface Ethernet10
no shutdown
no switchport
!
interface Ethernet10.100
description subinterface test
no shutdown
mtu 9000
encapsulation dot1q vlan 100
vrf Tenant_L3_VRF_Zone
ip address 10.10.11.10/24
!
interface Ethernet10.200
description subinterface test with vlan override
no shutdown
mtu 9000
encapsulation dot1q vlan 121
vrf Tenant_L3_VRF_Zone
ip address 10.10.21.10/24
!
interface Ethernet41
description P2P_LINK_TO_DC1-SPINE1_Ethernet6
no shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ vlan 350
| Ethernet7 | test | routed | - | 10.10.20.20/24 | Tenant_A_WAN_Zone | 9000 | false | - | - |
| Ethernet8 | test | routed | - | 10.10.30.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet9 | test | routed | - | 10.10.40.20/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet10.100 | subinterface test | l3dot1q | - | 10.10.31.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet10.200 | subinterface test with vlan override | l3dot1q | - | 10.10.41.10/24 | Tenant_L3_VRF_Zone | 9000 | false | - | - |
| Ethernet45 | P2P_LINK_TO_DC1-SPINE1_Ethernet7 | routed | - | 172.31.255.97/31 | default | 1500 | false | - | - |
| Ethernet46 | P2P_LINK_TO_DC1-SPINE2_Ethernet7 | routed | - | 172.31.255.99/31 | default | 1500 | false | - | - |
| Ethernet47 | P2P_LINK_TO_DC1-SPINE3_Ethernet7 | routed | - | 172.31.255.101/31 | default | 1500 | false | - | - |
Expand Down Expand Up @@ -327,6 +329,26 @@ interface Ethernet9
vrf Tenant_L3_VRF_Zone
ip address 10.10.40.20/24
!
interface Ethernet10
no shutdown
no switchport
!
interface Ethernet10.100
description subinterface test
no shutdown
mtu 9000
encapsulation dot1q vlan 100
vrf Tenant_L3_VRF_Zone
ip address 10.10.31.10/24
!
interface Ethernet10.200
description subinterface test with vlan override
no shutdown
mtu 9000
encapsulation dot1q vlan 141
vrf Tenant_L3_VRF_Zone
ip address 10.10.41.10/24
!
interface Ethernet45
description P2P_LINK_TO_DC1-SPINE1_Ethernet7
no shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Node Type,Node,Node Interface,Peer Type,Peer,Peer Interface
l3leaf,DC1-BL1A,Ethernet7,l3_interface,,
l3leaf,DC1-BL1A,Ethernet8,l3_interface,,
l3leaf,DC1-BL1A,Ethernet9,l3_interface,,
l3leaf,DC1-BL1A,Ethernet10,l3_interface,,
l3leaf,DC1-BL1A,Ethernet10.100,l3_interface,,
l3leaf,DC1-BL1A,Ethernet10.200,l3_interface,,
l3leaf,DC1-BL1A,Ethernet41,spine,DC1-SPINE1,Ethernet6
l3leaf,DC1-BL1A,Ethernet42,spine,DC1-SPINE2,Ethernet6
l3leaf,DC1-BL1A,Ethernet43,spine,DC1-SPINE3,Ethernet6
Expand All @@ -10,6 +13,9 @@ l3leaf,DC1-BL1A,Ethernet4000,my_precious,MY-own-peer,Ethernet123
l3leaf,DC1-BL1B,Ethernet7,l3_interface,,
l3leaf,DC1-BL1B,Ethernet8,l3_interface,,
l3leaf,DC1-BL1B,Ethernet9,l3_interface,,
l3leaf,DC1-BL1B,Ethernet10,l3_interface,,
l3leaf,DC1-BL1B,Ethernet10.100,l3_interface,,
l3leaf,DC1-BL1B,Ethernet10.200,l3_interface,,
l3leaf,DC1-BL1B,Ethernet45,spine,DC1-SPINE1,Ethernet7
l3leaf,DC1-BL1B,Ethernet46,spine,DC1-SPINE2,Ethernet7
l3leaf,DC1-BL1B,Ethernet47,spine,DC1-SPINE3,Ethernet7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ interface Ethernet9
vrf Tenant_L3_VRF_Zone
ip address 10.10.20.20/24
!
interface Ethernet10
no shutdown
no switchport
!
interface Ethernet10.100
description subinterface test
no shutdown
mtu 9000
encapsulation dot1q vlan 100
vrf Tenant_L3_VRF_Zone
ip address 10.10.11.10/24
!
interface Ethernet10.200
description subinterface test with vlan override
no shutdown
mtu 9000
encapsulation dot1q vlan 121
vrf Tenant_L3_VRF_Zone
ip address 10.10.21.10/24
!
interface Ethernet41
description P2P_LINK_TO_DC1-SPINE1_Ethernet6
no shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ interface Ethernet9
vrf Tenant_L3_VRF_Zone
ip address 10.10.40.20/24
!
interface Ethernet10
no shutdown
no switchport
!
interface Ethernet10.100
description subinterface test
no shutdown
mtu 9000
encapsulation dot1q vlan 100
vrf Tenant_L3_VRF_Zone
ip address 10.10.31.10/24
!
interface Ethernet10.200
description subinterface test with vlan override
no shutdown
mtu 9000
encapsulation dot1q vlan 141
vrf Tenant_L3_VRF_Zone
ip address 10.10.41.10/24
!
interface Ethernet45
description P2P_LINK_TO_DC1-SPINE1_Ethernet7
no shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,28 @@ ethernet_interfaces:
mtu: 9000
shutdown: false
description: test
Ethernet10.100:
type: l3dot1q
encapsulation_dot1q_vlan: 100
peer_type: l3_interface
vrf: Tenant_L3_VRF_Zone
ip_address: 10.10.11.10/24
mtu: 9000
shutdown: false
description: subinterface test
Ethernet10.200:
type: l3dot1q
encapsulation_dot1q_vlan: 121
peer_type: l3_interface
vrf: Tenant_L3_VRF_Zone
ip_address: 10.10.21.10/24
mtu: 9000
shutdown: false
description: subinterface test with vlan override
Ethernet10:
type: routed
peer_type: l3_interface
shutdown: false
Ethernet4000:
description: My test
ip_address: 10.3.2.1/21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,28 @@ ethernet_interfaces:
mtu: 9000
shutdown: false
description: test
Ethernet10.100:
type: l3dot1q
encapsulation_dot1q_vlan: 100
peer_type: l3_interface
vrf: Tenant_L3_VRF_Zone
ip_address: 10.10.31.10/24
mtu: 9000
shutdown: false
description: subinterface test
Ethernet10.200:
type: l3dot1q
encapsulation_dot1q_vlan: 141
peer_type: l3_interface
vrf: Tenant_L3_VRF_Zone
ip_address: 10.10.41.10/24
mtu: 9000
shutdown: false
description: subinterface test with vlan override
Ethernet10:
type: routed
peer_type: l3_interface
shutdown: false
Ethernet4000:
description: My second test
ip_address: 10.1.2.3/12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ tenants:
mtu: 9000
enabled: True
description: "test"
- interfaces: [ Ethernet10.100, Ethernet10.100 ]
ip_addresses: [10.10.11.10/24, 10.10.31.10/24]
nodes: [DC1-BL1A, DC1-BL1B]
mtu: 9000
enabled: True
description: "subinterface test"
- interfaces: [ Ethernet10.200, Ethernet10.200 ]
encapsulation_dot1q_vlan: [ 121, 141 ]
ip_addresses: [10.10.21.10/24, 10.10.41.10/24]
nodes: [DC1-BL1A, DC1-BL1B]
mtu: 9000
enabled: True
description: "subinterface test with vlan override"
l2vlans:
# L2 vlan as string
'160':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ tenants:
enabled: < true | false >
mtu: <mtu >

# For sub-interfaces the dot1q vlan is derived from the interface name by default, but can also be specified.
- interfaces: [ <interface_name1.sub-if-id>, <interface_name2.sub-if-id> ]
encapsulation_dot1q_vlan: [ <vlan id>, <vlan id> ]
ip_addresses: [ <IPv4_address/Mask>, <IPv4_address/Mask> ]
nodes: [ < node_1 >, < node_2 > ]
description: < description >
enabled: < true | false >
mtu: <mtu >

# Dictionary of static routes | Optional.
# This will create static routes inside the tenant VRF, if none specified, all l3leafs that carry the VRF also get the static routes.
# If a node has a static route in the VRF, redistribute static will be automatically enabled in that VRF. This automatic behaviour can be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
{# Leaf Tenant l3 interfaces #}
{% set l3_interface_subif_parents = [] %}
ethernet_interfaces:
{% for tenant in switch.tenants | arista.avd.natural_sort %}
{% for vrf in switch.tenants[tenant].vrfs | arista.avd.natural_sort %}
{% for l3_interface in tenants[tenant].vrfs[vrf].l3_interfaces | arista.avd.default([]) %}
{% if l3_interface.nodes is arista.avd.defined and l3_interface.ip_addresses is arista.avd.defined and l3_interface.interfaces is arista.avd.defined and inventory_hostname in l3_interface.nodes %}
{% if l3_interface.nodes is arista.avd.defined and inventory_hostname in l3_interface.nodes and l3_interface.ip_addresses is arista.avd.defined and l3_interface.interfaces is arista.avd.defined %}
{% for node in l3_interface.nodes %}
{% if node == inventory_hostname %}
{% if '.' in l3_interface.interfaces[loop.index0] %}
{% set l3_interface_subif_id = l3_interface.encapsulation_dot1q_vlan[loop.index0] | arista.avd.default(
l3_interface.interfaces[loop.index0].split('.') | last) %}
{% do l3_interface_subif_parents.append(l3_interface.interfaces[loop.index0].split('.') | first) %}
{% endif %}
{{ l3_interface.interfaces[loop.index0] }}:
{% if l3_interface_subif_id is arista.avd.defined %}
type: l3dot1q
encapsulation_dot1q_vlan: {{ l3_interface_subif_id }}
{% else %}
type: routed
{% endif %}
peer_type: l3_interface
vrf: {{ vrf }}
ip_address: {{ l3_interface.ip_addresses[loop.index0] }}
Expand All @@ -28,3 +39,11 @@ ethernet_interfaces:
{% endfor %}
{% endfor %}
{% endfor %}
{# Create parent / base interfaces as routed. Will be merged onto structured config, #}
{# so even if the same interfaces are created elsewhere, it will still work. #}
{% for l3_interface_subif_parent in l3_interface_subif_parents | arista.avd.natural_sort | unique %}
{{ l3_interface_subif_parent }}:
type: routed
peer_type: l3_interface
shutdown: false
{% endfor %}

0 comments on commit 0c77ce1

Please sign in to comment.