From 862ded02f4560b1703a8e3add4f16cf95a513b2e Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Thu, 23 Jun 2022 02:43:08 -0700 Subject: [PATCH 1/6] [dualtor][minigraph] Support new minigraph schema for SoC IP Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_dpg.j2 | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ansible/templates/minigraph_dpg.j2 b/ansible/templates/minigraph_dpg.j2 index f632de4c14..bc04123ff0 100644 --- a/ansible/templates/minigraph_dpg.j2 +++ b/ansible/templates/minigraph_dpg.j2 @@ -265,6 +265,71 @@ +{% if mux_cable_facts is defined %} +{% for cable in dual_tor_facts['cables'] %} +{% set intf_index = port_alias.index(cable['dut_intf'])|string %} + + + + + LoopbackInterface + HostIP + Loopback0 + + {{ mux_cable_facts[intf_index]['server_ipv4'] }} + + {{ mux_cable_facts[intf_index]['server_ipv4'] }} + + + LoopbackInterface + HostIP1 + Loopback0 + + {{ mux_cable_facts[intf_index]['server_ipv6'] }} + + {{ mux_cable_facts[intf_index]['server_ipv6'] }} + +{% if 'soc_ipv4' in mux_cable_facts[intf_index] %} + + LoopbackInterface + SoCHostIP0 + Servers{{ loop.index - 1 }}SOC + + {{ mux_cable_facts[intf_index]['soc_ipv4'] }} + + {{ mux_cable_facts[intf_index]['soc_ipv4'] }} + +{% endif %} +{% if 'soc_ipv6' in mux_cable_facts[intf_index] %} + + LoopbackInterface + SoCHostIP1 + Servers{{ loop.index - 1 }}SOC + + {{ mux_cable_facts[intf_index]['soc_ipv6'] }} + + {{ mux_cable_facts[intf_index]['soc_ipv6'] }} + + +{% endif %} + + + + + + Servers{{ loop.index - 1 }} + + + + + + + + + + +{% endfor %} +{% endif %} {% include 'minigraph_dpg_asic.j2' %} From 6eda964c810339e425b6ca5666e1066808da2b0a Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Tue, 5 Jul 2022 02:29:34 +0000 Subject: [PATCH 2/6] Check dict is not empty Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_dpg.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible/templates/minigraph_dpg.j2 b/ansible/templates/minigraph_dpg.j2 index bc04123ff0..cedcf28c51 100644 --- a/ansible/templates/minigraph_dpg.j2 +++ b/ansible/templates/minigraph_dpg.j2 @@ -265,7 +265,8 @@ -{% if mux_cable_facts is defined %} +{% if mux_cable_facts is defined and mux_cable_facts %} +{% if dual_tor_facts is defined and 'cables' in dual_tor_facts %}} {% for cable in dual_tor_facts['cables'] %} {% set intf_index = port_alias.index(cable['dut_intf'])|string %} @@ -330,6 +331,7 @@ {% endfor %} {% endif %} +{% endif %} {% include 'minigraph_dpg_asic.j2' %} From 3f97e7b8cf1e1c4955fc047262f76b602e8616bc Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Tue, 5 Jul 2022 06:51:17 -0700 Subject: [PATCH 3/6] Remove extra bracket Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_dpg.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/templates/minigraph_dpg.j2 b/ansible/templates/minigraph_dpg.j2 index cedcf28c51..dc262cb3b2 100644 --- a/ansible/templates/minigraph_dpg.j2 +++ b/ansible/templates/minigraph_dpg.j2 @@ -266,7 +266,7 @@ {% if mux_cable_facts is defined and mux_cable_facts %} -{% if dual_tor_facts is defined and 'cables' in dual_tor_facts %}} +{% if dual_tor_facts is defined and 'cables' in dual_tor_facts %} {% for cable in dual_tor_facts['cables'] %} {% set intf_index = port_alias.index(cable['dut_intf'])|string %} From 2ad800e26f3721043db55052e9481abf6c21bbfc Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Thu, 7 Jul 2022 01:47:04 -0700 Subject: [PATCH 4/6] Add `RedundancyType` Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_meta.j2 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ansible/templates/minigraph_meta.j2 b/ansible/templates/minigraph_meta.j2 index 3f459d61da..3ad2c28d25 100644 --- a/ansible/templates/minigraph_meta.j2 +++ b/ansible/templates/minigraph_meta.j2 @@ -28,6 +28,19 @@ True {% endif %} +{% if 'dualtor-mixed' in topo %} + + RedundancyType + + Mixed + +{% elif 'dualtor' in topo %} + + RedundancyType + + Gemini + +{% endif %} {% if dhcp_servers %} DhcpResources From 631f26b74fdbd8f975e1b24d17aae01e0ef55f2d Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Thu, 7 Jul 2022 01:47:55 -0700 Subject: [PATCH 5/6] Fix syntax issue Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_dpg.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/templates/minigraph_dpg.j2 b/ansible/templates/minigraph_dpg.j2 index dc262cb3b2..a79027a9e8 100644 --- a/ansible/templates/minigraph_dpg.j2 +++ b/ansible/templates/minigraph_dpg.j2 @@ -311,8 +311,8 @@ {{ mux_cable_facts[intf_index]['soc_ipv6'] }} - {% endif %} + From 921bcc36de56108c085a7cbad0eb614cd817ef5a Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Thu, 7 Jul 2022 01:48:16 -0700 Subject: [PATCH 6/6] Remove logical link for active-active ports Signed-off-by: Longxiang Lyu --- ansible/templates/minigraph_png.j2 | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/ansible/templates/minigraph_png.j2 b/ansible/templates/minigraph_png.j2 index e93c40c83f..430fc8e9d7 100644 --- a/ansible/templates/minigraph_png.j2 +++ b/ansible/templates/minigraph_png.j2 @@ -44,7 +44,10 @@ {% endfor %} {% if 'dualtor' in topo %} {% set cable_position = 'U' if inventory_hostname == dual_tor_facts['positions']['upper'] else 'L' %} +{% set mux_cable_facts = dual_tor_facts['mux_cable_facts'] if 'mux_cable_facts' in dual_tor_facts %} {% for cable in dual_tor_facts['cables'] %} +{% set intf_index = port_alias.index(cable['dut_intf'])|string %} +{% if mux_cable_facts is not defined or mux_cable_facts[intf_index]['cable_type'] == 'active-standby' %} LogicalLink {{ inventory_hostname }} @@ -52,6 +55,7 @@ {{ cable['hostname'] }} {{ cable_position }} +{% endif %} {% endfor %} {% endif %} {% endif %} @@ -139,21 +143,12 @@ {% set server_base_address_v6 = (vlan_configs.values() | list)[0]['prefix_v6'] %} {% set server_base_address_v6 = server_base_address_v6 | ipaddr('network') %} {% set server_base_address_v6 = ':'.join(server_base_address_v6.split(':')[:-1]) + ':{:x}' %} -{% set mux_cable_facts = dual_tor_facts['mux_cable_facts'] if 'mux_cable_facts' in dual_tor_facts %} {% for cable in dual_tor_facts['cables'] %} -{% set intf_index = port_alias.index(cable['dut_intf'])|string %} SmartCable -{% if mux_cable_facts is defined %} - {{ mux_cable_facts[intf_index]['cable_type'] }} -
- {{ mux_cable_facts[intf_index]['soc_ipv4'] if 'soc_ipv4' in mux_cable_facts[intf_index] else '0.0.0.0/0' }} -
-{% else %}
0.0.0.0/0
-{% endif %} ::/0 @@ -168,21 +163,12 @@
Server -{% if mux_cable_facts is defined %} -
- {{ mux_cable_facts[intf_index]['server_ipv4'] }} -
- - {{ mux_cable_facts[intf_index]['server_ipv6'] }} - -{% else %}
{{ server_base_address_v4.format(loop.index + 1) }}/26
{{ server_base_address_v6.format(loop.index + 1) }}/96 -{% endif %} 0.0.0.0/0