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

Fix ipmi pool api #554

Merged
merged 2 commits into from Jun 8, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/collins/controllers/actions/ipmi/GetPoolsAction.scala
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
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
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