GithubHelp home page GithubHelp logo

veracosta / cisco-config-parse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lozzd/cisco-config-parse

0.0 2.0 0.0 172 KB

A gem to allow easy parsing of Cisco configuration files

Ruby 100.00%

cisco-config-parse's Introduction

cisco-config-parse

What?

cisco-config-parse is a gem that given a Cisco configuration file, parses it to provide an easy breakdown of information for manipulation. For example, you can get the list of interfaces as a hash with relevant details, such as the description on the port, the VLAN configuration, etc.

How to use

require 'cisco-config-parse'
parser = CiscoConfigParse.new(IO.readlines("/path/to/file"))
# Parse the file
parser.parse
# Get a hash of the interfaces
puts parser.get_interfaces

{"FastEthernet0"=>{}, "GigabitEthernet0/1"=>{:description=>"host0119.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, "GigabitEthernet0/2"=>{:description=>"host0120.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, "GigabitEthernet0/3"=>{:description=>"host0123.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, "GigabitEthernet0/4"=>{:description=>"host0124.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, "GigabitEthernet0/5"=>{:description=>"host0127.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, "GigabitEthernet0/6"=>{:description=>"host0128.ilo", :access_vlan=>"21", :bpduguard=>"enable"}, ...[snip]

Methods

  • parse - Parses the configuration, required for any other operation
  • get_interfaces - Returns a hash of all interfaces in config along with their details
  • get_hostname - Returns the hostname of the switch
  • get_version - Returns the version of the software running on the switch

Bugs? Improvements?

Probably; this does the bare minimum right now (in my case, I wanted to compare the VLANs on all interfaces on two switches. Please do let me know if anything is broken, and as always please do submit pull requests with any improvements.

Thanks

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.