Skip to content

Conversation

@clement-ldr
Copy link

New template to add support for juniper junos show ethernet-switching interfaces 🤠

Use the normalized VLAN_ID capture group name for the VLAN tag.
Make the ethernet-switching regex pattern match another existing
command (where there are optional characters for the shortened version.)
@mjbear
Copy link
Collaborator

mjbear commented Dec 23, 2025

@clement-ldr
I made a couple of tweaks.

  • Fix the index order
  • Simplify the template to reduce some duplication (since the raw cli output is simple enough)
  • Shorten the TAGGING pattern via regex
  • Use the normalized VLAN_ID instead of TAG from data model
  • Adjust the ethernet-switching word pattern to match another instance (the "table")

Note to self:
Command output details via a Juniper ethernet-switching CLI reference doc.

^${INTERFACE}\s+${STATUS}\s+${VLAN_MEMBER}\s+${TAGGING}\s+${PORT_ERROR}
^${INTERFACE}\s+${STATUS}\s+${VLAN_MEMBER}\s+${PORT_ERROR}
^\s+${VLAN_MEMBER}\s+${VLAN_ID}\s+${TAGGING}\s+${PORT_ERROR}
^{.*}$$
Copy link
Collaborator

Choose a reason for hiding this comment

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

@clement-ldr What is the ^{.*}$$ regex intended to match?

Copy link
Author

Choose a reason for hiding this comment

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

Thats intended to match the {master:0} routing engine info juniper print before the user prompt.
its part of the prompt but may get mixed with the command body and somme templates have it, idk if its really needed.

Copy link
Author

@clement-ldr clement-ldr Dec 23, 2025

Choose a reason for hiding this comment

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

For example :

user@switch> show ethernet-switching interfaces
Interface    State  VLAN members        Tag   Tagging  Blocking
ae2.0        up     itx-s45-1           10    tagged   unblocked
                    itx-s45-1-adm       20    tagged   unblocked
                    l2rpn               4001  tagged   unblocked

bme0.32770   down   mgmt                      untagged unblocked
me0.0        down   mgmt                      untagged unblocked

{master:0}
user@switch>

{master:0}
user@switch>

{master:0}
user@switch>

{master:0} may be something else like {backup}, its more part of the the prompt though so im not sure its needed or if raising an error is better?

Copy link
Collaborator

@mjbear mjbear Dec 23, 2025

Choose a reason for hiding this comment

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

Thats intended to match the {master:0} routing engine info juniper print before the user prompt. its part of the prompt but may get mixed with the command body and somme templates have it, idk if its really needed.

Ah, gotcha.

I wouldn't have guessed that unless I stumbled on another template or its raw cli data. 😅

If the word varies from master some of the time then we could use a regex.
Would this ^{\S+:\d+}$$ be a viable alternative?

Update: From your output above, I wouldn't think we should see {master:0} in the output. It's not clear if it appears at the tail end after a command or following a carriage return.

If there are templates without a line/rule for this type of pattern then we probably don't need it. (I haven't checked all the junos templates.)

Copy link
Author

@clement-ldr clement-ldr Dec 23, 2025

Choose a reason for hiding this comment

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

There are some templates without it and napalm.cli does not return it (netmiko probably does the same) I think we can remove it fine 👍

Edit:
Removed in b051cc7

Copy link
Collaborator

@mjbear mjbear Dec 24, 2025

Choose a reason for hiding this comment

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

There are some templates without it and napalm.cli does not return it (netmiko probably does the same) I think we can remove it fine 👍

Ah, your mention about NAPALM and Netmiko made me realize that I looked into those lines a while back. For example, Netmiko strips those {master:0} strings before returning the output.

I suppose it's ok though if someone is parsing output retrieved using some other library or means (that doesn't remove those strings) then it's a potential wrinkle.

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.

2 participants