From c7d4947513caf0ceeb5f301daef3b4ce0d25cd06 Mon Sep 17 00:00:00 2001 From: maksymbelei95 <75987222+maksymbelei95@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:18:50 +0200 Subject: [PATCH] [show] Fix int status of LAGs, configured as Vlan members (#1478) Pass missed argument to function "appl_db_portchannel_status_get" in "intfutil" script to provide correct information in "Vlan" column of command "show int status" for LAG interfaces. - What I did Fixed status of LAG interfaces in Vlan column. LAG interfaces, configured as a Vlan member, should be seen as trunk interface. - How I did it Missed argument "self.combined_int_to_vlan_po_dict" passed to function "appl_db_portchannel_status_get" in "intfutil" script. - How to verify it admin@sonic:~$ show int status | grep PortChannel0011 Signed-off-by: Maksym Belei --- scripts/intfutil | 2 +- tests/intfutil_test.py | 2 +- tests/mock_tables/asic0/config_db.json | 6 + tests/mock_tables/config_db.json | 6 + tests/multi_asic_intfutil_test.py | 8 +- tests/vlan_test.py | 228 +++++++++++++------------ 6 files changed, 140 insertions(+), 112 deletions(-) diff --git a/scripts/intfutil b/scripts/intfutil index 4c25cb7eeed4..3a77338b3924 100755 --- a/scripts/intfutil +++ b/scripts/intfutil @@ -409,7 +409,7 @@ class IntfStatus(object): appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_MTU_STATUS, self.portchannel_speed_dict), appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_FEC, self.portchannel_speed_dict), appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_ALIAS, self.portchannel_speed_dict), - appl_db_portchannel_status_get(self.db, self.config_db, po, "vlan", self.portchannel_speed_dict), + appl_db_portchannel_status_get(self.db, self.config_db, po, "vlan", self.portchannel_speed_dict, self.combined_int_to_vlan_po_dict), appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_OPER_STATUS, self.portchannel_speed_dict), appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_ADMIN_STATUS, self.portchannel_speed_dict), appl_db_portchannel_status_get(self.db, self.config_db, po, PORT_OPTICS_TYPE, self.portchannel_speed_dict), diff --git a/tests/intfutil_test.py b/tests/intfutil_test.py index c607ff5b8ed3..c350c57e50a4 100644 --- a/tests/intfutil_test.py +++ b/tests/intfutil_test.py @@ -23,7 +23,7 @@ PortChannel0002 N/A 40G 9100 N/A N/A routed up up N/A N/A PortChannel0003 N/A 40G 9100 N/A N/A routed up up N/A N/A PortChannel0004 N/A 40G 9100 N/A N/A routed up up N/A N/A -PortChannel1001 N/A 40G 9100 N/A N/A routed N/A N/A N/A N/A +PortChannel1001 N/A 40G 9100 N/A N/A trunk N/A N/A N/A N/A """ show_interface_status_Ethernet32_output="""\ diff --git a/tests/mock_tables/asic0/config_db.json b/tests/mock_tables/asic0/config_db.json index cd7b49fd0aa1..14ee76aaa33d 100644 --- a/tests/mock_tables/asic0/config_db.json +++ b/tests/mock_tables/asic0/config_db.json @@ -176,5 +176,11 @@ "state": "enabled", "auto_restart": "enabled", "high_mem_alert": "disabled" + }, + "VLAN|Vlan1000": { + "vlanid": "1000" + }, + "VLAN_MEMBER|Vlan1000|PortChannel1002": { + "tagging_mode": "tagged" } } diff --git a/tests/mock_tables/config_db.json b/tests/mock_tables/config_db.json index dc951f977d74..14dec0192b3c 100644 --- a/tests/mock_tables/config_db.json +++ b/tests/mock_tables/config_db.json @@ -437,6 +437,9 @@ "VLAN|Vlan3000": { "vlanid": "3000" }, + "VLAN|Vlan4000": { + "vlanid": "4000" + }, "VLAN_INTERFACE|Vlan1000": { "NULL": "NULL" }, @@ -473,6 +476,9 @@ "VLAN_MEMBER|Vlan2000|Ethernet28": { "tagging_mode": "untagged" }, + "VLAN_MEMBER|Vlan4000|PortChannel1001": { + "tagging_mode": "tagged" + }, "PORTCHANNEL|PortChannel1001": { "admin_status": "up", "members@": "Ethernet32", diff --git a/tests/multi_asic_intfutil_test.py b/tests/multi_asic_intfutil_test.py index 6e1afb4cfab4..56e11fa0d3ed 100644 --- a/tests/multi_asic_intfutil_test.py +++ b/tests/multi_asic_intfutil_test.py @@ -19,7 +19,7 @@ Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off Ethernet-BP256 61,62,63,64 40G 9100 N/A Ethernet-BP256 PortChannel4009 up up N/A off Ethernet-BP260 57,58,59,60 40G 9100 N/A Ethernet-BP260 PortChannel4009 up up N/A off -PortChannel1002 N/A 80G 9100 N/A N/A routed up up N/A N/A +PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A PortChannel4009 N/A 80G 9100 N/A N/A routed up up N/A N/A """ @@ -28,7 +28,7 @@ --------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ---------- Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off -PortChannel1002 N/A 80G 9100 N/A N/A routed up up N/A N/A +PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A """ intf_status_asic0 = """\ @@ -36,7 +36,7 @@ --------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ---------- Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off -PortChannel1002 N/A 80G 9100 N/A N/A routed up up N/A N/A +PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A """ intf_status_asic0_all = """\ @@ -46,7 +46,7 @@ Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off -PortChannel1002 N/A 80G 9100 N/A N/A routed up up N/A N/A +PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A """ intf_description = """\ diff --git a/tests/vlan_test.py b/tests/vlan_test.py index f0559560daa6..d4832dc2cfd0 100644 --- a/tests/vlan_test.py +++ b/tests/vlan_test.py @@ -9,52 +9,58 @@ from utilities_common.db import Db show_vlan_brief_output="""\ -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+============+================+=======================+=============+ -| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | -| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | -| | | Ethernet12 | untagged | 192.0.0.3 | | -| | | Ethernet16 | untagged | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | +| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | +| | | Ethernet12 | untagged | 192.0.0.3 | | +| | | Ethernet16 | untagged | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ show_vlan_brief_in_alias_mode_output="""\ -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+=========+================+=======================+=============+ -| 1000 | 192.168.0.1/21 | etp2 | untagged | 192.0.0.1 | disabled | -| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | | -| | | etp4 | untagged | 192.0.0.3 | | -| | | etp5 | untagged | 192.0.0.4 | | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 1000 | 192.168.0.1/21 | etp2 | untagged | 192.0.0.1 | disabled | +| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | | +| | | etp4 | untagged | 192.0.0.3 | | +| | | etp5 | untagged | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ show_vlan_brief_empty_output="""\ -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+============+================+=======================+=============+ -| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ show_vlan_brief_with_portchannel_output="""\ @@ -74,30 +80,34 @@ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+ | 3000 | | | | | disabled | +-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ show_vlan_config_output="""\ -Name VID Member Mode --------- ----- ---------- -------- -Vlan1000 1000 Ethernet4 untagged -Vlan1000 1000 Ethernet8 untagged -Vlan1000 1000 Ethernet12 untagged -Vlan1000 1000 Ethernet16 untagged -Vlan2000 2000 Ethernet24 untagged -Vlan2000 2000 Ethernet28 untagged +Name VID Member Mode +-------- ----- --------------- -------- +Vlan1000 1000 Ethernet4 untagged +Vlan1000 1000 Ethernet8 untagged +Vlan1000 1000 Ethernet12 untagged +Vlan1000 1000 Ethernet16 untagged +Vlan2000 2000 Ethernet24 untagged +Vlan2000 2000 Ethernet28 untagged Vlan3000 3000 +Vlan4000 4000 PortChannel1001 tagged """ show_vlan_config_in_alias_mode_output="""\ -Name VID Member Mode --------- ----- -------- -------- -Vlan1000 1000 etp2 untagged -Vlan1000 1000 etp3 untagged -Vlan1000 1000 etp4 untagged -Vlan1000 1000 etp5 untagged -Vlan2000 2000 etp7 untagged -Vlan2000 2000 etp8 untagged +Name VID Member Mode +-------- ----- --------------- -------- +Vlan1000 1000 etp2 untagged +Vlan1000 1000 etp3 untagged +Vlan1000 1000 etp4 untagged +Vlan1000 1000 etp5 untagged +Vlan2000 2000 etp7 untagged +Vlan2000 2000 etp8 untagged Vlan3000 3000 +Vlan4000 4000 PortChannel1001 tagged """ config_vlan_add_dhcp_relay_output="""\ @@ -111,62 +121,68 @@ """ show_vlan_brief_output_with_new_dhcp_relay_address="""\ -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+============+================+=======================+=============+ -| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | -| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | -| | | Ethernet12 | untagged | 192.0.0.3 | | -| | | Ethernet16 | untagged | 192.0.0.4 | | -| | | | | 192.0.0.100 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | +| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | +| | | Ethernet12 | untagged | 192.0.0.3 | | +| | | Ethernet16 | untagged | 192.0.0.4 | | +| | | | | 192.0.0.100 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ config_add_del_vlan_and_vlan_member_output="""\ -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+============+================+=======================+=============+ -| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | -| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | -| | | Ethernet12 | untagged | 192.0.0.3 | | -| | | Ethernet16 | untagged | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 1001 | | Ethernet20 | untagged | | disabled | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+------------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled | +| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | | +| | | Ethernet12 | untagged | 192.0.0.3 | | +| | | Ethernet16 | untagged | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 1001 | | Ethernet20 | untagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ config_add_del_vlan_and_vlan_member_in_alias_mode_output="""\ -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | -+===========+=================+=========+================+=======================+=============+ -| 1000 | 192.168.0.1/21 | etp2 | untagged | 192.0.0.1 | disabled | -| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | | -| | | etp4 | untagged | 192.0.0.3 | | -| | | etp5 | untagged | 192.0.0.4 | | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| 1001 | | etp6 | untagged | | disabled | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled | -| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | | -| | | | | 192.0.0.3 | | -| | | | | 192.0.0.4 | | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ -| 3000 | | | | | disabled | -+-----------+-----------------+---------+----------------+-----------------------+-------------+ ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | ++===========+=================+=================+================+=======================+=============+ +| 1000 | 192.168.0.1/21 | etp2 | untagged | 192.0.0.1 | disabled | +| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | | +| | | etp4 | untagged | 192.0.0.3 | | +| | | etp5 | untagged | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 1001 | | etp6 | untagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled | +| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | | +| | | | | 192.0.0.3 | | +| | | | | 192.0.0.4 | | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 3000 | | | | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ +| 4000 | | PortChannel1001 | tagged | | disabled | ++-----------+-----------------+-----------------+----------------+-----------------------+-------------+ """ class TestVlan(object): @classmethod