Using Genie Conf objects to create a portable configuration script
So far, we have always used the Genie parser to go from unstructured textual output to structured data in the form of a Python dictionary, but Genie can also do it the other way around! Instead of specifying a configuration command and issuing this command to the network device we can, using pure Python objects, define our changed configuration in the form of Python objects. Genie then goes ahead and, based on the Python objects, generates the required configuration files and issues them to the device. This means that we can write consistent device configurations and let Genie handle the work of converting this into actual configuration instructions.
In this recipe, we are going to configure an interface and generate the required configuration file using pyATS and Genie.
Getting ready
Open your code editor and start by creating a file called testbed.yaml
, as well as a file called change.py
. Next, navigate...