initial commit
This commit is contained in:
53
pkg/compute/libvirt/libvirt.go
Normal file
53
pkg/compute/libvirt/libvirt.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package libvirt
|
||||
|
||||
// Client abstracts libvirt operations needed by the node-agent.
|
||||
type Client interface {
|
||||
ListVMs() ([]VM, error)
|
||||
CreateVM(spec VMSpec) (VM, error)
|
||||
StartVM(id string) error
|
||||
StopVM(id string) error
|
||||
RebootVM(id string) error
|
||||
DeleteVM(id string) error
|
||||
}
|
||||
|
||||
type VMSpec struct {
|
||||
ID string
|
||||
Name string
|
||||
CPU int
|
||||
MemoryMB int
|
||||
Disks []DiskSpec
|
||||
NICs []NICSpec
|
||||
CloudInit *CloudInitSpec
|
||||
CloudInitISO string
|
||||
}
|
||||
|
||||
type DiskSpec struct {
|
||||
Name string
|
||||
Pool string
|
||||
SizeGB int
|
||||
Bus string
|
||||
Path string
|
||||
Prealloc string // "", "metadata", "full"
|
||||
}
|
||||
|
||||
type NICSpec struct {
|
||||
Bridge string
|
||||
VLAN int
|
||||
Model string
|
||||
}
|
||||
|
||||
type CloudInitSpec struct {
|
||||
User string
|
||||
SSHKeys []string
|
||||
UserData string
|
||||
}
|
||||
|
||||
type VM struct {
|
||||
ID string
|
||||
Name string
|
||||
Status string
|
||||
CPU int
|
||||
MemoryMB int
|
||||
}
|
||||
|
||||
// TODO: implement a real libvirt-go backed client that renders domain XML from templates.
|
||||
Reference in New Issue
Block a user