Skip to main content

cisco interface rangifier

Project description

README

This repo contains function that takes cisco config and turns its interface configurations and makes ranged interfaces as it's much more compact. It compares every interface config block to others and extracts similar ones only. It also shortens the cisco interface names. ex: it prints GigabitEthernet1/0/1 as Gi1/0/1

Installation

Run the following to install:

pip install rangify

Usage

from rangify import ranger

ranger("cisco_config.txt") # or ranger(interfaces_dict)

It can accept 2 types of inputs.


Text config from file


Let's say test_config.txt contains following text(abbreviated, for full text please check the test_config.txt file)

!
interface GigabitEthernet1/0/1
 ...any text config block..
!
interface GigabitEthernet1/0/2
 ...any text config block..
!
interface GigabitEthernet1/0/3
 ...any text config block..
!

Then following function will print to screen more compact ranged version of configuration:

ranger("filename.txt")

Output:

interface range Gi1/0/1-3
 ...any text config block...

Interfaces as dictionary of dictionaries


This takes dictionary of dictionaries as an input. Key for dictionary is interface name and the value is the configuration dictionary. And returns same dictionary structure but this time the keys are in collapsed/ranged form. Example below.

# input dictionary
sample_ints = {
        "GigabitEthernet1/0/1": {},
        "GigabitEthernet1/0/2": {},
        "GigabitEthernet1/0/4": {"mode": "access"},
        "GigabitEthernet3/4/2": {"mode": "access"},
        "GigabitEthernet3/4/3": {"mode": "access"},
        "GigabitEthernet3/5/3": {"mode": "trunk"},
        "GigabitEthernet3/6/3": {"mode": "trunk"},
}
# range them all
print(ranger(interfaces))

Output:

    {'range Gi1/0/1-2': {}, 
    'range Gi1/0/4, Gi3/4/2-3': {'mode': 'access'}, 
    'range Gi3/5/3, Gi3/6/3': {'mode': 'trunk'}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rangify-0.0.8.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rangify-0.0.8-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file rangify-0.0.8.tar.gz.

File metadata

  • Download URL: rangify-0.0.8.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for rangify-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d434df3b1d82358c75773465dd83dabbca52d984aaf697024bc608d40641c470
MD5 38f3e3e7362b5d15d1c2a6232c0fdffe
BLAKE2b-256 ca7f1670eae6497beb2a091da7ad6a1f1e7fbc20be81204ce199e64e9d0512ad

See more details on using hashes here.

File details

Details for the file rangify-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: rangify-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for rangify-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 59ca842ae2e397c92f89964e6b37ad264a298fb3a5b00837ba71db05cb5e5ea3
MD5 ed1fd96a6b7f194a52c2baa2b0dab3eb
BLAKE2b-256 d99d21e0a4697e003e86f4621499444d7e72a748601624032eb8f9876e4a16e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page