Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master]fix #4716 show ipv6 interfaces neighbor_ip is N/A issue #948

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to have the mapping based on the ipaddr (dictionary) instead of an implicit index? Just a thought!


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