Skip to content

Commit

Permalink
Fix header for the output table following 'show ipv6 interface' comma…
Browse files Browse the repository at this point in the history
…nd (#2219)

- What I did
Fix the header for "show ipv6 interface" output that display "IPv4" instead of "IPv6"
This PR fix the following issue: sonic-net/sonic-buildimage#11124

- How I did it
Check if the table is for IPv4 or IPv6 and present the header accordingly. In addition, adjust the UT

- How to verify it
Run "show ip interface" CLi command and verify that the output header present "IPv4"
Run "show ipv6 interface" CLi command and verify that the output header present "IPv6"
  • Loading branch information
dprital committed Jun 16, 2022
1 parent fc5633f commit 05c79ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions scripts/ipintutil
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,13 @@ def get_ip_intfs_in_namespace(af, namespace, display):
return ip_intfs


def display_ip_intfs(ip_intfs):
def display_ip_intfs(ip_intfs,address_family):
header = ['Interface', 'Master', 'IPv4 address/mask',
'Admin/Oper', 'BGP Neighbor', 'Neighbor IP']

if address_family == 'ipv6':
header[2] = 'IPv6 address/mask'

data = []
for ip_intf, v in natsorted(ip_intfs.items()):
ip_address = v['ipaddr'][0][1]
Expand Down Expand Up @@ -265,7 +269,7 @@ def main():

load_db_config()
ip_intfs = get_ip_intfs(af, namespace, display)
display_ip_intfs(ip_intfs)
display_ip_intfs(ip_intfs,args.address_family)

sys.exit(0)

Expand Down
6 changes: 3 additions & 3 deletions tests/show_ip_int_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Vlan100 40.1.1.1/24 error/down N/A N/A"""

show_ipv6_intf_with_multiple_ips = """\
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP
--------------- -------- -------------------------------------------- ------------ -------------- -------------
Ethernet0 2100::1/64 error/down N/A N/A
aa00::1/64 N/A N/A
Expand All @@ -36,7 +36,7 @@
PortChannel0001 20.1.1.1/24 error/down T2-Peer 20.1.1.5"""

show_multi_asic_ipv6_intf = """\
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP
--------------- -------- -------------------------------------- ------------ -------------- -------------
Loopback0 fe80::60a5:9dff:fef4:1696%Loopback0/64 error/down N/A N/A
PortChannel0001 aa00::1/64 error/down N/A N/A
Expand All @@ -54,7 +54,7 @@
veth@eth2 193.1.1.1/24 error/down N/A N/A"""

show_multi_asic_ipv6_intf_all = """\
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP
--------------- -------- -------------------------------------- ------------ -------------- -------------
Loopback0 fe80::60a5:9dff:fef4:1696%Loopback0/64 error/down N/A N/A
PortChannel0001 aa00::1/64 error/down N/A N/A
Expand Down

0 comments on commit 05c79ef

Please sign in to comment.