Skip to content

[sfputil] Refactor to utilize sonic-platform package#1421

Merged
jleveque merged 21 commits intosonic-net:masterfrom
jleveque:sfputil_use_sonic_platform
Feb 18, 2021
Merged

[sfputil] Refactor to utilize sonic-platform package#1421
jleveque merged 21 commits intosonic-net:masterfrom
jleveque:sfputil_use_sonic_platform

Conversation

@jleveque
Copy link
Contributor

@jleveque jleveque commented Feb 10, 2021

What I did

Refactor sfputil to use sonic-platform package in lieu of old, deprecated platform plugins.

The sfputil utility is still useful, as sfpshow only reads and displays SFP data from State DB. However, we still need a utility to write to the transceivers (low power mode, reset, etc.), and the ability to read directly from the transceivers is helpful for debugging.

How I did it

  • Complete refactor to use sonic-platform package
  • Refactor display functions to align with sfpshow utility
  • Bump version to 3.0
  • Add unit tests

How to verify it

Run all sfputil commands, ensure they work. Do the same on multiple platforms. Output should be the same as before.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@lgtm-com

This comment has been minimized.

except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
import click
import sonic_platform

Choose a reason for hiding this comment

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

@jleveque - We tested this file on a multi-asic and single asic box, except we had to change this line to

import sonic_platform.platform

In common code, we are seeing a lot of places where we have to make the same change as above for python3 to work. Is this the best way to fix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have heard other accounts of this. Why do you need to change it? What is the error you encounter with it like this?

Copy link

@sanmalho-git sanmalho-git Feb 11, 2021

Choose a reason for hiding this comment

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

admin@Linecard2:$ /usr/bin/python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sonic_platform
>>> platform_chassis = sonic_platform.platform.Platform().get_chassis()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'sonic_platform' has no attribute 'platform'
>>>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see this issue on Arista, Dell or Mellanox platforms. Can you see if there is a noticeable difference in the way your sonic-platform packages are structured?

Also, I just pushed a couple new commits. Can you please test the latest changes?

Choose a reason for hiding this comment

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

@jleveque sorry for the delay. There was an issue in the packaging of our sonic-platform that we have now resolved and thus don't see the backtrace with the original contents.

Also, I have tested the latest main.py on multi-asic and single asic pizza box, and it works fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great to hear! And thanks for testing the changes!

@mlok-nokia
Copy link
Contributor

Should we also change psuutil as well to use the new PMON 2.0 API's?

@jleveque
Copy link
Contributor Author

Should we also change psuutil as well to use the new PMON 2.0 API's?

I just merged those changes, actually: #1434

@jleveque jleveque merged commit 6b0ca96 into sonic-net:master Feb 18, 2021
@jleveque jleveque deleted the sfputil_use_sonic_platform branch February 18, 2021 02:38
yxieca pushed a commit that referenced this pull request Feb 23, 2021
Refactor sfputil to use sonic-platform package in lieu of old, deprecated platform plugins.

The sfputil utility is still useful, as sfpshow only reads and displays SFP data from State DB. However, we still need a utility to write to the transceivers (low power mode, reset, etc.), and the ability to read directly from the transceivers is helpful for debugging.

- Complete refactor to use sonic-platform package
- Refactor display functions to align with sfpshow utility
- Bump version to 3.0
- Add unit tests
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
Refactor sfputil to use sonic-platform package in lieu of old, deprecated platform plugins.

The sfputil utility is still useful, as sfpshow only reads and displays SFP data from State DB. However, we still need a utility to write to the transceivers (low power mode, reset, etc.), and the ability to read directly from the transceivers is helpful for debugging.

- Complete refactor to use sonic-platform package
- Refactor display functions to align with sfpshow utility
- Bump version to 3.0
- Add unit tests
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
[portsorch] add buffer drop FC group 
[bitmap_vnet] Fix VNET route priority issue (sonic-net#1421)
[vnet] Maintain the reference count of the nexthop when creating a
vn… (sonic-net#1414)
[intfsorch] Retrieve Port object before setting NAT zone on router
interfaces. (sonic-net#1372)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants