genielibs icon indicating copy to clipboard operation
genielibs copied to clipboard

genie module or parsers unstable with cat4500 switch

Open gopurx opened this issue 1 year ago • 7 comments

Experiencing various errors while using pyats genie libs for cat4ks. Are cat4ks supported with this framework? Can someone review below observations and suggest?

Here is the testbed used: TEST-DEVICE: os: iosxe platform: cat4k credentials: default: password: "%ENV{device_password}" username: "%ENV{device_user}" connections: cli: protocol: ssh ip: 10.1.1.1 custom: abstraction: # added order: # Added - os # Added - platform # Added

python script to connect to device:

from genie.testbed import load from pprint import pprint tb = load('/tmp/testbed.yaml') device = tb.devices['TEST-DEVICE'] device.connect()

Trying to use genie module device.parse("show platform") receiving an error:

show platform show platform Incomplete command. %TEST-DEVICE Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/unicon/plugins/generic/service_implementation.py", line 740, in call_service self.result = self.get_service_result() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/unicon/bases/routers/services.py", line 235, in unicon.bases.routers.services.BaseService.get_service_result unicon.core.errors.SubCommandFailure: ('sub_command failure, patterns matched in the output:', ['^%\\s*[Ii]ncomplete (command|input)'], 'service result', 'show platform\r\nshow platform\r\n% Incomplete command.\r\n\r\nTEST-DEVICE#') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse File "/usr/local/lib/python3.11/site-packages/genie/libs/parser/iosxe/show_platform.py", line 2886, in cli out = self.device.execute(self.cli_command) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/unicon/bases/routers/services.py", line 259, in unicon.bases.routers.services.BaseService.__call__ File "/usr/local/lib/python3.11/site-packages/unicon/plugins/generic/service_implementation.py", line 745, in call_service raise SubCommandFailure("Command execution failed", err) from err unicon.core.errors.SubCommandFailure: ('Command execution failed', SubCommandFailure('sub_command failure, patterns matched in the output:', ['^%\\s*[Ii]ncomplete (command|input)'], 'service result', 'show platform\r\nshow platform\r\n% Incomplete command.\r\n\r\nTEST-DEVICE#')) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/tmp/run_commands.py", line 17, in <module> parse_info = device.parse("show platform") ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/genie/conf/base/device.py", line 531, in genie.conf.base.device.Device.parse File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output File "src/genie/metaparser/_metaparser.py", line 311, in genie.metaparser._metaparser.MetaParser.parse genie.metaparser.util.exceptions.InvalidCommandError: Invalid command has been executed

with parser show inventory:

TEST-DEVICE# Traceback (most recent call last): File "/tmp/run_commands.py", line 17, in <module> parse_info = device.parse("show inventory") ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/genie/conf/base/device.py", line 531, in genie.conf.base.device.Device.parse File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse File "/usr/local/lib/python3.11/site-packages/genie/libs/parser/ios/show_platform.py", line 327, in cli subslot = group['subslot'] ^^^^^^^ UnboundLocalError: cannot access local variable 'slot_dict' where it is not associated with a value

with parser show platform software sdwan service-chain database: switch_stack_info = device.parse("show platform software sdwan service-chain database") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/genie/conf/base/device.py", line 529, in genie.conf.base.device.Device.parse File "/usr/local/lib/python3.11/site-packages/genie/libs/parser/utils/common.py", line 285, in get_parser raise ParserNotFound(command, lookup._tokens) genie.libs.parser.utils.common.ParserNotFound: Could not find parser for show platform software sdwan service-chain database under ('ios', 'cat4k')

gopurx avatar Nov 16 '23 14:11 gopurx

Kindly give sometime analyze your issue and get back to you.

sumsehga avatar Nov 20 '23 17:11 sumsehga

Hi , From the above error , we found that the parser is not available for os :iosxe and platform cat4k . Since genieparser is community driven, would you like to contribute to the library by following this documentation. Please let me know if you need any help during the process of PR creation. And fallow the below steps :

You’ve written your parser, you’ve run tests on your parser, and you’re ready to contribute your parser. Great! For your convenience, the steps required to make a good pull request are outlined here, but before you start them, go read the pyATS contribution guide. Seriously. It’s good stuff. Please follow the steps closely as it saves time for you and also for our development team! The genieparser repo README also contains useful information on submitting your parser.

Make sure your testing passed via GitHub Actions.

Fix any errors found in GitHub Actions result.

Create a new changelog file in genieparser/changelog/undistributed/. The genieparser repo README explains how in the how to write changelog section.

Commit and push your changes to your forked genieparser repo.

Create a pull request

Fill out the Description, Motivation and Context, Impact, and Screenshots sections of the pull request form.

Complete the Checklist section.

Submit your pull request!

sumsehga avatar Nov 21 '23 11:11 sumsehga

Hi , Please could share the devices output the above commands.

sumsehga avatar Nov 27 '23 10:11 sumsehga

Hi , Please can share the devices output the above commands.

sumsehga avatar Nov 29 '23 13:11 sumsehga

I am sorry @sumsehga, I do not have any test/sandbox setup for these devices and will not be able to share actual device outputs

From: sumsehga @.> Date: Wednesday, November 29, 2023 at 7:51 AM To: CiscoTestAutomation/genielibs @.> Cc: Gopu, Revanth @.>, Manual @.> Subject: Re: [CiscoTestAutomation/genielibs] genie module or parsers unstable with cat4500 switch (Issue #143)

Hi , Please can share the devices output the above commands.

— Reply to this email directly, view it on GitHubhttps://github.com/CiscoTestAutomation/genielibs/issues/143#issuecomment-1831935493, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJHQUMP2WWEMDT3CVEP2RRDYG44XDAVCNFSM6AAAAAA7OGRGW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRHEZTKNBZGM. You are receiving this because you are subscribed to this thread.Message ID: @.***>

gopurx avatar Nov 29 '23 15:11 gopurx

Hi, If you are not comfortable sharing the device output here in open internet, you may share it on CISCO external mailer group [email protected].

So, kindly share the output in this group and let me know.

sumitsehgal123 avatar Nov 30 '23 12:11 sumitsehgal123

Hi , Please let know the updates on above .Once you share the output on this [email protected] ,.

sumitsehgal123 avatar Dec 05 '23 18:12 sumitsehgal123