function to dump all droplets
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c26699571d
commit
8724a07b0d
12
dump.go
12
dump.go
|
@ -30,19 +30,29 @@ func dumpCluster(w http.ResponseWriter) {
|
|||
}
|
||||
|
||||
// list running droplets and droplets that should be running
|
||||
func dumpDroplets(w http.ResponseWriter) {
|
||||
func dumpDroplets(w http.ResponseWriter, full bool) {
|
||||
for i, d := range me.cluster.Droplets {
|
||||
var macs []string
|
||||
for _, n := range d.Networks {
|
||||
macs = append(macs, n.Mac)
|
||||
}
|
||||
arp := strings.Join(macs, " ")
|
||||
|
||||
var filenames string
|
||||
for _, disk := range d.Disks {
|
||||
filenames += disk.Filename
|
||||
}
|
||||
|
||||
if d.CurrentState == pb.DropletState_ON {
|
||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, d.CurrentHypervisor)
|
||||
continue
|
||||
}
|
||||
if d.StartState == pb.DropletState_ON {
|
||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, "(should be on)")
|
||||
continue
|
||||
}
|
||||
if full {
|
||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, filenames)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
http.go
26
http.go
|
@ -21,25 +21,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var route string
|
||||
route = cleanURL(r.URL.Path)
|
||||
|
||||
// is the cluster running what it should?
|
||||
if route == "/droplets" {
|
||||
for _, d := range me.cluster.Droplets {
|
||||
var msg string
|
||||
if d.StartState == pb.DropletState_ON {
|
||||
msg = "(should be on)"
|
||||
}
|
||||
switch d.CurrentState {
|
||||
case pb.DropletState_ON:
|
||||
fmt.Fprintln(w, d.Hostname, "ON")
|
||||
case pb.DropletState_OFF:
|
||||
fmt.Fprintln(w, d.Hostname, msg)
|
||||
default:
|
||||
fmt.Fprintln(w, d.Hostname, "? state:", d.CurrentState, msg)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// show only what droplets should be running but are missing
|
||||
if route == "/missing" {
|
||||
var count int
|
||||
|
@ -132,7 +113,12 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if route == "/dumpdroplets" {
|
||||
dumpDroplets(w)
|
||||
dumpDroplets(w, false)
|
||||
return
|
||||
}
|
||||
|
||||
if route == "/dumpdropletsfull" {
|
||||
dumpDroplets(w, true)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue