Applying configuration changes through the REST API
So far, we've only shown how to make use of operational RPCs. This allows us a fair amount of control and flexibility, but it's also possible to change the configuration of Junos OS through the REST API. In this recipe, we'll modify the previous Python code, rest.py
, and make a modified version, rest-conf.py
, that takes a configuration change as a text file and applies it to the specified Junos OS host, checking the loading process and the commit process as it goes.
Getting ready
In order to complete this recipe, you'll need a Python development environment with access to a Junos OS device upon which you've previously completed the REST API setup recipe.
How to do it...
The steps for the recipe are as follows:
- Start the Python source code with the usual boilerplate to define the interpreter and the module import references. Include a general purpose exception handler.
#!/usr/bin/env python import sys import argparse import...