Skip to content

Add aruba_aoscx_show_interface_physical - #2338

Open
Ardeck wants to merge 12 commits into
networktocode:masterfrom
Ardeck:feat/aruba_aoscx_show_interface_physical
Open

Add aruba_aoscx_show_interface_physical#2338
Ardeck wants to merge 12 commits into
networktocode:masterfrom
Ardeck:feat/aruba_aoscx_show_interface_physical

Conversation

@Ardeck

@Ardeck Ardeck commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR adds a TextFSM template for show interface physical on Aruba AOS-CX switches (aruba_aoscx).

Details

  • Parses physical interface attributes across AOS-CX switch platforms.
  • Extracts core interface metrics including physical interface name, type/speed, admin/line status, mode, and physical layer details.
  • Handled edge cases across multiple hardware outputs (covered by sample 1 and sample 2).

Motivation

Providing structured output for show interface physical allows automation tools (Nornir, Ansible, Netmiko) to easily inspect physical port states, transceiver information, and media speeds across Aruba AOS-CX deployments.


Testing

  • Test .raw output samples added under tests/aruba_aoscx/show_interface_physical/ (2 test cases).
  • Test .yml files generated via invoke gen-yaml-folder.
  • Ran local test suite (poetry run pytest -k aruba_aoscx_show_interface_physical) — 100% passing.
  • Verified code quality via invoke yamllint, invoke black, and invoke flake8.
  • Registered command in ntc_templates/templates/index in correct alphabetical order.

Checklist

  • Template added in ntc_templates/templates/
  • Template registered in ntc_templates/templates/index
  • Test cases (.raw and .yml) added in tests/aruba_aoscx/show_interface_physical/
  • All tests passing locally
  • Tested on 100+ devices

@mjbear mjbear changed the title feat(aruba_aoscx): add aruba_aoscx_show_interface_physical template Add aruba_aoscx_show_interface_physical Jul 31, 2026
mjbear added 5 commits July 30, 2026 21:22
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
Comment thread tests/aruba_aoscx/show_interface_physical/aruba_aoscx_show_interface_physical.yml Outdated
@mjbear mjbear added the WIP Work in Progress label Jul 31, 2026
mjbear added 3 commits July 30, 2026 21:56
Eliminate unwanted capture of state information by description
capture group.
* consolidate regex, reducing duplication
* also fixes support for state info of Administratively Down
@mjbear mjbear added question and removed WIP Work in Progress labels Jul 31, 2026
@mjbear

mjbear commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

@Ardeck
I made several changes.
I'd highly advise you please test this template on live gear to further vet it.

Thank you!

@matt852 matt852 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 physical emits 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 Start state:

    -  ^${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_INFO matches the name already used for this field in aruba_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-folder on tests/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 .raw files is a single token, so the multi-word case is untested — and it currently loses data silently: a row described as Uplink to core A parses out as description: "A". The suggested regex above doesn't fix that either (the extra words land in LINK_STATE_INFO instead), 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)

@matt852

matt852 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@Ardeck reflecting @mjbear's comment, please test on live gear and confirm you have done so successfully after implementing above requested changes. Thank you!

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants