Skip to content

Commit

Permalink
[master]fix #4716 show ipv6 interfaces neighbor_ip is N/A issue (#948)
Browse files Browse the repository at this point in the history
Signed-off-by: tim-rj <[email protected]>
  • Loading branch information
tim-rj authored Jun 24, 2020
1 parent 5a13e0b commit f99f7e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ def interfaces():

if netifaces.AF_INET6 in ipaddresses:
ifaddresses = []
neighbor_info = []
for ipaddr in ipaddresses[netifaces.AF_INET6]:
neighbor_name = 'N/A'
neighbor_ip = 'N/A'
Expand All @@ -1557,6 +1558,7 @@ def interfaces():
neighbor_ip = bgp_peer[local_ip][1]
except Exception:
pass
neighbor_info.append([neighbor_name, neighbor_ip])

if len(ifaddresses) > 0:
admin = get_if_admin_state(iface)
Expand All @@ -1567,9 +1569,11 @@ def interfaces():
master = get_if_master(iface)
if get_interface_mode() == "alias":
iface = iface_alias_converter.name_to_alias(iface)
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_name, neighbor_ip])
for ifaddr in ifaddresses[1:]:
data.append(["", "", ifaddr[1], ""])
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
neighbor_info.pop(0)
for ifaddr in ifaddresses[1:]:
data.append(["", "", ifaddr[1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
neighbor_info.pop(0)

print tabulate(data, header, tablefmt="simple", stralign='left', missingval="")

Expand Down

0 comments on commit f99f7e1

Please sign in to comment.