Giter Club home page Giter Club logo

hier_config's Introduction

Build Status CodeFactor

Hierarchical Configuration

Hierarchical Configuration is a python library that is able to take a running configuration of a network device, compare it to its intended configuration, and build the remediation steps necessary bring a device into spec with its intended configuration.

Hierarchical Configuraiton has been used extensively on:

  • Cisco IOS
  • Cisco IOSXR
  • Cisco NXOS
  • Arista EOS

However, any NOS that utilizes a CLI syntax that is structured in a similar fasion to IOS should work mostly out of the box.

The code documentation can be found at: https://netdevops.io/hier_config/

Installation

Hierarchical Configuration can be installed directly from github or with pip:

  • Github
git clone [email protected]:netdevops/hier_config.git
cd hier_config; ./setup.py install
  • Pip
pip install hier-config

Basic Usage Example

In the below example, we create two hierarchical configuration objects, load one with a running configuration from a device, and the other with the intended configuration of the device, then we compare the two objects to derive the commands necessary to bring the device into spec.

>>> from hier_config import HConfig
>>> from hier_config.host import Host
>>> import yaml
>>>
>>> options = yaml.load(open('./tests/files/test_options_ios.yml'))
>>> host = Host('example.rtr', 'ios', options)
>>>
>>> # Build HConfig object for the Running Config
...
>>> running_config_hier = HConfig(host=host)
>>> running_config_hier.load_from_file('./tests/files/running_config.conf')
>>>
>>> # Build Hierarchical Configuration object for the Compiled Config
...
>>> compiled_config_hier = HConfig(host=host)
>>> compiled_config_hier.load_from_file('./tests/files/compiled_config.conf')
>>>
>>> # Build Hierarchical Configuration object for the Remediation Config
...
>>> remediation_config_hier = running_config_hier.config_to_get_to(compiled_config_hier)
>>>
>>> for line in remediation_config_hier.all_children():
...     print(line.cisco_style_text())
...
vlan 3
  name switch_mgmt_10.0.3.0/24
vlan 4
  name switch_mgmt_10.0.4.0/24
interface Vlan2
  no shutdown
  mtu 9000
  ip access-group TEST in
interface Vlan3
  description switch_mgmt_10.0.3.0/24
  ip address 10.0.3.1 255.255.0.0
interface Vlan4
  mtu 9000
  description switch_mgmt_10.0.4.0/24
  ip address 10.0.4.1 255.255.0.0
  ip access-group TEST in
  no shutdown

The files in the example can be seen in the tests/files folder.

hier_config's People

Contributors

aedwardstx avatar dfex avatar itdependsnetworks avatar jmcgill298 avatar jtdub avatar traviscibot avatar

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.