Files
nomad/client/driver/exec.go
Chris Bednarski d6604b9d8f Add storage fingerprinter
Breaking change: Added ID() to Fingerprint interface. This allows us to assign
each fingerprint implementation a unique ID, identify which fingerprinters have
been run, and also self-identify in log messages.

- Added storage fingerprinter for Windows and *nix
- Added storage tests under storage_test.go
- Added test helper functions under fingerprint/fingerprint_test.go
- Added ID() to existing finterprinters and drivers
- Added Fingerprint.ID() to log messages via log.SetPrefix()
2015-08-26 17:17:08 -07:00

63 lines
1.3 KiB
Go

package driver
import (
"log"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/nomad/structs"
)
// ExecDriver is the simplest possible driver. It literally just
// fork/execs tasks. It should probably not be used for most things,
// but is useful for testing purposes or for very simple tasks.
type ExecDriver struct {
id string
logger *log.Logger
}
// execHandle is returned from Start/Open as a handle to the PID
type execHandle struct {
waitCh chan error
}
// NewExecDriver is used to create a new exec driver
func NewExecDriver(logger *log.Logger) Driver {
d := &ExecDriver{
id: "driver.exec",
logger: logger,
}
return d
}
func (d *ExecDriver) ID() string {
return d.id
}
func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
// We can always do a fork/exec
node.Attributes["driver.exec"] = "1"
return true, nil
}
func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
// TODO
return nil, nil
}
func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error) {
// TODO
return nil, nil
}
func (h *execHandle) ID() string {
return "test"
}
func (h *execHandle) WaitCh() chan error {
return h.waitCh
}
func (h *execHandle) Kill() error {
return nil
}