Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show overview broken out by interface capacities #548

Merged
merged 2 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/collins/util/LshwRepresentation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ case class LshwRepresentation(
}

def nicCount: Int = nics.size
def hasGbNic: Boolean = nics.find { _.speed.inGigabits == 1 }.map { _ => true }.getOrElse(false)
def has10GbNic: Boolean = nics.find { _.speed.inGigabits == 10 }.map { _ => true }.getOrElse(false)
def nicsBySpeedGb = nics.groupBy { _.speed.inGigabits }

def macAddresses: Seq[String] = nics.map { _.macAddress }

def toJsValue() = Json.toJson(this)

// TODO(gabe): this method only performs squinty eye comparison. it will
// falsely report 2 lshw as equal if they have the same number of 1g nics
// but different mac addresses. FIXME
override def equals(that: Any) = that match {
case other: LshwRepresentation =>
(macAddresses.sorted == other.macAddresses.sorted) &&
Expand All @@ -114,9 +117,7 @@ case class LshwRepresentation(
(hasFlashStorage == other.hasFlashStorage) &&
(totalFlashStorage.inBytes == other.totalFlashStorage.inBytes) &&
(totalUsableStorage.inBytes == other.totalUsableStorage.inBytes) &&
(nicCount == other.nicCount) &&
(hasGbNic == other.hasGbNic) &&
(has10GbNic == other.has10GbNic)
(nicCount == other.nicCount)
case _ => false
}
}
9 changes: 5 additions & 4 deletions app/views/asset/show_overview.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ <h3>Hardware Summary <small>Summary of system components reported by LSHW</small
</tr>
<tr>
<td></td>
<td>Interfaces</td>
<td>Total Interfaces</td>
<td>@aa.lshw.nicCount</td>
</tr>
@aa.lshw.nicsBySpeedGb.map { case(speedGb,nics) =>
<tr>
<td></td>
<td>Has 10Gb Interface</td>
<td>@{if (aa.lshw.has10GbNic) "Yes" else "No"}</td>
<td>@{speedGb}G Interfaces</td>
<td>@{nics.size}</td>
</tr>

}
<tr>
<th colspan="3">Power</th>
</tr>
Expand Down
61 changes: 31 additions & 30 deletions test/collins/util/parsers/LshwParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class LshwParserSpec extends mutable.Specification {
rep.diskCount mustEqual 6

rep.nicCount mustEqual 3
rep.hasGbNic must beTrue
rep.has10GbNic must beTrue
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb(10).size mustEqual 1
rep.macAddresses must have length 3
rep.macAddresses must beNonEmptyStringSeq

Expand All @@ -59,8 +59,8 @@ class LshwParserSpec extends mutable.Specification {
parseResults must beRight
parseResults.right.toOption must beSome.which { rep =>
rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beTrue
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb(10).size mustEqual 2
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq

Expand Down Expand Up @@ -91,8 +91,8 @@ class LshwParserSpec extends mutable.Specification {
rep.totalUsableStorage.toHuman mustEqual "5.46 TB"

rep.nicCount mustEqual 2
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 2
rep.macAddresses must beNonEmptyStringSeq
}
Expand Down Expand Up @@ -120,8 +120,8 @@ class LshwParserSpec extends mutable.Specification {
rep.totalUsableStorage.toHuman mustEqual "931.52 GB"

rep.nicCount mustEqual 6
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 6
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 6
rep.macAddresses must beNonEmptyStringSeq
}
Expand Down Expand Up @@ -149,8 +149,9 @@ class LshwParserSpec extends mutable.Specification {
rep.totalUsableStorage.toHuman mustEqual "931.52 GB"

rep.nicCount mustEqual 6
rep.hasGbNic must beTrue
rep.has10GbNic aka "has 10 gig card" must beTrue // picked up from default in config
rep.nicsBySpeedGb(1).size mustEqual 5
// collins should assume 10g capacity for the nic that isnt reporting it
rep.nicsBySpeedGb(10).size mustEqual 1
rep.macAddresses must have length 6
rep.macAddresses must beNonEmptyStringSeq
}
Expand Down Expand Up @@ -178,8 +179,8 @@ class LshwParserSpec extends mutable.Specification {
rep.diskCount mustEqual 4

rep.nicCount mustEqual 2
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 2
rep.macAddresses must beNonEmptyStringSeq
}
Expand All @@ -206,8 +207,8 @@ class LshwParserSpec extends mutable.Specification {
rep.diskCount mustEqual 3

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq

Expand All @@ -234,8 +235,8 @@ class LshwParserSpec extends mutable.Specification {
rep.diskCount mustEqual 2

rep.nicCount mustEqual 6
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 6
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 6
rep.macAddresses must beNonEmptyStringSeq
}
Expand All @@ -259,8 +260,8 @@ class LshwParserSpec extends mutable.Specification {
rep.diskCount mustEqual 3

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq
}
Expand All @@ -287,8 +288,8 @@ class LshwParserSpec extends mutable.Specification {
rep.hasCdRom must beFalse

rep.nicCount mustEqual 2
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 2
rep.macAddresses must beNonEmptyStringSeq

Expand Down Expand Up @@ -349,8 +350,8 @@ class LshwParserSpec extends mutable.Specification {
rep.hasCdRom must beTrue

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq
}
Expand All @@ -377,8 +378,8 @@ class LshwParserSpec extends mutable.Specification {
rep.hasCdRom must beTrue

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq
}
Expand Down Expand Up @@ -415,8 +416,8 @@ class LshwParserSpec extends mutable.Specification {
rep.memoryBanksTotal mustEqual 24

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq

Expand Down Expand Up @@ -446,8 +447,8 @@ class LshwParserSpec extends mutable.Specification {
rep.totalUsableStorage.toHuman mustEqual "381.94 GB"

rep.nicCount mustEqual 4
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 4
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 4
rep.macAddresses must beNonEmptyStringSeq
}
Expand All @@ -470,8 +471,8 @@ class LshwParserSpec extends mutable.Specification {
rep.memoryBanksTotal mustEqual 12

rep.nicCount mustEqual 2
rep.hasGbNic must beTrue
rep.has10GbNic must beFalse
rep.nicsBySpeedGb(1).size mustEqual 2
rep.nicsBySpeedGb get 10 must beNone
rep.macAddresses must have length 2
rep.macAddresses must beNonEmptyStringSeq

Expand Down