Skip to content

Commit

Permalink
utils: Add LogicalName to drive if its easily available
Browse files Browse the repository at this point in the history
Necessary for nvme wiping and might as well store it for other devices
if we have it.
  • Loading branch information
mmlb committed Jun 4, 2024
1 parent 44d8d0b commit 9bbce07
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
28 changes: 14 additions & 14 deletions fixtures/supermicro/x11dph-t.go
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ var (
Model: "Micron_5200_MTFDDAK960TDN",
Serial: "20032613EE70",
ProductName: "Micron_5200_MTFD",
LogicalName: "/dev/sda",
LogicalName: "/dev/sdm",
Firmware: &common.Firmware{
Installed: "D1MU020",
Available: "",
Expand Down Expand Up @@ -2411,7 +2411,7 @@ var (
Model: "Micron_5200_MTFDDAK960TDN",
Serial: "20032613D813",
ProductName: "Micron_5200_MTFD",
LogicalName: "/dev/sdb",
LogicalName: "/dev/sdn",
Firmware: &common.Firmware{
Installed: "D1MU020",
Available: "",
Expand Down Expand Up @@ -2507,7 +2507,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJL8MVK",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdk",
LogicalName: "/dev/sdi",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2539,7 +2539,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJHR67K",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdl",
LogicalName: "/dev/sdj",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2571,7 +2571,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJJ51YK",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdm",
LogicalName: "/dev/sdk",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2603,7 +2603,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJLNERD",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdn",
LogicalName: "/dev/sdl",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2635,7 +2635,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJKG9LK",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdc",
LogicalName: "/dev/sda",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2667,7 +2667,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJBVPXD",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdd",
LogicalName: "/dev/sdb",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2699,7 +2699,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJJ7T3K",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sde",
LogicalName: "/dev/sdc",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2731,7 +2731,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJL8U5K",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdf",
LogicalName: "/dev/sdd",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2763,7 +2763,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJBP7SD",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdg",
LogicalName: "/dev/sde",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2795,7 +2795,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJKVBKK",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdh",
LogicalName: "/dev/sdf",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2827,7 +2827,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJK7E2K",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdi",
LogicalName: "/dev/sdg",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down Expand Up @@ -2859,7 +2859,7 @@ var (
Model: "HGST HUS728T8TALE6L4",
Serial: "VDJL2NUK",
ProductName: "HGST HUS728T8TAL",
LogicalName: "/dev/sdj",
LogicalName: "/dev/sdh",
Firmware: &common.Firmware{
Installed: "V8GNW460",
Available: "",
Expand Down
1 change: 1 addition & 0 deletions utils/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (n *Nvme) Drives(ctx context.Context) ([]*model.Drive, error) {

drives[i] = model.NewDrive(&common.Drive{
Common: common.Common{
LogicalName: d.DevicePath,
Serial: d.SerialNumber,
Vendor: vendor,
Model: dModel,
Expand Down
4 changes: 2 additions & 2 deletions utils/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_NvmeComponents(t *testing.T) {
// nolint:dupl
expected := []*model.Drive{
{Drive: common.Drive{Common: common.Common{
Serial: "Z9DF70I8FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL",
LogicalName: "/dev/nvme0n1", Serial: "Z9DF70I8FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL",
Metadata: map[string]string{
"Block Erase Sanitize Operation Supported": "false",
"Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false",
Expand All @@ -30,7 +30,7 @@ func Test_NvmeComponents(t *testing.T) {
},
}}},
{Drive: common.Drive{Common: common.Common{
Serial: "Z9DF70I9FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL",
LogicalName: "/dev/nvme1n1", Serial: "Z9DF70I9FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL",
Metadata: map[string]string{
"Block Erase Sanitize Operation Supported": "false",
"Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false",
Expand Down
1 change: 1 addition & 0 deletions utils/smartctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (s *Smartctl) Drives(ctx context.Context) ([]*model.Drive, error) {

item := &common.Drive{
Common: common.Common{
LogicalName: d.Name,
Vendor: cmp.Or(
common.VendorFromString(smartctlAll.ModelName),
common.VendorFromString(smartctlAll.ModelFamily),
Expand Down
10 changes: 5 additions & 5 deletions utils/smartctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func Test_SmartctlAllNVME(t *testing.T) {

func Test_SmartctlDeviceAttributes(t *testing.T) {
expected := []*model.Drive{
{Drive: common.Drive{Common: common.Common{Serial: "2013273A99BD", Vendor: common.VendorMicron, Model: "Micron_5200_MTFDDAK960TDN", ProductName: "Micron_5200_MTFDDAK960TDN", Firmware: &common.Firmware{Installed: "D1MU020"}}, Type: common.SlugDriveTypeSATASSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{Serial: "VDJ6SU9K", Vendor: common.VendorHGST, Model: "HGST HUS728T8TALE6L4", ProductName: "HGST HUS728T8TALE6L4", Firmware: &common.Firmware{Installed: "V8GNW460"}}, Type: common.SlugDriveTypeSATAHDD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{Serial: "PHYH1016001D240J", Vendor: common.VendorDell, Model: "SSDSCKKB240G8R", ProductName: "SSDSCKKB240G8R", Firmware: &common.Firmware{Installed: "XC31DL6R"}}, Type: "Unknown", SmartStatus: "ok", OemID: "DELL(tm)", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{Serial: "Z9DF70I8FY3L", Vendor: common.VendorToshiba, Model: "KXG60ZNV256G TOSHIBA", ProductName: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}}, Type: common.SlugDriveTypePCIeNVMEeSSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{Serial: "Z9DF70I9FY3L", Vendor: common.VendorToshiba, Model: "KXG60ZNV256G TOSHIBA", ProductName: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}}, Type: common.SlugDriveTypePCIeNVMEeSSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{LogicalName: "/dev/sda", Serial: "2013273A99BD", Vendor: common.VendorMicron, Model: "Micron_5200_MTFDDAK960TDN", ProductName: "Micron_5200_MTFDDAK960TDN", Firmware: &common.Firmware{Installed: "D1MU020"}}, Type: common.SlugDriveTypeSATASSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{LogicalName: "/dev/sdb", Serial: "VDJ6SU9K", Vendor: common.VendorHGST, Model: "HGST HUS728T8TALE6L4", ProductName: "HGST HUS728T8TALE6L4", Firmware: &common.Firmware{Installed: "V8GNW460"}}, Type: common.SlugDriveTypeSATAHDD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{LogicalName: "/dev/sdc", Serial: "PHYH1016001D240J", Vendor: common.VendorDell, Model: "SSDSCKKB240G8R", ProductName: "SSDSCKKB240G8R", Firmware: &common.Firmware{Installed: "XC31DL6R"}}, Type: "Unknown", SmartStatus: "ok", OemID: "DELL(tm)", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{LogicalName: "/dev/nvme0", Serial: "Z9DF70I8FY3L", Vendor: common.VendorToshiba, Model: "KXG60ZNV256G TOSHIBA", ProductName: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}}, Type: common.SlugDriveTypePCIeNVMEeSSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
{Drive: common.Drive{Common: common.Common{LogicalName: "/dev/nvme1", Serial: "Z9DF70I9FY3L", Vendor: common.VendorToshiba, Model: "KXG60ZNV256G TOSHIBA", ProductName: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}}, Type: common.SlugDriveTypePCIeNVMEeSSD, SmartStatus: "ok", StorageControllerDriveID: -1}},
}
s := newFakeSmartctl()

Expand Down

0 comments on commit 9bbce07

Please sign in to comment.