driver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2015 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinDrivers = map[string]Factory{
	"docker": NewDockerDriver,
	"exec":   NewExecDriver,
	"java":   NewJavaDriver,
	"qemu":   NewQemuDriver,
}

BuiltinDrivers contains the built in registered drivers which are available for allocation handling

Functions

func TaskEnvironmentVariables

func TaskEnvironmentVariables(ctx *ExecContext, task *structs.Task) environment.TaskEnvironment

TaskEnvironmentVariables converts exec context and task configuration into a TaskEnvironment.

Types

type DockerDriver

type DockerDriver struct {
	DriverContext
}

func (*DockerDriver) Fingerprint

func (d *DockerDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*DockerDriver) Open

func (d *DockerDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*DockerDriver) Start

func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error)

type Driver

type Driver interface {
	// Drivers must support the fingerprint interface for detection
	fingerprint.Fingerprint

	// Start is used to being task execution
	Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error)

	// Open is used to re-open a handle to a task
	Open(ctx *ExecContext, handleID string) (DriverHandle, error)
}

Driver is used for execution of tasks. This allows Nomad to support many pluggable implementations of task drivers. Examples could include LXC, Docker, Qemu, etc.

func NewDockerDriver

func NewDockerDriver(ctx *DriverContext) Driver

func NewDriver

func NewDriver(name string, ctx *DriverContext) (Driver, error)

NewDriver is used to instantiate and return a new driver given the name and a logger

func NewExecDriver

func NewExecDriver(ctx *DriverContext) Driver

NewExecDriver is used to create a new exec driver

func NewJavaDriver

func NewJavaDriver(ctx *DriverContext) Driver

NewJavaDriver is used to create a new exec driver

func NewQemuDriver

func NewQemuDriver(ctx *DriverContext) Driver

NewQemuDriver is used to create a new exec driver

type DriverContext

type DriverContext struct {
	// contains filtered or unexported fields
}

DriverContext is a means to inject dependencies such as loggers, configs, and node attributes into a Driver without having to change the Driver interface each time we do it. Used in conjection with Factory, above.

func NewDriverContext

func NewDriverContext(taskName string, config *config.Config, node *structs.Node, logger *log.Logger) *DriverContext

NewDriverContext initializes a new DriverContext with the specified fields. This enables other packages to create DriverContexts but keeps the fields private to the driver. If we want to change this later we can gorename all of the fields in DriverContext.

type DriverHandle

type DriverHandle interface {
	// Returns an opaque handle that can be used to re-open the handle
	ID() string

	// WaitCh is used to return a channel used wait for task completion
	WaitCh() chan error

	// Update is used to update the task if possible
	Update(task *structs.Task) error

	// Kill is used to stop the task
	Kill() error
}

DriverHandle is an opaque handle into a driver used for task manipulation

type ExecContext

type ExecContext struct {
	sync.Mutex

	// AllocDir contains information about the alloc directory structure.
	AllocDir *allocdir.AllocDir
}

ExecContext is shared between drivers within an allocation

func NewExecContext

func NewExecContext(alloc *allocdir.AllocDir) *ExecContext

NewExecContext is used to create a new execution context

type ExecDriver

type ExecDriver struct {
	DriverContext
}

ExecDriver fork/execs tasks using as many of the underlying OS's isolation features.

func (*ExecDriver) Fingerprint

func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*ExecDriver) Open

func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*ExecDriver) Start

func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error)

type Factory

type Factory func(*DriverContext) Driver

Factory is used to instantiate a new Driver

type JavaDriver

type JavaDriver struct {
	DriverContext
}

JavaDriver is a simple driver to execute applications packaged in Jars. It literally just fork/execs tasks with the java command.

func (*JavaDriver) Fingerprint

func (d *JavaDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*JavaDriver) Open

func (d *JavaDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*JavaDriver) Start

func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error)

type QemuDriver

type QemuDriver struct {
	DriverContext
}

QemuDriver is a driver for running images via Qemu We attempt to chose sane defaults for now, with more configuration available planned in the future

func (*QemuDriver) Fingerprint

func (d *QemuDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*QemuDriver) Open

func (d *QemuDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*QemuDriver) Start

func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error)

Run an existing Qemu image. Start() will pull down an existing, valid Qemu image and save it to the Drivers Allocation Dir

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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