GithubHelp home page GithubHelp logo

netcompare's Introduction

netcompare

netcompare is a python script that compares two Cisco IOS style's configuration files for a single network device (one origin and one target). It returns an ordered list of commands that can be applied to the network equipment in order to achieve the target configuration state. It's like a "diff" on steroids, which takes care of command's parent / child relationships. This script has been written with network configuration automation in mind, for crappy network equipments that does not support atomic changes.

Known to work with

  • Cisco IOS
  • Cisco NXOS
  • Cisco ASA
  • Dell FTOS
  • Huawei VRP

It can also work with these platforms (but they support -at least partially- atomic changes, so there's a better way):

  • Arista EOS
  • Cisco IOS XR

It should work with all Cisco IOS style kind of configuration files.

Comparison algorithm

The script does the work in two pass:

  1. For each line of the origin configuration file, check if this line is present in the target file. If not, we assume that we need to prefix this line with "no" and add it in our resulting command list.
  2. For each line of the target configuration file, check if this line is present in the origin file. If not, we assume that we need this line in our resulting command list.

Then, we sort the two resulting lists to be sure that "no" commands are placed before new commands.

That's the basics. We'll do a detailed diagram to explain everything in a near future.

Limitations

There's no black magic in this script, it can't invent commands, so be careful with implicit configurations.

Don't forget to yell at your favorite vendor's representatives about their bad CLI and lack of API.

How-to

That's quite simple, call netcompare.py with 3 arguments:

  • The origin configuration file
  • The target configuration file
  • The negation keyword used by your platform. Cisco IOS, NXOS, IOS-XR, ASA uses "no", Huawei uses "undo" for example
    python netcompare.py tests/sample1.conf tests/sample2.conf no

The script returns an ordered list of commands that can be applied to the network equipment in order to achieve the target configuration state.

Requirements

netcompare uses the awesome David Michael Pennington's CiscoConfParse library to parse the configuration files. More information in CiscoConfParse documentation. Be sure to install it before using netcompare:

    pip install ciscoconfparse

Documentation

(Minimalist) documentation will be available on Read the Docs soon.

Todo

A lot of things !

  • Ansible library and playbook example
  • Find a way to do changes in one command instead of two (like ip address or hostname changes)
  • Handle banner changes (and all multiline commands with delimiters)

Pull requests are warmly welcome :)

Authors

netcompare's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.