Skip to content

Commit

Permalink
define vrfs mentioned in sonic_ports_dict, sonic_vlans (in addition t…
Browse files Browse the repository at this point in the history
…o those occuring in sonic_interconnects)
  • Loading branch information
mwindower committed Oct 31, 2024
1 parent 1c07e77 commit 7b0d452
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions partition/roles/sonic/templates/metal.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#jinja2: lstrip_blocks: "False", trim_blocks: "False"
---
{% set vrfs = [] %}
DEVICE_METADATA:
localhost:
docker_routing_config_mode: "{{ sonic_docker_routing_config_mode }}"
Expand Down Expand Up @@ -78,6 +79,7 @@ INTERFACE:
ipv6_use_link_local_only: enable
{% endif %}
{% if port.vrf is defined %}
{% set vrfs = vrfs.append(port.vrf) %}
vrf_name: "{{ port.vrf }}"
{% endif %}
{% elif port.ips is defined %}
Expand Down Expand Up @@ -169,6 +171,7 @@ VLAN:
VLAN_INTERFACE:
{% for vlan in sonic_vlans %}
{% if vlan.vrf is defined %}
{% set vrfs = vrfs.append(vlan.vrf) %}
Vlan{{ vlan.id }}:
{% if vlan.sag is defined and vlan.sag %}
static_anycast_gateway: "true"
Expand Down Expand Up @@ -220,9 +223,11 @@ VXLAN_TUNNEL_MAP:

VRF:
{% endif %}
{% set defined_vrfs = [] %}
{% if sonic_interconnects is defined and sonic_interconnects|length > 0 %}
{% for k, i in sonic_interconnects.items() %}
{% if i.vrf is defined %}
{% set defined_vrfs = defined_vrfs.append(i.vrf) %}
{% if i.vni is defined %}
{{ i.vrf }}:
vni: "{{ i.vni }}"
Expand All @@ -232,6 +237,10 @@ VRF:
{% endif %}
{% endfor %}
{% endif %}
{% set vrfs_to_add = vrfs | difference(defined_vrfs) | unique %}
{% for vrf in vrfs_to_add %}
{{ vrf }}: {}
{% endfor %}
{% if sonic_lldp_hello_timer is defined %}

LLDP:
Expand Down
7 changes: 6 additions & 1 deletion partition/roles/sonic/test/data/exit/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ sonic_ports_dict:
vrf: VrfMpls
ips:
- 10.0.0.2/32
Ethernet1:
speed: 10000
vrf: VrfStorage
# spine uplinks
Ethernet112:
Ethernet116:
Expand Down Expand Up @@ -75,7 +78,9 @@ sonic_bgp_ports:

sonic_vlans:
- id: 4000
vrf: vrfMpls
vrf: VrfMpls
- id: 4001
vrf: VrfTest

sonic_vteps:
- comment: MPLS
Expand Down
12 changes: 11 additions & 1 deletion partition/roles/sonic/test/data/exit/metal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ INTERFACE:
Ethernet0:
vrf_name: "VrfMpls"
Ethernet0|10.0.0.2/32: {}
Ethernet1:
vrf_name: "VrfStorage"
Ethernet112:
ipv6_use_link_local_only: enable
Ethernet116:
Expand Down Expand Up @@ -70,6 +72,8 @@ PORT:
parent_port: Ethernet0
admin_status: up
speed: "10000"
mtu: "9216"
fec: none
Ethernet2:
alias: Eth1/3(Port1)
autoneg: "off"
Expand Down Expand Up @@ -110,10 +114,14 @@ PORT:
VLAN:
Vlan4000:
vlanid: 4000
Vlan4001:
vlanid: 4001

VLAN_INTERFACE:
Vlan4000:
vrf_name: "vrfMpls"
vrf_name: "VrfMpls"
Vlan4001:
vrf_name: "VrfTest"

VLAN_MEMBER:

Expand All @@ -134,6 +142,8 @@ VXLAN_TUNNEL_MAP:
VRF:
VrfMpls:
vni: "104000"
VrfStorage: {}
VrfTest: {}

LLDP:
Global:
Expand Down
Empty file modified partition/roles/sonic/test/template_test.py
100644 → 100755
Empty file.

0 comments on commit 7b0d452

Please sign in to comment.