25 lines
493 B
Go
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))
|
|
}
|