Open nkhambal opened 1 year ago
Just FYI, cDev.unlock() is something I added to see if thats the issue. But the timeout happens with or without it.
Made some progress. Used lock = False option to avoid locking the config db.
cDev = IOSXR(hostname=aHost, username=uName, password=uPassWd, port=22, timeout=300, lock=False, logfile=file)
changed the _XML_SHELL command to 'xml echo format' (tried 'xml echo' too).
_XML_SHELL = 'xml echo format'
Now I am getting XML parse error
Traceback (most recent call last):
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 368, in _execute_rpc
root = ET.fromstring(str.encode(response))
File "src/lxml/etree.pyx", line 3257, in lxml.etree.fromstring
File "src/lxml/parser.pxi", line 1916, in lxml.etree._parseMemoryDocument
File "src/lxml/parser.pxi", line 1803, in lxml.etree._parseDoc
File "src/lxml/parser.pxi", line 1144, in lxml.etree._BaseParser._parseDoc
File "src/lxml/parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 728, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 657, in lxml.etree._raiseParseError
File "<string>", line 2
lxml.etree.XMLSyntaxError: XML declaration allowed only at the start of the document, line 2, column 6
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/bgp_group_peer_verification_iosxr_native.py", line 169, in <module>
cDev.show_ip_bgp_vrf_APPLEVRF_summary()
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 126, in _getattr
response = self._execute_show(cmd)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 439, in _execute_show
response = self._execute_rpc(rpc_command)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 372, in _execute_rpc
raise InvalidXMLResponse('Unable to process the XML Response from the device!', self)
pyIOSXR.exceptions.InvalidXMLResponse: Unable to process the XML Response from the device!
Here is the netmiko session log.
DEBUG:netmiko:Clear buffer detects data in the channel
DEBUG:netmiko:read_channel:
DEBUG:netmiko:[find_prompt()]: prompt is RP/0/RP0/CPU0:usgrx107-bbisp-gw1#
DEBUG:netmiko:write_channel: b'xml echo format\n'
DEBUG:netmiko:read_channel: xml echo format
Fri Jun 2 06:17:11.509 UTC
DEBUG:netmiko:read_channel: XML>
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:write_channel: b'<?xml version="1.0" encoding="UTF-8"?><Request MajorVersion="1" MinorVersion="0"><CLI><Exec>show ip bgp vrf APPLEVRF summary</Exec></CLI></Request>\n'
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel: <?xml version="1.0" encoding="UTF-8"?><Request MajorVersion="1" MinorVersion="0"><CLI><Exec>show ip bgp vrf TESTVRF summary</Exec></CLI></Request>
DEBUG:netmiko:Pattern found: (<\?xml\ version="1\.0"\ encoding="UTF\-8"\?><Request\ MajorVersion="1"\ MinorVersion="0"><CLI><Exec>show\ ip\ bgp\ vrf\ TESTVRF\ summary</Exec></CLI></Request>) <?xml version="1.0" encoding="UTF-8"?><Request MajorVersion="1" MinorVersion="0"><CLI><Exec>show ip bgp vrf TESTVRF summary</Exec></CLI></Request>
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel: <?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0">
<CLI>
<Exec>
BGP VRF TESTVRF, state: Active
BGP Route Distinguisher: 65535:220020128
VRF ID: 0x60000002
BGP router identifier 10.12.88.111, local AS number 714
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000002 RD version: 422613664
BGP main routing table version 422613664
BGP NSR Initial initsync version 49893 (Reached)
BGP NSR/ISSU Sync-Group versions 422613664/0
BGP is operating in STANDALONE mode.
Process RcvTblVer RIBVer/RIBAckVer LabelVer ImportVer SendTblVer StandbyVer
Speaker 422613664 422613664/422613664 422613664 422613664 422613664 422613664
Neighbor Spk AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down St/PfxRcd
10.0.20.193 0 4217005001 3824455 3818028 422613664 0 0 3w1d 205
10.0.20.195 0 4217005001 3792582 3817752 422613664 0 0 3w1d 205
10.2.208.31 0 714 23106 1069556 0 0 0 3w2d Idle
172.18.36.110 0 714 107067 1150448 422613664 0 0 5w0d 0
</Exec>
</CLI>
<ResultSummary ErrorCount="0"/>
</Response>
XML>
Any ideas?
I printed the response for the CLI. Looks like there are 2 XML declaration at the top. One for request and other for response. It is probably why XML parsing is failing.
<?xml version="1.0" encoding="UTF-8"?><Request MajorVersion="1" MinorVersion="0"><CLI><Exec>show ip bgp vrf TESTVRF summary</Exec></CLI></Request>
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><CLI><Exec>
BGP VRF TESTVRF, state: Active
BGP Route Distinguisher: 65535:220020128
VRF ID: 0x60000002
BGP router identifier 10.12.88.111, local AS number 714
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000002 RD version: 422613664
BGP main routing table version 422613664
BGP NSR Initial initsync version 49893 (Reached)
BGP NSR/ISSU Sync-Group versions 422613664/0
BGP is operating in STANDALONE mode.
Process RcvTblVer RIBVer/RIBAckVer LabelVer ImportVer SendTblVer StandbyVer
Speaker 422613664 422613664/422613664 422613664 422613664 422613664 422613664
Neighbor Spk AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down St/PfxRcd
10.0.20.193 0 4217005001 3829209 3822085 422613664 0 0 3w1d 205
10.0.20.195 0 4217005001 3797336 3821809 422613664 0 0 3w1d 205
10.2.208.31 0 714 23106 1069556 0 0 0 3w2d Idle
172.18.36.110 0 714 107202 1150583 422613664 0 0 5w0d 0
</Exec></CLI><ResultSummary ErrorCount="0"/></Response>
I am getting following read timeout exception when I run my script
Processing Host: usgrx107-bbisp-gw1 Traceback (most recent call last): File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/bgp_group_peer_verification_iosxr_native.py", line 164, in
cDev.open()
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 176, in open
self._enter_xml_mode()
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 239, in _enter_xml_mode
self.lock()
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 477, in lock
self._execute_rpc(rpc_command)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 366, in _execute_rpc
response = self._send_command(xml_rpc_command, delay_factor=delay_factor)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/pyIOSXR/iosxr.py", line 271, in _send_command
last_read = self.device.send_command_expect(command,
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/netmiko/base_connection.py", line 1820, in send_command_expect
return self.send_command(*args, *kwargs)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/netmiko/utilities.py", line 592, in wrapper_decorator
return func(self, args, **kwargs)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/netmiko/base_connection.py", line 1740, in send_command
new_data = self.command_echo_read(cmd=cmd, read_timeout=10)
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/netmiko/base_connection.py", line 1452, in command_echo_read
new_data = self.read_until_pattern(
File "/Users/nileshkhambal/Documents/GIT_REPO/PIE/edge-bgp-peer-verification/all-route-verification/venv/lib/python3.9/site-packages/netmiko/base_connection.py", line 721, in read_until_pattern
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: '<\?xml\ version="1\.0"\ encoding="UTF\-8"\?><Request\ MajorVersion="1"\ MinorVersion="0"> ' in output.
Things you might try to fix this:
You can also look at the Netmiko session_log or debug log for more information.
Script is pretty simple
here is the netmiko session log