mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
799 stars 220 forks source link

[FEATURE]: IOS diffs via ciscoconfparse.ciscoconfparse.Diff() #293

Closed mpenning closed 1 year ago

mpenning commented 1 year ago

Version 1.9.40 adds an enhanced Diff() object, which performs intelligent IOS diffs...

Example usage of the new Diff() object...

from ciscoconfparse.ciscoconfparse import Diff

old_config = [
    "vlan 1",
    "vlan 2",
    " name management",
]
new_config = [
    "vlan 2",
    " name finance",
    "vlan 3",
    " name management",
    "vlan 4",
    " name IT",
]

diff = Diff(old_config=old_config, new_config=new_config)
for line in diff.diff():
    print(line)

This prints:

no vlan 1
vlan 2
  name finance
vlan 3
  name management
vlan 4
  name IT