shovey

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2014 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package shovey provides a means for pushing jobs out to nodes to be run independently of a chef-client run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllShoveyIDs

func AllShoveyIDs() ([]string, util.Gerror)

AllShoveyIDs returns all shovey run ids.

func GetList

func GetList() []string

GetList returns a list of all shovey ids.

func ImportShovey

func ImportShovey(shoveyJSON map[string]interface{}) error

ImportShovey is used to import shovey jobs from the exported JSON dump.

func ImportShoveyRun

func ImportShoveyRun(sRunJSON map[string]interface{}) error

ImportShoveyRun is used to import shovey jobs from the exported JSON dump.

func ImportShoveyRunStream

func ImportShoveyRunStream(srStreamJSON map[string]interface{}) error

ImportShoveyRunStream is used to import shovey jobs from the exported JSON dump.

Types

type BySeq

type BySeq []*ShoveyRunStream

BySeq is a type used to sort ShoveyRunStreams.

func (BySeq) Len

func (s BySeq) Len() int

func (BySeq) Less

func (s BySeq) Less(i, j int) bool

func (BySeq) Swap

func (s BySeq) Swap(i, j int)

type Qerror

type Qerror interface {
	String() string
	Error() string
	Status() string
	SetStatus(string)
	UpNodes() []string
	DownNodes() []string
	SetUpNodes([]string)
	SetDownNodes([]string)
}

Qerror is a special error type for shovey runs.

func CastErr

func CastErr(err error) Qerror

CastErr will easily cast a different kind of error to a Qerror.

func Errorf

func Errorf(format string, a ...interface{}) Qerror

Errorf creates a new Qerror, with a formatted error string.

type Shovey

type Shovey struct {
	RunID     string        `json:"id"`
	NodeNames []string      `json:"nodes"`
	Command   string        `json:"command"`
	CreatedAt time.Time     `json:"created_at"`
	UpdatedAt time.Time     `json:"updated_at"`
	Status    string        `json:"status"`
	Timeout   time.Duration `json:"timeout"`
	Quorum    string        `json:"quorum"`
}

Shovey holds all the overall information for a shovey run common to all nodes running the command.

func AllShoveys

func AllShoveys() []*Shovey

AllShoveys returns all shovey objects on the server

func Get

func Get(runID string) (*Shovey, util.Gerror)

Get a shovey instance with the given run id.

func New

func New(command string, timeout int, quorumStr string, nodeNames []string) (*Shovey, util.Gerror)

New creates a new shovey instance.

func (*Shovey) Cancel

func (s *Shovey) Cancel() util.Gerror

Cancel cancels all ShoveyRuns associated with this shovey instance.

func (*Shovey) CancelRuns

func (s *Shovey) CancelRuns(nodeNames []string) util.Gerror

CancelRuns cancels the shovey runs given in the slice of strings with the node names to cancel jobs on.

func (*Shovey) GetNodeRuns

func (s *Shovey) GetNodeRuns() ([]*ShoveyRun, util.Gerror)

GetNodeRuns gets all of the ShoveyRuns associated with this shovey instance.

func (*Shovey) GetRun

func (s *Shovey) GetRun(nodeName string) (*ShoveyRun, util.Gerror)

GetRun gets a particular node's shovey run associated with this shovey instance.

func (*Shovey) Start

func (s *Shovey) Start() util.Gerror

Start kicks off all the shovey runs for this shovey instance.

func (*Shovey) ToJSON

func (s *Shovey) ToJSON() (map[string]interface{}, util.Gerror)

ToJSON formats a shovey instance to render as JSON for the client.

type ShoveyRun

type ShoveyRun struct {
	ID         int       `json:"-"`
	ShoveyUUID string    `json:"run_id"`
	NodeName   string    `json:"node_name"`
	Status     string    `json:"status"`
	AckTime    time.Time `json:"ack_time"`
	EndTime    time.Time `json:"end_time"`
	Error      string    `json:"error"`
	ExitStatus uint8     `json:"exit_status"`
}

ShoveyRun represents a node's shovey run.

func AllShoveyRuns

func AllShoveyRuns() []*ShoveyRun

func (*ShoveyRun) AddStreamOutput

func (sr *ShoveyRun) AddStreamOutput(output string, outputType string, seq int, isLast bool) util.Gerror

AddStreamOutput adds a chunk of output from the job to the output list on the server stored in the ShoveyRunStream objects.

func (*ShoveyRun) CombineStreamOutput

func (sr *ShoveyRun) CombineStreamOutput(outputType string, seq int) (string, util.Gerror)

CombineStreamOutput combines a ShoveyRun's output streams.

func (*ShoveyRun) GetStreamOutput

func (sr *ShoveyRun) GetStreamOutput(outputType string, seq int) ([]*ShoveyRunStream, util.Gerror)

GetStreamOutput gets all ShoveyRunStream objects associated with a ShoveyRun of the given output type.

func (*ShoveyRun) ToJSON

func (sr *ShoveyRun) ToJSON() (map[string]interface{}, util.Gerror)

ToJSON formats a ShoveyRun for marshalling as JSON.

func (*ShoveyRun) UpdateFromJSON

func (sr *ShoveyRun) UpdateFromJSON(srData map[string]interface{}) util.Gerror

UpdateFromJSON updates a ShoveyRun with the given JSON from the client.

type ShoveyRunStream

type ShoveyRunStream struct {
	ShoveyUUID string
	NodeName   string
	Seq        int
	OutputType string
	Output     string
	IsLast     bool
	CreatedAt  time.Time
}

ShoveyRunStream holds a chunk of output from a shovey run.

func AllShoveyRunStreams

func AllShoveyRunStreams() []*ShoveyRunStream

Jump to

Keyboard shortcuts

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