NTC Templates

9.1.0 · active · verified Sun Apr 12

NTC Templates is a Python library providing a comprehensive collection of TextFSM templates for parsing command-line interface (CLI) output from various network devices. It converts unstructured CLI text into structured, machine-readable data (lists of dictionaries), acting as a crucial tool for network automation workflows. The library is actively maintained with frequent updates and bug fixes, currently at version 9.1.0, and often releases minor and major versions to incorporate new templates or data model changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse raw CLI output using `ntc-templates`. It defines a sample `show version` output from a Cisco IOS device and uses `parse_output` with the corresponding platform and command to transform it into structured Python data (a list of dictionaries). Error handling is included as a best practice.

import os
from ntc_templates.parse import parse_output

# Example raw CLI output from a Cisco IOS device
raw_output = """
Cisco IOS Software, C800 Series Software (C800-UNIVERSALK9-M), Version 15.6(3)M5, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2017 by Cisco Systems, Inc.
Compiled Wed 27-Sep-17 12:00 by prod_rel_team

ROM: System Bootstrap, Version 15.5(3)M, RELEASE SOFTWARE (fc1)

Cisco C891F (1RU) processor (revision 1.0) with 1007616K/54272K bytes of memory.
Processor board ID FHK2126210F
10 Gigabit Ethernet interfaces
8 FastEthernet interfaces
2 Gigabit Ethernet interfaces
1 Virtual Private Network (VPN) Module
256K bytes of non-volatile configuration memory.
1024000K bytes of ATA System CompactFlash (Read/Write)

License Level: ipservices
License Type: Permanent
Next reload will be a ipservices license

Configuration register is 0x2102
"""

# Define the platform and command corresponding to an NTC template
platform = "cisco_ios"
command = "show version"

try:
    parsed_data = parse_output(platform=platform, command=command, data=raw_output)
    print(parsed_data)
except Exception as e:
    print(f"Error parsing output: {e}")

# Expected output is a list of dictionaries with parsed data
# Example of accessing some data (output structure depends on template):
# if parsed_data:
#     print(f"Software Version: {parsed_data[0].get('VERSION')}")
#     print(f"Platform: {parsed_data[0].get('HARDWARE')}")

view raw JSON →