Skip to content

Add extra fields to aruba aoscx show interface - #2336

Open
Ardeck wants to merge 10 commits into
networktocode:masterfrom
Ardeck:add_aruba_aoscx_show_interface_extra_fields
Open

Add extra fields to aruba aoscx show interface#2336
Ardeck wants to merge 10 commits into
networktocode:masterfrom
Ardeck:add_aruba_aoscx_show_interface_extra_fields

Conversation

@Ardeck

@Ardeck Ardeck commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Enhance aruba_aoscx_show_interface parser with the capture of additional fields

Summary

Enhance the Aruba AOS-CX show_interface parser by capturing additional fields that are already present in the command output.

Breaking change :

  • prefix length -> split from ip_address
  • secondary_ip_prefix_length -> split from secondary_ip_address

Reason : standardization, IP_address is a valid IPv4 address and not a CIDR notation

Added fields:

  • active_gateway_ip
  • active_gateway_ip_mac
  • active_gateway_source_mac
  • leader_follower_mode
  • mdi_mode
  • subinterface_count

Also improved IPv4 address matching to tolerate trailing whitespace.

Validation

  • Regenerated all associated YAML test fixtures
  • Verified parsing across all available Aruba AOS-CX samples
  • Test suite passed successfully

@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 Required

Breaking Change: Yes

  • ntc_templates/templates/aruba_aoscx_show_interface.textfsm narrows Value IP_ADDRESS from (\S+) to (\d+\.\d+\.\d+\.\d+), so the existing ip_address key changes value format from 10.1.2.1/24 to 10.1.2.1.
  • 10 existing ip_address values change across tests/aruba_aoscx/show_interface/show_interface2.yml, show_interface3.yml, show_interface4.yml (5), show_interface6.yml (2), and show_interface7.yml.

Thanks @Ardeck — nice to see these fields picked up, and thanks for regenerating all nine fixtures. A few things to address before this can merge:

  • Please flag the breaking change in the PR description. Splitting the prefix out of ip_address changes the value of an existing key for every routed interface, which breaks downstream consumers that feed that value straight into something like ipaddress.ip_interface(). The description explains the mechanism ("netmask -> split from ip_address") but doesn't call it out as breaking — could you add that explicitly? It'll need to go out with a major release alongside the other queued breaking changes.

  • NETMASK should be PREFIX_LENGTH. The captured value is a CIDR prefix length, not a netmask, and every other template doing this same IPv4 address x.x.x.x/NN split uses PREFIX_LENGTHallied_telesis_awplus_show_interface, cisco_nxos_show_interface, cisco_ios_show_interfaces, ruckus_fastiron_show_interfaces, plus aruba_aoscx_show_ip_route_all-vrfs and aruba_aoscx_show_interface_mgmt on this same platform.

    In ntc_templates/templates/aruba_aoscx_show_interface.textfsm, the Value declaration:

    -Value NETMASK (\d+)
    +Value PREFIX_LENGTH (\d+)

    And the matching rule in the Start state:

    -  ^\s*IPv4\s+address\s+${IP_ADDRESS}(/${NETMASK})?\s*$$
    +  ^\s*IPv4\s+address\s+${IP_ADDRESS}(/${PREFIX_LENGTH})?\s*$$

    Then in the fixtures:

    -    netmask: "24"
    +    prefix_length: "24"

    Apply the same key rename to every other netmask: line in all nine fixture files, or just regenerate with gen-yaml-folder / clean-yaml-folder.

  • Please expand the GW_ abbreviations. These are the only GW_-prefixed values in the library — the project convention is full names. ACTIVE_GATEWAY_* also keeps them distinct from the default-gateway sense IPV4_GATEWAY has in aruba_aoscx_show_interface_mgmt.

    The Value declarations:

    -Value GW_IP (\S+)
    -Value GW_IP_MAC (\S+)
    -Value GW_SOURCE_MAC (\S+)
    +Value ACTIVE_GATEWAY_IP (\S+)
    +Value ACTIVE_GATEWAY_MAC_ADDRESS (\S+)
    +Value ACTIVE_GATEWAY_SOURCE_MAC_ADDRESS (\S+)

    And the rules (this also picks up the whitespace point below):

    -  ^\s*active-gateway L3 source mac ${GW_SOURCE_MAC}
    -  ^\s*active-gateway ip mac ${GW_IP_MAC}
    -  ^\s*active-gateway ip ${GW_IP}
    +  ^\s*active-gateway\s+L3\s+source\s+mac\s+${ACTIVE_GATEWAY_SOURCE_MAC_ADDRESS}
    +  ^\s*active-gateway\s+ip\s+mac\s+${ACTIVE_GATEWAY_MAC_ADDRESS}
    +  ^\s*active-gateway\s+ip\s+${ACTIVE_GATEWAY_IP}

    In tests/aruba_aoscx/show_interface/show_interface7.yml:

    -    gw_ip: "192.0.2.254"
    -    gw_ip_mac: "02:00:00:aa:bb:cc"
    -    gw_source_mac: "bc:d7:a5:aa:bb:cc"
    +    active_gateway_ip: "192.0.2.254"
    +    active_gateway_mac_address: "02:00:00:aa:bb:cc"
    +    active_gateway_source_mac_address: "bc:d7:a5:aa:bb:cc"

    Apply the same key rename to every other gw_ip: / gw_ip_mac: / gw_source_mac: line across all nine fixture files.

  • Literal spaces in the new rules — could you switch these to \s+? Future-proofing against CLI spacing drift, matching the rest of the template. The Subinterface count line also has a trailing space (harmless, since TextFSM strips rule lines, but worth removing while you're in there).

    -  ^\s*Subinterface count\s*:\s+${SUBINTERFACE_COUNT} 
    +  ^\s*Subinterface\s+count\s*:\s+${SUBINTERFACE_COUNT}
    -  ^\s*MDI mode\s*:\s*${MDI}
    -  ^\s*Leader-follower\s+mode:\s+${LEADER_FOLLOWER_MODE}
    +  ^\s*MDI\s+mode\s*:\s*${MDI}
    +  ^\s*Leader-follower\s+mode\s*:\s+${LEADER_FOLLOWER_MODE}

Two more that would be good to fold in while this is open:

  • MDIMDI_MODE. The raw label is MDI mode:, the value is a mode, your own sibling field uses the suffix (LEADER_FOLLOWER_MODE), and hp_procurve_show_interfaces_brief already uses MDI_MODE.

    -Value MDI (\S+)
    +Value MDI_MODE (\S+)
    -  ^\s*MDI\s+mode\s*:\s*${MDI}
    +  ^\s*MDI\s+mode\s*:\s*${MDI_MODE}

    Apply the matching mdi:mdi_mode: key rename across all nine fixture files.

  • secondary_ip_address still carries the prefix. After this change the template emits ip_address: "172.23.2.1" + a separate prefix, but secondary_ip_address: ["172.25.2.1/30"] — two address formats out of one parse. Since ip_address is already breaking here, splitting the secondary in the same release avoids a second breaking change later.

    -Value List SECONDARY_IP_ADDRESS (\S+)
    +Value List SECONDARY_IP_ADDRESS (\d+\.\d+\.\d+\.\d+)
    +Value List SECONDARY_PREFIX_LENGTH (\d+)
    -  ^\s*IPv4\s+address\s+${SECONDARY_IP_ADDRESS}\s+secondary
    +  ^\s*IPv4\s+address\s+${SECONDARY_IP_ADDRESS}(/${SECONDARY_PREFIX_LENGTH})?\s+secondary

    I checked this against the fixtures and the list alignment holds on the multi-secondary interface (1/1/45['172.22.19.1', '172.22.22.1'] / ['30', '30']).

Optional / FYI: the (/${NETMASK})? optional group has no test data for the bare-address case. I think the optional form is the right call — a required / would push an unmasked line into ^. -> Error — but a line in the description noting that AOS-CX always emits the mask would head off the question.

Thanks!
(review generated with Claude)

@matt852

matt852 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Additionally, with the netmask -> split from ip_address changes breaking the current ip_address field, what's the purpose for this?

@mjbear mjbear added breaking_change changes_requested Waiting on user to address feedback labels Jul 31, 2026
Anonymous and others added 7 commits August 5, 2026 12:55
- rename correctly netmask as prefix_length
- add prefix_length to secondary_ip_address
- rename MDI to MDI_MODE
- rename GW prefix to ACTIVE_GATEWAY
* Make optional colon regex a bit more self explanatory
  compared to :*
* Replace loose \s* with \s+ where test data does have a
  space after colon
* Replace loose \s* with \s+ where the test data has one or
  more spaces
The \s* at the end of the aggregated interfaces lines wasn't
necessary since the EoL isn't anchored by a regex.
@mjbear

mjbear commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

In addition to converting to unix file format, I made several white space regex related commits.

@mjbear

mjbear commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Note

While we're at it, we could normalize INTERFACE_DESC to DESCRIPTION (since we already have a breaking change).

@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.

A couple other suggestions. YAML test files will need to be regenerated if the INTERFACE_DESC --> DESCRIPTION change is accepted (as suggested by @mjbear)

Comment thread ntc_templates/templates/aruba_aoscx_show_interface.textfsm Outdated
Comment on lines +101 to +102
^\s*MDI\s+mode\s*:\s+${MDI_MODE}
^\s*Leader-follower\s+mode:\s+${LEADER_FOLLOWER_MODE}

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.

Suggested change
^\s*MDI\s+mode\s*:\s+${MDI_MODE}
^\s*Leader-follower\s+mode:\s+${LEADER_FOLLOWER_MODE}
^\s*MDI\s+mode\s*:\s+${MDI_MODE}
^\s*MDI\s+mode
^\s*Leader-follower\s+mode\s*:\s+${LEADER_FOLLOWER_MODE}
^\s*Leader-follower\s+mode

Add a fallback rule in case either value is empty, or if Leader-follower mode has a space before the colon, they fail to parse where it used to work.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we have test data for both of these lines being blank?

In the present data, MDI mode is either MDIX or none.

Maybe we need more data on the Leader-follower mode.

^\s*active-gateway\s
^\s*active-gateway\s+L3\s+source\s+mac\s+${ACTIVE_GATEWAY_SOURCE_MAC}
^\s*active-gateway\s+ip\s+mac\s+${ACTIVE_GATEWAY_IP_MAC}
^\s*active-gateway\s+ip\s+${ACTIVE_GATEWAY_IP}

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.

Suggested change
^\s*active-gateway\s+ip\s+${ACTIVE_GATEWAY_IP}
^\s*active-gateway\s+ip\s+${ACTIVE_GATEWAY_IP}
^\s*active-gateway

Fallback rule to keep IPv6 forms parsing correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar to MDI and Leader-follower modes -- do we have test data to support this?

It would seem when set, active-gateway is present in the output and if not it is absent from the output. (Though our test data output is likely from different versions and maybe the behavior has changed across versions.)

@Ardeck Would you please confirm this?

@mjbear mjbear changed the title Add aruba aoscx show interface extra fields Add extra fields to aruba aoscx show interface Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking_change changes_requested Waiting on user to address feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants