save config file kinda works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0ad4ffd0c6
commit
4e0dc17202
3
Makefile
3
Makefile
|
@ -51,6 +51,9 @@ http-toogle-ZOOD:
|
||||||
http-list-machines:
|
http-list-machines:
|
||||||
curl --silent http://localhost:8080/list
|
curl --silent http://localhost:8080/list
|
||||||
|
|
||||||
|
http-ConfigSave:
|
||||||
|
curl --silent http://localhost:8080/save
|
||||||
|
|
||||||
http-set-zood-target:
|
http-set-zood-target:
|
||||||
curl --silent "http://localhost:8080/target?package=zood&version=v0.0.8"
|
curl --silent "http://localhost:8080/target?package=zood&version=v0.0.8"
|
||||||
|
|
||||||
|
|
15
http.go
15
http.go
|
@ -43,7 +43,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Info("error =", err)
|
log.Info("error =", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(ZOOD, "proto.Unmarshal() worked on wire message len", len(msg), "from", m.Hostname)
|
log.Log(INFO, "proto.Unmarshal() worked on wire message len", len(msg), "from", m.Hostname)
|
||||||
b := me.upgrade[m.Hostname]
|
b := me.upgrade[m.Hostname]
|
||||||
switch updateMachine(m) {
|
switch updateMachine(m) {
|
||||||
case "upgrade":
|
case "upgrade":
|
||||||
|
@ -90,7 +90,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if zood == nil {
|
if zood == nil {
|
||||||
log.Info("machine", m.Hostname, "does not have zood installed")
|
log.Info("machine", m.Hostname, "does not have zood installed")
|
||||||
} else {
|
} else {
|
||||||
log.Info("know about machine", m.Hostname, "zood version", zood.Version, "vs target version", v)
|
log.Info("zood version", zood.Version, "vs target version", v, "on machine", m.Hostname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -98,7 +98,16 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// save the config file
|
// save the config file
|
||||||
if route == "/save" {
|
if route == "/save" {
|
||||||
// me.machines.SaveConfig()
|
log.HttpMode(w)
|
||||||
|
defer log.HttpMode(nil)
|
||||||
|
data, err := me.machines.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
log.Info("proto.Marshal() failed len", len(msg), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info("proto.Marshal() worked len", len(msg))
|
||||||
|
// me.machines.ConfigSave()
|
||||||
|
zoopb.ConfigSaveRaw(data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ func updateMachine(u *zoopb.Machine) string {
|
||||||
u.Packages = new(zoopb.Packages)
|
u.Packages = new(zoopb.Packages)
|
||||||
}
|
}
|
||||||
if zood := m.FindPackageByName("zood"); zood != nil {
|
if zood := m.FindPackageByName("zood"); zood != nil {
|
||||||
log.Log(ZOOD, m.Hostname, "has zood version", zood.Version)
|
log.Log(INFO, m.Hostname, "has zood version", zood.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePackages(m, u.Packages)
|
updatePackages(m, u.Packages)
|
||||||
|
@ -59,14 +59,15 @@ func updatePackages(m *zoopb.Machine, newp *zoopb.Packages) bool {
|
||||||
if p.Name == "zood" {
|
if p.Name == "zood" {
|
||||||
if pold := m.FindPackageByName("zood"); pold == nil {
|
if pold := m.FindPackageByName("zood"); pold == nil {
|
||||||
changed = true
|
changed = true
|
||||||
log.Log(ZOOD, m.Hostname, "updatePackages() new package", p.Name , "version", p.Version)
|
log.Log(ZOOD, "updatePackages() new package", p.Name , "version", p.Version, "machine", m.Hostname)
|
||||||
m.Packages.Append(p)
|
m.Packages.Append(p)
|
||||||
} else {
|
} else {
|
||||||
if p.Version == pold.Version {
|
if p.Version == pold.Version {
|
||||||
log.Log(ZOOD, m.Hostname, "updatePackages() unchanged", p.Version)
|
log.Log(ZOOD, "updatePackages() unchanged", p.Version, "machine", m.Hostname)
|
||||||
} else {
|
} else {
|
||||||
changed = true
|
changed = true
|
||||||
log.Log(ZOOD, m.Hostname, "updatePackages() package", p.Name , "version changed", pold.Version, "to", p.Version)
|
log.Log(NOW, "updatePackages() package", p.Name , "version changed", pold.Version, "to", p.Version, "machine", m.Hostname)
|
||||||
|
pold.Version = p.Version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue