catalyst-config-auditor 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- catalyst_config_auditor-1.4.0/CHANGELOG.md +32 -0
- catalyst_config_auditor-1.4.0/CLI_HELP_v1.4.0.txt +158 -0
- catalyst_config_auditor-1.4.0/CONTRIBUTING.md +22 -0
- catalyst_config_auditor-1.4.0/Catalyst_Config_Auditor.py +15 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/README.md +19 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_device-tracking_database.textfsm +11 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_environment_all.textfsm +12 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_interfaces_counters.textfsm +24 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_interfaces_counters_errors.textfsm +12 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_interfaces_trunk.textfsm +36 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_ip_arp_inspection_interfaces.textfsm +10 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_ip_dhcp_snooping.textfsm +18 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_ip_protocols.textfsm +19 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/index +9 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/README.md +6 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_device_tracking_database.ttp +4 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_interfaces_counters_errors.ttp +4 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_ip_arp.ttp +5 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_ip_arp_inspection_interfaces.ttp +4 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_ip_dhcp_snooping_binding.ttp +4 -0
- catalyst_config_auditor-1.4.0/Custom_Parsers/TTP/show_ip_interface_brief.ttp +4 -0
- catalyst_config_auditor-1.4.0/LICENSE +7 -0
- catalyst_config_auditor-1.4.0/MANIFEST.in +7 -0
- catalyst_config_auditor-1.4.0/PKG-INFO +232 -0
- catalyst_config_auditor-1.4.0/PROJECT_CONTEXT.md +40 -0
- catalyst_config_auditor-1.4.0/README.md +200 -0
- catalyst_config_auditor-1.4.0/SECURITY.md +10 -0
- catalyst_config_auditor-1.4.0/cmd.txt +11 -0
- catalyst_config_auditor-1.4.0/examples/Commands_Output.txt +40 -0
- catalyst_config_auditor-1.4.0/examples/LAB-SW01_Commands.xlsx +0 -0
- catalyst_config_auditor-1.4.0/examples/LAB-SW01_running_Config.txt +45 -0
- catalyst_config_auditor-1.4.0/examples/show_environment_all.txt +6 -0
- catalyst_config_auditor-1.4.0/examples/show_interfaces_trunk.txt +15 -0
- catalyst_config_auditor-1.4.0/examples/show_ip_arp.txt +3 -0
- catalyst_config_auditor-1.4.0/examples/template_interfaces.j2 +48 -0
- catalyst_config_auditor-1.4.0/pyproject.toml +54 -0
- catalyst_config_auditor-1.4.0/requirements.txt +7 -0
- catalyst_config_auditor-1.4.0/setup.cfg +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/README.md +19 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_device-tracking_database.textfsm +11 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_environment_all.textfsm +12 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_interfaces_counters.textfsm +24 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_interfaces_counters_errors.textfsm +12 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_interfaces_trunk.textfsm +36 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_ip_arp_inspection_interfaces.textfsm +10 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_ip_dhcp_snooping.textfsm +18 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/cisco_ios_show_ip_protocols.textfsm +19 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/NTC/index +9 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/README.md +6 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_device_tracking_database.ttp +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_interfaces_counters_errors.ttp +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_ip_arp.ttp +5 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_ip_arp_inspection_interfaces.ttp +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_ip_dhcp_snooping_binding.ttp +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/Custom_Parsers/TTP/show_ip_interface_brief.ttp +4 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/__init__.py +3 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/__main__.py +5 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/cli.py +1946 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/cmd.txt +11 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor/variables_selection.yaml +45 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/PKG-INFO +232 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/SOURCES.txt +67 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/dependency_links.txt +1 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/entry_points.txt +2 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/requires.txt +11 -0
- catalyst_config_auditor-1.4.0/src/catalyst_config_auditor.egg-info/top_level.txt +1 -0
- catalyst_config_auditor-1.4.0/tests/test_v139.py +92 -0
- catalyst_config_auditor-1.4.0/tests/test_v140.py +181 -0
- catalyst_config_auditor-1.4.0/variables_selection.yaml +45 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.4.0] — 2026-11-05
|
|
4
|
+
- Add separate SSH modes `--backup-only`, `--commands-only` and `--collect` (backup + show outputs only).
|
|
5
|
+
- Add `--excel --input <any/Commands_Output.txt>`; default workbook is saved beside input TXT, plus recursive `--input-dir DIR` batch mode.
|
|
6
|
+
- Add independent `--extract-vars` (YAML only) and `--generate-templates` (Jinja only) with `--vars-dir`.
|
|
7
|
+
- Add `--create-main`, `--create-interfaces`, and `--create-full` to render distinct offline configuration files.
|
|
8
|
+
- Preserve `--vars` for combined YAML/Jinja2 and `-AIO` for all stages including Excel.
|
|
9
|
+
- Expand CLI `--help` examples for each mode, retain TTP/NTC/custom/RAW parser logic.
|
|
10
|
+
- Ensure no file overwrites without `--overwrite`; protect original offline inputs.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [1.3.9] — 2026-11-04
|
|
14
|
+
- Parse recognized `show` outputs into Excel columns; use a single `RAW` column for unmatched commands.
|
|
15
|
+
- Remove the `Parsing_Summary` worksheet and write per-command parser results to logs.
|
|
16
|
+
- Support external custom NTC/TextFSM templates using `--ntc-dir`; keep TTP, built-in Python parsers and RAW fallback.
|
|
17
|
+
- Save configuration backups as `<hostname>_running_Config.txt` (legacy naming remains readable for offline extraction).
|
|
18
|
+
- Include routed interfaces in `var_interfaces.yaml` and their reusable blocks in generated interface templates.
|
|
19
|
+
- Try saved `show inventory`, `show version`, and `license udi` for chassis serial identification.
|
|
20
|
+
- Reduce extra lines in generated interface Jinja2 while preserving Cisco indentation.
|
|
21
|
+
|
|
22
|
+
## [1.3.8]
|
|
23
|
+
- Remove Genie/pyATS integration and runtime dependency; retain TTP/custom/RAW parsing.
|
|
24
|
+
|
|
25
|
+
## [1.3.7]
|
|
26
|
+
- Independently preserve existing `ip arp inspection trust` and `ip arp inspection limit rate N` commands; do not inject defaults.
|
|
27
|
+
|
|
28
|
+
## [1.3.6]
|
|
29
|
+
- Introduce optional TTP parsing, offline parser test/check and engine reporting.
|
|
30
|
+
|
|
31
|
+
## [1.3.5]
|
|
32
|
+
- Simplify VLAN/BGP/secondary-IP variable structures and generic Jinja2 templates.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
usage: Catalyst_Config_Auditor.py [-h] [-ho HOST | -hf HOST_FILE |
|
|
2
|
+
--from-config FROM_CONFIG] [-u USERNAME]
|
|
3
|
+
[-p PASSWORD] [-o OUTPUT] [-AIO] [--collect]
|
|
4
|
+
[--backup-only] [--commands-only] [--vars]
|
|
5
|
+
[--extract-vars] [--generate-templates]
|
|
6
|
+
[--create] [--create-main]
|
|
7
|
+
[--create-interfaces] [--create-full]
|
|
8
|
+
[--interface-template INTERFACE_TEMPLATE]
|
|
9
|
+
[--interface-vars INTERFACE_VARS] [--backup]
|
|
10
|
+
[--excel]
|
|
11
|
+
[--parser {auto,ttp,ntc,custom,raw}]
|
|
12
|
+
[--parser-dir DIR] [--ntc-dir DIR]
|
|
13
|
+
[--parser-test COMMAND] [--parser-check]
|
|
14
|
+
[--input FILE] [--input-dir DIR]
|
|
15
|
+
[--ttp-template FILE] [--json-output FILE]
|
|
16
|
+
[--yaml] [--cmd-file CMD_FILE]
|
|
17
|
+
[--selection SELECTION] [--vars-dir DIR]
|
|
18
|
+
[--template [FILE]] [--variables [FILE]]
|
|
19
|
+
[--extra-vars FILE] [--output-file FILE]
|
|
20
|
+
[--model MODEL] [-w WORKERS] [--overwrite]
|
|
21
|
+
[--debug] [--version]
|
|
22
|
+
|
|
23
|
+
Catalyst Config Auditor v1.4.0 | Excel, selective YAML and Jinja2
|
|
24
|
+
|
|
25
|
+
options:
|
|
26
|
+
-h, --help show this help message and exit
|
|
27
|
+
-ho, --host HOST Single hostname or management IP
|
|
28
|
+
-hf, --host-file, --hosts-file HOST_FILE
|
|
29
|
+
File with one hostname/IP per line
|
|
30
|
+
--from-config FROM_CONFIG
|
|
31
|
+
Read an existing local running-config instead of
|
|
32
|
+
connecting over SSH
|
|
33
|
+
-u, --username USERNAME
|
|
34
|
+
SSH username (prompt when missing)
|
|
35
|
+
-p, --password PASSWORD
|
|
36
|
+
SSH password (interactive prompt recommended)
|
|
37
|
+
-o, --output OUTPUT Root output folder (default: output)
|
|
38
|
+
-AIO, --all-in-one SSH backup + show commands + Excel + YAML + Jinja2
|
|
39
|
+
--collect SSH: running-config backup + show outputs (no Excel)
|
|
40
|
+
--backup-only SSH: save running-config only
|
|
41
|
+
--commands-only SSH: save show outputs only
|
|
42
|
+
--vars Offline YAML + Jinja2 (legacy combined mode)
|
|
43
|
+
--extract-vars Offline: generate only YAML files from running-config
|
|
44
|
+
--generate-templates Offline: generate only Jinja2 from running-config +
|
|
45
|
+
existing YAML
|
|
46
|
+
--create, --create_config
|
|
47
|
+
Offline: generic Jinja2 + YAML renderer
|
|
48
|
+
--create-main Offline: render only main config, excluding interface
|
|
49
|
+
include
|
|
50
|
+
--create-interfaces Offline: render only interface config
|
|
51
|
+
--create-full Offline: render complete main + interfaces config
|
|
52
|
+
--interface-template INTERFACE_TEMPLATE
|
|
53
|
+
Optional replacement for an included interface Jinja2
|
|
54
|
+
template (legacy support)
|
|
55
|
+
--interface-vars INTERFACE_VARS
|
|
56
|
+
Optional extra interface YAML file (legacy support)
|
|
57
|
+
--backup Alias for --backup-only (SSH)
|
|
58
|
+
--excel Offline Excel from --input FILE, or saved
|
|
59
|
+
output/<host>/Backups/Commands_Output.txt
|
|
60
|
+
--parser {auto,ttp,ntc,custom,raw}
|
|
61
|
+
Excel parser engine (auto: proven custom first, TTP >
|
|
62
|
+
NTC custom > NTC built-in > RAW)
|
|
63
|
+
--parser-dir DIR Folder holding .ttp templates (default:
|
|
64
|
+
Custom_Parsers/TTP)
|
|
65
|
+
--ntc-dir DIR External NTC TextFSM templates/index (default:
|
|
66
|
+
Custom_Parsers/NTC)
|
|
67
|
+
--parser-test COMMAND
|
|
68
|
+
Offline test parser for a single CLI command; requires
|
|
69
|
+
--input
|
|
70
|
+
--parser-check Display parser availability and TTP/NTC external
|
|
71
|
+
templates
|
|
72
|
+
--input FILE Source TXT for --excel or --parser-test (Excel stays
|
|
73
|
+
in TXT folder by default)
|
|
74
|
+
--input-dir DIR With --excel, recursively create workbooks for all
|
|
75
|
+
Commands_Output.txt files under DIR
|
|
76
|
+
--ttp-template FILE Explicit .ttp template for --parser-test (overrides
|
|
77
|
+
--parser-dir)
|
|
78
|
+
--json-output FILE Save --parser-test structured result as JSON
|
|
79
|
+
--yaml Alias for --vars (offline)
|
|
80
|
+
--cmd-file CMD_FILE Command list for --collect; asks interactively when
|
|
81
|
+
omitted (default cmd.txt)
|
|
82
|
+
--selection SELECTION
|
|
83
|
+
YAML field selection file
|
|
84
|
+
--vars-dir DIR Directory for generated YAML/Jinja2, or source folder
|
|
85
|
+
for --create-main/interfaces/full
|
|
86
|
+
--template [FILE] Main Jinja2 template; omit FILE to be prompted during
|
|
87
|
+
--create
|
|
88
|
+
--variables [FILE] ANY YAML variables; omit FILE to be prompted during
|
|
89
|
+
--create
|
|
90
|
+
--extra-vars FILE Additional YAML mapping; repeat to combine files (last
|
|
91
|
+
wins)
|
|
92
|
+
--output-file, --dest FILE
|
|
93
|
+
Exact output filename for --excel or config rendering
|
|
94
|
+
--model MODEL Model hint for offline running-config processing
|
|
95
|
+
-w, --workers WORKERS
|
|
96
|
+
Concurrent SSH sessions (default: 20)
|
|
97
|
+
--overwrite Allow overwriting existing output files
|
|
98
|
+
--debug Display detailed exceptions
|
|
99
|
+
--version show program's version number and exit
|
|
100
|
+
|
|
101
|
+
COLLECTION - SSH, read-only:
|
|
102
|
+
# Collect running-config plus show commands (does not generate Excel)
|
|
103
|
+
python Catalyst_Config_Auditor.py -ho SW01 --collect --cmd-file cmd.txt
|
|
104
|
+
python Catalyst_Config_Auditor.py -hf hosts.txt --collect -w 20 -o output
|
|
105
|
+
# Backup running-config only
|
|
106
|
+
python Catalyst_Config_Auditor.py -ho SW01 --backup-only
|
|
107
|
+
# Run show commands only, without running-config backup
|
|
108
|
+
python Catalyst_Config_Auditor.py -ho SW01 --commands-only --cmd-file cmd.txt
|
|
109
|
+
|
|
110
|
+
EXCEL - offline, no SSH:
|
|
111
|
+
# Input may be anywhere; Excel is saved NEXT TO that TXT by default
|
|
112
|
+
python Catalyst_Config_Auditor.py --excel --input "C:\Backups\SW01\Commands_Output.txt"
|
|
113
|
+
python Catalyst_Config_Auditor.py --excel --input "C:\Backups\SW01\Commands_Output.txt" --parser auto --overwrite
|
|
114
|
+
# Batch: generate Excel beside EVERY Commands_Output.txt under a folder
|
|
115
|
+
python Catalyst_Config_Auditor.py --excel --input-dir "C:\Backups\Cat9k" --parser auto
|
|
116
|
+
# Custom output file and device label (optional)
|
|
117
|
+
python Catalyst_Config_Auditor.py --excel --input saved.txt -ho SW01 --output-file SW01.xlsx
|
|
118
|
+
# Original device-folder workflow is still supported
|
|
119
|
+
python Catalyst_Config_Auditor.py -ho SW01 --excel -o output
|
|
120
|
+
# Custom NTC and TTP templates
|
|
121
|
+
python Catalyst_Config_Auditor.py --excel --input saved.txt --ntc-dir Custom_Parsers/NTC --parser-dir Custom_Parsers/TTP
|
|
122
|
+
|
|
123
|
+
VARIABLES AND TEMPLATES - offline, independent:
|
|
124
|
+
# Generate ONLY var_main.yaml + var_interfaces.yaml from a backup
|
|
125
|
+
python Catalyst_Config_Auditor.py -ho SW01 --extract-vars
|
|
126
|
+
python Catalyst_Config_Auditor.py --extract-vars --from-config "C:\Backups\SW01\SW01_running_Config.txt"
|
|
127
|
+
# Generate ONLY template_main.j2 + template_interfaces.j2, using existing YAML
|
|
128
|
+
python Catalyst_Config_Auditor.py -ho SW01 --generate-templates
|
|
129
|
+
# Legacy combined mode: variables AND templates
|
|
130
|
+
python Catalyst_Config_Auditor.py -ho SW01 --vars
|
|
131
|
+
|
|
132
|
+
CONFIG GENERATION - offline only, never sends changes to switches:
|
|
133
|
+
# Main configuration WITHOUT physical interface include
|
|
134
|
+
python Catalyst_Config_Auditor.py -ho SW01 --create-main
|
|
135
|
+
# Physical interfaces only
|
|
136
|
+
python Catalyst_Config_Auditor.py -ho SW01 --create-interfaces
|
|
137
|
+
# Complete configuration (main + included interfaces)
|
|
138
|
+
python Catalyst_Config_Auditor.py -ho SW01 --create-full
|
|
139
|
+
# Use a Variables folder at any location
|
|
140
|
+
python Catalyst_Config_Auditor.py --create-interfaces --vars-dir "C:\Backups\SW01\Variables"
|
|
141
|
+
# Generic Jinja2+YAML: any template/variables/output
|
|
142
|
+
python Catalyst_Config_Auditor.py --create --template policy.j2 --variables site.yaml --output-file policy.cfg
|
|
143
|
+
python Catalyst_Config_Auditor.py --create --template output/SW01/Variables/template_interfaces.j2 --variables output/SW01/Variables/var_interfaces.yaml
|
|
144
|
+
|
|
145
|
+
COMBINED / DIAGNOSTIC MODES:
|
|
146
|
+
python Catalyst_Config_Auditor.py -ho SW01 -AIO # collect + Excel + YAML + templates
|
|
147
|
+
python Catalyst_Config_Auditor.py --parser-check
|
|
148
|
+
python Catalyst_Config_Auditor.py --parser-test "show ip arp" --input arp.txt --parser ttp
|
|
149
|
+
|
|
150
|
+
NOTES:
|
|
151
|
+
--collect is backup + show commands only in v1.4.0; use --excel separately.
|
|
152
|
+
--vars retains old behavior (YAML + templates) for existing users.
|
|
153
|
+
--input with --excel places XLSX beside the input unless --output-file is set.
|
|
154
|
+
--input-dir recursively creates an XLSX beside every Commands_Output.txt.
|
|
155
|
+
--from-config places extracted files beside the backup, in Variables/.
|
|
156
|
+
Existing files are protected unless --overwrite is supplied.
|
|
157
|
+
No configuration commands are sent to devices.
|
|
158
|
+
See README.md for layout and security guidance.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setup (Windows / PowerShell)
|
|
4
|
+
|
|
5
|
+
```powershell
|
|
6
|
+
py -m venv .venv
|
|
7
|
+
.venv\Scripts\Activate.ps1
|
|
8
|
+
python -m pip install -r requirements.txt
|
|
9
|
+
python Catalyst_Config_Auditor.py --help
|
|
10
|
+
python -m unittest discover -s tests -v
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Before opening a PR
|
|
14
|
+
1. Preserve the single-file application (`Catalyst_Config_Auditor.py`) and public CLI flags unless a change is intentional.
|
|
15
|
+
2. Add offline fixture-based tests for new parser or rendering behavior; do not require switch access in CI.
|
|
16
|
+
3. Keep comments/docstrings in English and use fictitious hostnames, serials, MACs and RFC 5737 documentation IPv4 addresses.
|
|
17
|
+
4. Prefer parsing that verifies its record count/columns; keep the original output and use RAW on unrecognized formats.
|
|
18
|
+
5. Keep `PROJECT_CONTEXT.md`, `CHANGELOG.md` and the version constant in sync.
|
|
19
|
+
6. Never add production outputs or credentials. Generated variable YAML can contain BGP secrets.
|
|
20
|
+
|
|
21
|
+
## New parsing templates
|
|
22
|
+
For NTC/TextFSM, add `Custom_Parsers/NTC/cisco_ios_show_*.textfsm`, update `Custom_Parsers/NTC/index`, and add a synthetic sample test. For TTP, add an appropriately named `.ttp` in `Custom_Parsers/TTP/`. Verify on sanitized device outputs because IOS-XE may use multiple formatting variants.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Backward-compatible launcher and import alias to the packaged implementation."""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
_SRC = Path(__file__).resolve().parent / 'src'
|
|
7
|
+
if _SRC.is_dir():
|
|
8
|
+
sys.path.insert(0, str(_SRC))
|
|
9
|
+
from catalyst_config_auditor import cli as _implementation
|
|
10
|
+
|
|
11
|
+
if __name__ == '__main__':
|
|
12
|
+
raise SystemExit(_implementation.main())
|
|
13
|
+
else:
|
|
14
|
+
# Legacy unit tests and downstream monkeypatching must affect the real module.
|
|
15
|
+
sys.modules[__name__] = _implementation
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# NTC / TextFSM directory
|
|
2
|
+
|
|
3
|
+
Put your `cisco_ios_<command>.textfsm` files here and optionally register them in `index`.
|
|
4
|
+
|
|
5
|
+
The auditor accepts two discovery modes:
|
|
6
|
+
|
|
7
|
+
1. `index` file with NTC syntax: `Template, Hostname, Platform, Command` plus mappings.
|
|
8
|
+
2. Direct filename convention, e.g. `cisco_ios_show_interfaces_trunk.textfsm`.
|
|
9
|
+
|
|
10
|
+
The default `--ntc-dir` is `Custom_Parsers/NTC`, resolved from the working directory or beside the script. A full official collection in `Custom_Parsers/NTC/templates/index` is also accepted.
|
|
11
|
+
|
|
12
|
+
Install: `python -m pip install ntc-templates textfsm`.
|
|
13
|
+
|
|
14
|
+
The example templates in this package are based on **illustrative CLI formats**. Several IOS-XE releases and chassis differ. Test each template with `--parser-test` and representative saved outputs before relying on the Excel results. The original Commands_Output.txt is always retained.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
```
|
|
18
|
+
python Catalyst_Config_Auditor.py --parser-test "show interfaces trunk" --input examples/show_interfaces_trunk.txt --parser ntc
|
|
19
|
+
```
|
catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_device-tracking_database.textfsm
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Supports common IPv4 database layouts. Platform/version differences require local tests.
|
|
2
|
+
Value Required IP_ADDRESS (\d{1,3}(?:\.\d{1,3}){3})
|
|
3
|
+
Value MAC_ADDRESS ((?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4}|(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2})
|
|
4
|
+
Value VLAN (\d+)
|
|
5
|
+
Value INTERFACE (\S+)
|
|
6
|
+
Value STATE (\S+)
|
|
7
|
+
|
|
8
|
+
Start
|
|
9
|
+
^\s*${IP_ADDRESS}\s+${MAC_ADDRESS}\s+${VLAN}\s+${INTERFACE}\s+${STATE}\s*$$ -> Record
|
|
10
|
+
^\s*${IP_ADDRESS}\s+${MAC_ADDRESS}\s+${INTERFACE}\s+${VLAN}\s+${STATE}\s*$$ -> Record
|
|
11
|
+
^\s*${IP_ADDRESS}\s+${MAC_ADDRESS}\s+${VLAN}\s+${INTERFACE}\s*$$ -> Record
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Catalyst IOS-XE - selected fan/power/temperature status rows.
|
|
2
|
+
Value SWITCH (\d+)
|
|
3
|
+
Value COMPONENT (\S+(?:\s+\S+)?)
|
|
4
|
+
Value STATUS (\S+(?:\s+\S+)?)
|
|
5
|
+
Value TEMPERATURE_C (\d+(?:\.\d+)?)
|
|
6
|
+
|
|
7
|
+
Start
|
|
8
|
+
^\s*Switch\s+${SWITCH}\s+FAN\s+${COMPONENT}\s+is\s+${STATUS}\s*$$ -> Record
|
|
9
|
+
^\s*FAN\s+${COMPONENT}\s+is\s+${STATUS}\s*$$ -> Record
|
|
10
|
+
^\s*(?:Power Supply|POWER SUPPLY|PSU)\s+${COMPONENT}\s+is\s+${STATUS}\s*$$ -> Record
|
|
11
|
+
^\s*SYSTEM TEMPERATURE\s+is\s+${STATUS}\s*$$ -> Record
|
|
12
|
+
^\s*Temperature\s*:\s*${TEMPERATURE_C}\s*(?:C|Degree Celsius|degrees C)?\s*$$ -> Record
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# The two counter blocks yield separate rows; pivot/merge rows by PORT for Excel.
|
|
2
|
+
Value Required PORT (\S+)
|
|
3
|
+
Value IN_OCTETS (\d+)
|
|
4
|
+
Value IN_UCAST (\d+)
|
|
5
|
+
Value IN_MCAST (\d+)
|
|
6
|
+
Value IN_BCAST (\d+)
|
|
7
|
+
Value OUT_OCTETS (\d+)
|
|
8
|
+
Value OUT_UCAST (\d+)
|
|
9
|
+
Value OUT_MCAST (\d+)
|
|
10
|
+
Value OUT_BCAST (\d+)
|
|
11
|
+
|
|
12
|
+
Start
|
|
13
|
+
^\s*Port\s+InOctets\s+InUcastPkts\s+InMcastPkts\s+InBcastPkts\s*$$ -> InCounters
|
|
14
|
+
^\s*Port\s+OutOctets\s+OutUcastPkts\s+OutMcastPkts\s+OutBcastPkts\s*$$ -> OutCounters
|
|
15
|
+
|
|
16
|
+
InCounters
|
|
17
|
+
^\s*${PORT}\s+${IN_OCTETS}\s+${IN_UCAST}\s+${IN_MCAST}\s+${IN_BCAST}\s*$$ -> Record
|
|
18
|
+
^\s*Port\s+OutOctets\s+OutUcastPkts\s+OutMcastPkts\s+OutBcastPkts\s*$$ -> OutCounters
|
|
19
|
+
^\s*Port\s+InOctets\s+InUcastPkts\s+InMcastPkts\s+InBcastPkts\s*$$ -> InCounters
|
|
20
|
+
|
|
21
|
+
OutCounters
|
|
22
|
+
^\s*${PORT}\s+${OUT_OCTETS}\s+${OUT_UCAST}\s+${OUT_MCAST}\s+${OUT_BCAST}\s*$$ -> Record
|
|
23
|
+
^\s*Port\s+InOctets\s+InUcastPkts\s+InMcastPkts\s+InBcastPkts\s*$$ -> InCounters
|
|
24
|
+
^\s*Port\s+OutOctets\s+OutUcastPkts\s+OutMcastPkts\s+OutBcastPkts\s*$$ -> OutCounters
|
catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_interfaces_counters_errors.textfsm
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Common Catalyst error counter table variants.
|
|
2
|
+
Value Required PORT (\S+)
|
|
3
|
+
Value ALIGN_ERR (\d+)
|
|
4
|
+
Value FCS_ERR (\d+)
|
|
5
|
+
Value XMIT_ERR (\d+)
|
|
6
|
+
Value RCV_ERR (\d+)
|
|
7
|
+
Value UNDERSIZE (\d+)
|
|
8
|
+
Value OUTDISCARDS (\d+)
|
|
9
|
+
|
|
10
|
+
Start
|
|
11
|
+
^\s*${PORT}\s+${ALIGN_ERR}\s+${FCS_ERR}\s+${XMIT_ERR}\s+${RCV_ERR}\s+${UNDERSIZE}\s+${OUTDISCARDS}\s*$$ -> Record
|
|
12
|
+
^\s*${PORT}\s+${ALIGN_ERR}\s+${FCS_ERR}\s+${XMIT_ERR}\s+${RCV_ERR}\s*$$ -> Record
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Multiple tables in IOS-XE; rows should be merged by PORT for Excel.
|
|
2
|
+
Value Required PORT (\S+)
|
|
3
|
+
Value MODE (\S+)
|
|
4
|
+
Value ENCAPSULATION (\S+)
|
|
5
|
+
Value STATUS (\S+)
|
|
6
|
+
Value NATIVE_VLAN (\S+)
|
|
7
|
+
Value ALLOWED_VLANS (\S+)
|
|
8
|
+
Value ACTIVE_VLANS (\S+)
|
|
9
|
+
Value FORWARDING_VLANS (\S+)
|
|
10
|
+
|
|
11
|
+
Start
|
|
12
|
+
^\s*Port\s+Mode\s+Encapsulation\s+Status\s+Native vlan\s*$$ -> StatusTable
|
|
13
|
+
^\s*Port\s+Vlans allowed on trunk\s*$$ -> AllowedTable
|
|
14
|
+
^\s*Port\s+Vlans allowed and active in management domain\s*$$ -> ActiveTable
|
|
15
|
+
^\s*Port\s+Vlans in spanning tree forwarding state and not pruned\s*$$ -> ForwardTable
|
|
16
|
+
|
|
17
|
+
StatusTable
|
|
18
|
+
^\s*${PORT}\s+${MODE}\s+${ENCAPSULATION}\s+${STATUS}\s+${NATIVE_VLAN}\s*$$ -> Record
|
|
19
|
+
^\s*Port\s+Vlans allowed on trunk\s*$$ -> AllowedTable
|
|
20
|
+
^\s*Port\s+Vlans allowed and active in management domain\s*$$ -> ActiveTable
|
|
21
|
+
^\s*Port\s+Vlans in spanning tree forwarding state and not pruned\s*$$ -> ForwardTable
|
|
22
|
+
|
|
23
|
+
AllowedTable
|
|
24
|
+
^\s*${PORT}\s+${ALLOWED_VLANS}\s*$$ -> Record
|
|
25
|
+
^\s*Port\s+Vlans allowed and active in management domain\s*$$ -> ActiveTable
|
|
26
|
+
^\s*Port\s+Vlans in spanning tree forwarding state and not pruned\s*$$ -> ForwardTable
|
|
27
|
+
^\s*Port\s+Mode\s+Encapsulation\s+Status\s+Native vlan\s*$$ -> StatusTable
|
|
28
|
+
|
|
29
|
+
ActiveTable
|
|
30
|
+
^\s*${PORT}\s+${ACTIVE_VLANS}\s*$$ -> Record
|
|
31
|
+
^\s*Port\s+Vlans in spanning tree forwarding state and not pruned\s*$$ -> ForwardTable
|
|
32
|
+
^\s*Port\s+Vlans allowed on trunk\s*$$ -> AllowedTable
|
|
33
|
+
|
|
34
|
+
ForwardTable
|
|
35
|
+
^\s*${PORT}\s+${FORWARDING_VLANS}\s*$$ -> Record
|
|
36
|
+
^\s*Port\s+Mode\s+Encapsulation\s+Status\s+Native vlan\s*$$ -> StatusTable
|
catalyst_config_auditor-1.4.0/Custom_Parsers/NTC/cisco_ios_show_ip_arp_inspection_interfaces.textfsm
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Supports whitespace-separated and pipe-separated table examples.
|
|
2
|
+
Value Required INTERFACE (\S+)
|
|
3
|
+
Value TRUST_STATE (\S+)
|
|
4
|
+
Value RATE_PPS (\S+)
|
|
5
|
+
Value BURST_INTERVAL (\S+)
|
|
6
|
+
|
|
7
|
+
Start
|
|
8
|
+
^\s*${INTERFACE}\s+${TRUST_STATE}\s+${RATE_PPS}\s+${BURST_INTERVAL}\s*$$ -> Record
|
|
9
|
+
^\s*${INTERFACE}\s+${TRUST_STATE}\s+${RATE_PPS}\s*$$ -> Record
|
|
10
|
+
^\s*${INTERFACE}\s*\|\s*${TRUST_STATE}\s*\|\s*${RATE_PPS}\s*$$ -> Record
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Key summary settings and per-port trust/rate rows.
|
|
2
|
+
Value SWITCH_STATUS (\S+)
|
|
3
|
+
Value CONFIGURED_VLANS (\S+)
|
|
4
|
+
Value OPERATIONAL_VLANS (\S+)
|
|
5
|
+
Value OPTION82 (\S+)
|
|
6
|
+
Value INTERFACE (\S+)
|
|
7
|
+
Value TRUST (\S+)
|
|
8
|
+
Value RATE_PPS (\S+)
|
|
9
|
+
|
|
10
|
+
Start
|
|
11
|
+
^\s*Switch DHCP snooping is ${SWITCH_STATUS}\s*$$ -> Record
|
|
12
|
+
^\s*DHCP snooping is configured on following VLANs:\s*${CONFIGURED_VLANS}\s*$$ -> Record
|
|
13
|
+
^\s*DHCP snooping is operational on following VLANs:\s*${OPERATIONAL_VLANS}\s*$$ -> Record
|
|
14
|
+
^\s*Insertion of option 82 is ${OPTION82}\s*$$ -> Record
|
|
15
|
+
^\s*Interface\s+Trusted\s+Rate limit \(pps\)\s*$$ -> Interfaces
|
|
16
|
+
|
|
17
|
+
Interfaces
|
|
18
|
+
^\s*${INTERFACE}\s+${TRUST}\s+${RATE_PPS}\s*$$ -> Record
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Summary records by protocol; this does not decode all nested protocol detail.
|
|
2
|
+
Value Filldown PROTOCOL ([^"\r\n]+)
|
|
3
|
+
Value REDISTRIBUTING (.+)
|
|
4
|
+
Value NETWORK (.+)
|
|
5
|
+
Value DISTANCE (.+)
|
|
6
|
+
|
|
7
|
+
Start
|
|
8
|
+
^\s*Routing Protocol is "${PROTOCOL}"\s*$$ -> Record
|
|
9
|
+
^\s*Redistributing:\s+${REDISTRIBUTING}\s*$$ -> Record
|
|
10
|
+
^\s*Distance:\s+${DISTANCE}\s*$$ -> Record
|
|
11
|
+
^\s*Routing for Networks:\s*$$ -> Networks
|
|
12
|
+
|
|
13
|
+
Networks
|
|
14
|
+
^\s{4,}${NETWORK}\s*$$ -> Record
|
|
15
|
+
^\s*Routing Information Sources:\s*$$ -> Start
|
|
16
|
+
^\s*Distance:\s+${DISTANCE}\s*$$ -> Start
|
|
17
|
+
^\s*Routing Protocol is "${PROTOCOL}"\s*$$ -> Start
|
|
18
|
+
|
|
19
|
+
EOF
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Template, Hostname, Platform, Command
|
|
2
|
+
cisco_ios_show_interfaces_counters_errors.textfsm, .*, cisco_ios, sh[[ow]] int[[erfaces]] cou[[nters]] er[[rors]]
|
|
3
|
+
cisco_ios_show_ip_arp_inspection_interfaces.textfsm, .*, cisco_ios, sh[[ow]] ip arp insp[[ection]] int[[erfaces]]
|
|
4
|
+
cisco_ios_show_device-tracking_database.textfsm, .*, cisco_ios, sh[[ow]] device-tracking database
|
|
5
|
+
cisco_ios_show_interfaces_counters.textfsm, .*, cisco_ios, sh[[ow]] int[[erfaces]] cou[[nters]]
|
|
6
|
+
cisco_ios_show_interfaces_trunk.textfsm, .*, cisco_ios, sh[[ow]] int[[erfaces]] trunk
|
|
7
|
+
cisco_ios_show_environment_all.textfsm, .*, cisco_ios, sh[[ow]] env[[ironment]] all
|
|
8
|
+
cisco_ios_show_ip_dhcp_snooping.textfsm, .*, cisco_ios, sh[[ow]] ip dhcp snoop[[ing]]$
|
|
9
|
+
cisco_ios_show_ip_protocols.textfsm, .*, cisco_ios, sh[[ow]] ip prot[[ocols]]$
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# TTP templates
|
|
2
|
+
|
|
3
|
+
Optional Text Template Parser templates from v1.3.8. Use the filenames `show_<command>.ttp`. These parsers run before NTC in auto mode **except** that proven built-in Python parsers for certain tables are preferred to avoid partial multi-section output.
|
|
4
|
+
|
|
5
|
+
Test with `--parser-test "show ip arp" --input examples/show_ip_arp.txt --parser ttp`.
|
|
6
|
+
Outputs vary by IOS-XE version; treat the supplied patterns as starting points, not guaranteed full coverage.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
LICENSE STATUS: NOT YET SELECTED
|
|
2
|
+
|
|
3
|
+
This file is a placeholder, NOT an open-source license or grant of permission.
|
|
4
|
+
The project owner must select the applicable license, verify ownership of
|
|
5
|
+
third-party and contributed code, and replace this file before representing
|
|
6
|
+
the project as open source. In the absence of a license grant, all rights
|
|
7
|
+
remain reserved by their respective owners.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
include Catalyst_Config_Auditor.py
|
|
2
|
+
include README.md LICENSE CHANGELOG.md PROJECT_CONTEXT.md SECURITY.md CONTRIBUTING.md
|
|
3
|
+
include requirements.txt cmd.txt variables_selection.yaml CLI_HELP_v1.4.0.txt
|
|
4
|
+
recursive-include examples *.txt *.j2 *.xlsx
|
|
5
|
+
recursive-include tests *.py
|
|
6
|
+
recursive-include src/catalyst_config_auditor *.txt *.yaml *.ttp *.textfsm index
|
|
7
|
+
recursive-include Custom_Parsers *.textfsm *.ttp *.md index
|