Node-status displays drivers

This PR adds the drivers that are enabled to the output of `nomad
node-status`
This commit is contained in:
Alex Dadgar 2017-02-22 18:54:28 -08:00
parent 537d07c912
commit 3d353ffbcd
1 changed files with 21 additions and 0 deletions

View File

@ -284,6 +284,26 @@ func (c *NodeStatusCommand) Run(args []string) int {
return c.formatNode(client, node)
}
func nodeDrivers(n *api.Node) []string {
var drivers []string
for k, v := range n.Attributes {
// driver.docker = 1
parts := strings.Split(k, ".")
if len(parts) != 2 {
continue
} else if parts[0] != "driver" {
continue
} else if v != "1" {
continue
}
drivers = append(drivers, parts[1])
}
sort.Strings(drivers)
return drivers
}
func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
// Format the header output
basic := []string{
@ -293,6 +313,7 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
fmt.Sprintf("DC|%s", node.Datacenter),
fmt.Sprintf("Drain|%v", node.Drain),
fmt.Sprintf("Status|%s", node.Status),
fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ",")),
}
if c.short {