Making REST API calls to Junos with Python
In this recipe, we'll use Python's built-in standard library routines for HTTPS in order to access the Junos OS REST API. We'll build an example app, rest.py
, that allows a user to make simple RPC calls. In order to control the operation of the application, we'll define some command-line arguments.
Command line option | Description |
| Specify the output format |
| Specify the actual RPC call |
| Self-signed certificate from router |
| HTTPS port number, default 8443 |
| Username to authenticate with |
Getting ready...
In order to complete this recipe, you need access to a Junos OS router device running at least Junos OS 14.2, and you should have completed the previous recipe, REST API Setup. You'll also need access to a Python development environment.
How to do it...
We're going to make a new Python app, rest.py
, that will connect to the Junos OS REST interface over SSH.
- Create the Python script preamble and import the necessary...