Junos XML API Overview
In this lesson we’ll be talking about the XML API in more depth and really going over how the Juniper infrastructure uses the XML API on the back end. We’ll see how we can get more visibility into what exactly is going on when we try and enter commands into the CLI, or when we’re actually doing some XML API work through a NETCONF. So, let’s go ahead and jump right on in!

When we enter commands into our CLI Junos actually converts our commands into XML RPCs when we press enter. Then it submits that XML RPC into the XML API so that we can gather information or apply configuration changes to our Junos device.
The responses that we receive to these XML RPCs are also in XML. They are converted back into plain text format by the CLI process when we receive that information.

When we enter our show route table inet.0 command, as above, to be able to get all of our routing information for the inet.0, our IPv4 routing table, the CLI process actually converts this into our <get-route-information> XML RPC.
In order to get the table inet.0, it’s adding in the <table> element as an argument with inet.0 as the content of that element.
This XML RPC is submitted into the XML API of our device and that’s actually what is acted upon, rather than the command that we see in plain text above.
This conversion is done using the data description models, which we don’t really need to know about for the JNCIA-DevOps. However, if you go further into the JNCIS-DevOps certification, you’ll learn what these files look like so that you could actually create your own CLI commands. Creating your own operational mode command in that fashion would be going a step further than just an OpScript, where we run on-box scripts from operational mode commands and display the output.
When we’re entering in the show route table inet.0 command if we were to give the display modifier | display xml rpc to that command, then we would see our XML request that is being submitted.

When we get information back from our infrastructure it is also in XML, so that information is going to flow upwards like this. We see here our XML reply, our <rpc-reply> tag starting at the top. We have our <route-information> opening tag, and opening the <route-table> for the table named inet.0, and our information here that corresponds to the information displayed in plain text up top.
Check out the full lesson video below for a full lab demonstration of the XML API and gathering XML RPC commands!
Tag:api, automation, devops, jncia, jncia-devops, juniper, junos, rpc, xml