Documentation ¶
Index ¶
- Constants
- func EnvmapToSlice(envMap map[string]string) []string
- func GenerateISO(files map[string][]byte) ([]byte, error)
- type AfterNotifier
- type Disk
- type HTTPClient
- type ImageBuildConfig
- type ImageBuildTools
- type LibvirtConnection
- type ProvisionConfig
- type ProvisionDockerStep
- type ProvisionOption
- type ProvisionRsyncStep
- type ProvisionShellStep
- type ProvisionStep
- type ReaderProxy
- type ShellClient
- type ShellClientBuilder
- type VMConfig
- type VMDisk
- type VMDiskDevice
- type Virter
- func (v *Virter) Disconnect() error
- func (v *Virter) ForceDisconnect()
- func (v *Virter) ImageBuild(ctx context.Context, tools ImageBuildTools, vmConfig VMConfig, ...) error
- func (v *Virter) ImageExists(imageName string) (bool, error)
- func (v *Virter) ImagePull(ctx context.Context, client HTTPClient, readerProxy ReaderProxy, ...) error
- func (v *Virter) ImageRm(ctx context.Context, name string) error
- func (v *Virter) ImageSave(name string, to io.Writer) error
- func (v *Virter) VMCommit(ctx context.Context, afterNotifier AfterNotifier, vmName string, shutdown bool, ...) 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, sshPrivateKey []byte, ...) error
- func (v *Virter) VMRm(vmName string) error
- func (v *Virter) VMRun(shellClientBuilder ShellClientBuilder, vmConfig VMConfig) error
- func (v *Virter) VMSSHSession(ctx context.Context, vmName string, sshPrivateKey []byte) error
Constants ¶
const ( VMDiskDeviceDisk = "disk" VMDiskDeviceCDROM = "cdrom" )
Variables ¶
This section is empty.
Functions ¶
func EnvmapToSlice ¶
Types ¶
type AfterNotifier ¶
AfterNotifier wait for a duration to elapse
type HTTPClient ¶
HTTPClient contains required HTTP methods.
type ImageBuildConfig ¶
type ImageBuildConfig struct { ContainerName string SSHPrivateKeyPath string SSHPrivateKey []byte 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 LibvirtConnection ¶
type LibvirtConnection interface { StoragePoolLookupByName(Name string) (rPool libvirt.StoragePool, err error) StorageVolCreateXML(Pool libvirt.StoragePool, XML string, Flags libvirt.StorageVolCreateFlags) (rVol libvirt.StorageVol, err error) StorageVolDelete(Vol libvirt.StorageVol, Flags libvirt.StorageVolDeleteFlags) (err error) StorageVolGetPath(Vol libvirt.StorageVol) (rName string, err error) StorageVolLookupByName(Pool libvirt.StoragePool, Name string) (rVol libvirt.StorageVol, err error) StorageVolUpload(Vol libvirt.StorageVol, outStream io.Reader, Offset uint64, Length uint64, Flags libvirt.StorageVolUploadFlags) (err error) StorageVolGetXMLDesc(Vol libvirt.StorageVol, Flags uint32) (rXML string, err error) StorageVolCreateXMLFrom(Pool libvirt.StoragePool, XML string, Clonevol libvirt.StorageVol, Flags libvirt.StorageVolCreateFlags) (rVol libvirt.StorageVol, err error) StorageVolDownload(Vol libvirt.StorageVol, inStream io.Writer, Offset uint64, Length uint64, Flags libvirt.StorageVolDownloadFlags) (err error) StorageVolGetInfo(Vol libvirt.StorageVol) (rType int8, rCapacity uint64, rAllocation uint64, 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 uint32, 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 }
LibvirtConnection contains required libvirt connection methods.
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 ProvisionDockerStep ¶
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 ReaderProxy ¶
type ReaderProxy interface { SetTotal(total int64) ProxyReader(r io.ReadCloser) io.ReadCloser }
ReaderProxy wraps reading from a Reader with a known total size.
type ShellClient ¶
type ShellClient interface { Dial() 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 { ImageName string Name string MemoryKiB uint64 BootCapacityKiB uint64 VCPUs uint ID uint SSHPublicKeys []string SSHPrivateKey []byte WaitSSH bool SSHPingCount int SSHPingPeriod time.Duration ConsolePath string Disks []Disk }
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 Virter ¶
type Virter struct {
// contains filtered or unexported fields
}
Virter manipulates libvirt for virter.
func New ¶
func New(libvirtConnection LibvirtConnection, storagePoolName string, networkName string) *Virter
New configures a new Virter.
func (*Virter) Disconnect ¶
Disconnect disconnects virter's connection to libvirt
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) ImageBuild ¶
func (v *Virter) ImageBuild(ctx context.Context, tools ImageBuildTools, vmConfig VMConfig, buildConfig ImageBuildConfig) error
ImageBuild builds an image by running a VM and provisioning it
func (*Virter) ImageExists ¶
ImageExists checks whether an image called imageName exists in the libvirt virter storage pool.
func (*Virter) ImagePull ¶
func (v *Virter) ImagePull(ctx context.Context, client HTTPClient, readerProxy ReaderProxy, url, name string) error
ImagePull pulls an image from a URL into libvirt.
func (*Virter) VMCommit ¶
func (v *Virter) VMCommit(ctx context.Context, afterNotifier AfterNotifier, vmName string, shutdown bool, shutdownTimeout time.Duration) 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, sshPrivateKey []byte) 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, sshPrivateKey []byte, shellStep *ProvisionShellStep) error
VMExecShell runs a simple shell command against some VMs.