Skip to content

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

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

Merged
merged 11 commits into from
Oct 28, 2024

Conversation

ashwnsri
Copy link
Contributor

@ashwnsri ashwnsri 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

@ashwnsri
Copy link
Contributor Author

ashwnsri commented Jul 4, 2024

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Ashwin Srinivasan added 5 commits August 1, 2024 06:08
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.
@ashwnsri
Copy link
Contributor Author

ashwnsri commented Sep 9, 2024

@prgeor please help review/merge. Thanks.

@prgeor prgeor merged commit d64a90a into sonic-net:master Oct 28, 2024
7 checks passed
@ashwnsri
Copy link
Contributor Author

@bingwang-ms please help cherry-pick to 202405 branch, thanks!

mssonicbld pushed a commit to mssonicbld/sonic-utilities that referenced this pull request Nov 6, 2024
* Added function to check if disk is SATA

* Fixed eval bug unconvered by UT

* Changed logger to syslogger; fixed UT failures

* Added checks for partitions and filtered_disks; fixed static analysis issues

* Fix static analysis errors E303, E711

* Changed information delivery semantics per review comment

* Reverted syslogger to logger to maintain backward compatibility

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.

* Changed Disk 'type' --> 'Type' for uniformity

* Made the fields look uniform

* Disk Type Support for eMMC devices

* Removed old sonic_ssd import
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202405: #3601

mssonicbld pushed a commit that referenced this pull request Nov 6, 2024
* Added function to check if disk is SATA

* Fixed eval bug unconvered by UT

* Changed logger to syslogger; fixed UT failures

* Added checks for partitions and filtered_disks; fixed static analysis issues

* Fix static analysis errors E303, E711

* Changed information delivery semantics per review comment

* Reverted syslogger to logger to maintain backward compatibility

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.

* Changed Disk 'type' --> 'Type' for uniformity

* Made the fields look uniform

* Disk Type Support for eMMC devices

* Removed old sonic_ssd import
mssonicbld added a commit to mssonicbld/sonic-utilities.msft that referenced this pull request Apr 15, 2025
…ash drive is plugged in

Fix `show platform ssdhealth` not showing expected output when a usb flash drive is plugged in.

<!--
    Please make sure you've read and understood our contributing guidelines:
    https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

    ** Make sure all your commits include a signature generated with `git commit -s` **

    If this is a bug fix, make sure your description includes "closes #xxxx",
    "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related
    issue when the PR is merged.

    If you are adding/modifying/removing any command or utility script, please also
    make sure to add/modify/remove any unit tests from the tests
    directory as appropriate.

    If you are modifying or removing an existing 'show', 'config' or 'sonic-clear'
    subcommand, or you are adding a new subcommand, please make sure you also
    update the Command Line Reference Guide (doc/Command-Reference.md) to reflect
    your changes.

    Please provide the following information:
-->

#### What I did
When 'show platform ssdhealth' is not supplied with a device name and a usb flash drive is attached we show incorrect output as we deduce incorrect device name from 'lsblk' command and pass it to ssdutil. I removed this incorrect deduction of the device name.

#### How I did it

Instead of incorrectly deducing the device using the lsblk command we can instead not pass any device name as argument to the ssdutil and it will automatically choose the device on which /host partition is mounted which is the primary storage device in our case as per the PR: sonic-net/sonic-utilities#3399

#### How to verify it

Run `sudo show platform ssdhealth` without any arguments with a flash drive plugged into the sonic switch.

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

```
root@qa-eth-vt19-1-4280:~# show platform ssdhealth
Disk Type    : NVME
Device Model : N/A
Health       : N/A
Temperature  : N/A
```

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

```
root@qa-eth-vt19-1-4280:/home/admin# show platform ssdhealth
Disk Type    : NVME
Device Model : Virtium VTPM24CEXI080-BM110006
Health       : 100.0%
Temperature  : 51.0C
```

In the case where the user passes the device name as argument to the command (`show platform ssdhealth /dev/nvme0n1`) output remains the same and no changes have been made.
mssonicbld added a commit to Azure/sonic-utilities.msft that referenced this pull request Apr 15, 2025
…ash drive is plugged in (#166)

Fix `show platform ssdhealth` not showing expected output when a usb flash drive is plugged in.

<!--
 Please make sure you've read and understood our contributing guidelines:
 https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

 failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` **

 If this is a bug fix, make sure your description includes "closes #xxxx",
 "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related
 issue when the PR is merged.

 If you are adding/modifying/removing any command or utility script, please also
 make sure to add/modify/remove any unit tests from the tests
 directory as appropriate.

 If you are modifying or removing an existing 'show', 'config' or 'sonic-clear'
 subcommand, or you are adding a new subcommand, please make sure you also
 update the Command Line Reference Guide (doc/Command-Reference.md) to reflect
 your changes.

 Please provide the following information:
-->

#### What I did
When 'show platform ssdhealth' is not supplied with a device name and a usb flash drive is attached we show incorrect output as we deduce incorrect device name from 'lsblk' command and pass it to ssdutil. I removed this incorrect deduction of the device name.

#### How I did it

Instead of incorrectly deducing the device using the lsblk command we can instead not pass any device name as argument to the ssdutil and it will automatically choose the device on which /host partition is mounted which is the primary storage device in our case as per the PR: sonic-net/sonic-utilities#3399

#### How to verify it

Run `sudo show platform ssdhealth` without any arguments with a flash drive plugged into the sonic switch.

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

```
root@qa-eth-vt19-1-4280:~# show platform ssdhealth
Disk Type : NVME
Device Model : N/A
Health : N/A
Temperature : N/A
```

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

```
root@qa-eth-vt19-1-4280:/home/admin# show platform ssdhealth
Disk Type : NVME
Device Model : Virtium VTPM24CEXI080-BM110006
Health : 100.0%
Temperature : 51.0C
```

In the case where the user passes the device name as argument to the command (`show platform ssdhealth /dev/nvme0n1`) output remains the same and no changes have been made.
nmoray pushed a commit to nmoray/sonic-utilities that referenced this pull request Jun 25, 2025
* Added function to check if disk is SATA

* Fixed eval bug unconvered by UT

* Changed logger to syslogger; fixed UT failures

* Added checks for partitions and filtered_disks; fixed static analysis issues

* Fix static analysis errors E303, E711

* Changed information delivery semantics per review comment

* Reverted syslogger to logger to maintain backward compatibility

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.

* Changed Disk 'type' --> 'Type' for uniformity

* Made the fields look uniform

* Disk Type Support for eMMC devices

* Removed old sonic_ssd import
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.

6 participants