Skip to content

Add cisco_xr_show_running-config_interface#2241

Open
jorlandobr wants to merge 35 commits into
networktocode:masterfrom
jorlandobr:master
Open

Add cisco_xr_show_running-config_interface#2241
jorlandobr wants to merge 35 commits into
networktocode:masterfrom
jorlandobr:master

Conversation

@jorlandobr

Copy link
Copy Markdown
Contributor

Template and test files for Cisco XR command show running-config interface.

Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
@mjbear mjbear changed the title Add template cisco_xr_show_running-config_interface.textfsm Add cisco_xr_show_running-config_interface Nov 18, 2025
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
@mjbear mjbear added question changes_requested Waiting on user to address feedback labels Nov 18, 2025
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
- Normalize to NETMASK
- Change file format/line ending to unix format
- Make capture groups more self-describing
- Establish an normalization standard
- Add the capture group names to data model
- Update the recording pattern to be the exclamation mark !
- Match the date stamp more (to avoid inadvertent matches)
@mjbear

mjbear commented Nov 20, 2025

Copy link
Copy Markdown
Collaborator
  • ✅ Normalized IP_NETMASK to NETMASK
  • ✅ Normalized DOT1Q to OUTER_VLAN (added to data_model.md)
  • ✅ Normalized SECOND_DOT1Q to INNER_VLAN (added to data_model.md)
  • ✅ Matched the date stamp more (to avoid inadvertent matches)
  • ✅ Updated the Record pattern to be the exclamation mark !
  • ❓ Since IPv4 addresses, IPv6 addresses, and IPv6 prefix lengths are all plural, we probably should use the plural ones from the data_model.md
    • Though we don't have a standard plural capture group for NETMASK
    • I suppose in retrospect those templates with the plural form could have been the singular form with the expectation that consumers/users would type() check the returned key+value pairs in the dictionary.
    • Thoughts? @jmcgill298 @jvanderaa @matt852

@matt852

matt852 commented Nov 26, 2025

Copy link
Copy Markdown
Contributor
  • ❓ Since IPv4 addresses, IPv6 addresses, and IPv6 prefix lengths are all plural, we probably should use the plural ones from the data_model.md

    • Though we don't have a standard plural capture group for NETMASK
    • I suppose in retrospect those templates with the plural form could have been the singular form with the expectation that consumers/users would type() check the returned key+value pairs in the dictionary.
    • Thoughts? @jmcgill298 @jvanderaa @matt852

@mjbear I think adding a plural "NETMASKS" to keep it consistent with singluar/plural IP_ADDRESS(ES) is a good idea. I have a separate PR I'm working to update the data models, and can add this suggestion to it.

@mjbear mjbear mentioned this pull request Nov 27, 2025
@jorlandobr

Copy link
Copy Markdown
Contributor Author

@mjbear , I noticed that template still marked as open/WIP. Some more input needed?

@mjbear

mjbear commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

@mjbear , I noticed that template still marked as open/WIP. Some more input needed?

Yes, it's still open.

There were varying thoughts on the singular vs plural capture group names which stalled merging this one. Specifically netmasks (despite what I wrote below).

Update: I notice my mention contradicts a pattern that has been started in the data model and in templates with IP_ADDRESSES and IPV6_ADDRESSES ... so forget what I wrote, there are precedents. 🫣

👉 I will update the capture group names.

As a general statement, there are at least two schools of thought on the capture group names.

  1. Normalize so the capture group names are similar between vendors -- even despite the type potentially being a list.
    • We can (and should already be) type checking so for the specific returned data that is a List can be detected and handled accordingly.
    • 🎯 My vote is to retain capture group normalization (rather than pluralize name based on data type).
  2. Have plural capture group names when the data type is a List.
    • This breaks normalization and can be more difficult to work with.
    • It does somewhat document the data type (being a List) -- however this can (and should) be done with a type check (we type check the data we process post-parse, right? 😉).

🆕 In looking at this template again, I see that none of the IPv4 lists have more than one value. I have added an IPv4 secondary address by referencing some XR documentation that has an example.

And all of the IPv6 lists only have one value as well.
As it so happens the example (also at the above Cisco XR docs link) has an EUI-64 v6 address configured ... so I updated the template to work with those.

@jorlandobr Would you please test this eui-64 configuration on a lab/development XR device?
Thank you!

mjbear added 3 commits June 13, 2026 17:11
* Change NETMASK to be plural
* Change IPV6_PREFIX_LENGTH to be plural
* Update data_model.md with capture group names and definitions
* Regenerate structured test data
@mjbear mjbear requested a review from matt852 June 13, 2026 22:07

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

Thanks @jorlandobr, one suggestion before merge:

Add test coverage for the egress ACLs and the swallow-keyword rule. Every fixture interface uses only ingress ACLs, so access_group_out / access_group_v6_out are empty in every record, and the ^\s+(lacp|bundle|dampening|mpls|shutdown|!) rule never fires against the test data. One extra interface covers both. Append to cisco_xr_show_running-config_interface.raw:

+interface TenGigE3/0/0/1
+ description TEST EGRESS ACL
+ shutdown
+ ipv4 access-group iACL-IN ingress
+ ipv4 access-group iACL-OUT egress
+ ipv6 access-group FilterPackIPv6-IN ingress
+ ipv6 access-group FilterPackIPv6-OUT egress
+!

Then regenerate the .yml with gen-yaml-folder / clean-yaml-folder and commit both.

Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
Comment thread ntc_templates/templates/cisco_xr_show_running-config_interface.textfsm Outdated
@jorlandobr

jorlandobr commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@mjbear, @matt852 ,

since are many modifications I tested the new template against a newer box (over 900 interfaces, including bundle ones, that I hadn't before). I had to add new modifications. Please, take a look before I commit them.

Value Required INTERFACE (\S+)
Value DESCRIPTION (.*)
Value BANDWIDTH (\d+)
Value DOT1Q (\d+)
Value SECOND_DOT1Q (\d+)
Value VRF (\S+)
Value MAC_ADDRESS (\S+?)
Value List IP_ADDRESS (\d+.\d+.\d+.\d+)
Value List IP_NETMASK (\d+.\d+.\d+.\d+)
Value List IPV6_ADDRESS (\S+?)
Value List PREFIXV6_LENGTH (\d+)
Value LOAD_INTERVAL (\d+)
Value MTU (\d+)
Value MTU_IPV4 (\d+)
Value UNICAST_SOURCE (\S+)
Value UNICAST_SOURCE_V6 (\S+)
Value INPUT_POLICY (\S+)
Value OUTPUT_POLICY (\S+)
Value ACCESS_GROUP (\S+)
Value ACCESS_GROUP_V6 (\S+)
Value FLOW_MONITOR (\S+)
Value FLOW_MONITOR_V6 (\S+)
Value FLOW_MPLS (\S+)
Value FLOW_SAMPLER (\S+)
Value FLOW_SAMPLER_V6 (\S+)
Value FLOW_MPLS_SAMPLER (\S+)

Start
  ^interface\s+${INTERFACE}
  ^\s+description\s+${DESCRIPTION}
  ^\s+bandwidth\s+${BANDWIDTH}
  ^\s+service-policy\s+input\s+${INPUT_POLICY}
  ^\s+service-policy\s+output\s+${OUTPUT_POLICY}
  ^\s+vrf\s+${VRF}
  ^\s+ipv4\s+address\s+${IP_ADDRESS}\s+${IP_NETMASK}(?:\s+secondary)?
  ^\s+ipv4\s+verify\s+unicast\s+source\s+reachable-via\s+${UNICAST_SOURCE}(?:\s+allow\S)?
  ^\s+ipv4\s+unnumbered\s+\S
  ^\s+ipv6\s+(nd|verify)\s+\S
  ^\s+logging\s+\S
  ^\s+(mac-accounting|satellite-fabric-link|bfd|remote-ports|rewrite|carrier-delay|negotiation|ethernet|speed)\s+\S
  ^\s+ipv4\s+flowspec\s+disable
  ^\s+ipv6\s+flowspec\s+disable
  ^\s+ipv6\s+verify\s+unicast\s+source\s+reachable-via\s+${UNICAST_SOURCE_V6}\s+allow-self-ping
  ^\s+ipv6\s+address\s+${IPV6_ADDRESS}((?:\s+link-local)?|(?:\/+${PREFIXV6_LENGTH}\s*$$)?)
  ^\s+mac-address\s+${MAC_ADDRESS}
  ^\s+mtu\s+${MTU}
  ^\s+ipv4\s+mtu\s+${MTU_IPV4}
  ^\s+ipv6\s+enable
  ^\s+ipv6\s+mtu\s+\S
  ^\s+load-interval\s+${LOAD_INTERVAL}
  ^\s+flow\s+ipv4\s+monitor\s+${FLOW_MONITOR}\s+sampler\s+${FLOW_SAMPLER}\s+ingress
  ^\s+flow\s+ipv6\s+monitor\s+${FLOW_MONITOR_V6}\s+sampler\s+${FLOW_SAMPLER_V6}\s+ingress
  ^\s+flow\s+mpls\s+monitor\s+${FLOW_MPLS}\s+sampler\s+${FLOW_MPLS_SAMPLER}\s+ingress
  ^\s+encapsulation\s+(?:untagge|dot1q\s+${DOT1Q})?(?:\s+second-dot1q\s+${SECOND_DOT1Q})?
  ^\s+(lacp|bundle|dampening|mpls|shutdown|nv|lldp|l2transport|cdp|!)
  ^\s+ipv4\s+access-group\s+${ACCESS_GROUP}\s+(ingress|egress)
  ^\s+ipv6\s+access-group\s+${ACCESS_GROUP_V6}\s+(ingress|egress)
  ^\S+ -> Record
  ^. -> Error

@mjbear

mjbear commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

since are many modifications I tested the new template against a newer box (over 900 interfaces, including bundle ones, that I hadn't before). I had to add new modifications. Please, take a look before I commit them.

This took a bit to adjust as the output above doesn't base off the latest commit on this branch with the name changes.

We need the related raw output to support and test modifications.

Important

My suggestion would be to git pull the newest copy from your GitHub fork so you can work and test that. It would be easier to diff with git if commits are made to this branch -- certainly there could be a bit of discussion and adjustments as we go, but that's just the git workflow.


This is my attempt at a diff after updating some of the capture group names to match, but it's not precise and can't be easily referenced by line number on GH.

  1. Why is this regex Value List IPV6_ADDRESSES (\S+?) made optional?
    (supporting output would help and it's easier to commit the changes/files)

@jorlandobr Please share the raw cli test data to see and explain the changes. Please work off the latest commit 8feb15d and layer on your changes. Thank you!

6a7
> Value MAC_ADDRESS (\S+?)
9c10
< Value List IPV6_ADDRESSES (\S+)
---
> Value List IPV6_ADDRESSES (\S+?)
18,21c19,20
< Value ACCESS_GROUP_IN (\S+)
< Value ACCESS_GROUP_OUT (\S+)
< Value ACCESS_GROUP_V6_IN (\S+)
< Value ACCESS_GROUP_V6_OUT (\S+)
---
> Value ACCESS_GROUP (\S+)
> Value ACCESS_GROUP_V6 (\S+)
37c36,42
<   ^\s+ipv4\s+verify\s+unicast\s+source\s+reachable-via\s+${UNICAST_SOURCE}\s+allow-self-ping
---
>   ^\s+ipv4\s+verify\s+unicast\s+source\s+reachable-via\s+${UNICAST_SOURCE}(?:\s+allow\S)?
>   ^\s+ipv4\s+unnumbered\s+\S
>   ^\s+ipv6\s+(nd|verify)\s+\S
>   ^\s+logging\s+\S
>   ^\s+(mac-accounting|satellite-fabric-link|bfd|remote-ports|rewrite|carrier-delay|negotiation|ethernet|speed)\s+\S
>   ^\s+ipv4\s+flowspec\s+disable
>   ^\s+ipv6\s+flowspec\s+disable
39c44,45
<   ^\s+ipv6\s+address\s+${IPV6_ADDRESSES}\/+${IPV6_PREFIX_LENGTHS}\s*(eui-64)?$$
---
>   ^\s+ipv6\s+address\s+${IPV6_ADDRESSES}((?:\s+link-local)?|(?:\/+${IPV6_PREFIX_LENGTHS}\s*$$)?)
>   ^\s+mac-address\s+${MAC_ADDRESS}
42a49
>   ^\s+ipv6\s+mtu\s+\S
47,55c54,58
<   ^\s+encapsulation\s+dot1q\s+${OUTER_VLAN}(?:\s+second-dot1q\s+${INNER_VLAN})?
<   ^\s+(lacp|bundle|dampening|mpls|shutdown|!)
<   ^\s+ipv4\s+access-group\s+${ACCESS_GROUP_IN}\s+ingress
<   ^\s+ipv4\s+access-group\s+${ACCESS_GROUP_OUT}\s+egress
<   ^\s+ipv6\s+access-group\s+${ACCESS_GROUP_V6_IN}\s+ingress
<   ^\s+ipv6\s+access-group\s+${ACCESS_GROUP_V6_OUT}\s+egress
<   ^!$$ -> Record
<   # date stamp
<   ^\w+\s+\w+\s+\d+
---
>   ^\s+encapsulation\s+(?:untagge|dot1q\s+${OUTER_VLAN})?(?:\s+second-dot1q\s+${INNER_VLAN})?
>   ^\s+(lacp|bundle|dampening|mpls|shutdown|nv|lldp|l2transport|cdp|!)
>   ^\s+ipv4\s+access-group\s+${ACCESS_GROUP}\s+(ingress|egress)
>   ^\s+ipv6\s+access-group\s+${ACCESS_GROUP_V6}\s+(ingress|egress)
>   ^\S+ -> Record

@jorlandobr

Copy link
Copy Markdown
Contributor Author

@mjbear and @matt852 ,

added extra interfaces to cover the lines with rules not covered by the raw files.

ipv4 address 10.230.130.5 255.255.255.254
ipv6 address 2804:a8:2:b8::13a9/126
ipv6 address fe80::1000:16:3/126 link-local
ipv6 address fe80::1000:16:2 link-local

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.

The missing prefix length on raw file line 111, and 113 likely resulted in the None as seen in the parsed yaml file on lines 259 and 261.

The /19 prefix length on line 114 may seem off, but is otherwise valid.

@mjbear

mjbear commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

@mjbear and @matt852 ,

added extra interfaces to cover the lines with rules not covered by the raw files.

Thank you @jorlandobr

I updated a couple of capture group names to match the data_model.md

I also added a note about some lines in the raw file that show up with a prefix length of None in the parsed data (yaml).

@jorlandobr

Copy link
Copy Markdown
Contributor Author

Dumping a xr box I had IPv6 lines ending with link-local and eui-64 without prefix lengths, so I added these lines. It's not an exercise, it's a real value. The /19 line was an exercise 🙂

@mjbear

mjbear commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Dumping a xr box I had IPv6 lines ending with link-local and eui-64 without prefix lengths, so I added these lines. It's not an exercise, it's a real value. The /19 line was an exercise 🙂

Glad I asked - thank you @jorlandobr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes_requested Waiting on user to address feedback question WIP Work in Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants