diff --git a/fixtures/asrr/e3c246d4i-nl.go b/fixtures/asrr/e3c246d4i-nl.go index 02611999..d9bdba8c 100644 --- a/fixtures/asrr/e3c246d4i-nl.go +++ b/fixtures/asrr/e3c246d4i-nl.go @@ -187,6 +187,7 @@ var E3C246D4INL = &common.Device{ Model: "INTEL SSDSC2KB48", Serial: "PHYF001300HB480BGN", ProductName: "INTEL SSDSC2KB48", + LogicalName: "/dev/sda", Firmware: nil, Status: nil, }, @@ -212,6 +213,7 @@ var E3C246D4INL = &common.Device{ Model: "INTEL SSDSC2KB48", Serial: "PHYF001209KL480BGN", ProductName: "INTEL SSDSC2KB48", + LogicalName: "/dev/sdb", Firmware: nil, Status: nil, }, diff --git a/fixtures/dell/r6515.go b/fixtures/dell/r6515.go index ef786c43..daa51b99 100644 --- a/fixtures/dell/r6515.go +++ b/fixtures/dell/r6515.go @@ -683,6 +683,7 @@ var ( Model: "Micron_9300_MTFDHAL3T8TDP", Serial: "202728F691F5", ProductName: "Micron_9300_MTFDHAL3T8TDP", + LogicalName: "/dev/nvme0", Firmware: nil, Status: nil, }, @@ -708,6 +709,7 @@ var ( Model: "Micron_9300_MTFDHAL3T8TDP", Serial: "202728F691C6", ProductName: "Micron_9300_MTFDHAL3T8TDP", + LogicalName: "/dev/nvme1", Firmware: nil, Status: nil, }, @@ -733,6 +735,7 @@ var ( Model: "MTFDDAV240TDU", Serial: "203329F89392", ProductName: "MTFDDAV240TDU", + LogicalName: "/dev/sda", Firmware: nil, Status: nil, }, @@ -758,6 +761,7 @@ var ( Model: "MTFDDAV240TDU", Serial: "203329F89796", ProductName: "MTFDDAV240TDU", + LogicalName: "/dev/sdb", Firmware: nil, Status: nil, }, @@ -1305,6 +1309,7 @@ var ( Model: "Micron_9300_MTFDHAL3T8TDP", Serial: "202728F691F5", ProductName: "Micron_9300_MTFDHAL3T8TDP", + LogicalName: "/dev/nvme0", Firmware: &common.Firmware{ Installed: "11300DN0", Available: "", @@ -1335,6 +1340,7 @@ var ( Model: "Micron_9300_MTFDHAL3T8TDP", Serial: "202728F691C6", ProductName: "Micron_9300_MTFDHAL3T8TDP", + LogicalName: "/dev/nvme1", Firmware: &common.Firmware{ Installed: "11300DN0", Available: "", @@ -1365,6 +1371,7 @@ var ( Model: "MTFDDAV240TDU", Serial: "203329F89392", ProductName: "MTFDDAV240TDU", + LogicalName: "/dev/sda", Firmware: &common.Firmware{ Installed: "D3DJ004", Available: "", @@ -1395,6 +1402,7 @@ var ( Model: "MTFDDAV240TDU", Serial: "203329F89796", ProductName: "MTFDDAV240TDU", + LogicalName: "/dev/sdb", Firmware: &common.Firmware{ Installed: "D3DJ004", Available: "", diff --git a/fixtures/supermicro/x11dph-t.go b/fixtures/supermicro/x11dph-t.go index 2fe87e98..15e38ccb 100644 --- a/fixtures/supermicro/x11dph-t.go +++ b/fixtures/supermicro/x11dph-t.go @@ -713,6 +713,7 @@ var ( Model: "Micron_5200_MTFDDAK960TDN", Serial: "20032613EE70", ProductName: "Micron_5200_MTFD", + LogicalName: "/dev/sda", Firmware: &common.Firmware{ Installed: "D1MU020", Available: "", @@ -743,6 +744,7 @@ var ( Model: "Micron_5200_MTFDDAK960TDN", Serial: "20032613D813", ProductName: "Micron_5200_MTFD", + LogicalName: "/dev/sdb", Firmware: &common.Firmware{ Installed: "D1MU020", Available: "", @@ -773,6 +775,7 @@ var ( Model: "KXG60ZNV256G TOSHIBA", Serial: "Z9DF71TJFY3L", ProductName: "KXG60ZNV256G TOSHIBA", + LogicalName: "/dev/nvme0", Firmware: &common.Firmware{ Installed: "AGGA4104", Available: "", @@ -803,6 +806,7 @@ var ( Model: "KXG60ZNV256G TOSHIBA", Serial: "Z9DF71YGFY3L", ProductName: "KXG60ZNV256G TOSHIBA", + LogicalName: "/dev/nvme1", Firmware: &common.Firmware{ Installed: "AGGA4104", Available: "", @@ -833,6 +837,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJL8MVK", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdk", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -863,6 +868,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJHR67K", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdl", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -893,6 +899,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJJ51YK", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdm", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -923,6 +930,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJLNERD", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdn", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -953,6 +961,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJKG9LK", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdc", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -983,6 +992,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJBVPXD", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdd", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1013,6 +1023,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJJ7T3K", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sde", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1043,6 +1054,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJL8U5K", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdf", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1073,6 +1085,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJBP7SD", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdg", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1103,6 +1116,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJKVBKK", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdh", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1133,6 +1147,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJK7E2K", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdi", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", @@ -1163,6 +1178,7 @@ var ( Model: "HGST HUS728T8TALE6L4", Serial: "VDJL2NUK", ProductName: "HGST HUS728T8TAL", + LogicalName: "/dev/sdj", Firmware: &common.Firmware{ Installed: "V8GNW460", Available: "", diff --git a/go.mod b/go.mod index a3b28735..89844106 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module github.com/metal-toolbox/ironlib -go 1.17 +go 1.18 require ( github.com/beevik/etree v1.1.0 - github.com/bmc-toolbox/common v0.0.0-20220808122349-335517678873 + github.com/bmc-toolbox/common v0.0.0-20221018131042-912666fb3ebc github.com/dselans/dmidecode v0.0.0-20180814053009-65c3f9d81910 github.com/pkg/errors v0.9.1 github.com/r3labs/diff/v2 v2.15.1 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.0 github.com/tidwall/gjson v1.14.3 - golang.org/x/net v0.0.0-20221002022538-bcab6841153b + golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193 gotest.tools v2.2.0+incompatible ) @@ -19,14 +19,16 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/kr/pretty v0.3.0 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/stretchr/objx v0.4.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/sys v0.1.0 // indirect + golang.org/x/text v0.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index f6d66a07..a5946456 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= -github.com/bmc-toolbox/common v0.0.0-20220808122349-335517678873 h1:aHFMwerTuTpn38Q5LlqkP53RC4V6VYUL7nLa6E3EUT4= -github.com/bmc-toolbox/common v0.0.0-20220808122349-335517678873/go.mod h1:SY//n1PJjZfbFbmAsB6GvEKbc7UXz3d30s3kWxfJQ/c= +github.com/bmc-toolbox/common v0.0.0-20221018131042-912666fb3ebc h1:NBo6wB5N203iEyfJeiRTU/UjEocsoUFUc6KQHeiaLxo= +github.com/bmc-toolbox/common v0.0.0-20221018131042-912666fb3ebc/go.mod h1:SY//n1PJjZfbFbmAsB6GvEKbc7UXz3d30s3kWxfJQ/c= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -15,10 +15,9 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -30,12 +29,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/r3labs/diff/v2 v2.15.1 h1:EOrVqPUzi+njlumoqJwiS/TgGgmZo83619FNDB9xQUg= github.com/r3labs/diff/v2 v2.15.1/go.mod h1:I8noH9Fc2fjSaMxqF3G2lhDdC0b+JXCfyx85tWFM9kc= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -53,19 +52,16 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaU github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20221002022538-bcab6841153b h1:6e93nYa3hNqAvLr0pD4PN1fFS+gKzp2zAXqrnTCstqU= -golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193 h1:3Moaxt4TfzNcQH6DWvlYKraN1ozhBXQHcgvXjRGeim0= +golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193/go.mod h1:RpDiru2p0u2F0lLpEoqnP2+7xs0ifAuOcJ442g6GU2s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= @@ -76,10 +72,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/utils/lshw.go b/utils/lshw.go index 27f1af64..59fdb37b 100644 --- a/utils/lshw.go +++ b/utils/lshw.go @@ -48,6 +48,7 @@ type LshwNode struct { Vendor string `json:"vendor,omitempty"` Physid string `json:"physid,omitempty"` Businfo string `json:"businfo,omitempty"` + LogicalName interface{} `json:"logicalname,omitempty"` Dev string `json:"dev,omitempty"` Slot string `json:"slot,omitempty"` Units string `json:"units,omitempty"` @@ -467,6 +468,13 @@ func (l *Lshw) xDrive(node *LshwNode) *common.Drive { CapacityBytes: int64(node.Size), } + // type assert LogicalName since it can also be an array - in which case we + // do not care about the data. + logicalName, isString := node.LogicalName.(string) + if isString { + drive.LogicalName = logicalName + } + if drive.Vendor == "" { drive.Vendor = common.VendorFromString(node.Product) }