Python: Building a Simple NETCONF RPC Tool
Python: Building a simple NETCONF RPC Tool
For a while now I’ve been playing with NETCONF primarily with Cisco Nexus devices. It’s struck me how difficult it is to get good information on doing trivial things like building a simple NETCONF RPC wrapper
How would this be generated for instance? This is wrapper that can be submitted to the ‘xmlagent’ or ‘netconf’ subsystem on a Cisco Nexus device. Note the use of namespaces (nf:rpc, nxos:cmd) where nxos is a namespace? XML is easy for the most part. Namespaces on a personal level meant learning something new and how to deal with that knowledge programmatically.
<?xml version='1.0' encoding='ISO-8859-1'?> <nf:rpc xmlns:nxos="http://www.cisco.com/nxos:1.0" xmlns:nf="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42"> <nxos:exec-command> <nxos:cmd>interface ethernet 2/1; shutdown</nxos:cmd> </nxos:exec-command> </nf:rpc> ]]>]]>
Other than generating it via a text string and formatting placeholders with “%s”, there has to be a better way! Indeed there is!
NETCONF 101
The IPEngineer definition: NETCONF is an IETF standardizsed RFC (6241) defined mechanism to configure network devices over some kind of channel using XML encoded data over a secure layer such as SSH. When the channel is opened, a NETCONF ‘Hello’ exchange takes place between the client and Continue reading