blob: 3f4d23efc0dd14f3ae9228aed5d68d0005b11e4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package main
import (
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
// someone sent machine 'u' is it new?
// if not, update the record of it
func updateMachine(u *zoopb.Machine) string {
if u == nil {
return "nil"
}
m := me.machines.FindByName(u.Hostname)
if m == nil {
log.Info("adding new machine", u.Hostname)
me.machines.Append(u)
return "new"
}
// log.Info("updating machine", m.Hostname)
// did the # of cpus change?
if m.Cpus != u.Cpus {
m.Cpus = u.Cpus
log.Info("cpus changed to", m.Cpus)
}
// did the memory change?
if m.Memory != u.Memory {
m.Memory = u.Memory
log.Info("memory changed to", m.Memory)
}
// init these if nil
if m.Packages == nil {
m.Packages = new(zoopb.Packages)
}
if u.Packages == nil {
u.Packages = new(zoopb.Packages)
}
updatePackages(m.Packages, u.Packages)
return "upgrade"
}
// looks to see if any packages:
// changed versions
// were newly installed
// were uninstalled
func updatePackages(p *zoopb.Packages, u *zoopb.Packages) bool {
var changed bool = false
return changed
}
|