Skip to content

Commit cc6ddc1

Browse files
committed
Fix LLDP neighbors detail retrieval on ASR9K devices
The original implementation of the get_lldp_neighbors_detail method fails with an XMLCLIError exception when used on Cisco ASR9K devices. This is due to the ASR9K requiring a more specific XML path in the RPC call. Added a try/except block that: 1. First attempts the generic LLDP query 2. If that fails with XMLCLIError, tries a more specific query that includes the exact node path (Rack 0, Slot 0, Instance CPU0) 3. Also added an informative log message to indicate when fallback occurs This change maintains backward compatibility with standard IOS-XR devices while adding support for ASR9K devices.
1 parent ff59653 commit cc6ddc1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

napalm/iosxr/iosxr.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,18 @@ def get_lldp_neighbors_detail(self, interface=""):
879879
"</Operational></Get>"
880880
)
881881

882-
result_tree = ETREE.fromstring(self.device.make_rpc_call(rpc_command))
882+
try:
883+
result_tree = ETREE.fromstring(self.device.make_rpc_call(rpc_command))
884+
except napalm.pyIOSXR.exceptions.XMLCLIError:
885+
logger.info("Attempting more specific ASR9K rpc call for LLDP neighbors query")
886+
rpc_command = (
887+
"<Get><Operational>"
888+
"<LLDP><NodeTable><Node><Naming><NodeName>"
889+
"<Rack>0</Rack><Slot>0</Slot><Instance>CPU0</Instance>"
890+
"</NodeName></Naming></Node></NodeTable></LLDP>"
891+
"</Operational></Get>"
892+
)
893+
result_tree = ETREE.fromstring(self.device.make_rpc_call(rpc_command))
883894

884895
for neighbor in result_tree.xpath(".//Neighbors/DetailTable/Detail/Entry"):
885896
interface_name = napalm.base.helpers.convert(

0 commit comments

Comments
 (0)