Skip to content

[sonic-py-common] Add platform and chassis info methods to device_info#6

Closed
alexrallen wants to merge 4 commits intomasterfrom
chassis_info
Closed

[sonic-py-common] Add platform and chassis info methods to device_info#6
alexrallen wants to merge 4 commits intomasterfrom
chassis_info

Conversation

@alexrallen
Copy link
Copy Markdown
Owner

Why I did it

These methods were added to make some convenient platform and chassis information methods accessible through sonic-py-common. These methods were refactored from sonic-utilities and are used in the show platform summary and show version commands.

How I did it

There are two methods, one is get_platform_info() which simply calls local methods to collect useful platform information into a dictionary format, this came directly from sonic-utilities.

The other method is get_chassis_info() which retrieves the chassis model, serial number, and hardware revision from the STATE_DB directly. This is also utilized by sonic-utilities which is added by alexrallen/sonic-utilities#3

How to verify it

Open a python3 interpreter and enter the following lines

Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sonic_py_common import device_info
>>> device_info.get_platform_info()
{'platform': 'x86_64-mlnx_msn2700-r0', 'hwsku': 'ACS-MSN2700', 'asic_type': 'mellanox', 'asic_count': 1}
>>> device_info.get_chassis_info()
{'model':'MSN2700-CS2FO', 'serial':'MT1623X09522', 'revision': 'A1'}

For different platforms these values will be different, simply check if they are successfully populated. If alexrallen/sonic-platform-daemons#3 has not been merged then get_chassis_info() is expected to return an empty dictionary.

Description for the changelog

[sonic-py-common] Add platform and chassis info methods to device_info

A picture of a cute animal (not mandatory but encouraged)

Highland-Cow-Lavena-and-calf-Star

@Junchao-Mellanox
Copy link
Copy Markdown

Junchao-Mellanox commented May 12, 2021

It looks good to me, but could you please add unit test case for your change?

@alexrallen
Copy link
Copy Markdown
Owner Author

@keboliu @Junchao-Mellanox I have updated the unit test for the existing show platform summary test.

@alexrallen alexrallen closed this May 19, 2021
alexrallen pushed a commit that referenced this pull request Dec 8, 2021
#### What I did 

[sonic-linkmgrd][master] submodule update

6c6151b Fix unstable unit tests (state change handler wasn't invoked) (#8)
2f7dc0a support code diff coverage (#5)
83f0002 Force mux state switch to standby if triggered from Cli (#6)

signed-off-by: Jing Zhang zhangjing@microsoft.com
alexrallen pushed a commit that referenced this pull request Mar 30, 2022
6c6151b Fix unstable unit tests (state change handler wasn't invoked) (#8)
2f7dc0a support code diff coverage (#5)
83f0002 Force mux state switch to standby if triggered from Cli (#6)

signed-off-by: Jing Zhang zhangjing@microsoft.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

Successfully merging this pull request may close these issues.

3 participants