GithubHelp home page GithubHelp logo

laherre / ciscointerfacenameconverter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timothyharder/ciscointerfacenameconverter

0.0 0.0 0.0 48 KB

Convert between short and long versions of cisco interface names.

License: GNU General Public License v3.0

Python 100.00%

ciscointerfacenameconverter's Introduction

Cisco Interface Name Converter

Written because some Cisco CLI commands output a short version of the interface name, and some output a long version of the interface name. I needed a way to consistently map this relationship, and since I couldn't find something like this online, I decided to share the knowledge with the community.

You can use the interface_abbreviations dictionary in your own code, or use the supplied convert_interface method to convert interface names.

Getting started

from CiscoInterfaceNameConverter import converter converter.convert_interface(

  • interface_name="GigabitEthernet1/0/1" (REQUIRED)
  • return_short=False (Optional)
  • return_long=False (Optional)
  • simple_mode=True (Optional)
  • silent=False (Optional)

)

This will convert the interface name to the opposite of whatever you passed into the function.

You can force the return of the short or long version of the interface name. I tend to do this to all interfaces, even if I know it's already in one form. That way it's always consistent.

Simple mode will use a string slicing method to convert the long to short if the name doesn't match any known abbreviations.

Silent will disable output to stdout when names don't match.

If you don't want to use the converter function, feel free to just take the dictionary.

from CiscoInterfaceNameConverter.converter import interface_abbreviations

This dictionary has the long form as the key and the short form as the value.

Contributing

If suggesting a new abbreviation get added to the dictionary, please do so in a pull request. Please attach screenshots of the output from the Cisco device showing both the long and short versions of the interface name.

ciscointerfacenameconverter's People

Contributors

timothyharder 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.