Skip to content

Commit

Permalink
Finding drive vid in lsblk vendor (#1094)
Browse files Browse the repository at this point in the history
* Finding drive vid in lsblk vendor

* addressing review comments

* Initializing device

---------

Signed-off-by: Andrzej Zukowski <[email protected]>
  • Loading branch information
prasant123 authored and Andrzej-Zukowski committed Feb 26, 2024
1 parent 3123f10 commit da4463b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/base/linuxutils/lsblk/lsblk.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,8 @@ func (l *LSBLK) GetBlockDevices(device string) ([]BlockDevice, error) {
// Receives an instance of drivecrd.Drive struct
// Returns drive's path based on provided drivecrd.Drive or error if something went wrong
func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) {
// device path might be already set by hwmgr
device := drive.Path
if device != "" {
return device, nil
}

device := ""
// try to find it with lsblk
lsblkOut, err := l.GetBlockDevices("")
if err != nil {
Expand All @@ -178,8 +174,9 @@ func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) {
vid := drive.VID
pid := drive.PID
for _, l := range lsblkOut {
if strings.EqualFold(l.Serial, sn) && strings.EqualFold(l.Vendor, vid) &&
strings.EqualFold(l.Model, pid) {
lvid := strings.TrimSpace(l.Vendor)
if strings.EqualFold(l.Serial, sn) && strings.EqualFold(lvid, vid) &&
strings.HasPrefix(l.Model, pid) {
device = l.Name
break
}
Expand Down

0 comments on commit da4463b

Please sign in to comment.