-
Notifications
You must be signed in to change notification settings - Fork 63
genie module or parsers unstable with cat4500 switch #143
Description
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')