Documentation
¶
Index ¶
- Constants
- func ByteCountIEC(b uint64) string
- func GetOpenstackUUID(domain libvirt.Domain) string
- func MemoryToResource(value int64, unit string) (resource.Quantity, error)
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) Close() error
- func (mock *InterfaceMock) CloseCalls() []struct{}
- func (mock *InterfaceMock) Connect() error
- func (mock *InterfaceMock) ConnectCalls() []struct{}
- func (mock *InterfaceMock) Process(hv v1.Hypervisor) (v1.Hypervisor, error)
- func (mock *InterfaceMock) ProcessCalls() []struct{ ... }
- func (mock *InterfaceMock) WatchDomainChanges(eventId libvirt.DomainEventID, handlerId string, ...)
- func (mock *InterfaceMock) WatchDomainChangesCalls() []struct{ ... }
- type LibVirt
- type UUID
Constants ¶
const ( VIR_DOMAIN_JOB_NONE = iota /* No job is active (Since: 0.7.7) */ VIR_DOMAIN_JOB_BOUNDED /* Job with a finite completion time (Since: 0.7.7) */ VIR_DOMAIN_JOB_UNBOUNDED /* Job without a finite completion time (Since: 0.7.7) */ VIR_DOMAIN_JOB_COMPLETED /* Job has finished, but isn't cleaned up (Since: 0.7.7) */ VIR_DOMAIN_JOB_FAILED /* Job hit error, but isn't cleaned up (Since: 0.7.7) */ VIR_DOMAIN_JOB_CANCELLED /* Job was aborted, but isn't cleaned up (Since: 0.7.7) */ )
const ( VIR_DOMAIN_JOB_OPERATION_UNKNOWN = iota /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_START /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_SAVE /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_RESTORE /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_DUMP /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_BACKUP /* (Since: 6.0.0) */ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE /* (Since: 9.0.0) */ )
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC ¶
func GetOpenstackUUID ¶
Types ¶
type Interface ¶
type Interface interface {
// Connect connects to the libvirt daemon.
//
// This function also run a loop which listens for new events on the
// subscribed libvirt event channels and distributes them to the subscribed
// listeners (see the `Watch` method).
Connect() error
// Close closes the connection to the libvirt daemon.
Close() error
// Watch libvirt domain changes and notify the provided handler.
//
// The provided handlerId should be unique per handler, and is used to
// disambiguate multiple handlers for the same eventId.
//
// Note that the handler is called in a blocking manner, so long-running handlers
// should spawn goroutines if needed.
WatchDomainChanges(
eventId libvirt.DomainEventID,
handlerId string,
handler func(context.Context, any),
)
// Add information extracted from the libvirt socket to the hypervisor instance.
// If an error occurs, the instance is returned unmodified. The libvirt
// connection needs to be established before calling this function.
Process(hv v1.Hypervisor) (v1.Hypervisor, error)
}
type InterfaceMock ¶
type InterfaceMock struct {
// CloseFunc mocks the Close method.
CloseFunc func() error
// ConnectFunc mocks the Connect method.
ConnectFunc func() error
// WatchDomainChangesFunc mocks the WatchDomainChanges method.
WatchDomainChangesFunc func(eventId libvirt.DomainEventID, handlerId string, handler func(context.Context, any))
// ProcessFunc mocks the Process method.
ProcessFunc func(hv v1.Hypervisor) (v1.Hypervisor, error)
// contains filtered or unexported fields
}
InterfaceMock is a mock implementation of Interface.
func TestSomethingThatUsesInterface(t *testing.T) {
// make and configure a mocked Interface
mockedInterface := &InterfaceMock{
CloseFunc: func() error {
panic("mock out the Close method")
},
ConnectFunc: func() error {
panic("mock out the Connect method")
},
WatchDomainChangesFunc: func(eventId libvirt.DomainEventID, handlerId string, handler func(context.Context, any)) {
panic("mock out the WatchDomainChanges method")
},
ProcessFunc: func(hv v1.Hypervisor) (v1.Hypervisor, error) {
panic("mock out the Process method")
},
}
// use mockedInterface in code that requires Interface
// and then make assertions.
}
func (*InterfaceMock) CloseCalls ¶
func (mock *InterfaceMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedInterface.CloseCalls())
func (*InterfaceMock) Connect ¶
func (mock *InterfaceMock) Connect() error
Connect calls ConnectFunc.
func (*InterfaceMock) ConnectCalls ¶
func (mock *InterfaceMock) ConnectCalls() []struct { }
ConnectCalls gets all the calls that were made to Connect. Check the length with:
len(mockedInterface.ConnectCalls())
func (*InterfaceMock) Process ¶
func (mock *InterfaceMock) Process(hv v1.Hypervisor) (v1.Hypervisor, error)
Process calls ProcessFunc.
func (*InterfaceMock) ProcessCalls ¶
func (mock *InterfaceMock) ProcessCalls() []struct { Hv v1.Hypervisor }
ProcessCalls gets all the calls that were made to Process. Check the length with:
len(mockedInterface.ProcessCalls())
func (*InterfaceMock) WatchDomainChanges ¶
func (mock *InterfaceMock) WatchDomainChanges(eventId libvirt.DomainEventID, handlerId string, handler func(context.Context, any))
WatchDomainChanges calls WatchDomainChangesFunc.
func (*InterfaceMock) WatchDomainChangesCalls ¶
func (mock *InterfaceMock) WatchDomainChangesCalls() []struct { EventId libvirt.DomainEventID HandlerId string Handler func(context.Context, any) }
WatchDomainChangesCalls gets all the calls that were made to WatchDomainChanges. Check the length with:
len(mockedInterface.WatchDomainChangesCalls())
type LibVirt ¶
type LibVirt struct {
// contains filtered or unexported fields
}
func NewLibVirt ¶
func (*LibVirt) Process ¶
func (l *LibVirt) Process(hv v1.Hypervisor) (v1.Hypervisor, error)
Add information extracted from the libvirt socket to the hypervisor instance. If an error occurs, the instance is returned unmodified. The libvirt connection needs to be established before calling this function.
func (*LibVirt) WatchDomainChanges ¶
func (l *LibVirt) WatchDomainChanges( eventId libvirt.DomainEventID, handlerId string, handler func(context.Context, any), )
Watch libvirt domain changes and notify the provided handler.
The provided handlerId should be unique per handler, and is used to disambiguate multiple handlers for the same eventId.
Note that the handler is called in a blocking manner, so long-running handlers should spawn goroutines if needed.