2015-04-07 06:19:31 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-04-22 04:40:18 +00:00
|
|
|
"github.com/dballard/warren/cmd/warrend/conf"
|
2015-04-07 06:19:31 +00:00
|
|
|
"github.com/dballard/warren/lib/warren"
|
2015-04-20 04:03:54 +00:00
|
|
|
"bufio"
|
2015-04-22 04:40:18 +00:00
|
|
|
"strconv"
|
2015-04-07 06:19:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var poolUsage = `
|
|
|
|
pool [NAME] [LOW HIGH]
|
|
|
|
`
|
|
|
|
|
|
|
|
var poolCmd = &SockCommand{
|
|
|
|
Command: warren.Command{
|
|
|
|
Name: "pool",
|
|
|
|
Usage: poolUsage,
|
|
|
|
Summary: "Get/Set port pool range for deployment",
|
|
|
|
},
|
|
|
|
Run: poolRun,
|
|
|
|
}
|
|
|
|
|
|
|
|
// pool [name] -- get
|
|
|
|
// pool [name] [low] [high] -- set
|
2015-04-20 04:03:54 +00:00
|
|
|
func poolRun(cmd *SockCommand, writer *bufio.Writer, path string, args ...string) {
|
2015-04-22 04:40:18 +00:00
|
|
|
if len(args) == 0 || args[0] == "" || (len(args) > 0 && args[0] == "help") {
|
2015-04-20 04:03:54 +00:00
|
|
|
writer.WriteString(cmd.Usage)
|
2015-04-07 06:19:31 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GET
|
|
|
|
if len(args) == 1 {
|
2015-04-22 04:40:18 +00:00
|
|
|
deployment := conf.GetConfFor(args[0])
|
|
|
|
writer.WriteString("Pool " + strconv.Itoa(deployment.Pool.Low) + " to " + strconv.Itoa(deployment.Pool.High))
|
2015-04-07 06:19:31 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(args) == 3 {
|
2015-04-20 04:03:54 +00:00
|
|
|
writer.WriteString("Pool SET\n")
|
2015-04-07 06:19:31 +00:00
|
|
|
return
|
|
|
|
}
|
2015-04-20 04:03:54 +00:00
|
|
|
writer.WriteString(cmd.Usage)
|
2015-04-07 06:19:31 +00:00
|
|
|
return
|
|
|
|
}
|