From d42ae436853b5ab706124a6fab6d88017febe2c9 Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Wed, 21 Oct 2020 21:52:52 -0700 Subject: [PATCH 1/8] Add verification IPv4 address on LLDP conf Jinja2 Template Signed-off-by: Petro Bratash --- dockers/docker-lldp/lldpd.conf.j2 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dockers/docker-lldp/lldpd.conf.j2 b/dockers/docker-lldp/lldpd.conf.j2 index 421400037bbf..6ebc6b44825f 100644 --- a/dockers/docker-lldp/lldpd.conf.j2 +++ b/dockers/docker-lldp/lldpd.conf.j2 @@ -1,12 +1,19 @@ +{% set mgmt_if = {} %} {% if MGMT_INTERFACE %} +{% for interface in MGMT_INTERFACE.keys()|list %} +{% if not ':' in interface[1] %} +{% if mgmt_if.update({'port_name' : interface[0]}) %} {% endif %} +{% if mgmt_if.update({'ipv4' : interface[1].split('/')[0]}) %} {% endif %} +{% endif %} +{% endfor %} +{% endif %} +{% if mgmt_if %} {# If MGMT port alias is available, use it for port ID subtype, otherwise use port name #} -{% set mgmt_port_name = (MGMT_INTERFACE.keys()|list)[0][0] %} -{% set ipv4 = (MGMT_INTERFACE.keys()|list)[0][1].split('/')[0] %} -{% if MGMT_PORT and MGMT_PORT[mgmt_port_name] and MGMT_PORT[mgmt_port_name].alias %} -configure ports eth0 lldp portidsubtype local {{ MGMT_PORT[mgmt_port_name].alias }} +{% if MGMT_PORT and MGMT_PORT[mgmt_if.port_name] and MGMT_PORT[mgmt_if.port_name].alias %} +configure ports eth0 lldp portidsubtype local {{ MGMT_PORT[mgmt_if.port_name].alias }} {% else %} -configure ports eth0 lldp portidsubtype local {{ mgmt_port_name }} +configure ports eth0 lldp portidsubtype local {{ mgmt_if.port_name }} {% endif %} -configure system ip management pattern {{ ipv4 }} +configure system ip management pattern {{ mgmt_if.ipv4 }} {% endif %} configure system hostname {{ DEVICE_METADATA['localhost']['hostname'] }} From bda9e7dab162f15591d28c6404d2867197d8dbcf Mon Sep 17 00:00:00 2001 From: Petro Bratash <68950226+bratashX@users.noreply.github.com> Date: Fri, 23 Oct 2020 12:31:50 +0300 Subject: [PATCH 2/8] Code improvement --- dockers/docker-lldp/lldpd.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-lldp/lldpd.conf.j2 b/dockers/docker-lldp/lldpd.conf.j2 index 6ebc6b44825f..25c8228bb219 100644 --- a/dockers/docker-lldp/lldpd.conf.j2 +++ b/dockers/docker-lldp/lldpd.conf.j2 @@ -1,7 +1,7 @@ {% set mgmt_if = {} %} {% if MGMT_INTERFACE %} {% for interface in MGMT_INTERFACE.keys()|list %} -{% if not ':' in interface[1] %} +{% if interface[1]|ipv4 %} {% if mgmt_if.update({'port_name' : interface[0]}) %} {% endif %} {% if mgmt_if.update({'ipv4' : interface[1].split('/')[0]}) %} {% endif %} {% endif %} From ad2001f972e27034b876a79c6108f47420544bf5 Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Wed, 28 Oct 2020 20:43:58 -0700 Subject: [PATCH 3/8] Fix config file for correct work test_j2files.py(test_lldp) Signed-off-by: Petro Bratash --- src/sonic-config-engine/tests/t0-sample-graph.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index 237a2ff0f532..de3013d9f402 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -191,17 +191,17 @@ HostIP eth0 - 10.0.0.100/24 + 2603:10e2:0:2902::8/64 - 10.0.0.100/24 + 2603:10e2:0:2902::8/64 HostIP eth0 - 2603:10e2:0:2902::8/64 + 10.0.0.100/24 - 2603:10e2:0:2902::8/64 + 10.0.0.100/24 From de774cba9e79ee592f1127c95dd9fbcff03095dc Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Thu, 29 Oct 2020 16:02:19 -0700 Subject: [PATCH 4/8] Revert "Fix config file for correct work test_j2files.py(test_lldp)" This reverts commit ad2001f972e27034b876a79c6108f47420544bf5. --- src/sonic-config-engine/tests/t0-sample-graph.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index de3013d9f402..237a2ff0f532 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -191,17 +191,17 @@ HostIP eth0 - 2603:10e2:0:2902::8/64 + 10.0.0.100/24 - 2603:10e2:0:2902::8/64 + 10.0.0.100/24 HostIP eth0 - 10.0.0.100/24 + 2603:10e2:0:2902::8/64 - 10.0.0.100/24 + 2603:10e2:0:2902::8/64 From ad58479f185f31de8241c36d8f8142e53113ba31 Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Thu, 5 Nov 2020 00:46:08 -0800 Subject: [PATCH 5/8] Add test for lldp.conf Signed-off-by: Petro Bratash --- .../tests/sample_output/py2/lldpd_conf | 1 + .../lldp_conf/lldpd-ipv4-iface.conf} | 2 +- .../py3/lldp_conf/lldpd-ipv6-iface.conf | 2 + .../tests/sample_output/py3/lldpd.conf | 4 - .../tests/t0-sample-graph-ipv6-mgmt-iface.xml | 470 ++++++++++++++++++ src/sonic-config-engine/tests/test_j2files.py | 10 +- 6 files changed, 483 insertions(+), 6 deletions(-) create mode 120000 src/sonic-config-engine/tests/sample_output/py2/lldpd_conf rename src/sonic-config-engine/tests/sample_output/{py2/lldpd.conf => py3/lldp_conf/lldpd-ipv4-iface.conf} (95%) create mode 100644 src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf delete mode 100644 src/sonic-config-engine/tests/sample_output/py3/lldpd.conf create mode 100644 src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml diff --git a/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf b/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf new file mode 120000 index 000000000000..6f7640d43678 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf @@ -0,0 +1 @@ +../py3/lldp_conf \ No newline at end of file diff --git a/src/sonic-config-engine/tests/sample_output/py2/lldpd.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf similarity index 95% rename from src/sonic-config-engine/tests/sample_output/py2/lldpd.conf rename to src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf index c9cb2c8123dd..8d1457a6d401 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/lldpd.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf @@ -1,4 +1,4 @@ configure ports eth0 lldp portidsubtype local eth0 configure system ip management pattern 10.0.0.100 configure system hostname switch-t0 -pause +pause \ No newline at end of file diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf new file mode 100644 index 000000000000..175055c4f9d1 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf @@ -0,0 +1,2 @@ +configure system hostname switch-t0 +pause \ No newline at end of file diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldpd.conf b/src/sonic-config-engine/tests/sample_output/py3/lldpd.conf deleted file mode 100644 index c9cb2c8123dd..000000000000 --- a/src/sonic-config-engine/tests/sample_output/py3/lldpd.conf +++ /dev/null @@ -1,4 +0,0 @@ -configure ports eth0 lldp portidsubtype local eth0 -configure system ip management pattern 10.0.0.100 -configure system hostname switch-t0 -pause diff --git a/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml b/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml new file mode 100644 index 000000000000..141201c74a0d --- /dev/null +++ b/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml @@ -0,0 +1,470 @@ + + + + + + switch-t0 + 10.1.0.32 + BGPMonitor + 10.20.30.40 + 30 + 10 + 3 + + + false + switch-t0 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 180 + 60 + + + switch-t0 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 180 + 60 + + + switch-t0 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 180 + 60 + + + switch-t0 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 180 + 60 + + + switch-t0 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 180 + 60 + + + + + 0 + + BGPMonitor + + + BGPPeer +
10.1.0.32
+ + + +
+
+ +
+ + 65100 + switch-t0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + LoopbackIP1 + Loopback1 + + 10.10.0.99/32 + + 10.10.0.99/32 + + + + + HostIP + eth0 + + 2603:10e2:0:2902::8/64 + + 2603:10e2:0:2902::8/64 + + + + + + + switch-t0 + + + PortChannel01 + fortyGigE0/112 + + + + PortChannel02 + fortyGigE0/116 + + + + PortChannel03 + fortyGigE0/120 + + + + PortChannel04 + fortyGigE0/124 + + + + + + Vlan1000 + fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 + False + 0.0.0.0/0 + + 192.0.0.1;192.0.0.2 + 1000 + 1000 + 192.168.0.0/27 + + + + + + PortChannel01 + 10.0.0.56/31 + + + + PortChannel01 + FC00::71/126 + + + + PortChannel02 + 10.0.0.58/31 + + + + PortChannel02 + FC00::75/126 + + + + PortChannel03 + 10.0.0.60/31 + + + + PortChannel03 + FC00::79/126 + + + + PortChannel04 + 10.0.0.62/31 + + + + PortChannel04 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/27 + + + + + + ERSPAN + everflow + Everflow + + + ERSPANv6 + everflowV6 + Everflow + + + EGRESS_ERSPAN + everflow_egress + Everflow + + + PortChannel01;PortChannel02;PortChannel03;PortChannel04 + DataAclIngress + DataPlane + + + PortChannel01;PortChannel02 + DataAclEgress + DataPlane + + + SNMP + SNMP_ACL + SNMP + + + NTP + NTP_ACL + NTP + + + SSH + SSH_ACL + SSH + + + SSH + ROUTER-PROTECT + SSH + + + SNMP + ROUTER-PROTECT + SNMP + + + NTP + NTP_ACL + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1/1 + switch-t0 + fortyGigE0/112 + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1/1 + switch-t0 + fortyGigE0/116 + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1/1 + switch-t0 + fortyGigE0/120 + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1/1 + switch-t0 + fortyGigE0/124 + 100000 + + + DeviceInterfaceLink + true + 100000 + switch-t0 + fortyGigE0/4 + true + ARISTA05T1 + Ethernet1/33 + true + + + DeviceInterfaceLink + Servers0 + eth0 + switch-t0 + fortyGigE0/4 + + + DeviceInterfaceLink + Servers100 + eth0 + switch-t0 + fortyGigE0/100 + + + + + switch-t0 + Force10-S6000 + + + ARISTA01T1 + Arista + + + ARISTA02T1 + Arista + + + ARISTA03T1 + Arista + + + ARISTA04T1 + Arista + + + + + + + switch-t0 + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + + + + + + + + + + + FECDisabled + + True + + + ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4 + + + + + + FECDisabled + + True + + + ARISTA06T1:Ethernet1/34;switch-t0:fortyGigE0/8 + + + + switch-t0 + Force10-S6000 +
diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 2dec13425e19..4657de1309b4 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -14,6 +14,7 @@ def setUp(self): self.script_file = utils.PYTHON_INTERPRETTER + ' ' + os.path.join(self.test_dir, '..', 'sonic-cfggen') self.simple_minigraph = os.path.join(self.test_dir, 'simple-sample-graph.xml') self.t0_minigraph = os.path.join(self.test_dir, 't0-sample-graph.xml') + self.t0_minigraph_ipv6_mgmt_iface = os.path.join(self.test_dir, 't0-sample-graph-ipv6-mgmt-iface.xml') self.t0_mvrf_minigraph = os.path.join(self.test_dir, 't0-sample-graph-mvrf.xml') self.pc_minigraph = os.path.join(self.test_dir, 'pc-test-graph.xml') self.t0_port_config = os.path.join(self.test_dir, 't0-sample-port-config.ini') @@ -68,9 +69,16 @@ def test_dhcp_relay(self): def test_lldp(self): lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-lldp', 'lldpd.conf.j2') + + # Test generation of lldpd.conf if management interface IPv4 exist argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file self.run_script(argument) - self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldpd.conf'), self.output_file)) + self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf'), self.output_file)) + + # Test generation of lldpd.conf if Management interface IPv4 doesn't exist (IPv6 only) + argument = '-m ' + self.t0_minigraph_ipv6_mgmt_iface + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file + self.run_script(argument) + self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv6-iface.conf'), self.output_file)) def test_bgpd_quagga(self): conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2') From 0e81cc3a24260a27a1db9f158f696cf7c6dac0d4 Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Thu, 5 Nov 2020 03:08:12 -0800 Subject: [PATCH 6/8] Code refactoring Signed-off-by: Petro Bratash --- dockers/docker-lldp/lldpd.conf.j2 | 8 ++++---- .../sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf | 2 +- .../sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dockers/docker-lldp/lldpd.conf.j2 b/dockers/docker-lldp/lldpd.conf.j2 index c49234a22006..904784ef67b1 100644 --- a/dockers/docker-lldp/lldpd.conf.j2 +++ b/dockers/docker-lldp/lldpd.conf.j2 @@ -1,9 +1,9 @@ {% set mgmt_if = {} %} {% if MGMT_INTERFACE %} -{% for interface in MGMT_INTERFACE.keys()|list %} -{% if interface[1]|ipv4 %} -{% if mgmt_if.update({'port_name' : interface[0]}) %} {% endif %} -{% if mgmt_if.update({'ipv4' : interface[1].split('/')[0]}) %} {% endif %} +{% for (mgmt_name, mgmt_prefix) in MGMT_INTERFACE|pfx_filter %} +{% if mgmt_prefix|ipv4 %} +{% if mgmt_if.update({'port_name' : mgmt_name}) %} {% endif %} +{% if mgmt_if.update({'ipv4' : mgmt_prefix|ip}) %} {% endif %} {% endif %} {% endfor %} {% endif %} diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf index 8d1457a6d401..c9cb2c8123dd 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf @@ -1,4 +1,4 @@ configure ports eth0 lldp portidsubtype local eth0 configure system ip management pattern 10.0.0.100 configure system hostname switch-t0 -pause \ No newline at end of file +pause diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf index 175055c4f9d1..f5727556fdf3 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf @@ -1,2 +1,2 @@ configure system hostname switch-t0 -pause \ No newline at end of file +pause From 84649389837f513a034f5dc68bcde34a7409927a Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Thu, 5 Nov 2020 18:13:23 -0800 Subject: [PATCH 7/8] Add new case to test_lldp and remove link to output files Signed-off-by: Petro Bratash --- .../py2/lldp_conf/lldpd-ipv4-iface.conf | 4 + .../py2/lldp_conf/lldpd-ipv6-iface.conf | 2 + .../tests/sample_output/py2/lldpd_conf | 1 - .../tests/t0-sample-graph-ipv4-mgmt-iface.xml | 470 ++++++++++++++++++ src/sonic-config-engine/tests/test_j2files.py | 10 +- 5 files changed, 484 insertions(+), 3 deletions(-) create mode 100644 src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv4-iface.conf create mode 100644 src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv6-iface.conf delete mode 120000 src/sonic-config-engine/tests/sample_output/py2/lldpd_conf create mode 100644 src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml diff --git a/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv4-iface.conf b/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv4-iface.conf new file mode 100644 index 000000000000..c9cb2c8123dd --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv4-iface.conf @@ -0,0 +1,4 @@ +configure ports eth0 lldp portidsubtype local eth0 +configure system ip management pattern 10.0.0.100 +configure system hostname switch-t0 +pause diff --git a/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv6-iface.conf b/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv6-iface.conf new file mode 100644 index 000000000000..f5727556fdf3 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/lldp_conf/lldpd-ipv6-iface.conf @@ -0,0 +1,2 @@ +configure system hostname switch-t0 +pause diff --git a/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf b/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf deleted file mode 120000 index 6f7640d43678..000000000000 --- a/src/sonic-config-engine/tests/sample_output/py2/lldpd_conf +++ /dev/null @@ -1 +0,0 @@ -../py3/lldp_conf \ No newline at end of file diff --git a/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml b/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml new file mode 100644 index 000000000000..5c1e9e851708 --- /dev/null +++ b/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml @@ -0,0 +1,470 @@ + + + + + + switch-t0 + 10.1.0.32 + BGPMonitor + 10.20.30.40 + 30 + 10 + 3 + + + false + switch-t0 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 180 + 60 + + + switch-t0 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 180 + 60 + + + switch-t0 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 180 + 60 + + + switch-t0 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 180 + 60 + + + switch-t0 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 180 + 60 + + + + + 0 + + BGPMonitor + + + BGPPeer +
10.1.0.32
+ + + +
+
+ +
+ + 65100 + switch-t0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + LoopbackIP1 + Loopback1 + + 10.10.0.99/32 + + 10.10.0.99/32 + + + + + HostIP + eth0 + + 10.0.0.100/24 + + 10.0.0.100/24 + + + + + + + switch-t0 + + + PortChannel01 + fortyGigE0/112 + + + + PortChannel02 + fortyGigE0/116 + + + + PortChannel03 + fortyGigE0/120 + + + + PortChannel04 + fortyGigE0/124 + + + + + + Vlan1000 + fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 + False + 0.0.0.0/0 + + 192.0.0.1;192.0.0.2 + 1000 + 1000 + 192.168.0.0/27 + + + + + + PortChannel01 + 10.0.0.56/31 + + + + PortChannel01 + FC00::71/126 + + + + PortChannel02 + 10.0.0.58/31 + + + + PortChannel02 + FC00::75/126 + + + + PortChannel03 + 10.0.0.60/31 + + + + PortChannel03 + FC00::79/126 + + + + PortChannel04 + 10.0.0.62/31 + + + + PortChannel04 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/27 + + + + + + ERSPAN + everflow + Everflow + + + ERSPANv6 + everflowV6 + Everflow + + + EGRESS_ERSPAN + everflow_egress + Everflow + + + PortChannel01;PortChannel02;PortChannel03;PortChannel04 + DataAclIngress + DataPlane + + + PortChannel01;PortChannel02 + DataAclEgress + DataPlane + + + SNMP + SNMP_ACL + SNMP + + + NTP + NTP_ACL + NTP + + + SSH + SSH_ACL + SSH + + + SSH + ROUTER-PROTECT + SSH + + + SNMP + ROUTER-PROTECT + SNMP + + + NTP + NTP_ACL + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1/1 + switch-t0 + fortyGigE0/112 + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1/1 + switch-t0 + fortyGigE0/116 + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1/1 + switch-t0 + fortyGigE0/120 + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1/1 + switch-t0 + fortyGigE0/124 + 100000 + + + DeviceInterfaceLink + true + 100000 + switch-t0 + fortyGigE0/4 + true + ARISTA05T1 + Ethernet1/33 + true + + + DeviceInterfaceLink + Servers0 + eth0 + switch-t0 + fortyGigE0/4 + + + DeviceInterfaceLink + Servers100 + eth0 + switch-t0 + fortyGigE0/100 + + + + + switch-t0 + Force10-S6000 + + + ARISTA01T1 + Arista + + + ARISTA02T1 + Arista + + + ARISTA03T1 + Arista + + + ARISTA04T1 + Arista + + + + + + + switch-t0 + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + + + + + + + + + + + FECDisabled + + True + + + ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4 + + + + + + FECDisabled + + True + + + ARISTA06T1:Ethernet1/34;switch-t0:fortyGigE0/8 + + + + switch-t0 + Force10-S6000 +
diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 4657de1309b4..ac2856db9170 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -14,6 +14,7 @@ def setUp(self): self.script_file = utils.PYTHON_INTERPRETTER + ' ' + os.path.join(self.test_dir, '..', 'sonic-cfggen') self.simple_minigraph = os.path.join(self.test_dir, 'simple-sample-graph.xml') self.t0_minigraph = os.path.join(self.test_dir, 't0-sample-graph.xml') + self.t0_minigraph_ipv4_mgmt_iface = os.path.join(self.test_dir, 't0-sample-graph-ipv4-mgmt-iface.xml') self.t0_minigraph_ipv6_mgmt_iface = os.path.join(self.test_dir, 't0-sample-graph-ipv6-mgmt-iface.xml') self.t0_mvrf_minigraph = os.path.join(self.test_dir, 't0-sample-graph-mvrf.xml') self.pc_minigraph = os.path.join(self.test_dir, 'pc-test-graph.xml') @@ -70,12 +71,17 @@ def test_dhcp_relay(self): def test_lldp(self): lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-lldp', 'lldpd.conf.j2') - # Test generation of lldpd.conf if management interface IPv4 exist + # Test generation of lldpd.conf if IPv4 and IPv6 management interfaces exist argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file self.run_script(argument) self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf'), self.output_file)) - # Test generation of lldpd.conf if Management interface IPv4 doesn't exist (IPv6 only) + # Test generation of lldpd.conf if management interface IPv4 only exist + argument = '-m ' + self.t0_minigraph_ipv4_mgmt_iface + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file + self.run_script(argument) + self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf'), self.output_file)) + + # Test generation of lldpd.conf if Management interface IPv6 only exist argument = '-m ' + self.t0_minigraph_ipv6_mgmt_iface + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file self.run_script(argument) self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv6-iface.conf'), self.output_file)) From 3281d2fd922873c4de043ead83ed73b92644677a Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Thu, 5 Nov 2020 21:42:24 -0800 Subject: [PATCH 8/8] Use json-file instead of minigraph Signed-off-by: Petro Bratash --- .../tests/data/lldp/mgmt_iface_ipv4.json | 12 + .../data/lldp/mgmt_iface_ipv4_and_ipv6.json | 15 + .../tests/data/lldp/mgmt_iface_ipv6.json | 12 + .../tests/t0-sample-graph-ipv4-mgmt-iface.xml | 470 ------------------ .../tests/t0-sample-graph-ipv6-mgmt-iface.xml | 470 ------------------ src/sonic-config-engine/tests/test_j2files.py | 21 +- 6 files changed, 52 insertions(+), 948 deletions(-) create mode 100644 src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4.json create mode 100644 src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4_and_ipv6.json create mode 100644 src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv6.json delete mode 100644 src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml delete mode 100644 src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml diff --git a/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4.json b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4.json new file mode 100644 index 000000000000..c38b677aad7a --- /dev/null +++ b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4.json @@ -0,0 +1,12 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hostname": "switch-t0" + } + }, + "MGMT_INTERFACE": { + "eth0|10.0.0.100/24": { + "gwaddr": "10.0.0.100" + } + } +} diff --git a/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4_and_ipv6.json b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4_and_ipv6.json new file mode 100644 index 000000000000..87f887fb870d --- /dev/null +++ b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv4_and_ipv6.json @@ -0,0 +1,15 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hostname": "switch-t0" + } + }, + "MGMT_INTERFACE": { + "eth0|10.0.0.100/24": { + "gwaddr": "10.0.0.100" + }, + "eth0|2603:10e2:0:2902::8/64": { + "gwaddr": "2603:10e2:0:2902::8" + } + } +} diff --git a/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv6.json b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv6.json new file mode 100644 index 000000000000..c1dd4964c6bf --- /dev/null +++ b/src/sonic-config-engine/tests/data/lldp/mgmt_iface_ipv6.json @@ -0,0 +1,12 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hostname": "switch-t0" + } + }, + "MGMT_INTERFACE": { + "eth0|2603:10e2:0:2902::8/64": { + "gwaddr": "2603:10e2:0:2902::8" + } + } +} diff --git a/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml b/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml deleted file mode 100644 index 5c1e9e851708..000000000000 --- a/src/sonic-config-engine/tests/t0-sample-graph-ipv4-mgmt-iface.xml +++ /dev/null @@ -1,470 +0,0 @@ - - - - - - switch-t0 - 10.1.0.32 - BGPMonitor - 10.20.30.40 - 30 - 10 - 3 - - - false - switch-t0 - 10.0.0.56 - ARISTA01T1 - 10.0.0.57 - 1 - 180 - 60 - - - switch-t0 - FC00::71 - ARISTA01T1 - FC00::72 - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.58 - ARISTA02T1 - 10.0.0.59 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.60 - ARISTA03T1 - 10.0.0.61 - 1 - 180 - 60 - - - switch-t0 - FC00::79 - ARISTA03T1 - FC00::7A - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.62 - ARISTA04T1 - 10.0.0.63 - 1 - 180 - 60 - - - switch-t0 - FC00::7D - ARISTA04T1 - FC00::7E - 1 - 180 - 60 - - - - - 0 - - BGPMonitor - - - BGPPeer -
10.1.0.32
- - - -
-
- -
- - 65100 - switch-t0 - - -
10.0.0.57
- - - -
- -
10.0.0.59
- - - -
- -
10.0.0.61
- - - -
- -
10.0.0.63
- - - -
-
- -
- - 64600 - ARISTA01T1 - - - - 64600 - ARISTA02T1 - - - - 64600 - ARISTA03T1 - - - - 64600 - ARISTA04T1 - - -
-
- - - - - - HostIP - Loopback0 - - 10.1.0.32/32 - - 10.1.0.32/32 - - - HostIP1 - Loopback0 - - FC00:1::32/128 - - FC00:1::32/128 - - - LoopbackIP1 - Loopback1 - - 10.10.0.99/32 - - 10.10.0.99/32 - - - - - HostIP - eth0 - - 10.0.0.100/24 - - 10.0.0.100/24 - - - - - - - switch-t0 - - - PortChannel01 - fortyGigE0/112 - - - - PortChannel02 - fortyGigE0/116 - - - - PortChannel03 - fortyGigE0/120 - - - - PortChannel04 - fortyGigE0/124 - - - - - - Vlan1000 - fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 - False - 0.0.0.0/0 - - 192.0.0.1;192.0.0.2 - 1000 - 1000 - 192.168.0.0/27 - - - - - - PortChannel01 - 10.0.0.56/31 - - - - PortChannel01 - FC00::71/126 - - - - PortChannel02 - 10.0.0.58/31 - - - - PortChannel02 - FC00::75/126 - - - - PortChannel03 - 10.0.0.60/31 - - - - PortChannel03 - FC00::79/126 - - - - PortChannel04 - 10.0.0.62/31 - - - - PortChannel04 - FC00::7D/126 - - - - Vlan1000 - 192.168.0.1/27 - - - - - - ERSPAN - everflow - Everflow - - - ERSPANv6 - everflowV6 - Everflow - - - EGRESS_ERSPAN - everflow_egress - Everflow - - - PortChannel01;PortChannel02;PortChannel03;PortChannel04 - DataAclIngress - DataPlane - - - PortChannel01;PortChannel02 - DataAclEgress - DataPlane - - - SNMP - SNMP_ACL - SNMP - - - NTP - NTP_ACL - NTP - - - SSH - SSH_ACL - SSH - - - SSH - ROUTER-PROTECT - SSH - - - SNMP - ROUTER-PROTECT - SNMP - - - NTP - NTP_ACL - - - - - - - - - - DeviceInterfaceLink - ARISTA01T1 - Ethernet1/1 - switch-t0 - fortyGigE0/112 - - - DeviceInterfaceLink - ARISTA02T1 - Ethernet1/1 - switch-t0 - fortyGigE0/116 - - - DeviceInterfaceLink - ARISTA03T1 - Ethernet1/1 - switch-t0 - fortyGigE0/120 - - - DeviceInterfaceLink - ARISTA04T1 - Ethernet1/1 - switch-t0 - fortyGigE0/124 - 100000 - - - DeviceInterfaceLink - true - 100000 - switch-t0 - fortyGigE0/4 - true - ARISTA05T1 - Ethernet1/33 - true - - - DeviceInterfaceLink - Servers0 - eth0 - switch-t0 - fortyGigE0/4 - - - DeviceInterfaceLink - Servers100 - eth0 - switch-t0 - fortyGigE0/100 - - - - - switch-t0 - Force10-S6000 - - - ARISTA01T1 - Arista - - - ARISTA02T1 - Arista - - - ARISTA03T1 - Arista - - - ARISTA04T1 - Arista - - - - - - - switch-t0 - - - ErspanDestinationIpv4 - - 2.2.2.2 - - - - - - - - - - - - - FECDisabled - - True - - - ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4 - - - - - - FECDisabled - - True - - - ARISTA06T1:Ethernet1/34;switch-t0:fortyGigE0/8 - - - - switch-t0 - Force10-S6000 -
diff --git a/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml b/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml deleted file mode 100644 index 141201c74a0d..000000000000 --- a/src/sonic-config-engine/tests/t0-sample-graph-ipv6-mgmt-iface.xml +++ /dev/null @@ -1,470 +0,0 @@ - - - - - - switch-t0 - 10.1.0.32 - BGPMonitor - 10.20.30.40 - 30 - 10 - 3 - - - false - switch-t0 - 10.0.0.56 - ARISTA01T1 - 10.0.0.57 - 1 - 180 - 60 - - - switch-t0 - FC00::71 - ARISTA01T1 - FC00::72 - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.58 - ARISTA02T1 - 10.0.0.59 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.60 - ARISTA03T1 - 10.0.0.61 - 1 - 180 - 60 - - - switch-t0 - FC00::79 - ARISTA03T1 - FC00::7A - 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.62 - ARISTA04T1 - 10.0.0.63 - 1 - 180 - 60 - - - switch-t0 - FC00::7D - ARISTA04T1 - FC00::7E - 1 - 180 - 60 - - - - - 0 - - BGPMonitor - - - BGPPeer -
10.1.0.32
- - - -
-
- -
- - 65100 - switch-t0 - - -
10.0.0.57
- - - -
- -
10.0.0.59
- - - -
- -
10.0.0.61
- - - -
- -
10.0.0.63
- - - -
-
- -
- - 64600 - ARISTA01T1 - - - - 64600 - ARISTA02T1 - - - - 64600 - ARISTA03T1 - - - - 64600 - ARISTA04T1 - - -
-
- - - - - - HostIP - Loopback0 - - 10.1.0.32/32 - - 10.1.0.32/32 - - - HostIP1 - Loopback0 - - FC00:1::32/128 - - FC00:1::32/128 - - - LoopbackIP1 - Loopback1 - - 10.10.0.99/32 - - 10.10.0.99/32 - - - - - HostIP - eth0 - - 2603:10e2:0:2902::8/64 - - 2603:10e2:0:2902::8/64 - - - - - - - switch-t0 - - - PortChannel01 - fortyGigE0/112 - - - - PortChannel02 - fortyGigE0/116 - - - - PortChannel03 - fortyGigE0/120 - - - - PortChannel04 - fortyGigE0/124 - - - - - - Vlan1000 - fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 - False - 0.0.0.0/0 - - 192.0.0.1;192.0.0.2 - 1000 - 1000 - 192.168.0.0/27 - - - - - - PortChannel01 - 10.0.0.56/31 - - - - PortChannel01 - FC00::71/126 - - - - PortChannel02 - 10.0.0.58/31 - - - - PortChannel02 - FC00::75/126 - - - - PortChannel03 - 10.0.0.60/31 - - - - PortChannel03 - FC00::79/126 - - - - PortChannel04 - 10.0.0.62/31 - - - - PortChannel04 - FC00::7D/126 - - - - Vlan1000 - 192.168.0.1/27 - - - - - - ERSPAN - everflow - Everflow - - - ERSPANv6 - everflowV6 - Everflow - - - EGRESS_ERSPAN - everflow_egress - Everflow - - - PortChannel01;PortChannel02;PortChannel03;PortChannel04 - DataAclIngress - DataPlane - - - PortChannel01;PortChannel02 - DataAclEgress - DataPlane - - - SNMP - SNMP_ACL - SNMP - - - NTP - NTP_ACL - NTP - - - SSH - SSH_ACL - SSH - - - SSH - ROUTER-PROTECT - SSH - - - SNMP - ROUTER-PROTECT - SNMP - - - NTP - NTP_ACL - - - - - - - - - - DeviceInterfaceLink - ARISTA01T1 - Ethernet1/1 - switch-t0 - fortyGigE0/112 - - - DeviceInterfaceLink - ARISTA02T1 - Ethernet1/1 - switch-t0 - fortyGigE0/116 - - - DeviceInterfaceLink - ARISTA03T1 - Ethernet1/1 - switch-t0 - fortyGigE0/120 - - - DeviceInterfaceLink - ARISTA04T1 - Ethernet1/1 - switch-t0 - fortyGigE0/124 - 100000 - - - DeviceInterfaceLink - true - 100000 - switch-t0 - fortyGigE0/4 - true - ARISTA05T1 - Ethernet1/33 - true - - - DeviceInterfaceLink - Servers0 - eth0 - switch-t0 - fortyGigE0/4 - - - DeviceInterfaceLink - Servers100 - eth0 - switch-t0 - fortyGigE0/100 - - - - - switch-t0 - Force10-S6000 - - - ARISTA01T1 - Arista - - - ARISTA02T1 - Arista - - - ARISTA03T1 - Arista - - - ARISTA04T1 - Arista - - - - - - - switch-t0 - - - ErspanDestinationIpv4 - - 2.2.2.2 - - - - - - - - - - - - - FECDisabled - - True - - - ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4 - - - - - - FECDisabled - - True - - - ARISTA06T1:Ethernet1/34;switch-t0:fortyGigE0/8 - - - - switch-t0 - Force10-S6000 -
diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index ac2856db9170..e59cb010ef79 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -14,8 +14,6 @@ def setUp(self): self.script_file = utils.PYTHON_INTERPRETTER + ' ' + os.path.join(self.test_dir, '..', 'sonic-cfggen') self.simple_minigraph = os.path.join(self.test_dir, 'simple-sample-graph.xml') self.t0_minigraph = os.path.join(self.test_dir, 't0-sample-graph.xml') - self.t0_minigraph_ipv4_mgmt_iface = os.path.join(self.test_dir, 't0-sample-graph-ipv4-mgmt-iface.xml') - self.t0_minigraph_ipv6_mgmt_iface = os.path.join(self.test_dir, 't0-sample-graph-ipv6-mgmt-iface.xml') self.t0_mvrf_minigraph = os.path.join(self.test_dir, 't0-sample-graph-mvrf.xml') self.pc_minigraph = os.path.join(self.test_dir, 'pc-test-graph.xml') self.t0_port_config = os.path.join(self.test_dir, 't0-sample-port-config.ini') @@ -71,20 +69,27 @@ def test_dhcp_relay(self): def test_lldp(self): lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-lldp', 'lldpd.conf.j2') + expected_mgmt_ipv4 = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf') + expected_mgmt_ipv6 = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv6-iface.conf') + expected_mgmt_ipv4_and_ipv6 = expected_mgmt_ipv4 + # Test generation of lldpd.conf if IPv4 and IPv6 management interfaces exist - argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file + mgmt_iface_ipv4_and_ipv6_json = os.path.join(self.test_dir, "data", "lldp", "mgmt_iface_ipv4_and_ipv6.json") + argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv4_and_ipv6_json, lldpd_conf_template, self.output_file) self.run_script(argument) - self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf'), self.output_file)) + self.assertTrue(filecmp.cmp(expected_mgmt_ipv4_and_ipv6, self.output_file)) # Test generation of lldpd.conf if management interface IPv4 only exist - argument = '-m ' + self.t0_minigraph_ipv4_mgmt_iface + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file + mgmt_iface_ipv4_json = os.path.join(self.test_dir, "data", "lldp", "mgmt_iface_ipv4.json") + argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv4_json, lldpd_conf_template, self.output_file) self.run_script(argument) - self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv4-iface.conf'), self.output_file)) + self.assertTrue(filecmp.cmp(expected_mgmt_ipv4, self.output_file)) # Test generation of lldpd.conf if Management interface IPv6 only exist - argument = '-m ' + self.t0_minigraph_ipv6_mgmt_iface + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file + mgmt_iface_ipv6_json = os.path.join(self.test_dir, "data", "lldp", "mgmt_iface_ipv6.json") + argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv6_json, lldpd_conf_template, self.output_file) self.run_script(argument) - self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'lldp_conf', 'lldpd-ipv6-iface.conf'), self.output_file)) + self.assertTrue(filecmp.cmp(expected_mgmt_ipv6, self.output_file)) def test_bgpd_quagga(self): conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2')