Skip to content

Commit

Permalink
Merge pull request #565 from defect/nvme_lshw
Browse files Browse the repository at this point in the history
Add support for NVMe disks in LSHW
  • Loading branch information
defect authored Aug 30, 2017
2 parents a849584 + 5c5cb86 commit f964b6c
Show file tree
Hide file tree
Showing 5 changed files with 1,338 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/collins/util/parsers/LshwParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class LshwParser(txt: String) extends CommonParser[LshwRepresentation](txt) {
case size => ByteStorageUnit(size.toLong)
}
Disk(size, _type, asset.description, asset.product, asset.vendor)
case n if (n \ "@class" text) == "memory" && LshwConfig.flashProducts.exists(s => (n \ "product" text).toLowerCase.contains(s)) =>
case n if ((n \ "@class" text) == "memory" || (n \ "@class" text) == "storage") && LshwConfig.flashProducts.exists(s => (n \ "product" text).toLowerCase.contains(s)) =>
val asset = getAsset(n)
val size = ByteStorageUnit(LshwConfig.flashSize)
Disk(size, Disk.Type.Flash, asset.description, asset.product, asset.vendor)
Expand Down
7 changes: 7 additions & 0 deletions app/views/asset/show_overview.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ <h3>Hardware Summary <small>Summary of system components reported by LSHW</small
<td>SCSI Storage</td>
<td>@aa.lshw.totalStorage.toHuman</td>
</tr>
@if(aa.lshw.hasFlashStorage) {
<tr>
<td></td>
<td>Flash Storage</td>
<td>@(aa.lshw.totalFlashStorage.toHuman)</td>
</tr>
}
<tr>
<td></td>
<td>Total Storage</td>
Expand Down
2 changes: 1 addition & 1 deletion conf/test_base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ ipmi {
}

lshw {
flashProducts = ["fusionio", "tachION", "flashmax"]
flashProducts = ["fusionio", "tachION", "flashmax", "hgst, inc."]
flashSize="1400000000000"

# For assets whose NIC capacity cannot be determined
Expand Down
29 changes: 29 additions & 0 deletions test/collins/util/parsers/LshwParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,35 @@ class LshwParserSpec extends mutable.Specification {
}
}

"with a nvme flash card" in new LshwParserHelper("lshw-nvme.xml") {
val parseResults = parsed()
parseResults must beRight
parseResults.right.toOption must beSome.which { rep =>
rep.cpuCount mustEqual 2
rep.cpuCoreCount mustEqual 12
rep.hasHyperthreadingEnabled must beFalse
rep.cpuSpeed must beCloseTo(2.3, 0.1)

rep.totalMemory.inGigabytes must beCloseTo(32L, 1)
rep.memoryBanksUsed mustEqual 4
rep.memoryBanksUnused mustEqual 8
rep.memoryBanksTotal mustEqual 12

rep.hasFlashStorage must beTrue
rep.totalFlashStorage.toHuman mustEqual "1.27 TB"
rep.totalUsableStorage.toHuman mustEqual "1.55 TB"

rep.totalStorage.toHuman mustEqual "278.46 GB"
rep.diskCount mustEqual 4

rep.nicCount mustEqual 2
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 2
rep.macAddresses must beNonEmptyStringSeq
}
}

} // Parse dell (AMD) lshw output

"Parse different versioned formats" in {
Expand Down
Loading

0 comments on commit f964b6c

Please sign in to comment.