sonic-utilities
sonic-utilities copied to clipboard
Adds logic to get default disk and check disk type
What I did
Fix for sonic-buildimage issue 9407
To be merged
- after sonic-buildimage PR: https://github.com/sonic-net/sonic-buildimage/pull/19362
- before sonic-mgmt PR: https://github.com/sonic-net/sonic-mgmt/pull/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
/azpw run
/AzurePipelines run
Azure Pipelines successfully started running 1 pipeline(s).
@prgeor please help review/merge. Thanks.
@bingwang-ms please help cherry-pick to 202405 branch, thanks!
Cherry-pick PR to 202405: https://github.com/sonic-net/sonic-utilities/pull/3601