Documentation ¶
Index ¶
- Constants
- func AddToIP(ip net.IP, addend uint) net.IP
- func AddToMAC(mac net.HardwareAddr, addend uint) (net.HardwareAddr, error)
- func DynamicLayerName(name string) string
- func EnvmapToSlice(envMap map[string]string) []string
- func GenerateISO(files map[string][]byte) ([]byte, error)
- func QemuBaseMAC() net.HardwareAddr
- func QemuMAC(id uint) string
- type AfterNotifier
- type Disk
- type HTTPClient
- type ImageBuildConfig
- type ImageBuildTools
- type LayerOperationOption
- type LibvirtConnection
- type LibvirtGetError
- type LocalImage
- func (l *LocalImage) ConfigFile() (*regv1.ConfigFile, error)
- func (l *LocalImage) ConfigName() (regv1.Hash, error)
- func (l *LocalImage) Digest() (regv1.Hash, error)
- func (l *LocalImage) LayerByDiffID(hash regv1.Hash) (regv1.Layer, error)
- func (l *LocalImage) LayerByDigest(hash regv1.Hash) (regv1.Layer, error)
- func (l *LocalImage) Layers() ([]regv1.Layer, error)
- func (l *LocalImage) Manifest() (*regv1.Manifest, error)
- func (l *LocalImage) MediaType() (types.MediaType, error)
- func (l *LocalImage) Name() string
- func (l *LocalImage) RawConfigFile() ([]byte, error)
- func (l *LocalImage) RawManifest() ([]byte, error)
- func (l *LocalImage) Size() (int64, error)
- func (l *LocalImage) TopLayer() *VolumeLayer
- type NIC
- type NICType
- type NewLayerOption
- type ProgressOpt
- type ProvisionConfig
- type ProvisionDockerCopyStep
- type ProvisionDockerStep
- type ProvisionOption
- type ProvisionRsyncStep
- type ProvisionShellStep
- type ProvisionStep
- type RawLayer
- func (rl *RawLayer) CloneAs(name string, opts ...LayerOperationOption) (*RawLayer, error)
- func (rl *RawLayer) Delete() error
- func (rl *RawLayer) DeleteAllIfUnused() error
- func (rl *RawLayer) DeleteIfUnused() (bool, error)
- func (rl *RawLayer) Dependency() (*VolumeLayer, error)
- func (rl *RawLayer) Descriptor() (lx.StorageVolume, error)
- func (rl *RawLayer) DiffID() (regv1.Hash, error)
- func (rl *RawLayer) Name() string
- func (rl *RawLayer) ToVolumeLayer(diffID *regv1.Hash, opts ...LayerOperationOption) (*VolumeLayer, error)
- func (rl *RawLayer) Uncompressed() (io.ReadCloser, error)
- func (rl *RawLayer) Upload(reader io.Reader) error
- type SSHPingConfig
- type ShellClient
- type ShellClientBuilder
- type VMConfig
- type VMDisk
- type VMDiskDevice
- type VMMeta
- type VMNic
- type Virter
- func (v *Virter) AddDHCPHost(mac string, id uint) error
- func (v *Virter) Disconnect() error
- func (v *Virter) FindDynamicLayer(name string) (*RawLayer, error)
- func (v *Virter) FindImage(image string, opts ...LayerOperationOption) (*LocalImage, error)
- func (v *Virter) FindRawLayer(name string) (*RawLayer, error)
- func (v *Virter) FindVolumeLayer(name string) (*VolumeLayer, error)
- func (v *Virter) ForceDisconnect()
- func (v *Virter) GetVMID(wantedID uint, expectDHCPEntry bool) (uint, error)
- func (v *Virter) ImageBuild(ctx context.Context, tools ImageBuildTools, vmConfig VMConfig, ...) error
- func (v *Virter) ImageImport(name string, image regv1.Image, opts ...LayerOperationOption) (*LocalImage, error)
- func (v *Virter) ImageImportFromReader(image string, reader io.ReadCloser, opts ...LayerOperationOption) (*LocalImage, error)
- func (v *Virter) ImageList() ([]*LocalImage, error)
- func (v *Virter) ImageRm(name string) error
- func (v *Virter) ImageSpawn(name string, image *LocalImage, capacityKib uint64) (*RawLayer, error)
- func (v *Virter) LayerList() ([]*VolumeLayer, error)
- func (v *Virter) MakeImage(image string, topLayer *VolumeLayer, opts ...LayerOperationOption) (*LocalImage, error)
- func (v *Virter) NetworkAdd(desc libvirtxml.Network) error
- func (v *Virter) NetworkList() ([]libvirtxml.Network, error)
- func (v *Virter) NetworkListAttached(netname string) ([]VMNic, error)
- func (v *Virter) NetworkRemove(netname string) error
- func (v *Virter) NewDynamicLayer(name string, opts ...NewLayerOption) (*RawLayer, error)
- func (v *Virter) PingSSH(ctx context.Context, shellClientBuilder ShellClientBuilder, vmName string, ...) error
- func (v *Virter) RemoveMACDHCPEntries(mac string) error
- func (v *Virter) VMCommit(ctx context.Context, afterNotifier AfterNotifier, vmName, imageName string, ...) error
- func (v *Virter) VMExecCopy(ctx context.Context, copier netcopy.NetworkCopier, sourceSpecs []string, ...) error
- func (v *Virter) VMExecDocker(ctx context.Context, containerProvider containerapi.ContainerProvider, ...) error
- func (v *Virter) VMExecRsync(ctx context.Context, copier netcopy.NetworkCopier, vmNames []string, ...) error
- func (v *Virter) VMExecShell(ctx context.Context, vmNames []string, shellStep *ProvisionShellStep) error
- func (v *Virter) VMRm(vmName string, staticDHCP bool) error
- func (v *Virter) VMRun(vmConfig VMConfig) error
- func (v *Virter) VMSSHSession(ctx context.Context, vmName string) error
- type VolumeLayer
- func (vl *VolumeLayer) DiffID() (regv1.Hash, error)
- func (vl *VolumeLayer) MediaType() (types.MediaType, error)
- func (vl *VolumeLayer) Squashed() (*RawLayer, error)
- func (vl *VolumeLayer) ToRegistryLayer(opts ...LayerOperationOption) (regv1.Layer, error)
- func (vl *VolumeLayer) ToVolumeLayer() (*VolumeLayer, error)
- func (vl *VolumeLayer) Upload(io.Reader) error
Constants ¶
const ( RootFSType = "application/vnd.com.linbit.virter.image.v1.rootfs" ImageMediaType = "application/vnd.com.linbit.virter.image.v1" TagVolumePrefix = "virter:tag:" )
const ( // LayerMediaType is the media type used when upload a layer to a container registry. LayerMediaType = "application/vnd.com.linbit.virter.layer.v1.qcow2.gzip" // LayerVolumePrefix is the prefix for all VolumeLayer storage volumes in libvirt. LayerVolumePrefix = "virter:layer:" // WorkingLayerNamePrefix is the prefix for all layers that are actively attached to a libvirt VM. WorkingLayerNamePrefix = "virter:work:" )
const ( VMDiskDeviceDisk = "disk" VMDiskDeviceCDROM = "cdrom" )
const ( NICTypeNetwork = "network" NICTypeBridge = "bridge" )
Variables ¶
This section is empty.
Functions ¶
func AddToMAC ¶ added in v0.12.0
func AddToMAC(mac net.HardwareAddr, addend uint) (net.HardwareAddr, error)
func DynamicLayerName ¶ added in v0.14.0
DynamicLayerName returns the prefixed raw volume name for the given dynamic layer.
func EnvmapToSlice ¶
func GenerateISO ¶
GenerateISO generates a "CD-ROM" filesystem
func QemuBaseMAC ¶ added in v0.12.0
func QemuBaseMAC() net.HardwareAddr
Types ¶
type AfterNotifier ¶
AfterNotifier wait for a duration to elapse
type HTTPClient ¶
HTTPClient contains required HTTP methods.
type ImageBuildConfig ¶
type ImageBuildConfig struct { ImageName string ContainerName string ShutdownTimeout time.Duration ProvisionConfig ProvisionConfig ResetMachineID bool }
ImageBuildConfig contains the configuration for building an image
type ImageBuildTools ¶
type ImageBuildTools struct { ShellClientBuilder ShellClientBuilder ContainerProvider containerapi.ContainerProvider AfterNotifier AfterNotifier }
ImageBuildTools includes the dependencies for building an image
type LayerOperationOption ¶ added in v0.14.0
type LayerOperationOption = func(o *layerOperatorOpts)
func WithProgress ¶ added in v0.14.0
func WithProgress(p ProgressOpt) LayerOperationOption
type LibvirtConnection ¶
type LibvirtConnection interface { ConnectListAllDomains(NeedResults int32, Flags libvirt.ConnectListAllDomainsFlags) (rDomains []libvirt.Domain, rRet uint32, err error) StoragePoolLookupByName(Name string) (rPool libvirt.StoragePool, err error) StoragePoolListAllVolumes(Pool libvirt.StoragePool, NeedResults int32, Flags uint32) (rVols []libvirt.StorageVol, rRet uint32, err error) StorageVolCreateXML(Pool libvirt.StoragePool, XML string, Flags libvirt.StorageVolCreateFlags) (rVol libvirt.StorageVol, err error) StorageVolCreateXMLFrom(Pool libvirt.StoragePool, XML string, original libvirt.StorageVol, Flags libvirt.StorageVolCreateFlags) (rVol libvirt.StorageVol, err error) StorageVolDelete(Vol libvirt.StorageVol, Flags libvirt.StorageVolDeleteFlags) (err error) StorageVolLookupByName(Pool libvirt.StoragePool, Name string) (rVol libvirt.StorageVol, err error) StorageVolUpload(Vol libvirt.StorageVol, outStream io.Reader, Offset, Length uint64, Flags libvirt.StorageVolUploadFlags) (err error) StorageVolGetXMLDesc(Vol libvirt.StorageVol, Flags uint32) (rXML string, err error) StorageVolDownload(Vol libvirt.StorageVol, inStream io.Writer, Offset, Length uint64, Flags libvirt.StorageVolDownloadFlags) (err error) StorageVolGetInfo(Vol libvirt.StorageVol) (rType int8, rCapacity, rAllocation uint64, err error) ConnectListAllNetworks(NeedResults int32, Flags libvirt.ConnectListAllNetworksFlags) (rNets []libvirt.Network, rRet uint32, err error) NetworkGetDhcpLeases(Net libvirt.Network, Mac libvirt.OptString, NeedResults int32, Flags uint32) (rLeases []libvirt.NetworkDhcpLease, rRet uint32, err error) NetworkDefineXML(XML string) (rNet libvirt.Network, err error) NetworkSetAutostart(Net libvirt.Network, Autostart int32) (err error) NetworkCreate(Net libvirt.Network) (err error) NetworkDestroy(Net libvirt.Network) (err error) NetworkUndefine(Net libvirt.Network) (err error) NetworkLookupByName(Name string) (rNet libvirt.Network, err error) NetworkGetXMLDesc(Net libvirt.Network, Flags uint32) (rXML string, err error) NetworkUpdate(Net libvirt.Network, Command, Section uint32, ParentIndex int32, XML string, Flags libvirt.NetworkUpdateFlags) (err error) DomainLookupByName(Name string) (rDom libvirt.Domain, err error) DomainGetXMLDesc(Dom libvirt.Domain, Flags libvirt.DomainXMLFlags) (rXML string, err error) DomainDefineXML(XML string) (rDom libvirt.Domain, err error) DomainCreate(Dom libvirt.Domain) (err error) DomainIsActive(Dom libvirt.Domain) (rActive int32, err error) DomainIsPersistent(Dom libvirt.Domain) (rPersistent int32, err error) DomainShutdown(Dom libvirt.Domain) (err error) DomainDestroy(Dom libvirt.Domain) (err error) DomainUndefine(Dom libvirt.Domain) (err error) DomainListAllSnapshots(Dom libvirt.Domain, NeedResults int32, Flags uint32) (rSnapshots []libvirt.DomainSnapshot, rRet int32, err error) DomainSnapshotDelete(Snap libvirt.DomainSnapshot, Flags libvirt.DomainSnapshotDeleteFlags) (err error) Disconnect() error ConnectGetLibVersion() (uint64, error) }
LibvirtConnection contains required libvirt connection methods.
type LibvirtGetError ¶ added in v0.5.0
func (*LibvirtGetError) Error ¶ added in v0.5.0
func (e *LibvirtGetError) Error() string
func (*LibvirtGetError) Unwrap ¶ added in v0.5.0
func (e *LibvirtGetError) Unwrap() error
type LocalImage ¶ added in v0.14.0
type LocalImage struct {
// contains filtered or unexported fields
}
LocalImage represents a list of local layers addressable by a human readable name.
An image is stored in libvirt as an empty volume prefixed by TagVolumePrefix. This volume has the actual VolumeLayer as backing store. This type implements the regv1.Image interface, i.e. it can be pushed to a container registry.
func (*LocalImage) ConfigFile ¶ added in v0.14.0
func (l *LocalImage) ConfigFile() (*regv1.ConfigFile, error)
ConfigFile returns this image's config file.
For containers this specifies metadata like which command to run and permissions. For us this simply carries the list layers by their uncompressed id.
func (*LocalImage) ConfigName ¶ added in v0.14.0
func (l *LocalImage) ConfigName() (regv1.Hash, error)
ConfigName returns the hash of the image's config file, also known as the Image ID.
func (*LocalImage) Digest ¶ added in v0.14.0
func (l *LocalImage) Digest() (regv1.Hash, error)
Digest returns the sha256 of this image's manifest.
func (*LocalImage) LayerByDiffID ¶ added in v0.14.0
LayerByDiffID is an analog to LayerByDigest, looking up by "diff id" (the uncompressed hash).
func (*LocalImage) LayerByDigest ¶ added in v0.14.0
LayerByDigest returns a Layer for interacting with a particular layer of the image, looking it up by "digest" (the compressed hash).
func (*LocalImage) Layers ¶ added in v0.14.0
func (l *LocalImage) Layers() ([]regv1.Layer, error)
Layers returns the ordered list of layers that make up this image.
The order of layers is oldest/base layer first, most recent/top layer last. Since VolumeLayer are not directly suitable for pushing to a registry, this method pre-computes the compatible layers and caches the result for later use.
func (*LocalImage) Manifest ¶ added in v0.14.0
func (l *LocalImage) Manifest() (*regv1.Manifest, error)
Manifest returns this image's Manifest object.
The manifest ties a tag to layers. When fetching an image from a registry, first the matching manifest is fetched. The manifest references the layers to fetch and the (container) configuration. For our purpose, only the layers are of interest.
func (*LocalImage) MediaType ¶ added in v0.14.0
func (l *LocalImage) MediaType() (types.MediaType, error)
MediaType of this image's manifest.
func (*LocalImage) Name ¶ added in v0.14.0
func (l *LocalImage) Name() string
Name returns the local name of the image.
func (*LocalImage) RawConfigFile ¶ added in v0.14.0
func (l *LocalImage) RawConfigFile() ([]byte, error)
RawConfigFile returns the serialized bytes of ConfigFile().
func (*LocalImage) RawManifest ¶ added in v0.14.0
func (l *LocalImage) RawManifest() ([]byte, error)
RawManifest returns the serialized bytes of Manifest()
func (*LocalImage) Size ¶ added in v0.14.0
func (l *LocalImage) Size() (int64, error)
Size returns the size of the manifest.
func (*LocalImage) TopLayer ¶ added in v0.14.0
func (l *LocalImage) TopLayer() *VolumeLayer
TopLayer returns the top most VolumeLayer.
The returned volume layer can be used as backing volume when starting a new VM based on this image.
type NewLayerOption ¶ added in v0.14.0
type NewLayerOption = func(volume *lx.StorageVolume)
NewLayerOption can be passed when creating a new layer to make changes on the libvirt storage volume object.
func WithBackingLayer ¶ added in v0.14.0
func WithBackingLayer(layer *VolumeLayer) NewLayerOption
WithBackingLayer sets the backing layer.
func WithCapacity ¶ added in v0.14.0
func WithCapacity(minCapKib uint64) NewLayerOption
WithCapacity sets the minimal capacity of the new layer in KibiByte.
func WithFormat ¶ added in v0.14.0
func WithFormat(fmt string) NewLayerOption
WithFormat sets the format used by the storage volume.
Supported values are "qcow2" and "raw".
type ProgressOpt ¶ added in v0.14.0
type ProvisionConfig ¶
type ProvisionConfig struct { Values map[string]string `toml:"values"` Env map[string]string `toml:"env"` Steps []ProvisionStep `toml:"steps"` }
ProvisionConfig holds the configuration of the whole provisioning
func NewProvisionConfig ¶
func NewProvisionConfig(provOpt ProvisionOption) (ProvisionConfig, error)
NewProvisionConfig returns a ProvisionConfig from a ProvisionOption
func (*ProvisionConfig) NeedsContainers ¶ added in v0.4.2
func (p *ProvisionConfig) NeedsContainers() bool
NeedsContainers checks if there is a provision step that requires a docker client
type ProvisionDockerCopyStep ¶ added in v0.6.0
type ProvisionDockerStep ¶
type ProvisionDockerStep struct { Image string `toml:"image"` Env map[string]string `toml:"env"` Command []string `toml:"command"` Copy *ProvisionDockerCopyStep `toml:"copy"` }
ProvisionDockerStep is a single provisioniong step executed in a docker container
type ProvisionOption ¶
ProvisionOption sumarizes all the options used for generating the final ProvisionConfig
type ProvisionRsyncStep ¶
ProvisionRsyncStep is used to copy files to the target via the rsync utility
type ProvisionShellStep ¶
ProvisionShellStep is a single provisioniong step executed in a shell (via ssh)
type ProvisionStep ¶
type ProvisionStep struct { Docker *ProvisionDockerStep `toml:"docker,omitempty"` Shell *ProvisionShellStep `toml:"shell,omitempty"` Rsync *ProvisionRsyncStep `toml:"rsync,omitempty"` }
ProvisionStep is a single provisioniong step
type RawLayer ¶ added in v0.14.0
type RawLayer struct {
// contains filtered or unexported fields
}
RawLayer represents and wraps a libvirt storage volume.
func (*RawLayer) CloneAs ¶ added in v0.14.0
func (rl *RawLayer) CloneAs(name string, opts ...LayerOperationOption) (*RawLayer, error)
CloneAs creates a copy of this layer under the given name.
func (*RawLayer) Delete ¶ added in v0.14.0
Delete deletes this layer.
There are no checks that prevent deletion of an in-use layer (either directly attached, or part of a layer chain). A layer that did not exist in the backend will still delete successfully.
func (*RawLayer) DeleteAllIfUnused ¶ added in v0.14.0
func (*RawLayer) DeleteIfUnused ¶ added in v0.14.0
DeleteIfUnused deletes the layer if it not referenced as a backing layer of other layers.
This method assumes that only VolumeLayer can have child layers, i.e. if a non VolumeLayer layer depends on another non VolumeLayer layer, it will still be deleted. This should not be an issue, as only the top-most layers should be mutable (i.e. a non VolumeLayer layer).
func (*RawLayer) Dependency ¶ added in v0.14.0
func (rl *RawLayer) Dependency() (*VolumeLayer, error)
Dependency returns a reference to a backing VolumeLayer, if any.
Returns nil if no backing layer was found. Returns an error if the backing layer is not a VolumeLayer.
func (*RawLayer) Descriptor ¶ added in v0.14.0
func (rl *RawLayer) Descriptor() (lx.StorageVolume, error)
Descriptor returns the libvirt descriptor of the storage volume backing this layer.
func (*RawLayer) DiffID ¶ added in v0.14.0
DiffID computes a digest of the Uncompressed layer content.
func (*RawLayer) ToVolumeLayer ¶ added in v0.14.0
func (rl *RawLayer) ToVolumeLayer(diffID *regv1.Hash, opts ...LayerOperationOption) (*VolumeLayer, error)
ToVolumeLayer converts this layer into a VolumeLayer.
First, computes the DiffID of the given layer, creates a new VolumeLayer compatible volume and copies the content of this layer over to the new volume. Afterwards, deletes this layer in the libvirt backend. If diffID is nil, it will be computed from the volume content.
func (*RawLayer) Uncompressed ¶ added in v0.14.0
func (rl *RawLayer) Uncompressed() (io.ReadCloser, error)
Uncompressed returns a reader that yields the raw volume.
If the RawLayer is in qcow2 format, this will read the raw qcow2 file, without any backing store.
type SSHPingConfig ¶ added in v0.6.0
SSHPingConfig contains the configuration for pinging a VM via SSH
type ShellClient ¶
type ShellClient interface { DialContext(ctx context.Context) error Close() error StdoutPipe() (io.Reader, error) StderrPipe() (io.Reader, error) ExecScript(script string) error Shell() error }
ShellClient executes shell commands
type ShellClientBuilder ¶
type ShellClientBuilder interface {
NewShellClient(hostPort string, sshconfig ssh.ClientConfig) ShellClient
}
ShellClientBuilder provides SSH connections
type VMConfig ¶
type VMConfig struct { Image *LocalImage Name string MemoryKiB uint64 BootCapacityKiB uint64 VCPUs uint ID uint StaticDHCP bool ExtraSSHPublicKeys []string ConsolePath string Disks []Disk ExtraNics []NIC GDBPort uint }
VMConfig contains the configuration for starting a VM
func CheckVMConfig ¶
CheckVMConfig takes a VMConfig, does basic checks, and returns it back.
type VMDiskDevice ¶ added in v0.2.0
type VMDiskDevice string
type VMMeta ¶ added in v0.9.0
type VMMeta struct {
HostKey string `xml:"hostkey"`
}
VMMeta is additional metadata stored with each VM
type Virter ¶
type Virter struct {
// contains filtered or unexported fields
}
Virter manipulates libvirt for virter.
func New ¶
func New(libvirtConnection LibvirtConnection, storagePoolName string, networkName string, store sshkeys.KeyStore) *Virter
New configures a new Virter.
func (*Virter) AddDHCPHost ¶ added in v0.6.0
AddDHCPHost determines the IP for an ID and adds a DHCP mapping from a MAC address to it. The same MAC address should always be paired with a given IP so that DHCP entries do not need to be released between removing a VM and creating another with the same ID.
func (*Virter) Disconnect ¶
Disconnect disconnects virter's connection to libvirt
func (*Virter) FindDynamicLayer ¶ added in v0.14.0
FindDynamicLayer searches the default storage pool for the given dynamic layer, suitable for attaching to a VM.
If no matching layer could be found, returns (nil, nil).
func (*Virter) FindImage ¶ added in v0.14.0
func (v *Virter) FindImage(image string, opts ...LayerOperationOption) (*LocalImage, error)
FindImage searches the default storage pool for a LocalImage of the given name.
If no matching image could be found, returns (nil, nil).
func (*Virter) FindRawLayer ¶ added in v0.14.0
FindRawLayer searches the default storage pool for the given volume and returns a RawLayer.
If the layer could not be found, will return (nil, nil).
func (*Virter) FindVolumeLayer ¶ added in v0.14.0
func (v *Virter) FindVolumeLayer(name string) (*VolumeLayer, error)
FindVolumeLayer searches the default storage pool for the given volume layer and returns a VolumeLayer.
The name is the raw layer name, i.e. "sha256:xxxx". If no matching volume is found, returns (nil, nil).
func (*Virter) ForceDisconnect ¶ added in v0.3.0
func (v *Virter) ForceDisconnect()
ForceDisconnect disconnects virter's connection to libvirt
It behaves like Disconnect(), except it does not return an error. If an error would be returned, the error will be logged and the program will terminate. Note: this is useful for `defer` statements
func (*Virter) GetVMID ¶ added in v0.5.0
GetVMID returns wantedID if it is not 0 and free. If wantedID is 0 GetVMID searches for an unused ID and returns the first it can find. For searching it uses the set libvirt network and already reserved DHCP entries.
func (*Virter) ImageBuild ¶
func (v *Virter) ImageBuild(ctx context.Context, tools ImageBuildTools, vmConfig VMConfig, pingConfig SSHPingConfig, buildConfig ImageBuildConfig, opts ...LayerOperationOption) error
ImageBuild builds an image by running a VM and provisioning it.
func (*Virter) ImageImport ¶ added in v0.14.0
func (v *Virter) ImageImport(name string, image regv1.Image, opts ...LayerOperationOption) (*LocalImage, error)
ImageImport imports the given registry image into the local storage pool
func (*Virter) ImageImportFromReader ¶ added in v0.14.0
func (v *Virter) ImageImportFromReader(image string, reader io.ReadCloser, opts ...LayerOperationOption) (*LocalImage, error)
ImageImportFromReader imports a new image into the local storage pool from a basic reader.
func (*Virter) ImageList ¶ added in v0.14.0
func (v *Virter) ImageList() ([]*LocalImage, error)
ImageList returns the list of images in the local storage pool.
func (*Virter) ImageRm ¶ added in v0.3.0
ImageRm removes an image from the local storage pool.
If no image of the given name is present, returns nil. This will recursively delete any layers that are not referenced by other images or currently in use by a VM.
func (*Virter) ImageSpawn ¶ added in v0.14.0
ImageSpawn creates a new rw volume backed by this image.
The returned RawLayer can be attached to a VM.
func (*Virter) LayerList ¶ added in v0.14.0
func (v *Virter) LayerList() ([]*VolumeLayer, error)
LayerList returns all known VolumeLayer in the default storage pool
func (*Virter) MakeImage ¶ added in v0.14.0
func (v *Virter) MakeImage(image string, topLayer *VolumeLayer, opts ...LayerOperationOption) (*LocalImage, error)
MakeImage creates a new LocalImage of the given name, pointing to the given VolumeLayer.
If an image of the given name already exists it will be deleted first.
func (*Virter) NetworkAdd ¶ added in v0.11.0
func (v *Virter) NetworkAdd(desc libvirtxml.Network) error
func (*Virter) NetworkList ¶ added in v0.11.0
func (v *Virter) NetworkList() ([]libvirtxml.Network, error)
func (*Virter) NetworkListAttached ¶ added in v0.11.0
func (*Virter) NetworkRemove ¶ added in v0.11.0
func (*Virter) NewDynamicLayer ¶ added in v0.14.0
func (v *Virter) NewDynamicLayer(name string, opts ...NewLayerOption) (*RawLayer, error)
NewDynamicLayer create a new (empty) layer suitable for attaching to a VM.
The volume name is prefix with WorkingLayerNamePrefix. To set a backing layer, set the minimum capacity and more, pass in one or more NewLayerOption.
func (*Virter) PingSSH ¶ added in v0.6.0
func (v *Virter) PingSSH(ctx context.Context, shellClientBuilder ShellClientBuilder, vmName string, pingConfig SSHPingConfig) error
PingSSH repeatedly tries to connect to a VM via SSH until it succeeds
func (*Virter) RemoveMACDHCPEntries ¶ added in v0.5.0
RemoveMACDHCPEntries removes DHCP host entries associated with the given MAC address
func (*Virter) VMCommit ¶
func (v *Virter) VMCommit(ctx context.Context, afterNotifier AfterNotifier, vmName, imageName string, shutdown bool, shutdownTimeout time.Duration, staticDHCP bool, opts ...LayerOperationOption) error
VMCommit commits a VM to an image. If shutdown is true, the VM is shut down before committing. If shutdown is false, the caller is responsible for ensuring that the VM is not running.
func (*Virter) VMExecCopy ¶ added in v0.3.0
func (*Virter) VMExecDocker ¶
func (v *Virter) VMExecDocker(ctx context.Context, containerProvider containerapi.ContainerProvider, vmNames []string, containerCfg *containerapi.ContainerConfig, copyStep *ProvisionDockerCopyStep) error
VMExecDocker runs a docker container against some VMs.
func (*Virter) VMExecRsync ¶
func (v *Virter) VMExecRsync(ctx context.Context, copier netcopy.NetworkCopier, vmNames []string, rsyncStep *ProvisionRsyncStep) error
func (*Virter) VMExecShell ¶
func (v *Virter) VMExecShell(ctx context.Context, vmNames []string, shellStep *ProvisionShellStep) error
VMExecShell runs a simple shell command against some VMs.
type VolumeLayer ¶ added in v0.14.0
type VolumeLayer struct {
RawLayer
}
VolumeLayer is an immutable RawLayer with additional restrictions.
A VolumeLayer is immutable. Since this is not enforceable on the libvirt level, enforcement is best-effort only. A VolumeLayer is always addressed by its content, i.e. the backing volume is named "virter:layer:sha256:<content-digest>".
func (*VolumeLayer) DiffID ¶ added in v0.14.0
func (vl *VolumeLayer) DiffID() (regv1.Hash, error)
DiffID computes a digest of the Uncompressed layer content.
Since a VolumeLayer is immutable and named after its content digest, this doesn't do any computation. Instead it uses its own name to determine the digest.
func (*VolumeLayer) MediaType ¶ added in v0.14.0
func (vl *VolumeLayer) MediaType() (types.MediaType, error)
MediaType returns the media type for the compressed Layer
func (*VolumeLayer) Squashed ¶ added in v0.14.0
func (vl *VolumeLayer) Squashed() (*RawLayer, error)
Squashed creates a squashed copy of this layer.
All backing layers are squashed into a single layer, the returned layer will not depend on any other layers.
func (*VolumeLayer) ToRegistryLayer ¶ added in v0.14.0
func (vl *VolumeLayer) ToRegistryLayer(opts ...LayerOperationOption) (regv1.Layer, error)
ToRegistryLayer wraps this VolumeLayer for pushing to a container registry.
A layer in a container registry is a compressed (gzipped) blob. To push a VolumeLayer to a registry, we need 1. the digest of the _uncompressed_ layer content 2. the compressed layer content 3. the digest of the _compressed_ layer content 4. the size of the _compressed_ layer content Points 2-4 are easily computed based on the uncompressed content. For efficiency we only compute it once, as the layers can be quite large.
func (*VolumeLayer) ToVolumeLayer ¶ added in v0.14.0
func (vl *VolumeLayer) ToVolumeLayer() (*VolumeLayer, error)
ToVolumeLayer converts this layer into a VolumeLayer.
Since VolumeLayer are immutable, this is a no-op.