virt

package
v0.0.2-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigSpec

func ConfigSpec() *hclspec.Spec

func TaskConfigSpec

func TaskConfigSpec() *hclspec.Spec

Types

type Config

type Config struct {
	Emulator     *Emulator       `codec:"emulator"`
	Provider     *Provider       `codec:"provider"`
	DataDir      string          `codec:"data_dir"`
	ImagePaths   []string        `codec:"image_paths"` // allow-list of host paths to load
	StoragePools *storage.Config `codec:"storage_pools"`
}

Config contains configuration information for the plugin

func (*Config) Compat

func (c *Config) Compat()

Compat sets appropriate configuration using deprecated options.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration and sets default values.

type Emulator

type Emulator struct {
	URI      string `codec:"uri"`
	User     string `codec:"user"`
	Password string `codec:"password"`
}

type OS

type OS struct {
	Arch    string `codec:"arch"`
	Machine string `codec:"machine"`
}

type Provider

type Provider struct {
	Default string          `codec:"default"`
	Libvirt *libvirt.Config `codec:"libvirt"`
}

Provider contains provider specific configuration

func (*Provider) Validate

func (p *Provider) Validate() error

Validate validates the provider configuration.

type TaskConfig

type TaskConfig struct {
	ImagePath           string         `codec:"image"`
	Hostname            string         `codec:"hostname"`
	OS                  *OS            `codec:"os"`
	UserData            string         `codec:"user_data"`
	TimeZone            *time.Location `codec:"timezone"`
	CMDs                []string       `codec:"cmds"`
	DefaultUserSSHKey   string         `codec:"default_user_authorized_ssh_key"`
	DefaultUserPassword string         `codec:"default_user_password"`
	UseThinCopy         bool           `codec:"use_thin_copy"`
	PrimaryDiskSize     uint64         `codec:"primary_disk_size"`
	Disks               disks.Disks    `codec:"disk"`
	// The list of network interfaces that should be added to the VM.
	net.NetworkInterfacesConfig `codec:"network_interface"`
}

TaskConfig contains configuration information for a task that runs within this plugin.

type VMGetter

type VMGetter interface {
	// GetVM gets information about the named virtual machine.
	GetVM(name string) (*vm.Info, error)
}

VMGetter is a slim interface for retrieving information about virtual machines.

type Virtualizer

type Virtualizer interface {
	// Init is responsible for initialzing the virtualization
	// provider. This is handled with a dedicated function to
	// allow errors to be properly returned.
	Init() error

	// CreateVM creates new virtual machine using the provided
	// configuration.
	CreateVM(config *vm.Config) error

	// StopVM stops the named virtual machine.
	StopVM(name string) error

	// DestroyVM destroys the named virtual machine.
	DestroyVM(name string) error

	// GetInfo returns information about the virtualization provider.
	GetInfo() (vm.VirtualizerInfo, error)

	// GetNetworkInterfaces returns the network interfaces for the
	// named virtual machine.
	GetNetworkInterfaces(name string) ([]vm.NetworkInterface, error)

	// UseCloudInit informs if the provider supports cloud-init.
	UseCloudInit() bool

	// Networking returns the interface to the networking subsystem
	Networking() (net.Net, error)

	// Fingerprint returns fingerprint attributes for the provider
	Fingerprint() (map[string]*structs.Attribute, error)

	// SetupStorage prepares the configured storage pools for usage
	SetupStorage(config *storage.Config) error

	// Storage returns the storage interface
	Storage() storage.Storage

	// GenerateMountCommands generates the commands required to mount
	// the provided mount configurations in the virtual machine.
	GenerateMountCommands([]*vm.MountFileConfig) ([]string, error)

	VMGetter
}

Provider is the interface that defins the virtualization system.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL