clustvirt/main.go
Matthew Stobbs bab4f2506b Added ability to check domains on host
super simple example to show it can work
2024-03-10 00:15:49 -07:00

25 lines
493 B
Go

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))
}