{"id":4652,"library":"ntc-templates","title":"NTC Templates","description":"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.","status":"active","version":"9.1.0","language":"en","source_language":"en","source_url":"https://github.com/networktocode/ntc-templates","tags":["network automation","textfsm","cli parsing","network devices","templates","structured data"],"install":[{"cmd":"pip install ntc-templates","lang":"bash","label":"Install ntc-templates"}],"dependencies":[{"reason":"Core dependency for parsing network CLI output using TextFSM templates. Specific version '1.1.0' is often required to avoid import errors.","package":"textfsm","optional":false}],"imports":[{"note":"The `parse_output` function resides within the `ntc_templates.parse` module, not directly under the top-level package.","wrong":"from ntc_templates import parse_output","symbol":"parse_output","correct":"from ntc_templates.parse import parse_output"}],"quickstart":{"code":"import os\nfrom ntc_templates.parse import parse_output\n\n# Example raw CLI output from a Cisco IOS device\nraw_output = \"\"\"\nCisco IOS Software, C800 Series Software (C800-UNIVERSALK9-M), Version 15.6(3)M5, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2017 by Cisco Systems, Inc.\nCompiled Wed 27-Sep-17 12:00 by prod_rel_team\n\nROM: System Bootstrap, Version 15.5(3)M, RELEASE SOFTWARE (fc1)\n\nCisco C891F (1RU) processor (revision 1.0) with 1007616K/54272K bytes of memory.\nProcessor board ID FHK2126210F\n10 Gigabit Ethernet interfaces\n8 FastEthernet interfaces\n2 Gigabit Ethernet interfaces\n1 Virtual Private Network (VPN) Module\n256K bytes of non-volatile configuration memory.\n1024000K bytes of ATA System CompactFlash (Read/Write)\n\nLicense Level: ipservices\nLicense Type: Permanent\nNext reload will be a ipservices license\n\nConfiguration register is 0x2102\n\"\"\"\n\n# Define the platform and command corresponding to an NTC template\nplatform = \"cisco_ios\"\ncommand = \"show version\"\n\ntry:\n    parsed_data = parse_output(platform=platform, command=command, data=raw_output)\n    print(parsed_data)\nexcept Exception as e:\n    print(f\"Error parsing output: {e}\")\n\n# Expected output is a list of dictionaries with parsed data\n# Example of accessing some data (output structure depends on template):\n# if parsed_data:\n#     print(f\"Software Version: {parsed_data[0].get('VERSION')}\")\n#     print(f\"Platform: {parsed_data[0].get('HARDWARE')}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Review the official release notes (e.g., `https://ntc-templates.readthedocs.io/en/latest/admin/release_notes/version_9.0/`) to understand specific breaking changes and update your code/templates accordingly. This may involve changes to expected dictionary keys due to a move towards a common data model.","message":"Version 9.0.0 introduced breaking changes. Users upgrading from previous major versions, especially those with custom templates or relying on specific output field names, should consult the official release notes for migration steps.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Ensure `textfsm` is installed at version `1.1.0` using `pip install textfsm==1.1.0` before installing or using `ntc-templates`.","message":"A common 'Cannot import name clitable from textfsm' error occurs due to an incompatibility between `ntc-templates` and certain `textfsm` PyPI distributions. This is often seen when `textfsm` is not explicitly pinned to a compatible version.","severity":"gotcha","affected_versions":"All versions where `textfsm` is not `1.1.0`"},{"fix":"Always implement error handling around `parse_output` calls. Validate the parsed output before using it in automation. If a template fails or misses data, consider contributing a fix or creating a custom template.","message":"NTC Templates rely on TextFSM, which uses regular expressions. If the raw CLI output from a network device changes format in a way not anticipated by the template, parsing may fail or produce incomplete/incorrect data. Templates do not guarantee to capture all possible data fields.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If maintaining custom TextFSM templates, rename your template files from `.template` to `.textfsm` and your parsed test files from `.parsed` to `.yml` for consistency and to leverage modern tooling like YAML linting.","message":"Older versions of `ntc-templates` used `.template` for TextFSM template files and `.parsed` for expected output files. These extensions have been updated to `.textfsm` and `.yml` respectively.","severity":"deprecated","affected_versions":"<1.7.0 (transition began around this version)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}