Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDomainNotFound = errors.New("domain not found")
ErrDomainNotFound error is returned by DomainConnection's Lookup*() methods when the domain in question cannot be found
var ErrSecretNotFound = errors.New("secret not found")
ErrSecretNotFound error is returned by DomainConnection's Lookup*() methods when the domain in question cannot be found
var ErrStoragePoolNotFound = errors.New("storage pool not found")
ErrStoragePoolNotFound error is returned by StorageConnection's LookupByName() method when the pool in question cannot be found
var ErrStorageVolumeNotFound = errors.New("storage volume not found")
ErrStorageVolumeNotFound error is returned by StoragePool's LookupVolumeByName() method when the volume in question cannot be found
Functions ¶
This section is empty.
Types ¶
type Domain ¶ added in v1.0.0
type Domain interface {
// Create boots the domain
Create() error
// Destroy destroys the domain
Destroy() error
// Undefine removes the domain so it will no longer be possible
// to locate it using LookupByName() or LookupByUUIDString()
Undefine() error
// Shutdown shuts down the domain
Shutdown() error
// State obtains the current state of the domain
State() (DomainState, error)
// UUIDString returns UUID string for this domain
UUIDString() (string, error)
// Name returns the name of this domain
Name() (string, error)
// XML retrieves xml definition of the domain
XML() (*libvirtxml.Domain, error)
// GetRSS returns RSS used by VM in bytes
GetRSS() (uint64, error)
// GetCPUTime returns cpu time used by VM in nanoseconds per core
GetCPUTime() (uint64, error)
}
Domain represents a domain which corresponds to a VM
type DomainConnection ¶ added in v1.0.0
type DomainConnection interface {
// Define creates and returns a new domain based on the specified definition
DefineDomain(def *libvirtxml.Domain) (Domain, error)
// ListDomains lists all the domains available on the system
ListDomains() ([]Domain, error)
// LookupByName tries to locate the domain by name. In case if the
// domain cannot be found but no other error occurred, it returns
// ErrDomainNotFound
LookupDomainByName(name string) (Domain, error)
// LookupDomainByUUIDString tries to locate the domain by its UUID. In case if the
// domain cannot be found but no other error occurred, it returns
// ErrDomainNotFound
LookupDomainByUUIDString(uuid string) (Domain, error)
// DefineSecret defines a Secret with the specified value
DefineSecret(def *libvirtxml.Secret) (Secret, error)
// LookupSecretByUUIDString tries to locate the secret by its UUID. In case if the
// secret cannot be found but no other error occurred, it returns
// ErrSecretNotFound
LookupSecretByUUIDString(uuid string) (Secret, error)
// LookupSecretByUsageName tries to locate the secret by its Usage name. In case if the
// secret cannot be found but no other error occurred, it returns
// ErrSecretNotFound
LookupSecretByUsageName(usageType string, usageName string) (Secret, error)
}
DomainConnection provides operations on domains that correspond to VMs
type DomainState ¶
type DomainState int
DomainState represents a state of a domain
const ( // DomainStateNoState means "no state", i.e. that the domain state is undefined DomainStateNoState DomainState = iota // DomainStateRunning means that the domain is running DomainStateRunning // DomainStateBlocked means that the domain is blocked on resource DomainStateBlocked // DomainStatePaused means that the domain is paused by user DomainStatePaused // DomainStateShutdown means that the domain is being shut down DomainStateShutdown // DomainStateCrashed means that the domain is crashed DomainStateCrashed // DomainStatePMSuspended means that the domain is suspended DomainStatePMSuspended // DomainStateShutoff means that the domain is shut off DomainStateShutoff )
type Secret ¶ added in v1.0.0
type Secret interface {
// SetValue sets the value of the secret
SetValue(value []byte) error
// Remove removes the secret
Remove() error
}
Secret represents a secret that's used by the domain
type StorageConnection ¶ added in v1.0.0
type StorageConnection interface {
// CreateStoragePool creates a storage pool based on the specified definition
CreateStoragePool(def *libvirtxml.StoragePool) (StoragePool, error)
// LookupByName tries to locate the storage pool by its
// UUID. In case if the domain cannot be found but no other
// error occurred, it returns ErrStoragePoolNotFound
LookupStoragePoolByName(name string) (StoragePool, error)
// ListPools() retrieves the list of pools
ListPools() ([]StoragePool, error)
// PutFiles add files to the specified image.
PutFiles(imagePath string, files map[string][]byte) error
}
StorageConnection provides operations on the storage pools and storage volumes
type StoragePool ¶ added in v1.0.0
type StoragePool interface {
// CreateStorageVol creates a new storage volume based on the specified definition
CreateStorageVol(def *libvirtxml.StorageVolume) (StorageVolume, error)
// ListVolumes lists all the storage volumes available in the pool
ListVolumes() ([]StorageVolume, error)
// LookupVolumeByName tries to locate the storage volume by its
// UUID. In case if the domain cannot be found but no other
// error occurred, it returns ErrStorageVolumeNotFound
LookupVolumeByName(name string) (StorageVolume, error)
// RemoveVolumeByName removes the storage volume with the
// specified name
RemoveVolumeByName(name string) error
// XML retrieves xml definition of the pool
XML() (*libvirtxml.StoragePool, error)
}
StoragePool represents a pool of volumes
type StorageVolume ¶ added in v1.0.0
type StorageVolume interface {
// Name returns the name of this storage volume
Name() string
// Size returns the size of this storage volume
Size() (uint64, error)
// Path returns the path to the file representing this storage volume
Path() (string, error)
// Remove removes this storage volume
Remove() error
// Format formats the volume as ext4 filesystem
Format() error
// XML retrieves xml definition of the volume
XML() (*libvirtxml.StorageVolume, error)
}
StorageVolume represents a particular volume in pool