warren/cmd/warrend/cmd_pool.go

44 lines
914 B
Go
Raw Permalink Normal View History

package main
import (
2015-04-22 04:40:18 +00:00
"github.com/dballard/warren/cmd/warrend/conf"
"github.com/dballard/warren/lib/warren"
"bufio"
2015-04-22 04:40:18 +00:00
"strconv"
)
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
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") {
writer.WriteString(cmd.Usage)
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))
return
}
if len(args) == 3 {
writer.WriteString("Pool SET\n")
return
}
writer.WriteString(cmd.Usage)
return
}