Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genie module or parsers unstable with cat4500 switch #143

Open
gopurx opened this issue Nov 16, 2023 · 7 comments
Open

genie module or parsers unstable with cat4500 switch #143

gopurx opened this issue Nov 16, 2023 · 7 comments
Assignees

Comments

@gopurx
Copy link

gopurx commented Nov 16, 2023

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')

@sumsehga
Copy link

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

@sumsehga
Copy link

sumsehga commented Nov 21, 2023

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
Copy link

sumsehga commented Nov 27, 2023

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

@sumsehga
Copy link

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

@gopurx
Copy link
Author

gopurx commented Nov 29, 2023 via email

@sumitsehgal123
Copy link

sumitsehgal123 commented Nov 30, 2023

Hi,
If you are not comfortable sharing the device output here in open internet, you may share it on CISCO external mailer group pyats-support-ext@cisco.com.

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

@sumitsehgal123
Copy link

Hi ,
Please let know the updates on above .Once you share the output on this pyats-support-ext@cisco.com ,.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants