Documentation ¶
Index ¶
- Constants
- func EnvmapToSlice(envMap map[string]string) []string
- func GenerateISO(files map[string][]byte) ([]byte, error)
- type AfterNotifier
- type Disk
- type DockerClient
- type DockerContainerConfig
- type HTTPClient
- type ImageBuildConfig
- type ImageBuildTools
- type LibvirtConnection
- type NetworkCopier
- type ProvisionConfig
- type ProvisionDockerStep
- type ProvisionOption
- type ProvisionRsyncStep
- type ProvisionShellStep
- type ProvisionStep
- type ReaderProxy
- type ShellClient
- type ShellClientBuilder
- type VMConfig
- type VMConsoleFile
- type VMDisk
- type VMDiskDevice
- type Virter
- func (v *Virter) Disconnect() error
- func (v *Virter) ImageBuild(ctx context.Context, tools ImageBuildTools, vmConfig VMConfig, ...) error
- func (v *Virter) ImageExists(imageName string) (bool, error)
- func (v *Virter) ImagePull(client HTTPClient, readerProxy ReaderProxy, url string, name string) error
- func (v *Virter) VMCommit(afterNotifier AfterNotifier, vmName string, shutdown bool, ...) error
- func (v *Virter) VMExecDocker(ctx context.Context, docker DockerClient, vmNames []string, ...) error
- func (v *Virter) VMExecRsync(ctx context.Context, copier 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 DockerClient ¶
type DockerClient interface { ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) }
DockerClient contains the required docker methods.
type DockerContainerConfig ¶
type DockerContainerConfig struct { ContainerName string // the name of the container ImageName string // the name of the container image Env []string // the environment (variables) passed to the container }
DockerContainerConfig contains the configuration for a to be started container
type HTTPClient ¶
HTTPClient contains required HTTP methods.
type ImageBuildConfig ¶
type ImageBuildConfig struct { DockerContainerConfig DockerContainerConfig 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 DockerClient DockerClient 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) 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) LifecycleEvents() (<-chan libvirt.DomainEventLifecycleMsg, error) Disconnect() error }
LibvirtConnection contains required libvirt connection methods.
type NetworkCopier ¶
type NetworkCopier interface { // Copy transfers a list of files (source) from the local machine to // a target directory (destination) on a remote host (host). Copy(host string, source []string, destination string) error }
NetworkCopier copies files over the network
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) NeedsDocker ¶
func (p *ProvisionConfig) NeedsDocker() bool
NeedsDocker 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 VCPUs uint ID uint SSHPublicKeys []string SSHPrivateKey []byte WaitSSH bool SSHPingCount int SSHPingPeriod time.Duration ConsoleFile *VMConsoleFile Disks []Disk }
VMConfig contains the configuration for starting a VM
func CheckVMConfig ¶
CheckVMConfig takes a VMConfig, does basic checks, and returns it back.
type VMConsoleFile ¶
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) 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(client HTTPClient, readerProxy ReaderProxy, url string, name string) error
ImagePull pulls an image from a URL into libvirt.
func (*Virter) VMCommit ¶
func (v *Virter) VMCommit(afterNotifier AfterNotifier, vmName string, shutdown bool, shutdownTimeout time.Duration) error
VMCommit commits a VM to an image. If shutdown is true, a goroutine to watch for events will be started. This goroutine will only terminate when the libvirt connection is closed, so take care of leaking goroutines.
func (*Virter) VMExecDocker ¶
func (v *Virter) VMExecDocker(ctx context.Context, docker DockerClient, vmNames []string, dockerContainerConfig DockerContainerConfig, sshPrivateKey []byte) error
VMExecDocker runs a docker container against some VMs.
func (*Virter) VMExecRsync ¶
func (v *Virter) VMExecRsync(ctx context.Context, copier 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.