mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Merge pull request #4978 from hashicorp/f-device-tweaks
Display device attributes in `nomad node status -verbose`
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user