ironic_python_agent.extensions.base module

class ironic_python_agent.extensions.base.AgentCommandStatus[source]

Bases: object

Mapping of agent command statuses.

FAILED = 'FAILED'
RUNNING = 'RUNNING'
SUCCEEDED = 'SUCCEEDED'
VERSION_MISMATCH = 'CLEAN_VERSION_MISMATCH'
class ironic_python_agent.extensions.base.AsyncCommandResult(command_name, command_params, execute_method, agent=None)[source]

Bases: BaseCommandResult

A command that executes asynchronously in the background.

is_done()[source]

Checks to see if command is still RUNNING.

Returns:

True if command is done, False if still RUNNING

join(timeout=None)[source]

Block until command has completed, and return result.

Parameters:

timeout – float indicating max seconds to wait for command to complete. Defaults to None.

run()[source]

Run a command.

serialize()[source]

Serializes the AsyncCommandResult into a dict.

Returns:

dict containing serializable fields in AsyncCommandResult

start()[source]

Begin background execution of command.

class ironic_python_agent.extensions.base.BaseAgentExtension(agent=None)[source]

Bases: object

check_cmd_presence(ext_obj, ext, cmd)[source]
execute(command_name, **kwargs)[source]
class ironic_python_agent.extensions.base.BaseCommandResult(command_name, command_params)[source]

Bases: SerializableComparable

Base class for command result.

is_done()[source]

Checks to see if command is still RUNNING.

Returns:

True if command is done, False if still RUNNING

join()[source]
Returns:

result of completed command.

serializable_fields = ('id', 'command_name', 'command_status', 'command_error', 'command_result')
wait()[source]

Join the result and extract its value.

Raises if the command failed.

class ironic_python_agent.extensions.base.ExecuteCommandMixin[source]

Bases: object

execute_command(command_name, **kwargs)[source]

Execute an agent command.

get_extension(extension_name)[source]
split_command(command_name)[source]
class ironic_python_agent.extensions.base.SyncCommandResult(command_name, command_params, success, result_or_error)[source]

Bases: BaseCommandResult

A result from a command that executes synchronously.

ironic_python_agent.extensions.base.async_command(command_name, validator=None)[source]

Will run the command in an AsyncCommandResult in its own thread.

command_name is set based on the func name and command_params will be whatever args/kwargs you pass into the decorated command. Return values of type str or unicode are prefixed with the command_name parameter when returned for consistency.

ironic_python_agent.extensions.base.get_extension(name)[source]
ironic_python_agent.extensions.base.init_ext_manager(agent)[source]
ironic_python_agent.extensions.base.sync_command(command_name, validator=None)[source]

Decorate a method to wrap its return value in a SyncCommandResult.

For consistency with @async_command() can also accept a validator which will be used to validate input, although a synchronous command can also choose to implement validation inline.