Executions API¶
- class cloudify_rest_client.executions.Execution(execution)[source]¶
Bases:
dict
Cloudify workflow execution.
- KILL_CANCELLING = 'kill_cancelling'¶
- QUEUED = 'queued'¶
- SCHEDULED = 'scheduled'¶
- property id¶
- Returns:
The execution’s id.
- property deployment_id¶
- Returns:
The deployment’s id this execution is related to.
- property blueprint_id¶
- Returns:
The deployment’s main blueprint id this execution is related to.
- property status¶
- Returns:
The execution’s status.
- property status_display¶
- Returns:
The human-readable form of the execution’s status.
- property error¶
- Returns:
The execution error in a case of failure, otherwise None.
- property workflow_id¶
- Returns:
The id of the workflow this execution represents.
- property parameters¶
- Returns:
The execution’s parameters
- property is_system_workflow¶
- Returns:
True if the workflow executed is a system workflow, otherwise False
- property created_at¶
- Returns:
The execution creation time.
- property started_at¶
- Returns:
The execution start time.
- property ended_at¶
- Returns:
The execution end time.
- property created_by¶
- Returns:
The name of the execution creator.
- property scheduled_for¶
- Returns:
The time this execution is scheduled for (if any)
- property is_dry_run¶
- Returns:
True if the execution was performed as a dry run
- property total_operations¶
- Returns:
The total count of operations in this execution
- property finished_operations¶
- Returns:
The count of finished operations in this execution
- class cloudify_rest_client.executions.ExecutionGroup(group)[source]¶
Bases:
dict
- property id¶
The ID of this group
- property execution_ids¶
IDs of executions in this group
- property status¶
Status of this group, based on the status of each execution
- property deployment_group_id¶
Deployment group ID that this execution group was started from
- property workflow_id¶
The workflow that this execution group is running
- property concurrency¶
The group runs this many executions at a time
- class cloudify_rest_client.executions.ExecutionGroupsClient(api)[source]¶
Bases:
object
- create(deployment_group_id, workflow_id, executions, force=False, default_parameters=None, parameters=None, concurrency=5, created_by=None, created_at=None, id=None)[source]¶
Create an exec group without running it. Internal use only.
- start(deployment_group_id, workflow_id, force=False, default_parameters=None, parameters=None, concurrency=5)[source]¶
Start an execution group from a deployment group.
- Parameters:
deployment_group_id – start an execution for every deployment belonging to this deployment group
workflow_id – the workflow to run
force – force concurrent execution
default_parameters – default parameters for every execution
parameters – a dict of {deployment_id: params_dict}, overrides the default parameters on a per-deployment basis
concurrency – run this many executions at a time
- cancel(execution_group_id, force=False, kill=False)[source]¶
Cancel the executions in this group.
This cancels every non-queued execution according to the params, see executions.cancel for their semantics. Queued executions are marked cancelled immediately.
- set_target_group(execution_group_id, success_group=None, failed_group=None)[source]¶
Set the success or failure target group for this execution-group
Deployments that have executions in this execution-group which terminated successfully, will be added to the success group. Deployments that have executions in this execution-group which failed, will be added to the failure group. Cancelled executions have no effect.
- Parameters:
execution_group_id – ID of the execution group
success_group – ID of the target success deployment group
success_group – ID of the target failure deployment group
- Returns:
The updated ExecutionGroup
- set_concurrency(execution_group_id, concurrency)[source]¶
Change the concurrency setting of an execution-group.
This affects the de-queueing mechanism: when starting queued executions, the new concurrency setting will be used.
- Parameters:
execution_group_id – ID of the execution group
concurrency – the new concurrency setting, a natural number
- Returns:
The updated ExecutionGroup
- dump(execution_group_ids=None)[source]¶
Generate execution groups’ attributes for a snapshot.
- Parameters:
execution_group_ids – A list of execution groups’ identifiers, if not empty, used to select specific execution groups to be dumped.
- Returns:
A generator of dictionaries, which describe execution groups’ attributes.
- class cloudify_rest_client.executions.ExecutionsClient(api)[source]¶
Bases:
object
- should_start(execution_id)[source]¶
Check if an execution can currently start running (no system exeuctions / executions under the same deployment are currently running).
- Parameters:
execution_id – Id of the executions that needs to be checked.
- Returns:
Whether or not this execution can currently start
- list(_include=None, **kwargs)[source]¶
Returns a list of executions.
- Parameters:
deployment_id – Optional deployment id to get executions for.
include_system_workflows – Include executions of system workflows
_include – List of fields to include in response.
sort – Key for sorting the list.
is_descending – True for descending order, False for ascending.
kwargs – Optional filter fields. For a list of available fields see the REST service’s models.Execution.fields
- Returns:
Executions list.
- get(execution_id, _include=None)[source]¶
Get execution by its id.
- Parameters:
execution_id – Id of the execution to get.
_include – List of fields to include in response.
- Returns:
Execution.
- update(execution_id, status, error=None)[source]¶
Update execution with the provided status and optional error.
- Parameters:
execution_id – Id of the execution to update.
status – Updated execution status.
error – Updated execution error (optional).
- Returns:
Updated execution.
- start(*args, **kwargs)[source]¶
Starts a deployment’s workflow execution whose id is provided.
- Parameters:
deployment_id – The deployment’s id to execute a workflow for.
workflow_id – The workflow to be executed id.
parameters – Parameters for the workflow execution.
allow_custom_parameters – Determines whether to allow parameters which weren’t defined in the workflow parameters schema in the blueprint.
force – Determines whether to force the execution of the workflow in a case where there’s an already running execution for this deployment.
dry_run – If set to true, no actual actions will be performed. This is a dry run of the execution
queue – If set, blocked executions will be queued and automatically run when possible
schedule – A string representing the date and time this workflow should be executed at. If not passed this workflow will be executed immediately.
- Raises:
IllegalExecutionParametersError
- Returns:
The created execution.
- create(deployment_id, workflow_id, parameters=None, allow_custom_parameters=False, force=False, dry_run=False, queue=False, schedule=None, force_status=None, created_by=None, created_at=None, started_at=None, ended_at=None, execution_id=None, wait_after_fail=600, is_system_workflow=None, error=None)[source]¶
Creates an execution on a deployment. If force_status is provided, the execution will not be started. Otherwise, parameters and return value are identical to ‘start’.
- cancel(execution_id, force=False, kill=False)[source]¶
Cancels an execution.
- Parameters:
execution_id – id of the execution to cancel
force – force-cancel the execution: does not wait for the workflow function to return
kill – kill the workflow process and the operation processes
- Returns:
Cancelled execution.
- resume(execution_id, force=False)[source]¶
Resume an execution.
- Parameters:
execution_id – Id of the execution to resume.
force – Whether to resume failed/cancelled executions by retrying their failed tasks.
- Returns:
Resumed execution.
- requeue(execution_id)[source]¶
Requeue an execution (e.g. after snapshot restore).
- Parameters:
execution_id – Id of the execution to be requeued.
- Returns:
Requeued execution.
- delete(to_datetime=None, keep_last=None, **kwargs)[source]¶
Deletes finished executions from the DB.
- Parameters:
to_datetime – Until which timestamp to delete executions
keep_last – How many most recent executions to keep from deletion
kwargs – Optional filter fields. For a list of available fields see the REST service’s models.Execution.fields
- Returns:
List of deleted executions.
Parameters to_datetime and keep_last are mutually-exclusive.