labgrid.strategy package

Submodules

labgrid.strategy.bareboxstrategy module

class labgrid.strategy.bareboxstrategy.Status(value)[source]

Bases: enum.Enum

An enumeration.

unknown = 0
off = 1
barebox = 2
shell = 3
__module__ = 'labgrid.strategy.bareboxstrategy'
class labgrid.strategy.bareboxstrategy.BareboxStrategy(target, name, status=Status.unknown)[source]

Bases: labgrid.strategy.common.Strategy

BareboxStrategy - Strategy to switch to barebox or shell

bindings: Dict[str, Any] = {'barebox': 'BareboxDriver', 'console': 'ConsoleProtocol', 'power': 'PowerProtocol', 'shell': 'ShellDriver'}
__attrs_post_init__()[source]
transition(status, *, step)[source]
__attrs_attrs__ = (Attribute(name='target', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='name', default=NOTHING, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='state', default=<BindingState.idle: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=False, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='status', default=<Status.unknown: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None))
__init__(target, name, status=Status.unknown) None

Method generated by attrs for class BareboxStrategy.

__module__ = 'labgrid.strategy.bareboxstrategy'
__repr__()

Method generated by attrs for class BareboxStrategy.

labgrid.strategy.common module

exception labgrid.strategy.common.StrategyError(msg)[source]

Bases: Exception

__attrs_attrs__ = (Attribute(name='msg', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None),)
__init__(msg) None

Method generated by attrs for class StrategyError.

__module__ = 'labgrid.strategy.common'
__repr__()

Method generated by attrs for class StrategyError.

__weakref__

list of weak references to the object (if defined)

class labgrid.strategy.common.Strategy(target, name)[source]

Bases: labgrid.driver.common.Driver

Represents a strategy which places a target into a requested state by calling specific drivers. A strategy usually needs to know some details of a given target.

Life cycle: - create - bind (n times) - usage

TODO: This might also be just a driver?

__attrs_post_init__()[source]
on_client_bound(client)[source]

Called by the Target after a new client has been bound

on_activate()[source]

Called by the Target when this object has been activated

on_deactivate()[source]

Called by the Target when this object has been deactivated

resolve_conflicts(client)[source]

Called by the Target to allow this object to deactivate conflicting clients.

transition(status)[source]
force(status)[source]
prepare_export()[source]

By default, export all drivers bound by the strategy.

__attrs_attrs__ = (Attribute(name='target', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='name', default=NOTHING, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='state', default=<BindingState.idle: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=False, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None))
__init__(target, name) None

Method generated by attrs for class Strategy.

__module__ = 'labgrid.strategy.common'
__repr__()

Method generated by attrs for class Strategy.

labgrid.strategy.dockerstrategy module

class labgrid.strategy.dockerstrategy.Status(value)[source]

Bases: enum.Enum

The possible states of a docker container

unknown = 0
gone = 1
accessible = 2
__module__ = 'labgrid.strategy.dockerstrategy'
class labgrid.strategy.dockerstrategy.DockerStrategy(target, name, status=Status.unknown)[source]

Bases: labgrid.strategy.common.Strategy

DockerStrategy enables the user to directly transition to a state where a fresh docker container has been created and is ready for access (e.g. shell access via SSH if the docker image runs an SSH daemon).

bindings: Dict[str, Any] = {'docker_driver': <class 'labgrid.driver.dockerdriver.DockerDriver'>}
__attrs_post_init__()[source]
transition(status)[source]
__attrs_attrs__ = (Attribute(name='target', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='name', default=NOTHING, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='state', default=<BindingState.idle: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=False, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='status', default=<Status.unknown: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None))
__init__(target, name, status=Status.unknown) None

Method generated by attrs for class DockerStrategy.

__module__ = 'labgrid.strategy.dockerstrategy'
__repr__()

Method generated by attrs for class DockerStrategy.

labgrid.strategy.graphstrategy module

exception labgrid.strategy.graphstrategy.InvalidGraphStrategyError(msg)[source]

Bases: labgrid.strategy.graphstrategy.GraphStrategyError

GraphStrategy error raised during initialization of broken strategies

__module__ = 'labgrid.strategy.graphstrategy'
exception labgrid.strategy.graphstrategy.GraphStrategyRuntimeError(msg)[source]

Bases: labgrid.strategy.graphstrategy.GraphStrategyError

GraphStrategy error raised during runtime when used in unintended ways

__module__ = 'labgrid.strategy.graphstrategy'
exception labgrid.strategy.graphstrategy.GraphStrategyError(msg)[source]

Bases: labgrid.strategy.common.StrategyError

Generic GraphStrategy error

__module__ = 'labgrid.strategy.graphstrategy'
class labgrid.strategy.graphstrategy.GraphStrategy(target, name)[source]

Bases: labgrid.strategy.common.Strategy

__attrs_post_init__()[source]
invalidate()[source]

Marks the path to the current state as out-of-date. Subsequent transition() calls will start from the root state. Will be called if exceptions in state methods occur.

transition(state, via=None)[source]

Computes the path from root state (via “via” state, if given) to given state. If the computed path is fully incremental to the path executed previously, only the state’s methods relative to the previous path are executed. Otherwise all states’ methods of the computed path (starting from the root node) are executed.

find_abs_path(state, via=None)[source]

Computes the absolute path from the root state, via “via” (if given), to the given state.

find_rel_path(path)[source]

If the given path is fully incremental to the path executed before, returns the path relative to the previously executed one. Otherwise the given path is returned.

property graph

Returns a graphviz.Digraph for the directed graph the inerhiting strategy represents.

The graph can be rendered with: mystrategy.graph.render("filename") # renders to filename.png

classmethod depends(*dependencies)[source]

@depends decorator used to list states the decorated state directly depends on.

__module__ = 'labgrid.strategy.graphstrategy'

labgrid.strategy.shellstrategy module

class labgrid.strategy.shellstrategy.Status(value)[source]

Bases: enum.Enum

An enumeration.

unknown = 0
off = 1
shell = 2
__module__ = 'labgrid.strategy.shellstrategy'
class labgrid.strategy.shellstrategy.ShellStrategy(target, name, status=Status.unknown)[source]

Bases: labgrid.strategy.common.Strategy

ShellStrategy - Strategy to switch to shell

bindings: Dict[str, Any] = {'console': 'ConsoleProtocol', 'power': 'PowerProtocol', 'shell': 'ShellDriver'}
__attrs_post_init__()[source]
transition(status, *, step)[source]
force(status, *, step)[source]
__attrs_attrs__ = (Attribute(name='target', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='name', default=NOTHING, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='state', default=<BindingState.idle: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=False, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='status', default=<Status.unknown: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None))
__init__(target, name, status=Status.unknown) None

Method generated by attrs for class ShellStrategy.

__module__ = 'labgrid.strategy.shellstrategy'
__repr__()

Method generated by attrs for class ShellStrategy.

labgrid.strategy.ubootstrategy module

class labgrid.strategy.ubootstrategy.Status(value)[source]

Bases: enum.Enum

An enumeration.

unknown = 0
off = 1
uboot = 2
shell = 3
__module__ = 'labgrid.strategy.ubootstrategy'
class labgrid.strategy.ubootstrategy.UBootStrategy(target, name, status=Status.unknown)[source]

Bases: labgrid.strategy.common.Strategy

UbootStrategy - Strategy to switch to uboot or shell

bindings: Dict[str, Any] = {'console': 'ConsoleProtocol', 'power': 'PowerProtocol', 'shell': 'ShellDriver', 'uboot': 'UBootDriver'}
__attrs_post_init__()[source]
transition(status)[source]
__attrs_attrs__ = (Attribute(name='target', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='name', default=NOTHING, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='state', default=<BindingState.idle: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=False, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=True, on_setattr=None), Attribute(name='status', default=<Status.unknown: 0>, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None))
__init__(target, name, status=Status.unknown) None

Method generated by attrs for class UBootStrategy.

__module__ = 'labgrid.strategy.ubootstrategy'
__repr__()

Method generated by attrs for class UBootStrategy.