diff --git a/examples/inventory/inventory.go b/examples/inventory/inventory.go index 9630b48b5..cb20fbac4 100644 --- a/examples/inventory/inventory.go +++ b/examples/inventory/inventory.go @@ -15,7 +15,6 @@ import ( func main() { logger := logrus.New() logger.Formatter = new(logrus.JSONFormatter) - logger.SetLevel(logrus.TraceLevel) device, err := ironlib.New(logger) if err != nil { logger.Fatal(err) diff --git a/examples/inventory/inventory.json b/examples/inventory/inventory.json deleted file mode 100644 index c66a3fbdf..000000000 --- a/examples/inventory/inventory.json +++ /dev/null @@ -1,865 +0,0 @@ -{ - "oem": true, - "vendor": "Dell Inc.", - "model": "PowerEdge R6515", - "serial": "J0S2LM3", - "bios": { - "oem": false, - "description": "BIOS", - "vendor": "Dell Inc.", - "model": "PowerEdge R6515", - "firmware": { - "installed": "2.6.6" - }, - "size_bytes": 65536, - "capacity_bytes": 33554432 - }, - "bmc": { - "oem": false, - "model": "PowerEdge R6515", - "nic": { - "oem": false - } - }, - "mainboard": { - "oem": false, - "description": "Motherboard", - "vendor": "Dell Inc.", - "model": "068NXX", - "serial": ".J0S2LM3.MXWSJ00214015M.", - "product_name": "068NXX", - "physid": "0" - }, - "cplds": [], - "cpus": [ - { - "oem": false, - "description": "CPU", - "vendor": "Advanced Micro Devices [AMD]", - "model": "AMD EPYC 7513 32-Core Processor", - "product_name": "AMD EPYC 7513 32-Core Processor", - "slot": "CPU1", - "clock_speeed_hz": 2000000000, - "cores": 32, - "threads": 64 - } - ], - "memory": [ - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A865A", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A1", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A8777", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A2", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A866C", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A3", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A8666", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A4", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A86E7", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A5", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A8775", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A6", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A8665", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A7", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "DIMM DDR4 Synchronous Registered (Buffered) 3200 MHz (0.3 ns)", - "vendor": "Hynix Semiconductor (Hyundai Electronics)", - "model": "HMA84GR7DJR4N-XN", - "serial": "139A86E3", - "product_name": "HMA84GR7DJR4N-XN", - "slot": "A8", - "size_bytes": 34359738368, - "clock_speed_hz": 3200000000 - }, - { - "oem": false, - "description": "[empty]", - "slot": "A9" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A10" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A11" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A12" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A13" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A14" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A15" - }, - { - "oem": false, - "description": "[empty]", - "slot": "A16" - } - ], - "nics": [ - { - "oem": false, - "vendor": "Intel Corporation [8086]", - "model": "Ethernet Controller E810-XXV for SFP", - "serial": "b4:96:91:d1:f4:e6", - "product_name": "Ethernet Controller E810-XXV for SFP", - "pci_vendor_id": "8086", - "pci_product_id": "159B", - "metadata": { - "driver": "ice", - "duplex": "full", - "firmware": "3.00 0x80008944 20.5.13", - "link": "yes", - "speed": "25Gbit/s" - }, - "firmware": { - "installed": "20.5.13" - }, - "description": "Ethernet interface", - "speed_bits": 25000000000, - "physid": "0", - "bus_info": "pci@0000:41:00.0" - } - ], - "drives": [ - { - "oem": false, - "description": "NVMe device", - "vendor": "micron", - "model": "Micron_9300_MTFDHAL3T8TDP", - "serial": "2144328B02CD", - "product_name": "Micron_9300_MTFDHAL3T8TDP", - "logical_name": "/dev/nvme0n1", - "capabilities": [ - { - "Name": "sanicap", - "Description": "Sanitize Support", - "Enabled": false - }, - { - "Name": "ammasocsind", - "Description": "Additional media modification after sanitize operation completes successfully is not defined", - "Enabled": false - }, - { - "Name": "nasbiscs", - "Description": "No-Deallocate After Sanitize bit in Sanitize command Supported", - "Enabled": false - }, - { - "Name": "osons", - "Description": "Overwrite Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "besons", - "Description": "Block Erase Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "cesons", - "Description": "Crypto Erase Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "fna", - "Description": "Crypto Erase Support", - "Enabled": true - }, - { - "Name": "fbn(s", - "Description": "FormatNVM Broadcast NSID (FFFFFFFFh) Supported", - "Enabled": false - }, - { - "Name": "cesapose", - "Description": "Crypto Erase Supported as part of Secure Erase", - "Enabled": true - }, - { - "Name": "ceatsn", - "Description": "Crypto Erase Applies to Single Namespace(s)", - "Enabled": false - }, - { - "Name": "fatsn", - "Description": "Format Applies to Single Namespace(s)", - "Enabled": false - } - ], - "firmware": { - "installed": "11300DU0" - }, - "drive_type": "NVMe-PCIe-SSD", - "bus_info": "pci@0000:44:00.0", - "protocol": "nvme", - "smart_status": "ok" - }, - { - "oem": false, - "description": "NVMe device", - "vendor": "micron", - "model": "Micron_9300_MTFDHAL3T8TDP", - "serial": "2144328AF4E9", - "product_name": "Micron_9300_MTFDHAL3T8TDP", - "logical_name": "/dev/nvme1n1", - "capabilities": [ - { - "Name": "sanicap", - "Description": "Sanitize Support", - "Enabled": false - }, - { - "Name": "ammasocsind", - "Description": "Additional media modification after sanitize operation completes successfully is not defined", - "Enabled": false - }, - { - "Name": "nasbiscs", - "Description": "No-Deallocate After Sanitize bit in Sanitize command Supported", - "Enabled": false - }, - { - "Name": "osons", - "Description": "Overwrite Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "besons", - "Description": "Block Erase Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "cesons", - "Description": "Crypto Erase Sanitize Operation Not Supported", - "Enabled": false - }, - { - "Name": "fna", - "Description": "Crypto Erase Support", - "Enabled": true - }, - { - "Name": "fbn(s", - "Description": "FormatNVM Broadcast NSID (FFFFFFFFh) Supported", - "Enabled": false - }, - { - "Name": "cesapose", - "Description": "Crypto Erase Supported as part of Secure Erase", - "Enabled": true - }, - { - "Name": "ceatsn", - "Description": "Crypto Erase Applies to Single Namespace(s)", - "Enabled": false - }, - { - "Name": "fatsn", - "Description": "Format Applies to Single Namespace(s)", - "Enabled": false - } - ], - "firmware": { - "installed": "11300DU0" - }, - "drive_type": "NVMe-PCIe-SSD", - "bus_info": "pci@0000:45:00.0", - "protocol": "nvme", - "smart_status": "ok" - }, - { - "oem": false, - "description": "ATA Disk", - "vendor": "micron", - "model": "MTFDDAV240TDU", - "serial": "21433250F5BA", - "product_name": "MTFDDAV240TDU", - "logical_name": "/dev/sda", - "capabilities": [ - { - "Name": "sf", - "Description": "SMART feature", - "Enabled": true - }, - { - "Name": "pmf", - "Description": "Power Management feature", - "Enabled": true - }, - { - "Name": "wc", - "Description": "Write cache", - "Enabled": true - }, - { - "Name": "la", - "Description": "Look ahead", - "Enabled": true - }, - { - "Name": "wb", - "Description": "WRITE BUFFER", - "Enabled": true - }, - { - "Name": "rb", - "Description": "READ BUFFER", - "Enabled": true - }, - { - "Name": "nc", - "Description": "NOP cmd", - "Enabled": true - }, - { - "Name": "dm", - "Description": "DOWNLOAD MICROCODE", - "Enabled": true - }, - { - "Name": "apmf", - "Description": "Advanced Power Management feature", - "Enabled": true - }, - { - "Name": "4baf", - "Description": "48 bit Address feature", - "Enabled": true - }, - { - "Name": "mfc", - "Description": "Mandatory FLUSH CACHE", - "Enabled": true - }, - { - "Name": "fce", - "Description": "FLUSH CACHE EXT", - "Enabled": true - }, - { - "Name": "sel", - "Description": "SMART error logging", - "Enabled": true - }, - { - "Name": "sst", - "Description": "SMART self test", - "Enabled": true - }, - { - "Name": "gplf", - "Description": "General Purpose Logging feature", - "Enabled": true - }, - { - "Name": "6bwwn", - "Description": "64 bit World wide name", - "Enabled": true - }, - { - "Name": "iiwu", - "Description": "IDLE IMMEDIATE with UNLOAD", - "Enabled": true - }, - { - "Name": "wrvf", - "Description": "Write Read Verify feature", - "Enabled": false - }, - { - "Name": "wue", - "Description": "WRITE UNCORRECTABLE EXT", - "Enabled": true - }, - { - "Name": "rdegs", - "Description": "READWRITE DMA EXT GPL s", - "Enabled": true - }, - { - "Name": "sdm", - "Description": "Segmented DOWNLOAD MICROCODE", - "Enabled": true - }, - { - "Name": "u1", - "Description": "unknown 119[6]", - "Enabled": true - }, - { - "Name": "u1", - "Description": "unknown 119[8]", - "Enabled": false - }, - { - "Name": "gss1", - "Description": "Gen1 signaling speed 1.5Gb/s", - "Enabled": true - }, - { - "Name": "gss3", - "Description": "Gen2 signaling speed 3.0Gb/s", - "Enabled": true - }, - { - "Name": "gss6", - "Description": "Gen3 signaling speed 6.0Gb/s", - "Enabled": true - }, - { - "Name": "ncqn", - "Description": "Native Command Queueing NCQ", - "Enabled": true - }, - { - "Name": "pec", - "Description": "Phy event counters", - "Enabled": true - }, - { - "Name": "npi", - "Description": "NCQ priority information", - "Enabled": true - }, - { - "Name": "rldeetrle", - "Description": "READ LOG DMA EXT equivalent to READ LOG EXT", - "Enabled": true - }, - { - "Name": "dsaao", - "Description": "DMA Setup Auto Activate optimization", - "Enabled": true - }, - { - "Name": "stp", - "Description": "Software tings preservation", - "Enabled": true - }, - { - "Name": "sctsf", - "Description": "SMART Command Transport SCT feature", - "Enabled": true - }, - { - "Name": "swsa", - "Description": "SCT Write Same AC2", - "Enabled": true - }, - { - "Name": "serca", - "Description": "SCT Error Recovery Control AC3", - "Enabled": true - }, - { - "Name": "sfca", - "Description": "SCT Features Control AC4", - "Enabled": true - }, - { - "Name": "sdta", - "Description": "SCT Data Tables AC5", - "Enabled": true - }, - { - "Name": "sale", - "Description": "SANITIZE ANTIFREEZE LOCK EXT", - "Enabled": true - }, - { - "Name": "sf", - "Description": "SANITIZE feature", - "Enabled": true - }, - { - "Name": "cse", - "Description": "CRYPTO SCRAMBLE EXT", - "Enabled": true - }, - { - "Name": "bee", - "Description": "BLOCK ERASE EXT", - "Enabled": true - }, - { - "Name": "dmd", - "Description": "DOWNLOAD MICROCODE DMA", - "Enabled": true - }, - { - "Name": "wbd", - "Description": "WRITE BUFFER DMA", - "Enabled": true - }, - { - "Name": "rbd", - "Description": "READ BUFFER DMA", - "Enabled": true - }, - { - "Name": "dsmtsl8b", - "Description": "Data Set Management TRIM supported limit 8 blocks", - "Enabled": true - }, - { - "Name": "drzat", - "Description": "Deterministic read ZEROs after TRIM", - "Enabled": true - } - ], - "firmware": { - "installed": "D3DJ004" - }, - "oem_id": "DELL(tm)", - "drive_type": "Sata-SSD", - "bus_info": "scsi@0:0.0.0", - "protocol": "sata", - "smart_status": "ok", - "capacity_bytes": 240057409536 - }, - { - "oem": false, - "description": "ATA Disk", - "vendor": "micron", - "model": "MTFDDAV240TDU", - "serial": "21433250F717", - "product_name": "MTFDDAV240TDU", - "logical_name": "/dev/sdb", - "capabilities": [ - { - "Name": "sf", - "Description": "SMART feature", - "Enabled": true - }, - { - "Name": "pmf", - "Description": "Power Management feature", - "Enabled": true - }, - { - "Name": "wc", - "Description": "Write cache", - "Enabled": true - }, - { - "Name": "la", - "Description": "Look ahead", - "Enabled": true - }, - { - "Name": "wb", - "Description": "WRITE BUFFER", - "Enabled": true - }, - { - "Name": "rb", - "Description": "READ BUFFER", - "Enabled": true - }, - { - "Name": "nc", - "Description": "NOP cmd", - "Enabled": true - }, - { - "Name": "dm", - "Description": "DOWNLOAD MICROCODE", - "Enabled": true - }, - { - "Name": "apmf", - "Description": "Advanced Power Management feature", - "Enabled": true - }, - { - "Name": "4baf", - "Description": "48 bit Address feature", - "Enabled": true - }, - { - "Name": "mfc", - "Description": "Mandatory FLUSH CACHE", - "Enabled": true - }, - { - "Name": "fce", - "Description": "FLUSH CACHE EXT", - "Enabled": true - }, - { - "Name": "sel", - "Description": "SMART error logging", - "Enabled": true - }, - { - "Name": "sst", - "Description": "SMART self test", - "Enabled": true - }, - { - "Name": "gplf", - "Description": "General Purpose Logging feature", - "Enabled": true - }, - { - "Name": "6bwwn", - "Description": "64 bit World wide name", - "Enabled": true - }, - { - "Name": "iiwu", - "Description": "IDLE IMMEDIATE with UNLOAD", - "Enabled": true - }, - { - "Name": "wrvf", - "Description": "Write Read Verify feature", - "Enabled": false - }, - { - "Name": "wue", - "Description": "WRITE UNCORRECTABLE EXT", - "Enabled": true - }, - { - "Name": "rdegs", - "Description": "READWRITE DMA EXT GPL s", - "Enabled": true - }, - { - "Name": "sdm", - "Description": "Segmented DOWNLOAD MICROCODE", - "Enabled": true - }, - { - "Name": "u1", - "Description": "unknown 119[6]", - "Enabled": true - }, - { - "Name": "u1", - "Description": "unknown 119[8]", - "Enabled": false - }, - { - "Name": "gss1", - "Description": "Gen1 signaling speed 1.5Gb/s", - "Enabled": true - }, - { - "Name": "gss3", - "Description": "Gen2 signaling speed 3.0Gb/s", - "Enabled": true - }, - { - "Name": "gss6", - "Description": "Gen3 signaling speed 6.0Gb/s", - "Enabled": true - }, - { - "Name": "ncqn", - "Description": "Native Command Queueing NCQ", - "Enabled": true - }, - { - "Name": "pec", - "Description": "Phy event counters", - "Enabled": true - }, - { - "Name": "npi", - "Description": "NCQ priority information", - "Enabled": true - }, - { - "Name": "rldeetrle", - "Description": "READ LOG DMA EXT equivalent to READ LOG EXT", - "Enabled": true - }, - { - "Name": "dsaao", - "Description": "DMA Setup Auto Activate optimization", - "Enabled": true - }, - { - "Name": "stp", - "Description": "Software tings preservation", - "Enabled": true - }, - { - "Name": "sctsf", - "Description": "SMART Command Transport SCT feature", - "Enabled": true - }, - { - "Name": "swsa", - "Description": "SCT Write Same AC2", - "Enabled": true - }, - { - "Name": "serca", - "Description": "SCT Error Recovery Control AC3", - "Enabled": true - }, - { - "Name": "sfca", - "Description": "SCT Features Control AC4", - "Enabled": true - }, - { - "Name": "sdta", - "Description": "SCT Data Tables AC5", - "Enabled": true - }, - { - "Name": "sale", - "Description": "SANITIZE ANTIFREEZE LOCK EXT", - "Enabled": true - }, - { - "Name": "sf", - "Description": "SANITIZE feature", - "Enabled": true - }, - { - "Name": "cse", - "Description": "CRYPTO SCRAMBLE EXT", - "Enabled": true - }, - { - "Name": "bee", - "Description": "BLOCK ERASE EXT", - "Enabled": true - }, - { - "Name": "dmd", - "Description": "DOWNLOAD MICROCODE DMA", - "Enabled": true - }, - { - "Name": "wbd", - "Description": "WRITE BUFFER DMA", - "Enabled": true - }, - { - "Name": "rbd", - "Description": "READ BUFFER DMA", - "Enabled": true - }, - { - "Name": "dsmtsl8b", - "Description": "Data Set Management TRIM supported limit 8 blocks", - "Enabled": true - }, - { - "Name": "drzat", - "Description": "Deterministic read ZEROs after TRIM", - "Enabled": true - } - ], - "firmware": { - "installed": "D3DJ004" - }, - "oem_id": "DELL(tm)", - "drive_type": "Sata-SSD", - "bus_info": "scsi@1:0.0.0", - "protocol": "sata", - "smart_status": "ok", - "capacity_bytes": 240057409536 - } - ], - "storage_controller": [ - { - "oem": false, - "description": "SATA controller", - "vendor": "Marvell Technology Group Ltd.", - "model": "88SE9230 PCIe 2.0 x2 4-port SATA 6 Gb/s RAID Controller", - "serial": "1B4B:9230", - "product_name": "88SE9230 PCIe 2.0 x2 4-port SATA 6 Gb/s RAID Controller", - "pci_vendor_id": "1B4B", - "pci_product_id": "9230", - "supported_device_protocol": "SATA", - "physid": "0", - "bus_info": "pci@0000:c3:00.0" - } - ] - } diff --git a/fixtures/supermicro/x11dph-t.go b/fixtures/supermicro/x11dph-t.go index b6c6eaabd..065b3847d 100644 --- a/fixtures/supermicro/x11dph-t.go +++ b/fixtures/supermicro/x11dph-t.go @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", @@ -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: "", diff --git a/model/component.go b/model/component.go index 1cb1d5b0c..1ef5de688 100644 --- a/model/component.go +++ b/model/component.go @@ -14,30 +14,3 @@ type Component struct { Oem bool `json:"oem"` // Component is an OEM component FirmwareManaged bool `json:"firmware_managed"` // Firmware on the component is managed/unmanaged } - -// UpdateOptions sets firmware update options for a device component -type UpdateOptions struct { - AllowDowngrade bool // Allow firmware to be downgraded - InstallAll bool // Install all available updates (vendor tooling like DSU fetches the updates and installs them) - DownloadOnly bool // Only download updates, skip install - Works with InstallAll (where updates are fetched by the vendor tooling) - Serial string - Vendor string - Model string - Name string - Slug string - UpdateFile string // Location of the UpdateFile to be installed - InstallerVersion string // The all available updates installer version (specific to dell DSU) - RepositoryVersion string // The update repository version to activate when defined - BaseURL string // The BaseURL for the updates -} - -type CreateVirtualDiskOptions struct { - RaidMode string - PhysicalDiskIDs []uint - Name string - BlockSize uint -} - -type DestroyVirtualDiskOptions struct { - VirtualDiskID int -} diff --git a/model/device.go b/model/hardware.go similarity index 100% rename from model/device.go rename to model/hardware.go diff --git a/model/raid.go b/model/raid.go new file mode 100644 index 000000000..da5053385 --- /dev/null +++ b/model/raid.go @@ -0,0 +1,12 @@ +package model + +type CreateVirtualDiskOptions struct { + RaidMode string + PhysicalDiskIDs []uint + Name string + BlockSize uint +} + +type DestroyVirtualDiskOptions struct { + VirtualDiskID int +} diff --git a/model/consts.go b/model/stuff.go similarity index 100% rename from model/consts.go rename to model/stuff.go diff --git a/model/update.go b/model/update.go new file mode 100644 index 000000000..84860e1ca --- /dev/null +++ b/model/update.go @@ -0,0 +1,17 @@ +package model + +// UpdateOptions sets firmware update options for a device component +type UpdateOptions struct { + AllowDowngrade bool // Allow firmware to be downgraded + InstallAll bool // Install all available updates (vendor tooling like DSU fetches the updates and installs them) + DownloadOnly bool // Only download updates, skip install - Works with InstallAll (where updates are fetched by the vendor tooling) + Serial string + Vendor string + Model string + Name string + Slug string + UpdateFile string // Location of the UpdateFile to be installed + InstallerVersion string // The all available updates installer version (specific to dell DSU) + RepositoryVersion string // The update repository version to activate when defined + BaseURL string // The BaseURL for the updates +} diff --git a/utils/hdparm.go b/utils/hdparm.go index 99a9fd542..4e837d9e9 100644 --- a/utils/hdparm.go +++ b/utils/hdparm.go @@ -71,13 +71,8 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* return nil, err } - var capabilities []*common.Capability - var lines []string - - s := string(out) - - scanner := bufio.NewScanner(strings.NewReader(s)) + scanner := bufio.NewScanner(strings.NewReader(string(out))) for scanner.Scan() { lines = append(lines, scanner.Text()) } @@ -87,6 +82,10 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* return nil, err } + // TODO break up into features and security specific blocks/parsers + // use regex to grab features block and parse + // use regex to grab security block and parse + // Delimiters featStart := "Enabled" secStart := "Security:" @@ -98,18 +97,16 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* ",", "", "|", "", "set", "", "command", "") var featBool, secBool bool - + var capabilities []*common.Capability for _, line := range lines { line = strings.TrimSpace(line) parts := strings.Fields(line) - var flag string - // start/end match specific block delimiters // bools are toggled to indicate lines within a given block switch { case strings.Contains(line, featStart): - featBool = true + featBool, secBool = true, false case strings.Contains(line, secStart): featBool, secBool = false, true case strings.Contains(line, secEnd): @@ -117,6 +114,7 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* } // Parse command capabilities + var flag string if featBool && !strings.Contains(line, featStart) { if strings.Contains(line, "*") { line = strings.TrimSpace(strings.TrimPrefix(line, "*\t")) @@ -127,11 +125,11 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* flag += strings.ToLower(word[0:1]) } - capability := new(common.Capability) - capability.Name = flag - capability.Description = line - capability.Enabled = true - capabilities = append(capabilities, capability) + capabilities = append(capabilities, &common.Capability{ + Name: flag, + Description: line, + Enabled: true, + }) } else if !strings.Contains(line, "*") && !strings.Contains(line, featStart) { // Generate short flag identifier line = strings.TrimSpace(sfi.Replace(line)) @@ -139,52 +137,69 @@ func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]* flag += strings.ToLower(word[0:1]) } - capability := new(common.Capability) - capability.Name = flag - capability.Description = line - capability.Enabled = false - capabilities = append(capabilities, capability) + capabilities = append(capabilities, &common.Capability{ + Name: flag, + Description: line, + Enabled: false, + }) } } else if secBool { // Parse security capabilities secSupported := supported.MatchString(line) if !strings.Contains(line, secStart) { - capability := new(common.Capability) + var capability common.Capability switch { case strings.Contains(line, "65534"): - capability.Name, capability.Enabled = "pns", true - capability.Enabled = true - capability.Description = "password not set" + capability = common.Capability{ + Name: "pns", + Enabled: true, + Description: "password not set", + } case secSupported: - capability.Name = "es" - capability.Enabled = true - capability.Description = "encryption supported" + capability = common.Capability{ + Name: "es", + Enabled: true, + Description: "encryption supported", + } case strings.Contains(line, "not\tenabled"): - capability.Name = "ena" - capability.Enabled = true - capability.Description = "encryption not active" + capability = common.Capability{ + Name: "ena", + Enabled: true, + Description: "encryption not active", + } case strings.Contains(line, "not\tlocked"): - capability.Name = "dnl" - capability.Enabled = true - capability.Description = "device is not locked" + capability = common.Capability{ + Name: "dnl", + Enabled: true, + Description: "device is not locked", + } case strings.Contains(line, "not\tfrozen"): - capability.Name = "dnf" - capability.Enabled = true - capability.Description = "device is not frozen" + capability = common.Capability{ + Name: "dnf", + Enabled: true, + Description: "device is not frozen", + } case strings.Contains(line, "not\texpired"): - capability.Name = "ene" - capability.Enabled = true - capability.Description = "encryption not expired" + capability = common.Capability{ + Name: "ene", + Enabled: true, + Description: "encryption not expired", + } case strings.Contains(line, "supported: enhanced erase"): - capability.Name = "esee" - capability.Enabled = true - capability.Description = "encryption supports enhanced erase" + capability = common.Capability{ + Name: "esee", + Enabled: true, + Description: "encryption supports enhanced erase", + } case strings.Contains(line, "SECURITY ERASE UNIT"): seTime, sehTime := seu.Replace(parts[0]), seu.Replace(parts[5]) - capability.Name = "time" + seTime + ":" + sehTime - capability.Description = "erase time: " + seTime + "m, " + sehTime + "m (enhanced)" + capability = common.Capability{ + Name: "time" + seTime + ":" + sehTime, + Description: "erase time: " + seTime + "m, " + sehTime + "m (enhanced)", + Enabled: false, + } } - capabilities = append(capabilities, capability) + capabilities = append(capabilities, &capability) } } } diff --git a/utils/nvme.go b/utils/nvme.go index 245de520f..4e94c6425 100644 --- a/utils/nvme.go +++ b/utils/nvme.go @@ -74,8 +74,6 @@ func (n *Nvme) Attributes() (utilName model.CollectorUtility, absolutePath strin // Executes nvme list, parses the output and returns a slice of *common.Drive func (n *Nvme) Drives(ctx context.Context) ([]*common.Drive, error) { - drives := make([]*common.Drive, 0) - out, err := n.list(ctx) if err != nil { return nil, err @@ -88,7 +86,8 @@ func (n *Nvme) Drives(ctx context.Context) ([]*common.Drive, error) { return nil, err } - for _, d := range list.Devices { + drives := make([]*common.Drive, len(list.Devices)) + for i, d := range list.Devices { dModel := d.ModelNumber var vendor string @@ -98,19 +97,6 @@ func (n *Nvme) Drives(ctx context.Context) ([]*common.Drive, error) { if len(modelTokens) > 1 { vendor = modelTokens[1] } - drive := &common.Drive{ - Common: common.Common{ - Serial: d.SerialNumber, - Vendor: vendor, - Model: dModel, - ProductName: d.ProductName, - Description: d.ModelNumber, - Firmware: &common.Firmware{ - Installed: d.Firmware, - }, - Metadata: map[string]string{}, - }, - } // Collect drive capabilitiesFound capabilitiesFound, err := n.DriveCapabilities(ctx, d.DevicePath) @@ -118,11 +104,24 @@ func (n *Nvme) Drives(ctx context.Context) ([]*common.Drive, error) { return nil, err } + metadata := map[string]string{} for _, f := range capabilitiesFound { - drive.Common.Metadata[f.Description] = strconv.FormatBool(f.Enabled) + metadata[f.Description] = strconv.FormatBool(f.Enabled) } - drives = append(drives, drive) + drives[i] = &common.Drive{ + Common: common.Common{ + LogicalName: d.DevicePath, + Serial: d.SerialNumber, + Vendor: vendor, + Model: dModel, + ProductName: d.ProductName, + Description: d.ModelNumber, + Firmware: &common.Firmware{Installed: d.Firmware}, + Capabilities: capabilitiesFound, + Metadata: metadata, + }, + } } return drives, nil diff --git a/utils/nvme_test.go b/utils/nvme_test.go index 88453409b..a9f3f178a 100644 --- a/utils/nvme_test.go +++ b/utils/nvme_test.go @@ -14,9 +14,19 @@ import ( ) func Test_NvmeComponents(t *testing.T) { + // nolint:dupl expected := []*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", + Capabilities: []*common.Capability{ + {Name: "fmns", Description: "Format Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cens", Description: "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cese", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true}, + {Name: "cer", Description: "Crypto Erase Sanitize Operation Supported", Enabled: false}, + {Name: "ber", Description: "Block Erase Sanitize Operation Supported", Enabled: false}, + {Name: "owr", Description: "Overwrite Sanitize Operation Supported", Enabled: false}, + {Name: "ndi", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", Enabled: false}, + }, Metadata: map[string]string{ "Block Erase Sanitize Operation Supported": "false", "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false", @@ -28,7 +38,16 @@ func Test_NvmeComponents(t *testing.T) { }, }}, {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", + Capabilities: []*common.Capability{ + {Name: "fmns", Description: "Format Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cens", Description: "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cese", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true}, + {Name: "cer", Description: "Crypto Erase Sanitize Operation Supported", Enabled: false}, + {Name: "ber", Description: "Block Erase Sanitize Operation Supported", Enabled: false}, + {Name: "owr", Description: "Overwrite Sanitize Operation Supported", Enabled: false}, + {Name: "ndi", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", Enabled: false}, + }, Metadata: map[string]string{ "Block Erase Sanitize Operation Supported": "false", "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false", diff --git a/utils/smartctl.go b/utils/smartctl.go index a9fee1c28..4c6884664 100644 --- a/utils/smartctl.go +++ b/utils/smartctl.go @@ -1,6 +1,7 @@ package utils import ( + "cmp" "context" "encoding/json" "fmt" @@ -101,7 +102,11 @@ func (s *Smartctl) Drives(ctx context.Context) ([]*common.Drive, error) { item := &common.Drive{ Common: common.Common{ - Vendor: common.VendorFromString(smartctlAll.ModelName), + LogicalName: drive.Name, + Vendor: cmp.Or( + common.VendorFromString(smartctlAll.ModelName), + common.VendorFromString(smartctlAll.ModelFamily), + ), Model: smartctlAll.ModelName, Serial: smartctlAll.SerialNumber, ProductName: smartctlAll.ModelName, diff --git a/utils/smartctl_test.go b/utils/smartctl_test.go index a72da2b83..914a61f5d 100644 --- a/utils/smartctl_test.go +++ b/utils/smartctl_test.go @@ -61,11 +61,11 @@ func Test_SmartctlAllNVME(t *testing.T) { func Test_SmartctlDeviceAttributes(t *testing.T) { expected := []*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}, - {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}, - {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}, - {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}, - {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}, + {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}, + {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}, + {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}, + {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}, + {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()