Skip to main content

Package to return structured data from the output of network devices.

Project description

Build Status

REPOSITORY OF TEXTFSM TEMPLATES FOR NETWORK DEVICES

NTC-Templates contains a set of multi-vendor templates based around TEXTFSM parsing engine.

These templates take the raw string input from the CLI of network infrastructure devices, such as Cisco IOS, Juniper JUNOS or HPE Comware devices, run them through a TEXTFSM template and return structured text in the form of a Python dictionary.

Contributing

Pull request are welcomed and automatically built and tested through TravisCI.

To contribute new templates, each new pull request must include the folowing

  • TextFSM template
  • raw version of text to be parsed
  • YAML file containing the expected parsed dictionary
  • Modified version of the index file

Some notes on contributing that should help you ensure that your TravisCI builds comes back as successful:

TextFSM Templates

TextFSM templates should be placed in the ./templates folder and should adhere to the NTC-Templates style. The TextFSM template name should be in the following format

{{ vendor_name }}_{{show_command}}

Note: The vendor name must be valid from the Netmiko library.

The Value variable should be in UPPERCASE.

An example of the proper format is shown below.

Value TIME (\d+:\d+:\d+)
Value TIMEZONE (\S+)
Value DAYWEEK (\w+)
Value MONTH (\d+)
Value DAY (\d+)
Value YEAR (\d+)

Start
  ^${TIME}\s+${TIMEZONE}\s+${DAYWEEK}\s+${DAY}/${MONTH}/${YEAR} -> Record

Raw version of Input Text

The raw text file should contain only the output of the CLI command to be parsed. It should not contain the CLI command itself The raw text file should be placed in a folder in the ./tests directory with the same name as the template file minus the .template extension

An example of the proper format is shown below

19:35:31 UTC Sat 01/08/2011

YAML file containing expected parsed dictionary

The parsed dictionary must be in a dictionary format. All keys in the dictionary should be in all lowercase

The parsed text file should be placed in a folder in the ./tests directory with the same name as the template file minus the .template extension. The raw text file and the parsed text file should be in the same folder.

An example of the proper format is shown below

---

parsed_sample:


- {day: '01', dayweek: Sat, month: 08, time: '19:35:31', timezone: UTC, year: '2011'}

Multiple RAW and Parsed files are supported per folder, and are encouraged, as there are differences depending on version, length, etc... that additional testing and more real life data helps identify.

Index File

The Index file binds the templates to the commands being run. Special care has been taken on ordering, as there is potential for issues. e.g. show ip route picking up for show ip router vrf <vrf-name>. We have used a combination of ordering, as defined:

  • OS in alphabetical order
  • Command in length other
  • When Length is the same, use alphabetical order
  • Keep space between OS's

Example:

Template, Hostname, Platform, Command

arista_eos_show_mlag.template, .*, arista_eos, sh[[ow]] ml[[ag]]
arista_eos_show_vlan.template, .*, arista_eos, sh[[ow]] vl[[an]]

cisco_asa_dir.template,  .*, cisco_asa, dir

cisco_ios_show_capability_feature_routing.template,  .*, cisco_ios, sh[[ow]] cap[[ability]] f[[eature]] r[[outing]]
cisco_ios_show_interface_transceiver.template, .*, cisco_ios, sh[[ow]] int[[erface]] trans[[ceiver]]
cisco_ios_show_cdp_neighbors_detail.template, .*, cisco_ios, sh[[ow]] c[[dp]] neig[[hbors]] det[[ail]]

Questions

For any questions or comments, please feel free to swing by the networktocode slack channel.

Sign up here

Release History

1.0.0 +++++

  • First initial release

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

ntc_templates-1.1.0.tar.gz (88.8 kB view details)

Uploaded Source

Built Distribution

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

ntc_templates-1.1.0-py3-none-any.whl (172.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ntc_templates-1.1.0.tar.gz
  • Upload date:
  • Size: 88.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for ntc_templates-1.1.0.tar.gz
Algorithm Hash digest
SHA256 40bcc2f922baefcdebff37908b090971e120d685788470d2d62b4dc2fef3c7f4
MD5 0733712c83432ff05da63629e2c71488
BLAKE2b-256 a8fe8dc71398b1b47fbe94e689f9d8d1fc35e80984e5041ed837d134b69d50a9

See more details on using hashes here.

File details

Details for the file ntc_templates-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ntc_templates-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 172.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for ntc_templates-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1648121047e2c6fd861427cc1c9acd8c18a912d5a19f2bd54037930a958e1d
MD5 d8045996811ef720cb20afd358c804d7
BLAKE2b-256 186ac2bd05ab032319063034f337bc2e7b457beaa5896a6a7aac927f3fc34f53

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