One of the most common questions network engineers have to figure out is "What configuration changed?". Genie from Cisco makes answering this question super easy. And as a bonus, it can do far as well!
In this repo will provide you a quick example walkthrough how you can use this tool in your own environment.
Clone down the repo and change to the directory.
git clone https://github.com/hpreston/genie-config-diff
cd genie-config-diff
Setup Python Virtual Env
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
If you're going to leverage the DevNet Sandboxes, the file sandbox-testbed.yaml
is ready to go, feel free to take a look at it.
If you'd like to use your own lab gear you'll need to create a testbed file for your lab. Check the docs for how to create one, or just use sandbox-testbed.yaml
as a template.
In order to find changes in the configuration, you need to capture a gold config. One is included in the repository in the folder sample_gold_config
, but you can also capture one of your own like this.
Simply learn config
using Genie CLI.
genie learn config --testbed-file sandbox-testbed.yaml --output gold_config
If you look in the gold_config
folder, you'll find 3 files for each device in the topology.
connection_DEVICE.txt
- Raw console connection log for deviceconfig_iosxe_DEVICE_console.txt
- Raw device output from the configuration captureconfig_iosxe_DEVICE_ops.txt
- A JSON file created for the configurationNow to change something that we want to find... you could wait around for something to change, but that could take a while. Instead, go ahead and make a change.
You can simply log into any of the sandbox devices we are working with using the connection info provide in the testbed or DevNet portal and use typical CLI commands to make some changes.
In this repo I've provided a script that will make a configuration change on one or more of the devices for you. I won't tell you what the changes are (but you could certainly look at the script) so you'll be surprised when you run the test.
Simply run this script to make the change.
python change_device_config.py
Now for the good part, let's find the change.
Re-learn the current configuration. You need to provide a new value for the output
.
genie learn config --testbed-file sandbox-testbed.yaml --output changed
Now find the diff
between the gold_config
and changed
.
genie diff gold_config changed# Output +==============================================================================+ | Genie Diff Summary between directories gold_config/ and changed/ | +==============================================================================+ | File: config_iosxe_csr1000v-1_ops.txt | | - Diff can be found at ./diff_config_iosxe_csr1000v-1_ops.txt | |------------------------------------------------------------------------------| | File: config_iosxr_iosxr_ops.txt | | - Diff can be found at ./diff_config_iosxr_iosxr_ops.txt | |------------------------------------------------------------------------------| | File: config_nxos_sbx-n9kv-ao_ops.txt | | - Diff can be found at ./diff_config_nxos_sbx-n9kv-ao_ops.txt | |------------------------------------------------------------------------------|
The output of the command shows you where the diffences are, and you can check the files referenced for the specific changes.
--- gold_config/config_iosxe_csr1000v-1_ops.txt +++ changed/config_iosxe_csr1000v-1_ops.txt +Current configuration : 9351 bytes: +interface Loopback1001: + description GenieLoop1001: + no ip address: +interface Loopback1184: + description New Interface Created with Genie change: + no ip address: -Current configuration : 9191 bytes:
Cisco pyATS | Genie includes tools that enable network engineers to capture a snapshot of an environment and compare that snapshot to different configurations. This helps engineers answer one of the most common networking questions: what has changed?
This code provides a quick example of a walkthrough that demonstrates how you can use this tool in your own environment.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community