pyATS Tip:
Use Genie Diff to compare structured data and easily identify differences. It works with dictionaries, including structured output from Genie Parse and Genie Learn.
Below is an example of using Genie Diff to compare the results of a Genie Parse command:
from genie.utils.diff import Diff
from genie.testbed import load
testbed = load("testbed.yaml")
device = testbed.devices["router1"]
device.connect()
before = device.parse("show ip interface brief")
after = device.parse("show ip interface brief")
diff = Diff(before, after)
diff.findDiff()
if diff:
print(diff)
# Output:
# +interface:
# + GigabitEthernet2:
# + status: up
# + protocol: up
# - GigabitEthernet3:
# - status: down
# - protocol: down