networktocode / ntc-templates

TextFSM templates for parsing show commands of network devices
https://ntc-templates.readthedocs.io/
Other
1.11k stars 723 forks source link

Juniper vmhost "show version" template not compatible with the output #1224

Closed achhabr1 closed 2 months ago

achhabr1 commented 1 year ago

`>>> output=''' ... Hostname: ptr76-ucp ... Model: nfx250_att_s1_10_t ... Junos: 21.1X3.3 ... JUNOS OS Kernel 64-bit [20220419.9889e6f_builder_stable_11] ... JUNOS OS libs [20220419.9889e6f_builder_stable_11] ... JUNOS OS runtime [20220419.9889e6f_builder_stable_11] ... JUNOS OS time zone information [20220419.9889e6f_builder_stable_11] ... JUNOS network stack and utilities [20220825.064945_builder_junos_211_x3] ... JUNOS libs [20220825.064945_builder_junos_211_x3] ... JUNOS OS libs compat32 [20220419.9889e6f_builder_stable_11] ... JUNOS OS 32-bit compatibility [20220419.9889e6f_builder_stable_11] ... JUNOS libs compat32 [20220825.064945_builder_junos_211_x3] ... JUNOS runtime [20220825.064945_builder_junos_211_x3] ... JUNOS Packet Forwarding Engine Simulation Package [20220825.064945_builder_junos_211_x3] ... JUNOS sflow mx [20220825.064945_builder_junos_211_x3] ... JUNOS py extensions [20220825.064945_builder_junos_211_x3] ... JUNOS py base [20220825.064945_builder_junos_211_x3] ... JUNOS OS vmguest [20220419.9889e6f_builder_stable_11] ... JUNOS OS crypto [20220419.9889e6f_builder_stable_11] ... JUNOS OS boot-ve files [20220419.9889e6f_builder_stable_11] ... JUNOS na telemetry [21.1X3.3] ... JUNOS Wireless WAN Module [20220825.064945_builder_junos_211_x3] ... Junos vmguest package [20220825.064945_builder_junos_211_x3] ... JUNOS Unified Threat Management Module [20220825.064945_builder_junos_211_x3] ... JUNOS userfw [20220825.064945_builder_junos_211_x3] ... JUNOS syshmd [20220825.064945_builder_junos_211_x3] ... JUNOS switch CLI for NFX-3 [20220825.064945_builder_junos_211_x3] ... JUNOS security base [20220825.064945_builder_junos_211_x3] ... JUNOS mx libs compat32 [20220825.064945_builder_junos_211_x3] ... JUNOS mx runtime [20220825.064945_builder_junos_211_x3] ... JUNOS RPD Telemetry Application [21.1X3.3] ... JUNOS Routing mpls-oam-basic [20220825.064945_builder_junos_211_x3] ... JUNOS Routing mpls-oam-advanced [20220825.064945_builder_junos_211_x3] ... JUNOS Routing lsys [20220825.064945_builder_junos_211_x3] ... JUNOS Routing controller-internal [20220825.064945_builder_junos_211_x3] ... JUNOS Routing controller-external [20220825.064945_builder_junos_211_x3] ... JUNOS Routing 32-bit Compatible Version [20220825.064945_builder_junos_211_x3] ... JUNOS Routing aggregated [20220825.064945_builder_junos_211_x3] ... Redis [20220825.064945_builder_junos_211_x3] ... JUNOS probe utility [20220825.064945_builder_junos_211_x3] ... JUNOS pppoe [20220825.064945_builder_junos_211_x3] ... JUNOS common platform support [20220825.064945_builder_junos_211_x3] ... JUNOS nfx platform support [20220825.064945_builder_junos_211_x3] ... JUNOS Openconfig [21.1X3.3] ... JUNOS mtx network modules [20220825.064945_builder_junos_211_x3] ... JUNOS named module [20220825.064945_builder_junos_211_x3] ... JUNOS modules [20220825.064945_builder_junos_211_x3] ... JUNOS mx modules [20220825.064945_builder_junos_211_x3] ... JUNOS mx libs [20220825.064945_builder_junos_211_x3] ... JUNOS SQL Sync Daemon [20220825.064945_builder_junos_211_x3] ... JUNOS jdm ure cmd [20220825.064945_builder_junos_211_x3] ... JUNOS jdm cmd [20220825.064945_builder_junos_211_x3] ... JUNOS Security Intelligence [20220825.064945_builder_junos_211_x3] ... JUNOS idpd64 [20220825.064945_builder_junos_211_x3] ... JUNOS idpd [20220825.064945_builder_junos_211_x3] ... JUNOS Web management gatekeeper module [20220825.064945_builder_junos_211_x3] ... JUNOS High Availability [20220825.064945_builder_junos_211_x3] ... JUNOS Firewall Authentication[20220825.064945_builder_junos_211_x3] ... JUNOS nfx Data Plane Crypto Support [20220825.064945_builder_junos_211_x3] ... JUNOS daemons [20220825.064945_builder_junos_211_x3] ... JUNOS mx daemons [20220825.064945_builder_junos_211_x3] ... JUNOS Broadband Egde User Plane Apps [21.1X3.3] ... JUNOS appidd-srx application-identification daemon [20220825.064945_builder_junos_211_x3] ... JUNOS Advanced Anti-Malware [20220825.064945_builder_junos_211_x3] ... JUNOS Services URL Filter package [20220825.064945_builder_junos_211_x3] ... JUNOS Services TLB Service PIC package [20220825.064945_builder_junos_211_x3] ... JUNOS Services Telemetry [20220825.064945_builder_junos_211_x3] ... JUNOS Services TCP-LOG [20220825.064945_builder_junos_211_x3] ... JUNOS Services SSL [20220825.064945_builder_junos_211_x3] ... JUNOS Services SOFTWIRE [20220825.064945_builder_junos_211_x3] ... JUNOS Services Stateful Firewall [20220825.064945_builder_junos_211_x3] ... JUNOS Services RTCOM [20220825.064945_builder_junos_211_x3] ... JUNOS Services RPM [20220825.064945_builder_junos_211_x3] ... JUNOS Services PCEF package [20220825.064945_builder_junos_211_x3] ... JUNOS Services NAT [20220825.064945_builder_junos_211_x3] ... JUNOS Services Mobile Subscriber Service Container package [20220825.064945_builder_junos_211_x3] ... JUNOS Services MobileNext Software package [20220825.064945_builder_junos_211_x3] ... JUNOS Services Logging Report Framework package [20220825.064945_builder_junos_211_x3] ... JUNOS Services LL-PDF Container package [20220825.064945_builder_junos_211_x3] ... JUNOS Services Jflow Container package [20220825.064945_builder_junos_211_x3] ... JUNOS Services Deep Packet Inspection package [20220825.064945_builder_junos_211_x3] ... JUNOS Services IPSec [20220825.064945_builder_junos_211_x3] ... JUNOS Services IDS [20220825.064945_builder_junos_211_x3] ... JUNOS IDP Services [20220825.064945_builder_junos_211_x3] ... JUNOS Services HTTP Content Management package [20220825.064945_builder_junos_211_x3] ... JUNOS Services DNS Filter package (i386) [20220825.064945_builder_junos_211_x3] ... JUNOS Services Crypto [20220825.064945_builder_junos_211_x3] ... JUNOS Services Captive Portal and Content Delivery Container package [20220825.064945_builder_junos_211_x3] ... JUNOS Services COS [20220825.064945_builder_junos_211_x3] ... JUNOS AppId Services [20220825.064945_builder_junos_211_x3] ... JUNOS Services Application Level Gateways [20220825.064945_builder_junos_211_x3] ... JUNOS Services AACL Container package [20220825.064945_builder_junos_211_x3] ... JUNOS SDN Software Suite [20220825.064945_builder_junos_211_x3] ... JUNOS Extension Toolkit [20220825.064945_builder_junos_211_x3] ... JUNOS Phone-home [20220825.064945_builder_junos_211_x3] ... JUNOS FXPC Package [20220825.064945_builder_junos_211_x3] ... JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20220825.064945_builder_junos_211_x3] ... JUNOS J-Insight [20220825.064945_builder_junos_211_x3] ... JUNOS Online Documentation [20220825.064945_builder_junos_211_x3] ... JUNOS jail runtime [20220419.9889e6f_builder_stable_11] ... '''

output '\nHostname: ptr76-ucp\nModel: nfx250_att_s1_10_t\nJunos: 21.1X3.3\nJUNOS OS Kernel 64-bit [20220419.9889e6f_builder_stable_11]\nJUNOS OS libs [20220419.9889e6f_builder_stable_11]\nJUNOS OS runtime [20220419.9889e6f_builder_stable_11]\nJUNOS OS time zone information [20220419.9889e6f_builder_stable_11]\nJUNOS network stack and utilities [20220825.064945_builder_junos_211_x3]\nJUNOS libs [20220825.064945_builder_junos_211_x3]\nJUNOS OS libs compat32 [20220419.9889e6f_builder_stable_11]\nJUNOS OS 32-bit compatibility [20220419.9889e6f_builder_stable_11]\nJUNOS libs compat32 [20220825.064945_builder_junos_211_x3]\nJUNOS runtime [20220825.064945_builder_junos_211_x3]\nJUNOS Packet Forwarding Engine Simulation Package [20220825.064945_builder_junos_211_x3]\nJUNOS sflow mx [20220825.064945_builder_junos_211_x3]\nJUNOS py extensions [20220825.064945_builder_junos_211_x3]\nJUNOS py base [20220825.064945_builder_junos_211_x3]\nJUNOS OS vmguest [20220419.9889e6f_builder_stable_11]\nJUNOS OS crypto [20220419.9889e6f_builder_stable_11]\nJUNOS OS boot-ve files [20220419.9889e6f_builder_stable_11]\nJUNOS na telemetry [21.1X3.3]\nJUNOS Wireless WAN Module [20220825.064945_builder_junos_211_x3]\nJunos vmguest package [20220825.064945_builder_junos_211_x3]\nJUNOS Unified Threat Management Module [20220825.064945_builder_junos_211_x3]\nJUNOS userfw [20220825.064945_builder_junos_211_x3]\nJUNOS syshmd [20220825.064945_builder_junos_211_x3]\nJUNOS switch CLI for NFX-3 [20220825.064945_builder_junos_211_x3]\nJUNOS security base [20220825.064945_builder_junos_211_x3]\nJUNOS mx libs compat32 [20220825.064945_builder_junos_211_x3]\nJUNOS mx runtime [20220825.064945_builder_junos_211_x3]\nJUNOS RPD Telemetry Application [21.1X3.3]\nJUNOS Routing mpls-oam-basic [20220825.064945_builder_junos_211_x3]\nJUNOS Routing mpls-oam-advanced [20220825.064945_builder_junos_211_x3]\nJUNOS Routing lsys [20220825.064945_builder_junos_211_x3]\nJUNOS Routing controller-internal [20220825.064945_builder_junos_211_x3]\nJUNOS Routing controller-external [20220825.064945_builder_junos_211_x3]\nJUNOS Routing 32-bit Compatible Version [20220825.064945_builder_junos_211_x3]\nJUNOS Routing aggregated [20220825.064945_builder_junos_211_x3]\nRedis [20220825.064945_builder_junos_211_x3]\nJUNOS probe utility [20220825.064945_builder_junos_211_x3]\nJUNOS pppoe [20220825.064945_builder_junos_211_x3]\nJUNOS common platform support [20220825.064945_builder_junos_211_x3]\nJUNOS nfx platform support [20220825.064945_builder_junos_211_x3]\nJUNOS Openconfig [21.1X3.3]\nJUNOS mtx network modules [20220825.064945_builder_junos_211_x3]\nJUNOS named module [20220825.064945_builder_junos_211_x3]\nJUNOS modules [20220825.064945_builder_junos_211_x3]\nJUNOS mx modules [20220825.064945_builder_junos_211_x3]\nJUNOS mx libs [20220825.064945_builder_junos_211_x3]\nJUNOS SQL Sync Daemon [20220825.064945_builder_junos_211_x3]\nJUNOS jdm ure cmd [20220825.064945_builder_junos_211_x3]\nJUNOS jdm cmd [20220825.064945_builder_junos_211_x3]\nJUNOS Security Intelligence [20220825.064945_builder_junos_211_x3]\nJUNOS idpd64 [20220825.064945_builder_junos_211_x3]\nJUNOS idpd [20220825.064945_builder_junos_211_x3]\nJUNOS Web management gatekeeper module [20220825.064945_builder_junos_211_x3]\nJUNOS High Availability [20220825.064945_builder_junos_211_x3]\nJUNOS Firewall Authentication[20220825.064945_builder_junos_211_x3]\nJUNOS nfx Data Plane Crypto Support [20220825.064945_builder_junos_211_x3]\nJUNOS daemons [20220825.064945_builder_junos_211_x3]\nJUNOS mx daemons [20220825.064945_builder_junos_211_x3]\nJUNOS Broadband Egde User Plane Apps [21.1X3.3]\nJUNOS appidd-srx application-identification daemon [20220825.064945_builder_junos_211_x3]\nJUNOS Advanced Anti-Malware [20220825.064945_builder_junos_211_x3]\nJUNOS Services URL Filter package [20220825.064945_builder_junos_211_x3]\nJUNOS Services TLB Service PIC package [20220825.064945_builder_junos_211_x3]\nJUNOS Services Telemetry [20220825.064945_builder_junos_211_x3]\nJUNOS Services TCP-LOG [20220825.064945_builder_junos_211_x3]\nJUNOS Services SSL [20220825.064945_builder_junos_211_x3]\nJUNOS Services SOFTWIRE [20220825.064945_builder_junos_211_x3]\nJUNOS Services Stateful Firewall [20220825.064945_builder_junos_211_x3]\nJUNOS Services RTCOM [20220825.064945_builder_junos_211_x3]\nJUNOS Services RPM [20220825.064945_builder_junos_211_x3]\nJUNOS Services PCEF package [20220825.064945_builder_junos_211_x3]\nJUNOS Services NAT [20220825.064945_builder_junos_211_x3]\nJUNOS Services Mobile Subscriber Service Container package [20220825.064945_builder_junos_211_x3]\nJUNOS Services MobileNext Software package [20220825.064945_builder_junos_211_x3]\nJUNOS Services Logging Report Framework package [20220825.064945_builder_junos_211_x3]\nJUNOS Services LL-PDF Container package [20220825.064945_builder_junos_211_x3]\nJUNOS Services Jflow Container package [20220825.064945_builder_junos_211_x3]\nJUNOS Services Deep Packet Inspection package [20220825.064945_builder_junos_211_x3]\nJUNOS Services IPSec [20220825.064945_builder_junos_211_x3]\nJUNOS Services IDS [20220825.064945_builder_junos_211_x3]\nJUNOS IDP Services [20220825.064945_builder_junos_211_x3]\nJUNOS Services HTTP Content Management package [20220825.064945_builder_junos_211_x3]\nJUNOS Services DNS Filter package (i386) [20220825.064945_builder_junos_211_x3] \nJUNOS Services Crypto [20220825.064945_builder_junos_211_x3]\nJUNOS Services Captive Portal and Content Delivery Container package [20220825.064945_builder_junos_211_x3]\nJUNOS Services COS [20220825.064945_builder_junos_211_x3]\nJUNOS AppId Services [20220825.064945_builder_junos_211_x3]\nJUNOS Services Application Level Gateways [20220825.064945_builder_junos_211_x3]\nJUNOS Services AACL Container package [20220825.064945_builder_junos_211_x3]\nJUNOS SDN Software Suite [20220825.064945_builder_junos_211_x3]\nJUNOS Extension Toolkit [20220825.064945_builder_junos_211_x3]\nJUNOS Phone-home [20220825.064945_builder_junos_211_x3]\nJUNOS FXPC Package [20220825.064945_builder_junos_211_x3]\nJUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20220825.064945_builder_junos_211_x3]\nJUNOS J-Insight [20220825.064945_builder_junos_211_x3]\nJUNOS Online Documentation [20220825.064945_builder_junos_211_x3]\nJUNOS jail runtime [20220419.9889e6f_builder_stable_11]\n' from ntc_templates.parse import parse_output output_parsed = parse_output(platform="juniper_junos", command="show version", data=output) Traceback (most recent call last): File "", line 1, in File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/ntc_templates/parse.py", line 57, in parse_output cli_table.ParseCmd(data, attrs) File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/textfsm/clitable.py", line 282, in ParseCmd self.table = self._ParseCmdItem(self.raw, template_file=template_files[0]) File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/textfsm/clitable.py", line 315, in _ParseCmdItem for record in fsm.ParseText(cmd_input): File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/textfsm/parser.py", line 897, in ParseText self._CheckLine(line) File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/textfsm/parser.py", line 946, in _CheckLine if self._Operations(rule, line): File "/Users/ac043s/python38-venv/lib/python3.9/site-packages/textfsm/parser.py", line 1026, in _Operations raise TextFSMError('State Error raised. Rule Line: %s. Input Line: %s' textfsm.parser.TextFSMError: State Error raised. Rule Line: 81. Input Line: Junos vmguest package [20220825.064945_builder_junos_211_x3] `

itdependsnetworks commented 1 year ago

Can you provide the raw output? It is not clear if you are providing all of the spacing or not the way it is formatted.

andyb2000 commented 1 year ago

Unsure if this is the same issue or not, here is raw output from min and error:

`Raw output fpc0:

Hostname: asxx.xx.xx Model: qfx5100-48t-6q Junos: 21.4R3-S3.4 JUNOS Base OS boot [21.4R3-S3.4] JUNOS Base OS Software Suite [21.4R3-S3.4] JUNOS Online Documentation [21.4R3-S3.4] JUNOS Crypto Software Suite [21.4R3-S3.4] JUNOS Crypto Software Suite [21.4R3-S3.4] JUNOS Kernel Software Suite [21.4R3-S3.4] JUNOS Packet Forwarding Engine Support (qfx-ex-x86-32) [21.4R3-S3.4] JUNOS Phone-Home Software Suite [21.4R3-S3.4] JUNOS Routing Software Suite [21.4R3-S3.4] JUNOS SDN Software Suite [21.4R3-S3.4] JUNOS jsd [i386-21.4R3-S3.4-jet-1] JUNOS Enterprise Software Suite [21.4R3-S3.4] JUNOS Web Management Platform Package [21.4R3-S3.4] JUNOS Openconfig [21.4R3-S3.4] JUNOS py-base-i386 [21.4R3-S3.4] JUNOS py-extensions-i386 [21.4R3-S3.4] CHEF client bundle [11.10.4_2.0_i386] JUNOS Host Software [20.4R3-S4.8] Junos for Automation Enhancement`

Error message:

('State Error raised. Rule Line: 89. Input Line: CHEF client bundle ' '[11.10.4_2.0_i386]')

ItsReaDz commented 1 year ago

We have the samme issue with vmhost packages here but you can remove the: ^. -> Error

And it should be working i'm unsure why but i get this error when i try and use it via ansible.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: textfsm.parser.TextFSMError: State Error raised. Rule Line: 93. Input Line: Junos vmguest package [20211120.090111_builder_junos_204_r3_s1]

mjbear commented 3 months ago

@achhabr1 Any chance you could post the raw CLI output from your Juniper vmhost in code blocks? Your output above has extra extraneous characters from what I figure is the Python interactive interpreter because of the >>> and ....

@andyb2000 Huge thank you for posting raw output. The code block got munged since it needed three backticks ```

I was able to graft the raw output together by comparing to the existing test data. If what I have below isn't right please ping me back! Thank you! :grinning:

fpc0:
-------------------------------------------------------------------------
Hostname: asxx.xx.xx
Model: qfx5100-48t-6q
Junos: 21.4R3-S3.4
JUNOS Base OS boot [21.4R3-S3.4]
JUNOS Base OS Software Suite [21.4R3-S3.4]
JUNOS Online Documentation [21.4R3-S3.4]
JUNOS Crypto Software Suite [21.4R3-S3.4]
JUNOS Crypto Software Suite [21.4R3-S3.4]
JUNOS Kernel Software Suite [21.4R3-S3.4]
JUNOS Packet Forwarding Engine Support (qfx-ex-x86-32) [21.4R3-S3.4]
JUNOS Phone-Home Software Suite [21.4R3-S3.4]
JUNOS Routing Software Suite [21.4R3-S3.4]
JUNOS SDN Software Suite [21.4R3-S3.4]
JUNOS jsd [i386-21.4R3-S3.4-jet-1]
JUNOS Enterprise Software Suite [21.4R3-S3.4]
JUNOS Web Management Platform Package [21.4R3-S3.4]
JUNOS Openconfig [21.4R3-S3.4]
JUNOS py-base-i386 [21.4R3-S3.4]
JUNOS py-extensions-i386 [21.4R3-S3.4]
CHEF client bundle [11.10.4_2.0_i386]
JUNOS Host Software [20.4R3-S4.8]
Junos for Automation Enhancement

@ItsReaDz There are templates that do not have the ^. -> Error line, but it is project policy to match all lines and not leave parsing to chance. In a pinch though ... yeah pull that line and parsing will at least continue even if there's an unmatched line.

mjbear commented 3 months ago

@achhabr1 I believe I was able to successfully slice off the extraneous characters in the pasted output. Please ping me back with the raw output so the viability of my changes can be confirmed before I submit a pull request (PR).

Thank you!

jmcgill298 commented 2 months ago

@mjbear do you want to go ahead and submit what you have?

mjbear commented 2 months ago

@mjbear do you want to go ahead and submit what you have?

@jmcgill298 I've been trying to see if can get access to Juniper's lab system. If I don't succeed with that then yes, I'll send in just what I have. :smile: