diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8dca580 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module git.staur.ca/stobbsm/clustvirt + +go 1.22.1 + +require libvirt.org/go/libvirt v1.10001.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5306274 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +libvirt.org/go/libvirt v1.10001.0 h1:lEVDNE7xfzmZXiDEGIS8NvJSuaz11OjRXw+ufbQEtPY= +libvirt.org/go/libvirt v1.10001.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ= diff --git a/main.go b/main.go new file mode 100644 index 0000000..634696b --- /dev/null +++ b/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "log" + + "libvirt.org/go/libvirt" +) + +func main() { + log.Println("Starting clustvirt, the libvirt cluster manager") + + // Try connecting to libvirt + conn, err := libvirt.NewConnect("qemu+ssh://earth.staur.ca/system") + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + doms, err := conn.ListAllDomains(libvirt.CONNECT_LIST_DOMAINS_ACTIVE | libvirt.CONNECT_LIST_DOMAINS_INACTIVE) + if err != nil { + log.Fatal(err) + } + log.Printf("Domains on earth: %d", len(doms)) +}