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

Adds logic to get default disk and check disk type #3399

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

assrinivasan
Copy link
Contributor

@assrinivasan assrinivasan commented Jul 4, 2024

What I did

Fix for sonic-buildimage issue 9407

To be merged

  1. after sonic-buildimage PR: Added blkinfo module to host for use by ssdutil sonic-buildimage#19362
  2. before sonic-mgmt PR: Modified ssdhealth test to account for currently supported disk types sonic-mgmt#14071

How I did it

Added logic using python libraries blkinfo and psutil to get the default disk, and the disk type (SATA/non-SATA).

How to verify it

call sudo ssdutil on a device with non-SATA disk (such as EUSB). Expected output is:


#EUSB disk:
admin@sonic-switch-usb:~$ realpath /sys/block/sda/device
/sys/devices/pci0000:00/0000:00:12.2/usb1/1-2/1-2:1.0/host2/target2:0:0/2:0:0:0

root@sonic-switch-usb:~# ssdutil
Disk type: USB
Device Model : N/A
Health       : N/A
Temperature  : N/A
root@sonic-switch-usb:~#
root@sonic-switch-usb:~# show plat ssdh
Disk type: USB
Device Model : N/A
Health       : N/A
Temperature  : N/A
root@sonic-switch-usb:~#

#EMMC Disk:

root@sonic-switch-emmc:~# realpath /sys/block/mmcblk0/device
/sys/devices/pci0000:00/0000:00:14.7/mmc_host/mmc0/mmc0:0001

root@sonic-switch-emmc:~# ssdutil
Disk Type    : EMMC
Device Model : N/A
Health       : N/A
Temperature  : N/A

root@sonic-switch-emmc:~# show plat ssd
Disk Type    : EMMC
Device Model : N/A
Health       : N/A
Temperature  : N/A

#NVMe Disk

root@sonic-switch-nvme:~# realpath /sys/block/nvme0n1/device
/sys/devices/pci0000:00/0000:00:10.0/0000:01:00.0/nvme/nvme0

root@sonic-switch-nvme:~# ssdutil
Disk Type    : NVME
Device Model : Micron_7450_MTFDKBA400TFS
Health       : 100.0%
Temperature  : 27.0C

root@sonic-switch-nvme:~# show plat ssdh
Disk Type    : NVME
Device Model : Micron_7450_MTFDKBA400TFS
Health       : 100.0%
Temperature  : 27.0C

#SATA Disk

root@sonic-switch-sata:~$ realpath /sys/block/sda/device
/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0

root@sonic-switch-sata:~# ssdutil
Disk type: SATA
Device Model : TRSC41BM030M4-46EN
Health       : N/A
Temperature  : 100C

root@sonic-switch-sata:~# show platform ssdhealth
Disk type: SATA
Device Model : TRSC41BM030M4-46EN
Health       : N/A
Temperature  : 100C
root@sonic-switch-sata:~#

Also ran a modified test_show_platform_ssdhealth (See sonic-mgmt PR mentioned above) on switches with all 4 disk types and verified that test was either skipped or passed. Logs attached: test_show_platform_ssdhealth.txt

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

admin@sonic:~$ sudo ssdutil
Device Model : N/A
Health       : N/A
Temperature  : N/A

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

admin@sonic:~$ sudo ssdutil
Disk type: <disk_type>
Device Model : N/A
Health       : N/A
Temperature  : N/A

@assrinivasan
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

ssdutil/main.py Show resolved Hide resolved
ssdutil/main.py Show resolved Hide resolved
ssdutil/main.py Outdated Show resolved Hide resolved
The syslogger-to-logger change is unrelated to the sonic-utilities
change and breaks backwards compatibility. It should be a separate
commit once SysLogger is in all the older versions.
@assrinivasan
Copy link
Contributor Author

@prgeor please help review/merge. Thanks.

Comment on lines +82 to +88
from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil
except ImportError as e:
log.log_error("Failed to import default SsdUtil. Error: {}".format(str(e)), True)
raise e
try:
from sonic_platform_base.sonic_storage.ssd import SsdUtil
except ImportError as e:
log.log_error("Failed to import default SsdUtil. Error: {}".format(str(e)), True) # noqa: E501
raise e
Copy link
Contributor

Choose a reason for hiding this comment

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

@assrinivasan why we need two different SsdUtil implementation?

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 was going to say to maintain backwards compatibility, but since you said we should only take this into master and 202405+, there is no need for SsdUtil anymore. I will therefore change this to just import StorageUtil.

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