persistant and dumps out vms

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-11 23:18:45 -05:00
parent e35b47fd5f
commit 3636bc1670
3 changed files with 20 additions and 2 deletions

View File

@ -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:

15
http.go
View File

@ -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

View File

@ -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) {