Merge pull request #4978 from hashicorp/f-device-tweaks

Display device attributes in `nomad node status -verbose`
This commit is contained in:
Mahmood Ali
2018-12-12 19:45:07 -05:00
committed by GitHub
9 changed files with 266 additions and 87 deletions

View File

@@ -418,6 +418,7 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
if c.verbose {
c.formatAttributes(node)
c.formatDeviceAttributes(node)
c.formatMeta(node)
}
return 0
@@ -528,6 +529,32 @@ func (c *NodeStatusCommand) formatAttributes(node *api.Node) {
c.Ui.Output(formatKV(attributes))
}
func (c *NodeStatusCommand) formatDeviceAttributes(node *api.Node) {
devices := node.NodeResources.Devices
if len(devices) == 0 {
return
}
sort.Slice(devices, func(i, j int) bool {
return devices[i].ID() < devices[j].ID()
})
first := true
for _, d := range devices {
if len(d.Attributes) == 0 {
continue
}
if first {
c.Ui.Output("\nDevice Group Attributes")
first = false
} else {
c.Ui.Output("")
}
c.Ui.Output(formatKV(getDeviceAttributes(d)))
}
}
func (c *NodeStatusCommand) formatMeta(node *api.Node) {
// Print the meta
keys := make([]string, 0, len(node.Meta))