06-05-2024 05:10 AM
Trying to ping do a simple ping ont a Cisco NCS540 IOSXR 7.6.2 , eventually pings from vrf as well, but for now I want to get this working.
I'm using the dispatch operation. Is there a argument i need to put beside xml_data object ??
See the code below:
Solved! Go to Solution.
06-05-2024 05:49 AM
from ncclient import manager, xml_
send_xml_data = '''
<ping xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ping-act">
<destination>
<destination>8.8.8.8</destination>
<repeat-count>5</repeat-count>
<interval>1</interval>
<source>Loopback0</source>
</destination>
</ping>'''
xml_commands_send = connection.rpc(xml_.to_ele(send_xml_data))
06-05-2024 05:50 AM
GOT IT WORKING !!!! SO HAPPY thanks a million that was the issue
06-05-2024 05:15 AM
I also tried this according to the instructions from the link below
06-05-2024 05:26 AM - edited 06-05-2024 05:33 AM
Hi
Is the following working?
xml_commands_send = connection.rpc(xml_.to_ele(send_xml_data))
You need to import xml_ from ncclient:
from ncclient import manager, xml_
06-05-2024 05:45 AM
tried it. it see the output below
>>> from ncclient import manager, xml_
>>>
>>> send_xml_data = '''
... <ping xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ping-act">
... <input>
... <destination>8.8.8.8</destination>
... <repeat-count>5</repeat-count>
... <interval>1</interval>
... <source>Loopback0</source>
... </input>
... </ping>
... '''
>>>
>>> xml_commands_send = connection.rpc(xml_.to_ele(send_xml_data))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\manager.py", line 257, in execute
return cls(self._session,
^^^^^^^^^^^^^^^^^^
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\operations\rpc.py", line 521, in request
return self._request(node)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\operations\rpc.py", line 375, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: <input> tag is not required.
>>>
>>> send_xml_data = '''
... <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
... <ping xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ping-act">
... <input>
... <destination>8.8.8.8</destination>
... <repeat-count>5</repeat-count>
... <interval>1</interval>
... <source>Loopback0</source>
... </input>
... </ping>
... </rpc>
... '''
>>> xml_commands_send = connection.rpc(xml_.to_ele(send_xml_data))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\manager.py", line 257, in execute
return cls(self._session,
^^^^^^^^^^^^^^^^^^
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\operations\rpc.py", line 521, in request
return self._request(node)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\dgutierrez\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\ncclient\operations\rpc.py", line 375, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-namespace', 'app_tag': None, 'severity': 'error', 'info': '<?xml version="1.0" encoding="UTF-8"?><error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">\n <bad-element>rpc</bad-element>\n <bad-namespace>urn:ietf:params:xml:ns:netconf:base:1.0</bad-namespace>\n </error-info>\n ', 'path': None, 'message': None}
>>>
06-05-2024 05:46 AM
I need to check the yang module for the payload. I let you know asap.
06-05-2024 05:49 AM
from ncclient import manager, xml_
send_xml_data = '''
<ping xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ping-act">
<destination>
<destination>8.8.8.8</destination>
<repeat-count>5</repeat-count>
<interval>1</interval>
<source>Loopback0</source>
</destination>
</ping>'''
xml_commands_send = connection.rpc(xml_.to_ele(send_xml_data))
06-05-2024 05:50 AM
GOT IT WORKING !!!! SO HAPPY thanks a million that was the issue
06-05-2024 05:53 AM
No problem, happy I could help. However, it would be nice to mark my answer as the accepted solution and not your own post
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide