mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
Show node attribute in node-status
Adds node attributes to the node-status command when a single node ID is passed
This commit is contained in:
committed by
Abhishek Chanda
parent
fd3dccead2
commit
db2dd3b614
@@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -103,6 +104,20 @@ func (c *NodeStatusCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
m := node.Attributes
|
||||
keys := make([]string, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
var attributes []string
|
||||
for _, k := range keys {
|
||||
if k != "" {
|
||||
attributes = append(attributes, fmt.Sprintf("%s:%s", k, m[k]))
|
||||
}
|
||||
}
|
||||
|
||||
// Format the output
|
||||
basic := []string{
|
||||
fmt.Sprintf("ID|%s", node.ID),
|
||||
@@ -111,6 +126,7 @@ func (c *NodeStatusCommand) Run(args []string) int {
|
||||
fmt.Sprintf("Datacenter|%s", node.Datacenter),
|
||||
fmt.Sprintf("Drain|%v", node.Drain),
|
||||
fmt.Sprintf("Status|%s", node.Status),
|
||||
fmt.Sprintf("Attributes|%s", strings.Join(attributes, ", ")),
|
||||
}
|
||||
|
||||
var allocs []string
|
||||
|
||||
Reference in New Issue
Block a user