Add aruba_aoscx_show_interface_physical - #2338
Conversation
The default action is Next, so it isn't necessary to specify. https://github.com/google/textfsm/wiki/TextFSM#line-actions
The line with Link and Admin has several spaces, so the regex should change to reflect the output.
The leading whitespace regex is not needed on the Port and Type line as there isn't any whitespace.
* Simplify regex * Make the regex more predictable
\S+ will match double dashes --, so we can simplify the regex
Eliminate unwanted capture of state information by description capture group.
* consolidate regex, reducing duplication * also fixes support for state info of Administratively Down
|
@Ardeck Thank you! |
matt852
left a comment
There was a problem hiding this comment.
Recommendation: Changes Suggested
Breaking Change: No
Thanks @Ardeck — the template parses both samples cleanly and tests/lint pass. Two things worth addressing before merge:
-
Five of the eleven columns aren't captured, and the
(\S+\s+){5,8}skip is doing the work instead.show interface physicalemits Port, Type, Link Status, Admin Config, Speed Status|Config, Flow-Control Status|Config, PoE Power, State Information, and Port Description. State Information in particular carries the useful strings your own samples show (No XCVR installed, 100M/1G/10G/25G/50G,Waiting for link, 1G-FDx,Administratively down). Capturing each column explicitly also drops the positional token count, which currently lands on the right token only by luck.In
ntc_templates/templates/aruba_aoscx_show_interface_physical.textfsm, the Value declarations:Value SPEED_STATUS (\S+) -Value DESCRIPTION (.*) +Value SPEED_CONFIG (\S+) +Value FLOW_CONTROL_STATUS (\S+) +Value FLOW_CONTROL_CONFIG (\S+) +Value POE_POWER (\S+) +Value LINK_STATE_INFO (.+?) +Value DESCRIPTION (\S+)
And the matching rule in the
Startstate:- ^${PORT}\s+${TYPE}\s+${LINK_STATUS}\s+${ADMIN_STATUS}\s+${SPEED_STATUS}\s+(\S+\s+){5,8}${DESCRIPTION}\s*$$ -> Record + ^${PORT}\s+${TYPE}\s+${LINK_STATUS}\s+${ADMIN_STATUS}\s+${SPEED_STATUS}\s+${SPEED_CONFIG}\s+${FLOW_CONTROL_STATUS}\s+${FLOW_CONTROL_CONFIG}\s+${POE_POWER}\s+${LINK_STATE_INFO}\s+${DESCRIPTION}\s*$$ -> Record
LINK_STATE_INFOmatches the name already used for this field inaruba_aoscx_show_interface.textfsm. This version is tested against both of your samples — including the rows where the state string overflows its column and leaves a single space before the description (1/5/8,1/5/48).Then regenerate both fixtures (
invoke gen-yaml-folder+invoke clean-yaml-folderontests/aruba_aoscx/show_interface_physical), which adds five keys to every entry:- admin_status: "up" description: "Switch_name" + flow_control_config: "off" + flow_control_status: "--" + link_state_info: "10G" link_status: "up" + poe_power: "--" port: "1/1/1" + speed_config: "n/a" speed_status: "10G" type: "10G-LR" -
Could you add a sample with a port description that contains spaces? Every description in both
.rawfiles is a single token, so the multi-word case is untested — and it currently loses data silently: a row described asUplink to core Aparses out asdescription: "A". The suggested regex above doesn't fix that either (the extra words land inLINK_STATE_INFOinstead), because splitting the last two variable-width columns is ambiguous without a real example to anchor on. If your fleet has descriptions with spaces, a raw sample containing one would let us anchor the split properly; if AOS-CX descriptions are always single-token in practice, saying so on the PR is enough.
Also worth a look, though not blocking: SPEED_STATUS is unique to this template where 37 others use SPEED — with the config column captured, SPEED / SPEED_CONFIG may read better.
Thanks!
(review generated with Claude)
- more test sample with space - added extra fields - took care of optionnal EE fields - some hacks aka check for two spaces to separate fields containing spaces
This PR adds a TextFSM template for
show interface physicalon Aruba AOS-CX switches (aruba_aoscx).Details
Motivation
Providing structured output for
show interface physicalallows automation tools (Nornir, Ansible, Netmiko) to easily inspect physical port states, transceiver information, and media speeds across Aruba AOS-CX deployments.Testing
.rawoutput samples added undertests/aruba_aoscx/show_interface_physical/(2 test cases)..ymlfiles generated viainvoke gen-yaml-folder.poetry run pytest -k aruba_aoscx_show_interface_physical) — 100% passing.invoke yamllint,invoke black, andinvoke flake8.ntc_templates/templates/indexin correct alphabetical order.Checklist
ntc_templates/templates/ntc_templates/templates/index.rawand.yml) added intests/aruba_aoscx/show_interface_physical/