Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EventTargetAcquired = event.Name("TargetAcquired")
EventTargetAcquired indicates that a target has been acquired for a Test
var EventTargetErr = event.Name("TargetErr")
EventTargetErr indicates that a target has encountered an error in a TestStep
var EventTargetIn = event.Name("TargetIn")
EventTargetIn indicates that a target has entered a TestStep
var EventTargetInErr = event.Name("TargetInErr")
EventTargetInErr indicates that a target has encountered an error while entering a TestStep
var EventTargetOut = event.Name("TargetOut")
EventTargetOut indicates that a target has left a TestStep
var EventTargetReleased = event.Name("TargetReleased")
EventTargetAcquired indicates that a target has been released
Functions ¶
Types ¶
type ErrPayload ¶
type ErrPayload struct {
Error string
}
ErrPayload represents the payload associated with a TargetErr event
type Locker ¶
type Locker interface { // Lock locks the specified targets. // The job ID is the owner of the lock. // This function either succeeds and locks all the requested targets, or // leaves the existing locks untouched in case of conflicts. // Locks are reentrant, locking existing locks (with the same owner) // extends the deadline. // Passing empty list of targets is allowed and is a no-op. Lock(ctx xcontext.Context, jobID types.JobID, duration time.Duration, targets []*Target) error // TryLock attempts to lock up to limit of the given targets. // The job ID is the owner of the lock. // This function attempts to lock up to limit of the given targets, // and returns a list of target IDs that it was able to lock. // This function does not return an error if it was not able to lock any targets. // Locks are reentrant, locking existing locks (with the same owner) // extends the deadline. // Passing empty list of targets is allowed and is a no-op. TryLock(ctx xcontext.Context, jobID types.JobID, duration time.Duration, targets []*Target, limit uint) ([]string, error) // Unlock unlocks the specificied targets if they are held by the given owner. // Unlock allows expired locks by the same owner but unlocking a target that wasn't locked // or that is now or has since been locked by a different owner is a failure. // Passing empty list of targets is allowed and is a no-op. Unlock(ctx xcontext.Context, jobID types.JobID, targets []*Target) error // RefreshLocks extends existing locks on the given targets for the specified duration. // This call will fail if even a single target is not currently locked by the specified job. // Passing empty list of targets is allowed and is a no-op. RefreshLocks(ctx xcontext.Context, jobID types.JobID, duration time.Duration, targets []*Target) error // Close finalizes the locker and releases resources. // No API calls must be in flight when this is invoked or afterwards. Close() error }
Locker defines an interface to lock and unlock targets. It is passed to TargetManager's Acquire and Release methods. TargetManagers are not required to lock targets, but they are allowed to. The framework will lock targets after Acquire returns, but if this fails due to a race, the job fails. Calling any of the functions with an empty list of targets is allowed and will return without error.
type LockerFactory ¶
LockerFactory is a type representing a function which builds a Locker.
type Target ¶
type Target struct { ID string `json:"ID"` FQDN string `json:"FQDN,omitempty"` PrimaryIPv4 net.IP `json:"PrimaryIPv4,omitempty"` PrimaryIPv6 net.IP `json:"PrimaryIPv6,omitempty"` // This field is reserved for TargetManager to associate any state needed to keep track of the target between Acquire and Release. // It will be serialized between server restarts. Please keep it small. TargetManagerState json.RawMessage `json:"TMS,omitempty"` }
Target represents a target to run tests on. ID is required and must be unique. This is used to identify targets, some storage plugins use it as primary key. Common choices include IDs from inventory management systems, (fully qualified) hostnames, or textual representations of IP addresses. No assumptions about the format of IDs should be made (except being unique and not empty). FQDN, PrimaryIPv4, and PrimaryIPv6 are used by plugins to contact the target, set as many as possible for maximum plugin compatibility. Plugins are generally expected to attempt contacting devices via FQDN, IPv4, and IPv6. Note there is no way to enforce this and more specialized plugins might only support a subset.
func FilterTargets ¶
FilterTargets - Filter targets from targets based on targetIDs
type TargetManager ¶
type TargetManager interface { ValidateAcquireParameters([]byte) (interface{}, error) ValidateReleaseParameters([]byte) (interface{}, error) Acquire(ctx xcontext.Context, jobID types.JobID, jobTargetManagerAcquireTimeout time.Duration, parameters interface{}, tl Locker) ([]*Target, error) Release(ctx xcontext.Context, jobID types.JobID, targets []*Target, parameters interface{}) error }
TargetManager is an interface used to acquire and release the targets to run tests on.
type TargetManagerBundle ¶
type TargetManagerBundle struct { TargetManager TargetManager AcquireParameters interface{} ReleaseParameters interface{} }
TargetManagerBundle bundles the selected TargetManager together with its acquire and release parameters based on the content of the job descriptor
type TargetManagerFactory ¶
type TargetManagerFactory func() TargetManager
TargetManagerFactory is a type representing a function which builds a TargetManager.
type TargetManagerLoader ¶
type TargetManagerLoader func() (string, TargetManagerFactory)
TargetManagerLoader is a type representing a function which returns all the needed things to be able to load a TestStep.