Added ability to check domains on host
super simple example to show it can work
This commit is contained in:
parent
9ce8b81e06
commit
bab4f2506b
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module git.staur.ca/stobbsm/clustvirt
|
||||
|
||||
go 1.22.1
|
||||
|
||||
require libvirt.org/go/libvirt v1.10001.0 // indirect
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -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=
|
24
main.go
Normal file
24
main.go
Normal file
@ -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))
|
||||
}
|
Loading…
Reference in New Issue
Block a user