06-12-2024 02:52 AM
Hi Team ,
i want to shutdown interface by using xml rpc in cisco ios-xr router by router itself manually .
ssh root@10.1.1.1 -p830 -s netconf and then hello rpc and then given this shutdown rpc .
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>Bundle-Ether103</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="102">
<commit/>
</rpc>
Getting following error in ios-xr router .
]]>]]><hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
</capabilities>
</hello>
]]>]]>
#599
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>Bundle-Ether103</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="102">
<commit/>
</rpc>
##
#237
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>rpc</error-type>
<error-tag>malformed-message</error-tag>
<error-severity>error</error-severity>
</rpc-error>
</rpc-reply>
##
Please let me know how to do that in cisco ios xr router push edit rpc by manually
Thanks
Jay
06-12-2024 04:12 AM - edited 06-12-2024 10:18 PM
To shut down an interface on a Cisco IOS-XR router using XML RPC via NETCONF, first connect using ssh root@10.1.1.1 -p 830 -s netconf. Then, send a hello RPC to establish the session. Next, use the following edit-config RPC to shut down the interface:
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>Bundle-Ether103</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
Finally, commit the changes with: ADPVantage
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="102">
<commit/>
</rpc>
If you encounter errors, ensure the interface name is correct and the XML structure is properly formatted.
06-12-2024 04:23 AM
Hi Interface name and XML structure are correct . i am getting ok reply for first shutdown rpc .
]]>]]>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
</capabilities>
</hello>
]]>]]>
#487
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>Bundle-Ether103</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
##
#119
<?xml version="1.0"?>
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>
After that how to to for commit rpc ? Please let me know , can u provide router output how you are doing it .
06-12-2024 09:51 PM
Hi Team ,
Kindly let me know after shutdown rpc and getting ok reply , how to commit after ok reply . please let me know .
Because after shutdown rpc ok reply unable to execute commit rpc and its exiting .
Please help!
Thanks
Jay
06-13-2024 02:40 AM - edited 06-13-2024 02:43 AM
Hi @js726u ,
The commit operation is another RPC call on the same session.
Here is a payload example from my setup:
Sending: #177 <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f7703833-92a8-4206-b803-806b264f74c7"> <nc:commit/> </nc:rpc> ##
Received message from host
<rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f7703833-92a8-4206-b803-806b264f74c7"> <ok/> </rpc-reply>
NETCONF commit COMPLETE
The complete session output is in attach.
Are you using a tool to build the RPC call? I recommend use yangsuite...
In this case, to add the commit payload you have an option under RPC options, in NETCONF Protocol explorer.
Hope it helps...
Kratz
06-13-2024 02:56 AM
hi How u r connecting to router using ssh or telnet or any tool ?
my ssh connection hello is fine and edit config is fine and commit rpc time its exiting .PF output
</hello>
]]>]]><hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
</capabilities>
</hello>
]]>]]>
#509
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>Bundle-Ether103</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
##
#119
<?xml version="1.0"?>
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>
##
#89
06-13-2024 04:09 AM
Hi @js726u ,
I'm using yangsuite (https://github.com/CiscoDevNet/yangsuite) to interact with NETCONF capable devices.
The advantage of use this kind of tool is that it will take care of the protocol specifics, and you can concentrate in build your payloads. In this tool, as a bonus, you can create an initial python script that consumes ncclient library or an ansible playbook.
It's fine to use ssh with netconf subsystem to interact with the device, but you need to be strict with the protocol.
For example, in the last payloads you shared, you are reusing the message-id, something I believe is not expected/desirable.
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