Exploring the XML RPC using PyEZ
In this recipe, we’ll use the PyEZ framework to explore the XML RPC APIs to determine the necessary calls for equivalent command lines and parameters. Introspecting the XML RPC API like this can be a useful technique for building bigger fully-fledged automation applications.
Getting ready
In order to complete this recipe, you’ll need Python 2.7 in a Linux or BSD-based development environment of your choice. You should have already:
- Configured NETCONF-over-SSH setup (Chapter 1, Configuring JUNOS through NETCONF)
- Set up a PyEZ Environment (Chapter 2, Working with Junos REST API).
How to do it…
We’re going to use the Python interactive shell (or REPL – read-evaluate-print loop) in order to use PyEZ to connect to a JUNOS device, and then we’re going to explore the XML RPCs for certain commands:
- Start up the Python interpreter and load the essential PyEZ framework classes and the associated XML parsing routines:
Python 2.7.13 (default, Dec 17 2016, 23:03:43) ...