Replies: 5 comments 1 reply
-
Try to repost code sample in separated files : |
Beta Was this translation helpful? Give feedback.
-
The "boxed" style seems to difficult a lot of capture. The extra spaces in TRUNKSTATE didn't helped also Best I could figure out:
|
Beta Was this translation helpful? Give feedback.
-
Hello @jorlandobr Thanx for the answer, the problem is not on the hearder, i can manage it
and i continue to try managing list in textfsm... |
Beta Was this translation helpful? Give feedback.
-
Hello @jorlandobr, i haven't the your behaviour on my local machine and nornir textfsm page (please see screenshot) : only got the 1st reference of On my local linux machine:` python -V With your template: And that not exactly what i need, i want to extract as list as it's possible interface list in cisco_ios show vlan command. Instead of "INDEX": [ |
Beta Was this translation helpful? Give feedback.
-
My bad! I wasn't using your input text, I copy/pasted from your messages and lost the initial spaces. At least it was easy to modify the template to give the needed output. See the lines with INDEX and STATE before and after the mofification.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
i'm trying to parse trkstat command from alcatel OXE equipment. I'm trying to use ntc_templates/textfsm libraries to parse it correctly. But i got trouble with list variables.
Here is an exemple of output:
+==============================================================================+
| T R U N K S T A T E Trunk group number : 17 |
| Trunk group name : 17-XXXX |
| Number of Trunks : 30 |
+------------------------------------------------------------------------------+
| Index : 1 2 3 4 5 6 7 8 9 10 11 12 13 |
| State : F F F B F B F F B F B F B |
+------------------------------------------------------------------------------+
| Index : 14 15 16 17 18 19 20 21 22 23 24 25 26 |
| State : B B B F B F F B B B F B B |
+------------------------------------------------------------------------------+
| Index : 27 28 29 30 |
| State : F F F B |
+------------------------------------------------------------------------------+
| F: Free | B: Busy | Ct: busy Comp trunk | Cl: busy Comp link |
| WB: Busy Without B Channel| Cr: busy Comp trunk for RLIO inter-ACT link |
| WBD: Data Transparency without chan.| WBM: Modem transparency without chan. |
| D: Data Transparency | M: Modem transparency |
+------------------------------------------------------------------------------+
Remarks : it's possible to more/less index on each trunk: From 4 to 250 channels
I try to find inspiration from 'show vlan' with cisco_ios but cannot reproduce behaviour.
Here is my custom template:
`Value GROUP_NUMBER (\d+)
Value GROUP_NAME (\w+)
Value NUM_TRUNK (\d+)
Value List INDEX (\d+)
Value List STATE ([FBD])
Start
^|\s+S I P\s+T R U N K\s+S T A T E\s+Trunk group number\s+:\s+${GROUP_NUMBER}
^|\s+Trunk group name\s+:\s${GROUP_NAME}
^|\s+Number of Trunks\s+:\s${NUM_TRUNK}
^|\s+Index\s:\s+${INDEX}\s* -> Continue
^\s*{2}${INDEX}\s* -> Continue
^\s*{3}${INDEX}\s* -> Continue
^\s*{4}${INDEX}\s* -> Continue
^\s*{5}${INDEX}\s* -> Continue
^\s*{6}${INDEX}\s* -> Continue
^\s*{7}${INDEX}\s* -> Continue
^\s*{8}${INDEX}\s* -> Continue
^\s*{9}${INDEX}\s* -> Continue
^\s*{10}${INDEX}\s* -> Continue
^\s*{11}${INDEX}\s* -> Continue
^\s*{12}${INDEX}\s* -> Continue
^\s*{13}${INDEX}\s* -> Continue
^|\s+State\s:\s+${STATE}\s* -> Continue
^\s*{2}${STATE}\s* -> Continue
^\s*{3}${STATE}\s* -> Continue
^\s*{4}${STATE}\s* -> Continue
^\s*{5}${STATE}\s* -> Continue
^\s*{6}${STATE}\s* -> Continue
^\s*{7}${STATE}\s* -> Continue
^\s*{8}${STATE}\s* -> Continue
^\s*{9}${STATE}\s* -> Continue
^\s*{10}${STATE}\s* -> Continue
^\s*{11}${STATE}\s* -> Continue
^\s*{12}${STATE}\s* -> Continue
^\s*{13}${STATE}\s* -> Continue`
I got error on line 13.
File "/usr/lib/python3.11/re/_parser.py", line 685, in _parse
raise source.error("multiple repeat",
re.error: multiple repeat at position 7
...
textfsm.parser.TextFSMTemplateError: Invalid regular expression: '^\s+{2}(?P\d+)\s+*'. Line: 13.
Can someone help me to understand my error ?
Thanx
try debug, and change regex.
Try to apply advice from this page without succes : https://blog.networktocode.com/post/parsing-strategies-ntc-templates/
Beta Was this translation helpful? Give feedback.
All reactions