In this lesson, we will cover:

  • What is Genie Diff?
  • How to run Genie Diff via the command line.
  • How to exclude keys from comparison via the command line.
  • How to run Genie Diff via Python.
  • How to use pickle to save the network state when comparing.
  • How to exclude keys from comparison via Python.

The scripts and code for this lesson can be found within the pyATS repo under the directory: 003_genie/diff/.

What is Genie Diff?

So far, we have used Genie Parse and Learn to take a snapshot of the network at a given point in time. However, let’s say it was reported that there were issues in the network. A user has contacted us, and they cannot get to an internal app. Sure, we could run a Genie Parse or a Genie Learn. But we would need to dig through the whole output, looking for issues. Wouldn’t it be better to compare this output against a known working output (snapshot) and report just the differences? This is where Diff comes into play.

Diff allows you to perform a comparison between 2 snapshots and return the differences.

Therefore, using the Diff features opens up some extremely useful use cases:

  • Creating a golden snapshot. You can take a new snapshot at the point of network failure and compare it to the golden snapshot to pinpoint the issue.
  • Create a snapshot before a maintenance and then compare the two to ensure the maintenance hasn't caused any potential issues in the network.

Whether we are running the Diff via the command line or Python depends on what we provide the Diff tool for it to make its comparison. When running Diff via the command line, we provide it with the Genie text output files. When running Diff using Python, we provide the Diff Python objects.

Let's dive into some examples!

Diff via the Command-Line

To perform a diff using the command-line we use `pyats diff `. Diff will then write all the differences detected to a set of output files.
Members Only Content
Want to Learn Network Automation?
Join our membership to access:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.