Merge pull request #6 from hashicorp/cpu-resources

populate CPU in Node Resources
This commit is contained in:
Clint
2015-08-27 15:26:00 -05:00
2 changed files with 12 additions and 1 deletions

View File

@@ -52,7 +52,14 @@ func (f *CPUFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (bo
}
if mhz > 0 && numCores > 0 {
node.Attributes["cpu.totalcompute"] = fmt.Sprintf("%.6f", float64(numCores)*mhz)
tc := float64(numCores) * mhz
node.Attributes["cpu.totalcompute"] = fmt.Sprintf("%.6f", tc)
if node.Resources == nil {
node.Resources = &structs.Resources{}
}
node.Resources.CPU = tc
}
if modelName != "" {

View File

@@ -35,4 +35,8 @@ func TestCPUFingerprint(t *testing.T) {
t.Fatalf("Missing CPU Total Compute")
}
if node.Resources == nil {
t.Fatalf("Expected resources on node, but got nil")
}
}