Documentation
¶
Index ¶
- Variables
- func NewPlugin(logger hclog.Logger) drivers.DriverPlugin
- type Config
- type DomainGetter
- type Emulator
- type ImageHandler
- type Net
- type OS
- type TaskConfig
- type TaskState
- type VirtDriverPlugin
- func (d *VirtDriverPlugin) Capabilities() (*drivers.Capabilities, error)
- func (d *VirtDriverPlugin) ConfigSchema() (*hclspec.Spec, error)
- func (d *VirtDriverPlugin) DestroyTask(taskID string, force bool) error
- func (d *VirtDriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (d *VirtDriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (d *VirtDriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (d *VirtDriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
- func (d *VirtDriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
- func (d *VirtDriverPlugin) SetConfig(cfg *base.Config) error
- func (d *VirtDriverPlugin) SignalTask(taskID string, signal string) error
- func (d *VirtDriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (d *VirtDriverPlugin) StopTask(taskID string, timeout time.Duration, signal string) error
- func (d *VirtDriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
- func (d *VirtDriverPlugin) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (d *VirtDriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (d *VirtDriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type Virtualizer
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Config ¶
type Config struct {
Emulator Emulator `codec:"emulator"`
DataDir string `codec:"data_dir"`
// ImagePaths is an allow-list of paths qemu is allowed to load an image from
ImagePaths []string `codec:"image_paths"`
}
Config contains configuration information for the plugin
type ImageHandler ¶
type Net ¶
type Net interface {
// Fingerprint interrogates the host system and populates the attribute
// mapping with relevant network information. Any errors performing this
// should be logged by the implementor, but not considered terminal, which
// explains the lack of error response. Each entry should use
// FingerprintAttributeKeyPrefix as a base.
Fingerprint(map[string]*structs.Attribute)
// Init performs any initialization work needed by the network sub-system
// prior to being used by the driver. This will be called when the plugin
// is set up by Nomad and should be expected to run multiple times during
// a Nomad client's lifecycle. It should therefore be idempotent. Any error
// returned is considered fatal to the plugin.
Init() error
// VMStartedBuild performs any network configuration required once the
// driver has successfully started a VM. Any error returned will be
// considered terminal to the start of the VM and therefore halt any
// further progress and result in the task being restarted.
VMStartedBuild(*net.VMStartedBuildRequest) (*net.VMStartedBuildResponse, error)
// VMTerminatedTeardown performs all the network teardown required to clean
// the host and any systems of configuration specific to the task. If an
// error is encountered, Nomad will retry the stop/kill process, so all
// implementations must be able to support this and not enter death spirals
// when an error occurs.
VMTerminatedTeardown(*net.VMTerminatedTeardownRequest) (*net.VMTerminatedTeardownResponse, error)
}
Net is the interface that defines the virtualization network sub-system. It should be the only link from the main driver and compute functionality, into the network. This helps encapsulate the logic making future development easier, even allowing for this code to be moved into its own application if desired.
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"`
// 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 TaskState ¶
type TaskState struct {
TaskConfig *drivers.TaskConfig
StartedAt time.Time
// NetTeardown is the specification used to delete all the network
// configuration associated to a VM.
NetTeardown *net.TeardownSpec
}
TaskState is the runtime state which is encoded in the handle returned to Nomad client. This information is needed to rebuild the task state and handler during recovery.
type VirtDriverPlugin ¶
type VirtDriverPlugin struct {
// contains filtered or unexported fields
}
func (*VirtDriverPlugin) Capabilities ¶
func (d *VirtDriverPlugin) Capabilities() (*drivers.Capabilities, error)
Capabilities returns the features supported by the driver.
func (*VirtDriverPlugin) ConfigSchema ¶
func (d *VirtDriverPlugin) ConfigSchema() (*hclspec.Spec, error)
ConfigSchema returns the plugin configuration schema.
func (*VirtDriverPlugin) DestroyTask ¶
func (d *VirtDriverPlugin) DestroyTask(taskID string, force bool) error
DestroyTask function cleans up and removes a task that has terminated. If force is set to true, the driver must destroy the task even if it is still running.
func (*VirtDriverPlugin) ExecTask ¶
func (d *VirtDriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
ExecTask returns the result of executing the given command inside a task. This is an optional capability, currently not supported by the virt driver.
func (*VirtDriverPlugin) Fingerprint ¶
func (d *VirtDriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
Fingerprint returns a channel that will be used to send health information and other driver specific node attributes.
func (*VirtDriverPlugin) InspectTask ¶
func (d *VirtDriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
InspectTask returns detailed status information for the referenced taskID.
func (*VirtDriverPlugin) PluginInfo ¶
func (d *VirtDriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
PluginInfo returns information describing the plugin.
func (*VirtDriverPlugin) RecoverTask ¶
func (d *VirtDriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
RecoverTask recreates the in-memory state of a task from a TaskHandle.
func (*VirtDriverPlugin) SetConfig ¶
func (d *VirtDriverPlugin) SetConfig(cfg *base.Config) error
SetConfig is called by the client to pass the configuration for the plugin.
func (*VirtDriverPlugin) SignalTask ¶
func (d *VirtDriverPlugin) SignalTask(taskID string, signal string) error
SignalTask forwards a signal to a task. This is an optional capability, currently not supported by the virt driver.
func (*VirtDriverPlugin) StartTask ¶
func (d *VirtDriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
StartTask returns a task handle and a driver network if necessary.
func (*VirtDriverPlugin) StopTask ¶
StopTask function is expected to stop a running task by sending the given signal to it. If the task does not stop during the given timeout, the driver must forcefully kill the task. StopTask does not clean up resources of the task or remove it from the driver's internal state.
func (*VirtDriverPlugin) TaskConfigSchema ¶
func (d *VirtDriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
TaskConfigSchema returns the HCL schema for the configuration of a task.
func (*VirtDriverPlugin) TaskEvents ¶
TaskEvents returns a channel that the plugin can use to emit task related events.
func (*VirtDriverPlugin) TaskStats ¶
func (d *VirtDriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
TaskStats returns a channel which the driver should send stats to at the given interval.
func (*VirtDriverPlugin) WaitTask ¶
func (d *VirtDriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
WaitTask function is expected to return a channel that will send an *ExitResult when the task exits or close the channel when the context is canceled. It is also expected that calling WaitTask on an exited task will immediately send an *ExitResult on the returned channel. A call to WaitTask after StopTask is valid and should be handled. If WaitTask is called after DestroyTask, it should return drivers.ErrTaskNotFound as no task state should exist after DestroyTask is called.