diff --git a/Makefile b/Makefile index 6d00510..1d8fded 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= all: GO111MODULE=off go build -v -x -ldflags "-X main.Version=${VERSION} -X gui.GUIVERSION=${VERSION}" ./virtigod --version + sudo ./virtigod # this is for release builds using the go.mod files release-build: diff --git a/http.go b/http.go index 19e1bb8..44cfc88 100644 --- a/http.go +++ b/http.go @@ -18,6 +18,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { var tmp string tmp = cleanURL(r.URL.Path) + log.Info("Got URL:", tmp) if tmp == "/" { fmt.Fprintln(w, "OK") return @@ -31,11 +32,23 @@ func okHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, j) return } + + if tmp == "/vms" { + s := poolHypervisor(hv) + fmt.Fprint(w, s) + return + } + if tmp == "/favicon.ico" { writeFile(w, "ipv6.png") return } - // used for uptime monitor checking + if tmp == "/uptime" { + writeFile(w, "uptime.html") + return + } + + // used for uptime monitor checking (like Kuma) if tmp == "/uptime" { writeFile(w, "uptime.html") return diff --git a/hypervisior.go b/hypervisior.go index 02ee539..e338889 100644 --- a/hypervisior.go +++ b/hypervisior.go @@ -22,7 +22,8 @@ import ( "github.com/digitalocean/go-qemu/qemu" ) -func poolHypervisor(hv *hypervisor.Hypervisor) { +func poolHypervisor(hv *hypervisor.Hypervisor) string { + var out string // fmt.Printf("\n**********Domains**********\n") domains, err := hv.Domains() if err != nil { @@ -57,10 +58,13 @@ func poolHypervisor(hv *hypervisor.Hypervisor) { } if status == qemu.StatusRunning { fmt.Println("ON ", name, drives) + out += "ON " + name + "\n" } else { fmt.Println("OFF", status, name, drives) + out += "OFF " + name + "\n" } } + return out } func displayBlockDevices(domain *qemu.Domain) {