Workflow Context¶
Cloudify workflow context
This module defines the WorkflowContext, which is available as workflow_ctx in workflow functions. The main uses of a workflow context are:
being an interface to all the data stored (in the Manager)
exposing a way to run operations
- 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)
- property type¶
The relationship type
- property source_id¶
The relationship source node-instance id
- property target_id¶
The relationship target node-instance id
- property target_node_instance¶
The relationship’s target node CloudifyWorkflowNodeInstance instance
- property relationship¶
The relationship object for this relationship instance
- 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)
- property type¶
The type of this relationship
- property target_id¶
The relationship target node id
- property target_node¶
The relationship target node WorkflowContextNode instance
- property source_operations¶
The relationship source operations
- property target_operations¶
The relationship target operations
- property properties¶
- 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-instance state
- Parameters:
state – The new node-instance state
- Returns:
a state-setting workflow task
- send_event(event, additional_context=None)[source]¶
Sends a workflow node event.
- 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
- property id¶
The node instance id
- property state¶
The node instance state
- property version¶
The node instance version
Node-instance storage uses an optimistic concurrency control approach: when updating a node-instance, also include the version that the client thinks is current (ie. this value). If the server has a more recent version, it will return an error, allowing the client to fetch the more recent version and retry.
- property node_id¶
The node id (this instance is an instance of that node)
- property relationships¶
The node relationships
- property node¶
The node object for this node instance
- property modification¶
Modification enum (None, added, removed)
- property scaling_groups¶
- property deployment_id¶
- property runtime_properties¶
The node instance runtime properties
Note that in workflow code, it is common for runtime-properties to be outdated, if a prior operation changed them. Before using this value, consider if it is up to date. You can use the refresh_node_instances method to bring all node-instance properties up to date.
- property system_properties¶
- property logger¶
A logger for this workflow node
- property contained_instances¶
Returns node instances directly contained in this instance (children)
- 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
- property id¶
The node id
- property type¶
The node type
- property type_hierarchy¶
The node type hierarchy
- property properties¶
The node properties
- property plugins_to_install¶
The plugins to install in this node. (Only relevant for host nodes)
- property plugins¶
The plugins associated with this node
- property host_id¶
- property host_node¶
- property number_of_instances¶
- property planned_number_of_instances¶
Current planned amount of instances of this node
- property relationships¶
The node relationships
- property operations¶
The node operations
- property instances¶
The node instances
- class cloudify.workflows.workflow_context.WorkflowNodesAndInstancesContainer(workflow_context, raw_nodes=None, raw_instances=None)[source]¶
Bases:
object
- property nodes¶
- property node_instances¶
- 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
- class cloudify.workflows.workflow_context.CloudifyWorkflowContext(ctx)[source]¶
Bases:
_WorkflowContextBase
A context used in workflow operations
- Parameters:
ctx – a cloudify_context workflow dict
- property nodes¶
- property node_instances¶
- class cloudify.workflows.workflow_context.LocalTasksProcessing(workflow_ctx, thread_pool_size=1)[source]¶
Bases:
object
- class cloudify.workflows.workflow_context.CloudifyWorkflowContextHandler(workflow_ctx)[source]¶
Bases:
object
- property bootstrap_context¶
- property operation_cloudify_context¶
- class cloudify.workflows.workflow_context.RemoteContextHandler(*args, **kwargs)[source]¶
Bases:
CloudifyWorkflowContextHandler
- property rest_client¶
- property bootstrap_context¶
- property operation_cloudify_context¶
- class cloudify.workflows.workflow_context.RemoteCloudifyWorkflowContextHandler(*args, **kwargs)[source]¶
Bases:
RemoteContextHandler
- property scaling_groups¶
- class cloudify.workflows.workflow_context.LocalCloudifyWorkflowContextHandler(workflow_ctx, storage)[source]¶
Bases:
CloudifyWorkflowContextHandler
- property bootstrap_context¶
- property operation_cloudify_context¶
- property scaling_groups¶
- class cloudify.workflows.workflow_context.Modification(workflow_ctx, modification)[source]¶
Bases:
object
- property added¶
- Returns:
Added and related nodes
- Return type:
- property removed¶
- Returns:
Removed and related nodes
- Return type:
- property id¶
- class cloudify.workflows.workflow_context.ModificationNodes(modification, raw_nodes, raw_node_instances)[source]¶
- class cloudify.workflows.workflow_context.WorkflowDeploymentContext(cloudify_context, workflow_ctx)[source]¶
Bases:
DeploymentContext
- start_modification(nodes)[source]¶
Start deployment modification process
- Parameters:
nodes – Modified nodes specification
- Returns:
Workflow modification wrapper
- Return type:
- list_started_modifications()[source]¶
List modifications already started (and not finished)
- Returns:
A list of workflow modification wrappers
- Return type:
list of Modification
- property scaling_groups¶
- property resource_tags¶
Resource tags associated with this deployment.