Skip to main content

Python tools for interacting with UMnet's network tools

Project description

umnet-scripts

A set of python modules/classes for interacting with UMnet tools.

This package is hosted on pypi - you can install it with pip install umnet-scripts and use it in your own code.

Database Helper Classes

As of Dec 2021 this repo defines db wrapper classes for Equipdb, Netinfo, and Netdisco. To use these classes you need to set specific environment variables with the credentials for each db respectively:

  • Netinfo: NETINFO_USERNAME, NETINFO_PASSSWORD
  • Netdisco: NETDISCO_DB_USER, NETDISCO_DB_PASSWORD
  • Equipdb: EQUIP_DB_USER, EQUIP_DB_PASSWORD

Queries for specific things are added as they're needed. As of Dec 2021 there are only a few methods defined for netdisco and equipdb. Each class inherits a super basic sql query builder method as well as an 'execute' method from a base class (see umnetdb.py).

Rancid Helper Class

The rancid helper class currently parses the router.db files in /home/rancid/ as well as the /home/rancid/Topology into a list of Device objects with rancid-related data as attributes, particularly the following:

  • rancid_name: The name of the device as rancid knows it (the name of the config file). IP address for AL, DNS name for everything else.
  • rancid_type: The rancid perl script that is used to back up the device (eg juniper or Cat3750)
  • rancid_role: This is the folder the device config lives in, eg accesslayer or core. Maps 1:1 to the equipdb device type.
  • model: Device model as populated in equipdb, eg 'EX2200-24T-4G'
  • cfg_file: Full path to the config file, eg /home/rancid/accesslayer/10.233.0.10
  • status: Up or down per the equipdb offline flag (offline is down).
  • neighbors: A dict of the device's neighbors as reported by TopologyWalker.

There are also two attributes that look like attributes but are actually 'property' functions: hostname and ip that return the device's hostname or IP respectively. If you call 'hostname' for a device whose rancid name is an IP, a dns reverse lookup is done. Similarly, if you call 'ip' on a device whose rancid name is a DNS name, a forward dns lookup is done.

Note that if you're only focusing on one rancid config folder (eg datacenter, accesslayer, etc), to speed your code up you can limit which folders are processed when you instantiate the Rancid class. Note that if you want to get devices by dl_zone you must include the distlayer folder at minimum.

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

umnet_scripts-1.1.0.tar.gz (29.5 kB view details)

Uploaded Source

File details

Details for the file umnet_scripts-1.1.0.tar.gz.

File metadata

  • Download URL: umnet_scripts-1.1.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/8.5.0 keyring/25.6.0 pkginfo/1.12.0 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for umnet_scripts-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ca33b51bc8de0ccb49091d3e4828426df43cdbc2e094d9b649b506e10fdea7a4
MD5 ae264963912a841e662eabec8d4b132c
BLAKE2b-256 6f51d2127e68ffc2db21926044cdb4ce857de38fb4a4386224565de93e80c8d5

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