[multi_asic_host]: Add __repr__ method#3090
Merged
theasianpianist merged 3 commits intosonic-net:masterfrom Mar 9, 2021
Merged
[multi_asic_host]: Add __repr__ method#3090theasianpianist merged 3 commits intosonic-net:masterfrom
theasianpianist merged 3 commits intosonic-net:masterfrom
Conversation
Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
wangxin
reviewed
Mar 4, 2021
tests/common/devices/multi_asic.py
Outdated
| self.critical_services_tracking_list() | ||
|
|
||
| def __repr__(self): | ||
| return self.hostname |
Collaborator
There was a problem hiding this comment.
Is it better to return something like '<MultiAsicSonicHost {}>'.format(self.hostname)?
Contributor
Author
There was a problem hiding this comment.
Good idea, will change
neethajohn
reviewed
Mar 8, 2021
tests/common/devices/multi_asic.py
Outdated
| self.critical_services_tracking_list() | ||
|
|
||
| def __repr__(self): | ||
| return '<MultiAsicSonicHost> {}'.format(self.hostname) |
Contributor
There was a problem hiding this comment.
can you fix the alignment?
neethajohn
approved these changes
Mar 9, 2021
wangxin
approved these changes
Mar 9, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Lawrence Lee lawlee@microsoft.com
Description of PR
Summary:
Fixes # (issue)
Type of change
Approach
What is the motivation for this PR?
When viewing stack traces for failed tests, any
duthostobjects are displayed using the default Python representation which simply gives the object's location in memory. On single DUT testbeds this is not an issue, but on dual ToR systems it is difficult to tell which DUT is relevant to the failure.How did you do it?
Add the
__repr__method to theMultiAsicSonicHostclass, which makes the class readable by using the device hostname as the representation.This also gives the added benefit of returning the hostname when the duthost object is cast to a string (for example when formatting a string)
How did you verify/test it?
Run a test that failed. Confirm in the stack trace that the device hostname is shown instead of the host object's memory location.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation