Add Node Labels to Cluster Info information

Updates: docker info output and /info API
Check for labels in API integration tests

Signed-off-by: Sriram Natarajan <natarajan.sriram@gmail.com>
This commit is contained in:
Sriram Natarajan 2015-04-17 16:13:36 -07:00
parent 051c1fa5a8
commit 9f29e95abc
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"sort" "sort"
"strings"
"sync" "sync"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
@ -310,6 +311,12 @@ func (c *Cluster) Info() [][2]string {
info = append(info, [2]string{" └ Containers", fmt.Sprintf("%d", len(engine.Containers()))}) info = append(info, [2]string{" └ Containers", fmt.Sprintf("%d", len(engine.Containers()))})
info = append(info, [2]string{" └ Reserved CPUs", fmt.Sprintf("%d / %d", engine.UsedCpus(), engine.TotalCpus())}) info = append(info, [2]string{" └ Reserved CPUs", fmt.Sprintf("%d / %d", engine.UsedCpus(), engine.TotalCpus())})
info = append(info, [2]string{" └ Reserved Memory", fmt.Sprintf("%s / %s", units.BytesSize(float64(engine.UsedMemory())), units.BytesSize(float64(engine.TotalMemory())))}) info = append(info, [2]string{" └ Reserved Memory", fmt.Sprintf("%s / %s", units.BytesSize(float64(engine.UsedMemory())), units.BytesSize(float64(engine.TotalMemory())))})
labels := make([]string, 0, len(engine.Labels))
for k, v := range engine.Labels {
labels = append(labels, k+"="+v)
}
sort.Strings(labels)
info = append(info, [2]string{" └ Labels", fmt.Sprintf("%s", strings.Join(labels, ", "))})
} }
return info return info

View File

@ -114,11 +114,12 @@ function teardown() {
} }
@test "docker info" { @test "docker info" {
start_docker 3 start_docker 1 --label foo=bar
swarm_manage swarm_manage
run docker_swarm info run docker_swarm info
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "${lines[3]}" == *"Nodes: 3" ]] [[ "${lines[3]}" == *"Nodes: 1" ]]
[[ "${output}" == *"└ Labels:"*"foo=bar"* ]]
} }
# FIXME # FIXME