Node: Expose reserved memory and CPUs.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-11-17 13:31:17 -08:00
parent 004450a910
commit 6585d4cfb6
1 changed files with 18 additions and 0 deletions

18
node.go
View File

@ -161,6 +161,24 @@ func (n *Node) updateLoop() {
}
}
// Return the sum of memory reserved by containers.
func (n *Node) ReservedMemory() int64 {
var r int64 = 0
for _, c := range n.containers {
r += int64(c.Info.Config.Memory)
}
return r
}
// Return the sum of CPUs reserved by containers.
func (n *Node) ReservedCpus() float64 {
r := 0.0
for _, c := range n.containers {
r += float64(c.Info.Config.CpuShares) / 100.0 * float64(n.Cpus)
}
return r
}
func (n *Node) Create(config *dockerclient.ContainerConfig, name string, pullImage bool) (*Container, error) {
var (
err error