Command Parsers Datasource¶
This datasource provides custom TextFSM and TTP parser templates that the app uses at runtime to parse CLI command output. This is useful when:
- You need a custom parser not available in ntc-templates
- You want to override an existing ntc-templates parser with a custom version
- You are using TTP templates (which are not included in ntc-templates)
Directory Structure¶
repository_root/
├── parsers/
│ ├── cisco_ios/
│ │ ├── show_version.textfsm
│ │ ├── show_ip_bgp_summary.textfsm
│ │ └── show_interfaces.ttp
│ ├── arista_eos/
│ │ ├── show_version.textfsm
│ │ └── show_ip_bgp_summary.ttp
│ └── juniper_junos/
│ └── show_bgp_summary.ttp
File Naming Convention¶
The app converts the CLI command to a filename by replacing spaces with underscores:
| CLI Command | Expected Filename |
|---|---|
show version |
show_version.textfsm or show_version.ttp |
show ip bgp summary |
show_ip_bgp_summary.textfsm or show_ip_bgp_summary.ttp |
show interfaces |
show_interfaces.textfsm or show_interfaces.ttp |
The file extension (.textfsm or .ttp) must match the parser type configured on the CommandParser object.
Parser File Path Resolution¶
At runtime, the app resolves parser file paths using a Jinja2 template. The default template renders to a path like cisco_ios/show_version, which is then appended to the parsers/ directory in the Git repository and given the appropriate file extension.
The full resolution path is: <repo>/parsers/<network_driver>/<command_filename>.<parser_type>
Example: For a device with platform cisco_ios running show ip bgp summary with a textfsm parser:
Customizing the Path Template¶
The path template can be customized via the GIT_PARSERS_PATH setting in your Nautobot configuration or via the Constance admin UI. Available template variables:
| Variable | Description |
|---|---|
{{ obj }} |
The device object |
{{ obj.platform.network_driver }} |
The platform's network driver (e.g., cisco_ios) |
{{ cmd }} |
The command converted to a filename (spaces replaced with underscores) |
Parser Lookup Behavior¶
When the app needs to parse command output, it follows this lookup order:
| Parser Type | Custom Git Template | Fallback |
|---|---|---|
| TextFSM | Checks Git repos for .textfsm file |
Falls back to ntc-templates built-in templates |
| TTP | Checks Git repos for .ttp file |
No fallback — fails if not found in a Git repo |
| NAPALM | N/A | Uses NAPALM getter directly |
| JSON | N/A | Parses JSON output directly |
Warning
TTP parsers must be provided through a Git repository. There is no built-in fallback for TTP templates. If a TTP template is not found, the command output parsing will fail.