diff options
Diffstat (limited to 'dump.go')
| -rw-r--r-- | dump.go | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -3,10 +3,8 @@ package main import ( "fmt" "net/http" - "strings" "time" - "go.wit.com/lib/gui/shell" pb "go.wit.com/lib/protobuf/virtbuf" ) @@ -36,29 +34,33 @@ func dumpDroplets(w http.ResponseWriter, full bool) { d := loop.Droplet() fmt.Println(w, "Droplet UUID:", d.Uuid) - var macs []string - for _, n := range d.Networks { - macs = append(macs, n.Mac) - } - // this line in golang could replace 80 lines of COBOL - header := fmt.Sprintf("%-3s %20s %-8s", d.Current.State, strings.Join(macs, " "), d.Current.Hypervisor) + header := d.SprintDumpHeader() - var filenames string - for _, disk := range d.Disks { - filenames += disk.Filename + // check if this is a locally defined libvirt domain that needs to be imported + if d.LocalOnly != "" { + header += "(local)" } + header += d.Hostname if d.Current.State == pb.DropletState_ON { - fmt.Fprintln(w, header, d.Hostname) + // everything is as it should be with this vm + fmt.Fprintln(w, header) continue } if d.StartState == pb.DropletState_ON { - fmt.Fprintln(w, header, d.Hostname, "(should be on)") + // this is supposed to be ON and needs to be turned on + fmt.Fprintln(w, header, "(should be on). todo: start() here") continue } if full { - fmt.Fprintln(w, header, d.Hostname, filenames) + var filenames string + for _, disk := range d.Disks { + filenames += disk.Filename + } + + // this needs to be turned on + fmt.Fprintln(w, header, filenames) } } } @@ -70,11 +72,11 @@ func dumpHypervisors(w http.ResponseWriter) { for _, h := range me.hypers { // lastpoll time.Time // the last time the hypervisor polled dur := time.Since(h.lastpoll) - tmp := shell.FormatDuration(dur) + tmp := pb.FormatDuration(dur) fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp) for name, t := range h.lastDroplets { dur := time.Since(t) - tmp := shell.FormatDuration(dur) + tmp := pb.FormatDuration(dur) totalDroplets += 1 d := me.cluster.FindDropletByName(name) if d == nil { |
