Workflow Context

class cloudify.workflows.workflow_context.CloudifyWorkflowRelationshipInstance(ctx, node_instance, nodes_and_instances, relationship_instance)[source]

Bases: object

A node instance relationship instance

Parameters:
  • ctx – a CloudifyWorkflowContext instance
  • node_instance – a CloudifyWorkflowNodeInstance instance
  • nodes_and_instances – a WorkflowNodesAndInstancesContainer instance
  • relationship_instance – A relationship dict from a NodeInstance instance (of the rest client model)
target_id

The relationship target node id

target_node_instance

The relationship’s target node CloudifyWorkflowNodeInstance instance

relationship

The relationship object for this relationship instance

execute_source_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]

Execute a node relationship source operation

Parameters:
  • operation – The node relationship operation
  • kwargs – optional kwargs to be passed to the called operation
execute_target_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]

Execute a node relationship target operation

Parameters:
  • operation – The node relationship operation
  • kwargs – optional kwargs to be passed to the called operation
class cloudify.workflows.workflow_context.CloudifyWorkflowRelationship(ctx, node, nodes_and_instances, relationship)[source]

Bases: object

A node relationship

Parameters:
  • ctx – a CloudifyWorkflowContext instance
  • node – a CloudifyWorkflowNode instance
  • nodes_and_instances – a WorkflowNodesAndInstancesContainer instance
  • relationship – a relationship dict from a Node instance (of the rest client mode)
target_id

The relationship target node id

target_node

The relationship target node WorkflowContextNode instance

source_operations

The relationship source operations

target_operations

The relationship target operations

is_derived_from(other_relationship)[source]
Parameters:other_relationship – a string like cloudify.relationships.contained_in
class cloudify.workflows.workflow_context.CloudifyWorkflowNodeInstance(ctx, node, node_instance, nodes_and_instances)[source]

Bases: object

A plan node instance

Parameters:
  • ctx – a CloudifyWorkflowContext instance
  • node – a CloudifyWorkflowContextNode instance
  • node_instance – a NodeInstance (rest client response model)
  • nodes_and_instances – a WorkflowNodesAndInstancesContainer instance
set_state(state)[source]

Set the node state

Parameters:state – The node state
Returns:the state set
get_state()[source]

Get the node state

Returns:The node state
send_event(event, additional_context=None)[source]

Sends a workflow node event to RabbitMQ

Parameters:
  • event – The event
  • additional_context – additional context to be added to the context
execute_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]

Execute a node operation

Parameters:
  • operation – The node operation
  • kwargs – optional kwargs to be passed to the called operation
id

The node instance id

node_id

The node id (this instance is an instance of that node)

relationships

The node relationships

node

The node object for this node instance

modification

Modification enum (None, added, removed)

logger

A logger for this workflow node

contained_instances

Returns node instances directly contained in this instance (children)

get_contained_subgraph()[source]

Returns a set containing this instance and all nodes that are contained directly and transitively within it

class cloudify.workflows.workflow_context.CloudifyWorkflowNode(ctx, node, nodes_and_instances)[source]

Bases: object

A plan node instance

Parameters:
  • ctx – a CloudifyWorkflowContext instance
  • node – a Node instance (rest client response model)
  • nodes_and_instances – a WorkflowNodesAndInstancesContainer instance
id

The node id

type

The node type

type_hierarchy

The node type hierarchy

properties

The node properties

plugins_to_install

The plugins to install in this node. (Only relevant for host nodes)

host_id
host_node
number_of_instances
relationships

The node relationships

operations

The node operations

instances

The node instances

get_relationship(target_id)[source]

Get a node relationship by its target id

class cloudify.workflows.workflow_context.WorkflowNodesAndInstancesContainer(workflow_context, raw_nodes, raw_node_instances)[source]

Bases: object

nodes
get_node(node_id)[source]

Get a node by its id

Parameters:node_id – The node id
Returns:a CloudifyWorkflowNode instance for the node or None if not found
get_node_instance(node_instance_id)[source]

Get a node instance by its id

Parameters:node_instance_id – The node instance id
Returns:a CloudifyWorkflowNode instance for the node or None if not found
class cloudify.workflows.workflow_context.CloudifyWorkflowContext(ctx)[source]

Bases: cloudify.workflows.workflow_context.WorkflowNodesAndInstancesContainer

A context used in workflow operations

Parameters:ctx – a cloudify_context workflow dict
graph_mode()[source]

Switch the workflow context into graph mode

Returns:A task dependency graph instance
execution_id

The execution id

workflow_id

The workflow id

local

Is the workflow running in a local or remote context

logger

A logger for this workflow

send_event(event, event_type='workflow_stage', args=None, additional_context=None)[source]

Sends a workflow event to RabbitMQ

Parameters:
  • event – The event
  • event_type – The event type
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
update_execution_status(new_status)[source]

Updates the execution status to new_status. Note that the workflow status gets automatically updated before and after its run (whether the run succeeded or failed)

execute_task(task_name, task_queue=None, kwargs=None, node_context=None, send_task_events=True, total_retries=None, retry_interval=None)[source]

Execute a task

Parameters:
  • task_name – the task named
  • task_queue – the task queue, if None runs the task locally
  • kwargs – optional kwargs to be passed to the task
  • node_context – Used internally by node.execute_operation
local_task(local_task, node=None, info=None, kwargs=None, task_id=None, name=None, send_task_events=True, override_task_config=False, total_retries=None, retry_interval=None)[source]

Create a local workflow task

Parameters:
  • local_task – A callable implementation for the task
  • node – A node if this task is called in a node context
  • info – Additional info that will be accessed and included in log messages
  • kwargs – kwargs to pass to the local_task when invoked
  • task_id – The task id
remote_task(task, cloudify_context, task_id, send_task_events=True, total_retries=None, retry_interval=None)[source]

Create a remote workflow task

Parameters:
  • task – The underlying celery task
  • cloudify_context – A dict for creating the CloudifyContext used by the called task
  • task_id – The task id
class cloudify.workflows.workflow_context.LocalTasksProcessing(thread_pool_size=1)[source]

Bases: object

start()[source]
stop()[source]
add_task(task)[source]
class cloudify.workflows.workflow_context.CloudifyWorkflowContextHandler(workflow_ctx)[source]

Bases: object

get_context_logging_handler()[source]
get_node_logging_handler(workflow_node_instance)[source]
bootstrap_context
get_send_task_event_func(task)[source]
get_update_execution_status_task(new_status)[source]
get_send_node_event_task(workflow_node_instance, event, additional_context=None)[source]
get_send_workflow_event_task(event, event_type, args, additional_context=None)[source]
get_operation_task_queue(workflow_node_instance, operation_executor)[source]
operation_cloudify_context
get_set_state_task(workflow_node_instance, state)[source]
get_get_state_task(workflow_node_instance)[source]
send_workflow_event(event_type, message=None, args=None)[source]
download_blueprint_resource(resource_path, target_path=None)[source]
start_deployment_modification(nodes)[source]
finish_deployment_modification(modification)[source]
rollback_deployment_modification(modification)[source]
class cloudify.workflows.workflow_context.RemoteCloudifyWorkflowContextHandler(workflow_ctx)[source]

Bases: cloudify.workflows.workflow_context.CloudifyWorkflowContextHandler

get_context_logging_handler()[source]
get_node_logging_handler(workflow_node_instance)[source]
bootstrap_context
get_send_task_event_func(task)[source]
get_update_execution_status_task(new_status)[source]
get_send_node_event_task(workflow_node_instance, event, additional_context=None)[source]
get_send_workflow_event_task(event, event_type, args, additional_context=None)[source]
get_operation_task_queue(workflow_node_instance, operation_executor)[source]
operation_cloudify_context
get_set_state_task(workflow_node_instance, state)[source]
get_get_state_task(workflow_node_instance)[source]
send_workflow_event(event_type, message=None, args=None)[source]
download_blueprint_resource(resource_path, target_path=None)[source]
start_deployment_modification(nodes)[source]
finish_deployment_modification(modification)[source]
rollback_deployment_modification(modification)[source]
class cloudify.workflows.workflow_context.LocalCloudifyWorkflowContextHandler(workflow_ctx, storage)[source]

Bases: cloudify.workflows.workflow_context.CloudifyWorkflowContextHandler

get_context_logging_handler()[source]
get_node_logging_handler(workflow_node_instance)[source]
bootstrap_context
get_send_task_event_func(task)[source]
get_update_execution_status_task(new_status)[source]
get_send_node_event_task(workflow_node_instance, event, additional_context=None)[source]
get_send_workflow_event_task(event, event_type, args, additional_context=None)[source]
get_operation_task_queue(workflow_node_instance, operation_executor)[source]
operation_cloudify_context
get_set_state_task(workflow_node_instance, state)[source]
get_get_state_task(workflow_node_instance)[source]
send_workflow_event(event_type, message=None, args=None)[source]
download_blueprint_resource(resource_path, target_path=None)[source]
class cloudify.workflows.workflow_context.Modification(workflow_ctx, modification)[source]

Bases: object

added
Returns:Added and related nodes
Return type:ModificationNodes
removed
Returns:Removed and related nodes
Return type:ModificationNodes
id
finish()[source]

Finish deployment modification process

rollback()[source]

Rollback deployment modification process

class cloudify.workflows.workflow_context.ModificationNodes(modification, raw_nodes, raw_node_instances)[source]

Bases: cloudify.workflows.workflow_context.WorkflowNodesAndInstancesContainer

class cloudify.workflows.workflow_context.WorkflowDeploymentContext(cloudify_context, workflow_ctx)[source]

Bases: cloudify.context.DeploymentContext

start_modification(nodes)[source]

Start deployment modification process

Parameters:nodes – Modified nodes specification
Returns:Workflow modification wrapper
Return type:Modification
cloudify.workflows.workflow_context.task_config(fn=None, **arguments)[source]