Cluster: Implemented support to return a list of all containers

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-11-10 16:25:09 -08:00
parent 74c23faeeb
commit 4a7068d94a
1 changed files with 16 additions and 0 deletions

View File

@ -38,3 +38,19 @@ func (c *Cluster) AddNode(n *Node) error {
c.nodes[n.ID] = n
return nil
}
// Containers returns all the containers running in the cluster.
func (c *Cluster) Containers() []*Container {
c.mux.Lock()
defer c.mux.Unlock()
out := []*Container{}
for _, n := range c.nodes {
containers := n.Containers()
for _, container := range containers {
out = append(out, container)
}
}
return out
}