simple_automation.transaction.ActiveTransaction

class simple_automation.transaction.ActiveTransaction

Bases: object

Represents a transaction on a remote host. Transactions are operational units, which alter the state of a remote from an initial state A to a known target state. When they begin, they must examine the initial state, and transition the remote into the target state. This possible state change will be presented to the user.

Methods

extra_info

Purely extraneous information that will be shown additionally to the user.

failure

Completes the transaction, marking it as failed with the given reason.

final_state

Records the (expected) final state of the remote.

finalize

Finalizes this transaction, which will verify that all states are set corectly, and print the transaction.

initial_state

Records the observed initial state of the remote.

success

Completes the transaction with successful status.

unchanged

Sets the final state to the initial state and returns success(**kwargs).

extra_info(**kwargs)

Purely extraneous information that will be shown additionally to the user.

Parameters

**kwargs – Extra information assocations

failure(reason, set_final_state=False, **kwargs)

Completes the transaction, marking it as failed with the given reason. If reason is a RemoteExecError, additional information will be printed.

Parameters
  • reason (str) – The reason for the failure.

  • set_final_state (bool) – If true, the final transaction state will be set. Defaults to false.

  • **kwargs – Final state assocations

Returns

The completed transaction.

Return type

CompletedTransaction

final_state(**kwargs)

Records the (expected) final state of the remote.

Parameters

**kwargs – Final state assocations

finalize(context, transaction)

Finalizes this transaction, which will verify that all states are set corectly, and print the transaction.

Parameters
  • context (Context) – The associated context.

  • transaction (Transaction) – The transaction that should be finalized.

initial_state(**kwargs)

Records the observed initial state of the remote.

Parameters

**kwargs – Initial state assocations

success(**kwargs)

Completes the transaction with successful status.

Parameters

**kwargs – Final state assocations

Returns

The completed transaction.

Return type

CompletedTransaction

unchanged(**kwargs)

Sets the final state to the initial state and returns success(**kwargs).

Parameters

**kwargs – Final state assocations

Returns

The completed transaction.

Return type

CompletedTransaction