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

Junos get_lldp_neighbor port returns the port-id, not the port-decription #1470

Merged
Merged
13 changes: 12 additions & 1 deletion napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,18 @@ def get_lldp_neighbors(self):
for neigh in result:
if neigh[0] not in neighbors.keys():
neighbors[neigh[0]] = []
neighbors[neigh[0]].append({x[0]: str(x[1]) for x in neigh[1]})

neigh_dict = {}
for neigh_data in neigh[1]:
key = neigh_data[0]
value = (
str(neigh_data[1][0])
# When return value is a list of multiple objects, we pick the first one
if neigh_data[1] and isinstance(neigh_data[1], list)
else str(neigh_data[1])
)
neigh_dict[key] = value
neighbors[neigh[0]].append(neigh_dict)

return neighbors

Expand Down
2 changes: 1 addition & 1 deletion napalm/junos/utils/junos_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ junos_lldp_table:
junos_lldp_view:
fields:
hostname: lldp-remote-system-name
port: lldp-remote-port-description | lldp-remote-port-id
Copy link
Member

Choose a reason for hiding this comment

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

lldp-remote-port-description needs to stay as that's what older Junos versions provide.

port: lldp-remote-port-id | lldp-remote-port-description

####
#### Interface counters
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"me0.0": [{"hostname": "lom-bjg61-r1-1", "port": "27"}], "xe-4/3/6": [{"hostname": "peer00.lab.demo", "port": "Ethernet1"}], "xe-0/1/0.0": [{"hostname": "spine00", "port": "xe-0/0/0"}], "ge-0/0/0.0": [{"hostname": "rtr00.demo", "port": "GigabitEthernet0/0/0/0"}]}
{"me0.0": [{"hostname": "lom-bjg61-r1-1", "port": "27"}], "xe-4/3/6": [{"hostname": "peer00.lab.demo", "port": "Ethernet1"}], "xe-0/1/0.0": [{"hostname": "spine00", "port": "xe-0/0/0"}], "ge-0/0/0.0": [{"hostname": "rtr00.demo", "port": "ge-0/0/0"}]}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
<lldp-remote-chassis-id>00:1c:73:8f:0a:ed</lldp-remote-chassis-id>
<lldp-remote-port-id-subtype>Interface name</lldp-remote-port-id-subtype>
<lldp-remote-port-id>Ethernet1</lldp-remote-port-id>
<lldp-remote-port-description>Ethernet1 interface</lldp-remote-port-description>
<lldp-remote-system-name>peer00.lab.demo</lldp-remote-system-name>
</lldp-neighbor-information>
<lldp-neighbor-information>
<lldp-local-interface>me0.0</lldp-local-interface>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>00:23:47:50:21:40</lldp-remote-chassis-id>
<lldp-remote-port-description>27</lldp-remote-port-description>
<lldp-remote-port-id>27</lldp-remote-port-id>
<lldp-remote-port-description>Interface 27</lldp-remote-port-description>
<lldp-remote-system-name>lom-bjg61-r1-1</lldp-remote-system-name>
</lldp-neighbor-information>
<lldp-neighbor-information>
<lldp-local-interface>ge-0/0/0.0</lldp-local-interface>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>02:e4:c8:6c:a4:00</lldp-remote-chassis-id>
<lldp-remote-port-id>ge-0/0/0</lldp-remote-port-id>
<lldp-remote-port-description>GigabitEthernet0/0/0/0</lldp-remote-port-description>
<lldp-remote-system-name>rtr00.demo</lldp-remote-system-name>
</lldp-neighbor-information>
Expand All @@ -29,6 +32,7 @@
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>dc:38:e1:b7:26:16</lldp-remote-chassis-id>
<lldp-remote-port-id>xe-0/0/0</lldp-remote-port-id>
<lldp-remote-port-description>xe-0/0/0</lldp-remote-port-description>
<lldp-remote-system-name>spine00</lldp-remote-system-name>
</lldp-neighbor-information>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"me0.0": [{"hostname": "lom-bjg61-r1-1", "port": "Interface 27"}], "xe-4/3/6": [{"hostname": "peer00.lab.demo", "port": "Ethernet1 interface"}], "xe-0/1/0.0": [{"hostname": "spine00", "port": "xe-0/0/0"}], "ge-0/0/0.0": [{"hostname": "rtr00.demo", "port": "GigabitEthernet0/0/0/0"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<lldp-neighbors-information style="brief">
<lldp-neighbor-information>
<lldp-local-port-id>xe-4/3/6</lldp-local-port-id>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>00:1c:73:8f:0a:ed</lldp-remote-chassis-id>
<lldp-remote-port-id-subtype>Interface name</lldp-remote-port-id-subtype>
<lldp-remote-port-description>Ethernet1 interface</lldp-remote-port-description>
<lldp-remote-system-name>peer00.lab.demo</lldp-remote-system-name>
</lldp-neighbor-information>
<lldp-neighbor-information>
<lldp-local-interface>me0.0</lldp-local-interface>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>00:23:47:50:21:40</lldp-remote-chassis-id>
<lldp-remote-port-description>Interface 27</lldp-remote-port-description>
<lldp-remote-system-name>lom-bjg61-r1-1</lldp-remote-system-name>
</lldp-neighbor-information>
<lldp-neighbor-information>
<lldp-local-interface>ge-0/0/0.0</lldp-local-interface>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>02:e4:c8:6c:a4:00</lldp-remote-chassis-id>
<lldp-remote-port-description>GigabitEthernet0/0/0/0</lldp-remote-port-description>
<lldp-remote-system-name>rtr00.demo</lldp-remote-system-name>
</lldp-neighbor-information>
<lldp-neighbor-information>
<lldp-local-interface>xe-0/1/0.0</lldp-local-interface>
<lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
<lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
<lldp-remote-chassis-id>dc:38:e1:b7:26:16</lldp-remote-chassis-id>
<lldp-remote-port-id>xe-0/0/0</lldp-remote-port-id>
<lldp-remote-port-description>xe-0/0/0</lldp-remote-port-description>
<lldp-remote-system-name>spine00</lldp-remote-system-name>
</lldp-neighbor-information>
</lldp-neighbors-information>