apt update triggers
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0b78c1f2d1
commit
82c559e657
12
Makefile
12
Makefile
|
@ -47,3 +47,15 @@ git-clone:
|
|||
|
||||
http-toogle-ZOOD:
|
||||
curl --silent http://localhost:8080/flag?flag=ZOOD
|
||||
|
||||
http-list-machines:
|
||||
curl --silent http://localhost:8080/list
|
||||
|
||||
http-set-zood-target:
|
||||
curl --silent "http://localhost:8080/target?package=zood&version=v0.0.8"
|
||||
|
||||
http-upgrade-hpdev2.grid.wit.com:
|
||||
curl --silent "http://localhost:8080/upgrade?hostname=hpdev2.grid.wit.com"
|
||||
|
||||
http-upgrade-mirrors.wit.com:
|
||||
curl --silent "http://localhost:8080/upgrade?hostname=mirrors.wit.com"
|
||||
|
|
52
http.go
52
http.go
|
@ -22,6 +22,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
hostname := r.URL.Query().Get("hostname")
|
||||
flag := r.URL.Query().Get("flag")
|
||||
packname := r.URL.Query().Get("package")
|
||||
version := r.URL.Query().Get("version")
|
||||
|
||||
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
||||
if err != nil {
|
||||
|
@ -42,9 +44,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
log.Log(ZOOD, "proto.Unmarshal() worked on wire message len", len(msg), "from", m.Hostname)
|
||||
b := me.upgrade[m.Hostname]
|
||||
switch updateMachine(m) {
|
||||
case "upgrade":
|
||||
fmt.Fprintln(w, "upgrade")
|
||||
if b {
|
||||
fmt.Fprintln(w, "apt update")
|
||||
me.upgrade[m.Hostname] = false
|
||||
} else {
|
||||
fmt.Fprintln(w, "upgrade")
|
||||
}
|
||||
default:
|
||||
fmt.Fprintln(w, "notsure")
|
||||
}
|
||||
|
@ -70,6 +78,48 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// list out the machines and thier version of zood
|
||||
if route == "/list" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
loop := me.machines.SortByName()
|
||||
for loop.Scan() {
|
||||
m := loop.Machine()
|
||||
zood := m.FindPackageByName("zood")
|
||||
v := me.targets["zood"] // this is the target version
|
||||
if zood == nil {
|
||||
log.Info("machine", m.Hostname, "does not have zood installed")
|
||||
} else {
|
||||
log.Info("know about machine", m.Hostname, "zood version", zood.Version, "vs target version", v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// save the config file
|
||||
if route == "/save" {
|
||||
// me.machines.SaveConfig()
|
||||
return
|
||||
}
|
||||
|
||||
// flag a package to attempt to upgrade
|
||||
if route == "/upgrade" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
me.upgrade[hostname] = true
|
||||
log.Log(NOW, "setting package ", packname, " to upgrade")
|
||||
return
|
||||
}
|
||||
|
||||
// set the target version for a package
|
||||
if route == "/target" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
me.targets[packname] = version
|
||||
log.Log(NOW, "setting package/version to ", packname, " ", version)
|
||||
return
|
||||
}
|
||||
|
||||
// toggle logging flags
|
||||
if route == "/flag" {
|
||||
log.HttpMode(w)
|
||||
|
|
2
main.go
2
main.go
|
@ -48,6 +48,8 @@ func main() {
|
|||
me.hostname, _ = os.Hostname()
|
||||
me.pollDelay = 10 * time.Second
|
||||
me.machines = new(zoopb.Machines)
|
||||
me.targets = make(map[string]string) // keep track of what versions the machines should be running
|
||||
me.upgrade = make(map[string]bool) // used to trigger upgrade attempts
|
||||
|
||||
go NewWatchdog()
|
||||
|
||||
|
|
16
structs.go
16
structs.go
|
@ -10,11 +10,13 @@ var me *stuff
|
|||
|
||||
// this app's variables
|
||||
type stuff struct {
|
||||
hostname string // my fqdn dns zookeeper hostname
|
||||
pollDelay time.Duration // how often to report our status
|
||||
dog *time.Ticker // the watchdog timer
|
||||
dogchan chan bool // can kill the watchdog
|
||||
distro string // debian,redhat,gentoo,macos,wincrap
|
||||
packages *zoopb.Packages // installed packages and versions
|
||||
machines *zoopb.Machines // every machine that has reported itself to the zookeeper
|
||||
hostname string // my fqdn dns zookeeper hostname
|
||||
pollDelay time.Duration // how often to report our status
|
||||
dog *time.Ticker // the watchdog timer
|
||||
dogchan chan bool // can kill the watchdog
|
||||
distro string // debian,redhat,gentoo,macos,wincrap
|
||||
packages *zoopb.Packages // installed packages and versions
|
||||
machines *zoopb.Machines // every machine that has reported itself to the zookeeper
|
||||
targets map[string]string // what versions the machines should be running
|
||||
upgrade map[string]bool // use this to trigger builds
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue