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

updated P2 pattern to make sn optional #601

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

aclaughan
Copy link

Description

Changed P2 regex to make sn field optional

Motivation and Context

show_inventory.py was only parsing lines that included a serial number

@aclaughan aclaughan requested a review from a team as a code owner January 17, 2022 18:38
Copy link
Contributor

@LukasMcClelland LukasMcClelland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing! Left a comment

output = self.device.execute(self.cli_command)

return super().cli(output=output)
''' show_inventory.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something a little odd happening here.

Only p2 was changed but git is highlighting around 100 lines as being changed. Perhaps did you commit files that had different line endings?

Please investigate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats odd, let me go check.

Copy link
Author

@aclaughan aclaughan Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Lukas,

It is the line ending, but pycharm doesn't give me the option to change to CRLF (it's grey out). Not sure if this is a MAC thing. I tried changing the file encoding too. The most frustrating thing, is the pycharm diff only shows that single line as being changed. I only see the problem after I push to github and run diff there. Not sure how to sort this any ideas?

@LukasMcClelland
Copy link
Contributor

Nice! I think that fixed the line endings. I also went ahead and removed trailing white space from the lines.

Please add a changelog (instructions are in this repos README)

name_dict['sn'] = group['sn']
continue

name_dict['sn'] = group['sn']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If sn is optional, then a check will be needed here

Suggested change
name_dict['sn'] = group['sn']
if group['sn']:
name_dict['sn'] = group['sn']

@LukasMcClelland
Copy link
Contributor

Also, it seems one of the unit tests is failing

2022-02-07T12:34:39: %AETEST-INFO: +------------------------------------------------------------------------------+
2022-02-07T12:34:39: %AETEST-INFO: |                      Starting section ShowInventoryRaw                       |
2022-02-07T12:34:39: %AETEST-INFO: +------------------------------------------------------------------------------+
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %AETEST-INFO: :                  Starting STEP 1: iosxe -> ShowInventoryRaw                  :
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %AETEST-INFO: :         Starting STEP 1.1: Test Golden -> iosxe -> ShowInventoryRaw          :
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %AETEST-INFO: :    Starting STEP 1.1.1: Gold -> iosxe -> ShowInventoryRaw -> golden_outpu    :
2022-02-07T12:34:39: %AETEST-INFO: :                                      t                                       :
2022-02-07T12:34:39: %AETEST-INFO: +..............................................................................+
2022-02-07T12:34:39: %SCRIPT-ERROR: Traceback (most recent call last):
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/_metaparser.py", line 292, in parse
2022-02-07T12:34:39: %SCRIPT-ERROR:     output = Schema(self.schema).validate(
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/util/schemaengine.py", line 284, in validate
2022-02-07T12:34:39: %SCRIPT-ERROR:     matchValue = Schema(sv, path).validate(
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/util/schemaengine.py", line 359, in validate
2022-02-07T12:34:39: %SCRIPT-ERROR:     matchValue = Schema(sv, path).validate(
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/util/schemaengine.py", line 359, in validate
2022-02-07T12:34:39: %SCRIPT-ERROR:     matchValue = Schema(sv, path).validate(
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/util/schemaengine.py", line 252, in validate
2022-02-07T12:34:39: %SCRIPT-ERROR:     raise SchemaTypeError(self.path, self.schema, data, command=command)
2022-02-07T12:34:39: %SCRIPT-ERROR: genie.metaparser.util.exceptions.SchemaTypeError: name.slot R0.sn: Expected type '<class 'str'>' but got type 'None'(<class 'NoneType'>)
2022-02-07T12:34:39: %SCRIPT-ERROR: 
2022-02-07T12:34:39: %SCRIPT-ERROR: The above exception was the direct cause of the following exception:
2022-02-07T12:34:39: %SCRIPT-ERROR: 
2022-02-07T12:34:39: %SCRIPT-ERROR: Traceback (most recent call last):
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/external_genieparser/src/genie/libs/parser/utils/unittests.py", line 574, in test_golden
2022-02-07T12:34:39: %SCRIPT-ERROR:     parsed_output = obj.parse(**arguments)
2022-02-07T12:34:39: %SCRIPT-ERROR:   File "/ws/lumcclel-ott/unicon_dev/pypi/genie/src/genie/metaparser/_metaparser.py", line 315, in parse
2022-02-07T12:34:39: %SCRIPT-ERROR:     raise Exception("Parser {cls} schema checking failed".format(
2022-02-07T12:34:39: %SCRIPT-ERROR: Exception: Parser ShowInventoryRaw schema checking failed
Caught an assertion failure while executing STEP 1.1.1: Gold -> iosxe -> ShowInventoryRaw -> golden_output:
Traceback (most recent call last):
  File "/ws/lumcclel-ott/unicon_dev/pypi/external_genieparser/src/genie/libs/parser/utils/unittests.py", line 618, in test_golden
    raise AssertionError("Device output and expected output do not match")
AssertionError: Device output and expected output do not match

You can test your changes with the following command

python folder_parsing_job.py -o iosxe -c ShowInventoryRaw

from the genieparser/tests directory

@sjpatel21 sjpatel21 requested a review from Taarini May 25, 2022 18:16
Copy link
Contributor

@Taarini Taarini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add change log for your changes.

@domachad
Copy link
Contributor

@aclaughan Are you still working on this PR?

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

Successfully merging this pull request may close these issues.

4 participants