Replies: 2 comments 3 replies
-
Hi Adriana, |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi Jose,
I was not able to see your comment in Github. I am quite busy atm, but I will give a try your suggestion. It looks interesting 🙂
Thanks a lot!
Kind regards,
Adriana
Adriana Mitsova
https://www.linkedin.com/in/adriana-mitsova-188606116/
…________________________________
From: Jose Orlando ***@***.***>
Sent: 28 December 2023 21:53
To: networktocode/ntc-templates ***@***.***>
Cc: amitsova ***@***.***>; Author ***@***.***>
Subject: Re: [networktocode/ntc-templates] TextFSM template help (Discussion #1578)
Hi! I got curious about your problem and started fiddling around a template following these instructions here:
<https://pyneng.readthedocs.io/en/latest/book/21_textfsm/textfsm_examples.html>
So I modified a little the example input, to get a more clear (in terms of found values) to this:
Port Mode Encapsulation Status Native vlan
Fa1/8 on 802.1q trunking 3
Gi1/1 on 802.1q trunking 2
Gi1/2 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa1/8 1-4094
Gi1/1 1-4094
Gi1/2 1-4094
Port Vlans allowed and active in management domain
Fa1/8 1,105,110,130,1000
Gi1/1 1,105,110,130,1010
Gi1/2 1,105,110,130,1020
Port Vlans in spanning tree forwarding state and not pruned
Fa1/8 1,105,109,129,1009
Gi1/1 1,105,110,130,1010
Gi1/2 1,105,120,140,1011
And made that template:
Value List PORT (\S+)
Value List MODE (\S+)
Value List ENCAPS (\S+)
Value List STATUS (\S+)
Value List NATIVE (\d+)
Value List VLAN_ON_TRUNK (\S+)
Value List VLAN_MGMT_DOMAIN (\S+)
Value List VLAN_SPT (\S+)
Start
^Port\s+Mode\s+Encapsulation\s+Status\s+Native\s+vlan\s*$$ -> Continue.Record
^${PORT}\s+${MODE}\s+${ENCAPS}\s+${STATUS}\s+${NATIVE}\s*$$ -> Continue
^Port\s+Vlans\s+allowed\s+on\s+trunk -> Continue
^\S+\s+${VLAN_ON_TRUNK}\s*$$ -> Continue
^Port\s+Vlans\s+allowed\s+and\s+active\s+in\s+management\s+domain\s*$$ -> Continue
^\S+\s+${VLAN_MGMT_DOMAIN}\s*$$ -> Continue
^Port\s+Vlans\s+in\s+spanning\s+tree\s+forwarding\s+state\s+and\s+not\s+pruned
^\S+\s+${VLAN_SPT}\s*$$
That gives that output:
[
{
"ENCAPS": [
"802.1q",
"802.1q",
"802.1q"
],
"MODE": [
"on",
"on",
"on"
],
"NATIVE": [
"3",
"2",
"1"
],
"PORT": [
"Fa1/8",
"Gi1/1",
"Gi1/2"
],
"STATUS": [
"trunking",
"trunking",
"trunking"
],
"VLAN_MGMT_DOMAIN": [
"1-4094",
"1-4094",
"1-4094",
"1,105,110,130,1000",
"1,105,110,130,1010",
"1,105,110,130,1020",
"1,105,109,129,1009",
"1,105,110,130,1010",
"1,105,120,140,1011"
],
"VLAN_ON_TRUNK": [
"1-4094",
"1-4094",
"1-4094",
"1,105,110,130,1000",
"1,105,110,130,1010",
"1,105,110,130,1020",
"1,105,109,129,1009",
"1,105,110,130,1010",
"1,105,120,140,1011"
],
"VLAN_SPT": [
"1-4094",
"1-4094",
"1-4094",
"1,105,110,130,1000",
"1,105,110,130,1010",
"1,105,110,130,1020",
"1,105,109,129,1009",
"1,105,110,130,1010",
"1,105,120,140,1011"
]
}
]
I think that is close to what you need. I am not familiar with the labeled solution that you used (Entry...) but it seems that it would be needed to separate the VLANs, since my method combined all three types of VLANs :-(
HTH
—
Reply to this email directly, view it on GitHub<#1578 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJNA5MMUR4CDJSJ3EUIKRRDYLXL57AVCNFSM6AAAAABA2EPK5OVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TSNRYGAZDI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I am struggling to create a template which works for Cisco's "show interfaces trunk" command. Can someone share some hints? I tried a lot of regex variations in a combination with the textfsm options with no success. This is the output:
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions