Documentation
¶
Index ¶
- Constants
- type Client
- type ClientWithLegacySupport
- type Cluster
- type ClusterClient
- type Disk
- type DiskClient
- type Host
- type HostClient
- type HostStatus
- type ImageFormat
- type Logger
- type MockClient
- type StorageDomain
- type StorageDomainClient
- type StorageDomainExternalStatus
- type StorageDomainStatus
- type Template
- type TemplateClient
- type TestHelper
- type UploadImageProgress
- type UploadImageResult
- type VMBlockDevice
- type VMCPUTopo
- type VMClient
Constants ¶
const BlankTemplateID = "00000000-0000-0000-0000-000000000000"
BlankTemplateID is the blank template in oVirt.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// GetURL returns the oVirt engine base URL.
GetURL() string
DiskClient
VMClient
ClusterClient
StorageDomainClient
HostClient
TemplateClient
}
Client is a simplified client for the oVirt API.
type ClientWithLegacySupport ¶
type ClientWithLegacySupport interface {
// GetSDKClient returns a configured oVirt SDK client for the use cases that are not covered by goVirt.
GetSDKClient() *ovirtsdk4.Connection
// GetHTTPClient returns a configured HTTP client for the oVirt engine. This can be used to send manual
// HTTP request to the oVirt engine.
GetHTTPClient() http.Client
Client
}
ClientWithLegacySupport is an extension of Client that also offers the ability to retrieve the underlying SDK connection or a configured HTTP client.
type Cluster ¶
type Cluster interface {
// ID returns the UUID of the cluster.
ID() string
// Name returns the textual name of the cluster.
Name() string
}
Cluster represents a cluster returned from a ListClusters or GetCluster call.
type ClusterClient ¶
type ClusterClient interface {
// ListClusters returns a list of all clusters in the oVirt engine.
ListClusters() ([]Cluster, error)
// GetCluster returns a specific cluster based on the cluster ID. An error is returned if the cluster doesn't exist.
GetCluster(id string) (Cluster, error)
}
ClusterClient is a part of the Client that deals with clusters in the oVirt Engine.
type Disk ¶
type Disk interface {
ID() string
Alias() string
ProvisionedSize() uint64
Format() ImageFormat
StorageDomainID() string
}
type DiskClient ¶
type DiskClient interface {
// UploadImage uploads an image file into a disk. The actual upload takes place in the
// background and can be tracked using the returned UploadImageProgress object.
//
// Parameters are as follows:
//
// - ctx: this context can be used to abort the upload if it takes too long.
// - alias: this is the name used for the uploaded image.
// - storageDomainID: this is the UUID of the storage domain that the image should be uploaded to.
// - sparse: use sparse provisioning
// - size: this is the file size of the image. This must match the bytes read.
// - reader: this is the source of the image data.
//
// You can wait for the upload to complete using the Done() method:
//
// progress, err := cli.StartImageUpload(...)
// if err != nil {
// //...
// }
// <-progress.Done()
//
// After the upload is complete you can check the Err() method if it completed successfully:
//
// if err := progress.Err(); err != nil {
// //...
// }
//
StartImageUpload(
ctx context.Context,
alias string,
storageDomainID string,
sparse bool,
size uint64,
reader io.Reader,
) (UploadImageProgress, error)
// UploadImage is identical to StartImageUpload, but waits until the upload is complete. It returns the disk ID
// as a result, or the error if one happened.
UploadImage(
ctx context.Context,
alias string,
storageDomainID string,
sparse bool,
size uint64,
reader io.Reader,
) (UploadImageResult, error)
// ListDisks lists all disks.
ListDisks() ([]Disk, error)
// GetDisk fetches a disk with a specific ID from the
GetDisk(diskID string) (Disk, error)
// RemoveDisk removes a disk with a specific ID.
RemoveDisk(diskID string) error
}
type Host ¶
type Host interface {
ID() string
ClusterID() string
Status() HostStatus
}
Host is the representation of a host returned from the oVirt Engine API.
type HostClient ¶
HostClient contains the API portion that deals with hosts.
type HostStatus ¶
type HostStatus string
const ( HostStatusConnecting HostStatus = "connecting" HostStatusDown HostStatus = "down" HostStatusError HostStatus = "error" HostStatusInitializing HostStatus = "initializing" HostStatusInstallFailed HostStatus = "install_failed" HostStatusInstalling HostStatus = "installing" HostStatusInstallingOS HostStatus = "installing_os" HostStatusKDumping HostStatus = "kdumping" HostStatusMaintenance HostStatus = "maintenance" HostStatusNonOperational HostStatus = "non_operational" HostStatusNonResponsive HostStatus = "non_responsive" HostStatusPendingApproval HostStatus = "pending_approval" HostStatusPreparingForMaintenance HostStatus = "preparing_for_maintenance" HostStatusReboot HostStatus = "reboot" HostStatusUnassigned HostStatus = "unassigned" HostStatusUp HostStatus = "up" )
type ImageFormat ¶
type ImageFormat string
ImageFormat is a constant for representing the format that images can be in.
const ( ImageFormatCow ImageFormat = "cow" ImageFormatRaw ImageFormat = "raw" )
type Logger ¶
type Logger interface {
Log(v ...interface{})
Logf(format string, v ...interface{})
}
func NewGoLogLogger ¶
func NewGoLogLogger() Logger
func NewGoTestLogger ¶
type MockClient ¶
type MockClient interface {
Client
// GenerateUUID generates a UUID for testing purposes.
GenerateUUID() string
}
MockClient provides in-memory client functions, and additionally provides the ability to inject information.
func NewMock ¶
func NewMock() MockClient
NewMock creates a new in-memory mock client. This client can be used as a testing facility for higher level code.
type StorageDomain ¶
type StorageDomain interface {
ID() string
Name() string
// Available returns the number of available bytes on the storage domain
Available() uint64
// Status returns the status of the storage domain. This status may be unknown if the storage domain is external.
// Check ExternalStatus as well.
Status() StorageDomainStatus
// ExternalStatus returns the external status of a storage domain.
ExternalStatus() StorageDomainExternalStatus
}
StorageDomain represents a storage domain returned from the oVirt Engine API.
type StorageDomainClient ¶
type StorageDomainClient interface {
ListStorageDomains() ([]StorageDomain, error)
GetStorageDomain(id string) (StorageDomain, error)
}
StorageDomainClient contains the portion of the goVirt API that deals with storage domains.
type StorageDomainExternalStatus ¶
type StorageDomainExternalStatus string
const ( StorageDomainExternalStatusNA StorageDomainExternalStatus = "" StorageDomainExternalStatusError StorageDomainExternalStatus = "error" StorageDomainExternalStatusFailure StorageDomainExternalStatus = "failure" StorageDomainExternalStatusInfo StorageDomainExternalStatus = "info" StorageDomainExternalStatusOk StorageDomainExternalStatus = "ok" StorageDomainExternalStatusWarning StorageDomainExternalStatus = "warning" )
type StorageDomainStatus ¶
type StorageDomainStatus string
const ( StorageDomainStatusActivating StorageDomainStatus = "activating" StorageDomainStatusActive StorageDomainStatus = "active" StorageDomainStatusDetaching StorageDomainStatus = "detaching" StorageDomainStatusInactive StorageDomainStatus = "inactive" StorageDomainStatusLocked StorageDomainStatus = "locked" StorageDomainStatusMaintenance StorageDomainStatus = "maintenance" StorageDomainStatusMixed StorageDomainStatus = "mixed" StorageDomainStatusPreparingForMaintenance StorageDomainStatus = "preparing_for_maintenance" StorageDomainStatusUnattached StorageDomainStatus = "unattached" StorageDomainStatusUnknown StorageDomainStatus = "unknown" StorageDomainStatusNA StorageDomainStatus = "" )
type TemplateClient ¶
type TestHelper ¶
type TestHelper interface {
// GetClient returns the goVirt client.
GetClient() Client
// GetClusterID returns the ID for the cluster.
GetClusterID() string
// GetBlankTemplateID returns the ID of the blank template that can be used for creating dummy VMs.
GetBlankTemplateID() string
// GetStorageDomainID returns the ID of the storage domain to create the images on.
GetStorageDomainID() string
// GenerateRandomID generates a random ID for testing.
GenerateRandomID(length uint) string
}
TestHelper is a helper to run tests against an oVirt engine. When created it scans the oVirt Engine and tries to find working resources (hosts, clusters, etc) for running tests against. Tests should clean up after themselves.
func MustNewTestHelper ¶
type UploadImageProgress ¶
type UploadImageProgress interface {
// Disk returns the disk created as part of the upload process once the upload is complete. Before the upload
// is complete it will return nil.
Disk() Disk
// CorrelationID returns the correlation ID for the upload.
CorrelationID() string
// UploadedBytes returns the number of bytes already uploaded.
UploadedBytes() uint64
// TotalBytes returns the total number of bytes to be uploaded.
TotalBytes() uint64
// Err returns the error of the upload once the upload is complete or errored.
Err() error
// Done returns a channel that will be closed when the upload is complete.
Done() <-chan struct{}
}
UploadImageProgress is a tracker for the upload progress happening in the background.
type UploadImageResult ¶
type VMBlockDevice ¶
type VMCPUTopo ¶
func MustNewVMCPUTopo ¶
MustNewVMCPUTopo is identical to NewVMCPUTopo, but panics instead of returning an error if cores, threads, or sockets is zero.
func NewVMCPUTopo ¶
NewVMCPUTopo creates a new CPU topology with the given parameters. It returns an error if cores, threads, or sockets is 0. If the parameters are guaranteed to be non-zero MustNewVMCPUTopo should be used.
Source Files
¶
- client.go
- client_cluster.go
- client_cluster_get.go
- client_cluster_list.go
- client_disk.go
- client_disk_get.go
- client_disk_list.go
- client_disk_remove.go
- client_disk_uploadimage.go
- client_host.go
- client_host_get.go
- client_host_list.go
- client_storagedomain.go
- client_storagedomain_get.go
- client_storagedomain_list.go
- client_template.go
- client_template_get.go
- client_template_list.go
- client_vm.go
- client_vm_create.go
- const.go
- consts.go
- logger.go
- mock.go
- mock_disk_uploadimage.go
- new.go
- newmock.go
- test_helper.go
- util_qcow.go