Making remote procedure calls
In this recipe, we'll create a Stylesheet Language Alternative Syntax (SLAX) op script, show-int.slax
, in order to simulate the behavior of the show interfaces JUNOS CLI command. We'll do this by executing the normal RPC associated with the show interface command and pick out the information that we need.
Getting ready
In order to complete this recipe, you'll need access to a JUNOS router running with a basic configuration. If available, a simple VM-based Juniper Olive or virtual Route Reflector (vRR) is perfectly adequate for the level of complexity here.
How to do it...
We're going to create a SLAX script to call the necessary RPC to get the interface information and with the structured XML document that is returned, we're going to pick out a simple set of parameters and tabulate it in a neat form to make life simpler for the operator. The example is a little contrived, but it's a good illustration of how to call RPCs from within SLAX. The steps are given as follows...