Skip to content

Commit

Permalink
Merge pull request #132 from byxorna/gabe-lshw-flash-detection
Browse files Browse the repository at this point in the history
allow multiple product strings to be matched for flash disk detection
  • Loading branch information
William Richard committed Mar 17, 2014
2 parents 43dfda1 + a827b6b commit 8565715
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/util/config/LshwConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ object LshwConfig extends Configurable {
override val referenceConfigFilename = "lshw_reference.conf"

def flashProduct = getString("flashProduct", "flashmax").toLowerCase
def flashProducts = Set(flashProduct) ++ getStringSet("flashProducts", Set[String]()).map(s => s.toLowerCase)
def flashSize = getLong("flashSize", 1400000000000L)
def includeDisabledCpu = getBoolean("includeDisabledCpu", false)
def includeEmptySocket = getBoolean("includeEmptySocket", false)
def defaultNicCapacity = getString("defaultNicCapacity")(ConfigValue.Optional)

override protected def validateConfig() {
flashProduct
flashProducts
flashSize
includeDisabledCpu
includeEmptySocket
Expand Down
2 changes: 1 addition & 1 deletion app/util/parsers/LshwParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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" && (n \ "product" text).toLowerCase.contains(LshwConfig.flashProduct) =>
case n if (n \ "@class" text) == "memory" && 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
2 changes: 1 addition & 1 deletion conf/dev_base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ipmi {
}

lshw {
flashProduct="flashmax"
flashProducts = ["fusionio", "tachION", "flashmax"]
flashSize="1400000000000"

# For assets whose NIC capacity cannot be determined
Expand Down

0 comments on commit 8565715

Please sign in to comment.