Skip to content

Commit

Permalink
Merge pull request #554 from michaeljs1990/fix-ipmi-pool-api
Browse files Browse the repository at this point in the history
Fix ipmi pool api
  • Loading branch information
byxorna committed Jun 8, 2017
2 parents 1ab8a94 + f149964 commit 978bc36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/collins/controllers/actions/ipmi/GetPoolsAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ case class GetPoolsAction(

override def validate(): Validation = {
var pools: Set[String] =
IpmiInfo.AddressConfig.filter(_.poolNames.isEmpty) match {
case Set => IpmiInfo.AddressConfig.map(_.poolNames).getOrElse(Set(""))
case _ => Set(IpmiInfo.AddressConfig.flatMap(_.defaultPoolName).getOrElse(""))
IpmiInfo.AddressConfig.map(_.poolNames) match {
case x if !x.isEmpty => x.getOrElse(Set())
case _ => Set(IpmiInfo.AddressConfig.flatMap(_.defaultPoolName).getOrElse(""))
}

Right(ActionDataHolder(pools))
Expand Down
5 changes: 5 additions & 0 deletions conf/test_base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ ipmi {
gateway="172.16.32.1"
startAddress="172.16.32.20"
}
OOB-POD02 {
network="172.99.32.0/20"
gateway="172.99.32.1"
startAddress="172.99.32.20"
}
}

# to use with multiple OOB allocations, instead of the inline
Expand Down
8 changes: 7 additions & 1 deletion test/collins/controllers/IpmiApiSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IpmiApiSpec extends mutable.Specification with ControllerSpec {
args(sequential = true)

"the REST API" should {
"Support getting ipmi pools" in new WithApplication with AssetApiHelper {
"Support getting multiple ipmi pools" in new WithApplication with AssetApiHelper {
override val assetTag = "tumblrtag42"
val getRequest = FakeRequest("GET", "/api/ipmi/pools")
val getResult = Extract.from(api.getIpmiAddressPools.apply(getRequest))
Expand All @@ -24,6 +24,12 @@ class IpmiApiSpec extends mutable.Specification with ControllerSpec {
s must /("data") */("POOLS") */ ("START_ADDRESS" -> "172.16.32.20")
s must /("data") */("POOLS") */ ("BROADCAST" -> "172.16.47.255")
s must /("data") */("POOLS") */ ("POSSIBLE_ADDRESSES" -> 4094)

s must /("data") */("POOLS") */ ("NAME" -> "OOB-POD02")
s must /("data") */("POOLS") */ ("GATEWAY" -> "172.99.32.1")
s must /("data") */("POOLS") */ ("START_ADDRESS" -> "172.99.32.20")
s must /("data") */("POOLS") */ ("BROADCAST" -> "172.99.47.255")
s must /("data") */("POOLS") */ ("POSSIBLE_ADDRESSES" -> 4094)
}
}
}
Expand Down

0 comments on commit 978bc36

Please sign in to comment.