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:
-
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
-
execute_source_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]
Execute a node relationship source operation
- Parameters:
-
-
execute_target_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]
Execute a node relationship target operation
- Parameters:
-
-
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
-
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-instance state
- Parameters:
state – The new node-instance state
- Returns:
a state-setting workflow task
-
get_state()[source]
Get the node-instance state
- Returns:
The node-instance state
-
send_event(event, additional_context=None)[source]
Sends a workflow node event.
- Parameters:
-
-
execute_operation(operation, kwargs=None, allow_kwargs_override=False, send_task_events=True)[source]
Execute a node operation
- Parameters:
-
-
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)
-
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
-
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
-
has_operation(operation_interface)[source]
-
get_relationship(target_id)[source]
Get a node relationship by its target id
-
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
-
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
-
refresh_node_instances()[source]
-
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
-
get_node(*args, **kwargs)[source]
-
get_node_instance(*args, **kwargs)[source]
-
refresh_node_instances(*args, **kwargs)[source]
-
class cloudify.workflows.workflow_context.LocalTasksProcessing(workflow_ctx, 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
-
cleanup(finished)[source]
-
get_context_logging_handler()[source]
-
get_node_logging_handler(workflow_node_instance)[source]
-
property bootstrap_context
-
get_send_task_event_func(task)[source]
-
property operation_cloudify_context
-
send_workflow_event(event_type, message=None, args=None, additional_context=None)[source]
-
download_deployment_resource(resource_path, target_path=None)[source]
-
start_deployment_modification(nodes)[source]
-
finish_deployment_modification(modification)[source]
-
rollback_deployment_modification(modification)[source]
-
list_deployment_modifications(status)[source]
-
scaling_groups()[source]
-
get_operations(graph_id)[source]
-
get_tasks_graph(execution_id, name)[source]
-
update_operation(operation_id, state, result=None, exception=None)[source]
-
store_tasks_graph(execution_id, name, operations)[source]
-
store_operation(graph_id, dependencies, id, name, type, parameters, **kwargs)[source]
-
remove_operation(operation_id)[source]
-
get_execution(execution_id)[source]
-
get_nodes()[source]
-
get_node_instances()[source]
-
get_plugin(plugin_spec)[source]
-
get_plugin_properties(deployment_id, plugin_spec)[source]
-
evaluate_plugin_properties(deployment_id, plugin_properties)[source]
-
update_node_instance(node_instance_id, version, state=None, runtime_properties=None, system_properties=None, relationships=None, force=False)[source]
-
set_deployment_attributes(deployment_id, **kwargs)[source]
-
get_deployment_update(update_id)[source]
-
set_deployment_update_attributes(update_id, **kwargs)[source]
-
get_blueprint(blueprint_id)[source]
-
get_deployment(deployment_id)[source]
-
list_nodes(**kwargs)[source]
-
list_node_instances(**kwargs)[source]
-
update_node(deployment_id, node_id, **kwargs)[source]
-
delete_node(deployment_id, node_id)[source]
-
delete_node_instance(instance_id)[source]
-
create_nodes(deployment_id, nodes)[source]
-
create_node_instances(deployment_id, node_instances)[source]
-
list_execution_schedules(**kwargs)[source]
-
update_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
create_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
get_managers()[source]
-
list_idds(**kwargs)[source]
-
update_idds(deployment_id, idds)[source]
-
start_execution(deployment_id, workflow_id, **kwargs)[source]
-
evaluate_functions(deployment_id, ctx, payload)[source]
-
class cloudify.workflows.workflow_context.RemoteContextHandler(*args, **kwargs)[source]
Bases: CloudifyWorkflowContextHandler
-
property rest_client
-
cleanup(finished)[source]
-
property bootstrap_context
-
get_send_task_event_func(task)[source]
-
send_task(*args, **kwargs)[source]
-
wait_for_result(*args, **kwargs)[source]
-
property operation_cloudify_context
-
download_deployment_resource(blueprint_id, deployment_id, tenant_name, resource_path, target_path=None)[source]
-
get_operations(graph_id)[source]
-
update_operation(operation_id, state, result=None, exception=None)[source]
-
get_tasks_graph(execution_id, name)[source]
-
store_tasks_graph(execution_id, name, operations)[source]
-
store_operation(graph_id, dependencies, id, name, type, parameters, **kwargs)[source]
-
remove_operation(operation_id)[source]
-
get_execution(execution_id)[source]
-
get_nodes()[source]
-
get_node_instances()[source]
-
get_plugin(plugin)[source]
-
get_plugin_properties(deployment_id, plugin_spec)[source]
-
update_node_instance(*args, **kwargs)[source]
-
set_deployment_attributes(deployment_id, **kwargs)[source]
-
get_deployment_update(update_id)[source]
-
set_deployment_update_attributes(update_id, **kwargs)[source]
-
get_blueprint(blueprint_id)[source]
-
get_deployment(deployment_id)[source]
-
list_nodes(**kwargs)[source]
-
list_node_instances(**kwargs)[source]
-
update_node(deployment_id, node_id, **kwargs)[source]
-
delete_node(deployment_id, node_id)[source]
-
delete_node_instance(instance_id)[source]
-
create_nodes(deployment_id, nodes)[source]
-
create_node_instances(deployment_id, node_instances)[source]
-
list_execution_schedules(**kwargs)[source]
-
update_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
create_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
get_managers()[source]
-
list_idds(**kwargs)[source]
-
update_idds(deployment_id, idds)[source]
-
get_secret(key)[source]
-
start_execution(deployment_id, workflow_id, **kwargs)[source]
-
evaluate_functions(deployment_id, ctx, payload)[source]
-
class cloudify.workflows.workflow_context.RemoteCloudifyWorkflowContextHandler(*args, **kwargs)[source]
Bases: RemoteContextHandler
-
get_node_logging_handler(workflow_node_instance)[source]
-
get_context_logging_handler()[source]
-
download_deployment_resource(resource_path, target_path=None)[source]
-
start_deployment_modification(nodes)[source]
-
finish_deployment_modification(modification)[source]
-
rollback_deployment_modification(modification)[source]
-
list_deployment_modifications(status)[source]
-
send_workflow_event(event_type, message=None, args=None, additional_context=None)[source]
-
property scaling_groups
-
class cloudify.workflows.workflow_context.LocalCloudifyWorkflowContextHandler(workflow_ctx, storage)[source]
Bases: CloudifyWorkflowContextHandler
-
get_context_logging_handler()[source]
-
get_node_logging_handler(workflow_node_instance)[source]
-
property bootstrap_context
-
get_send_task_event_func(task)[source]
-
property operation_cloudify_context
-
send_workflow_event(event_type, message=None, args=None, additional_context=None)[source]
-
download_deployment_resource(resource_path, target_path=None)[source]
-
property scaling_groups
-
get_tasks_graph(execution_id, name)[source]
-
update_operation(operation_id, state, result=None, exception=None)[source]
-
store_tasks_graph(execution_id, name, operations)[source]
-
store_operation(graph_id, dependencies, id, name, type, parameters, **kwargs)[source]
-
remove_operation(operation_id)[source]
-
get_execution(execution_id)[source]
-
get_nodes()[source]
-
get_node_instances()[source]
-
get_plugin(plugin)[source]
-
get_plugin_properties(deployment_id, plugin_spec)[source]
-
update_node_instance(*args, **kwargs)[source]
-
set_deployment_attributes(deployment_id, **kwargs)[source]
-
get_deployment_update(update_id)[source]
-
set_deployment_update_attributes(update_id, **kwargs)[source]
-
get_blueprint(blueprint_id)[source]
-
get_deployment(deployment_id)[source]
-
list_nodes(**kwargs)[source]
-
list_node_instances(**kwargs)[source]
-
update_node(deployment_id, node_id, **kwargs)[source]
-
delete_node(deployment_id, node_id)[source]
-
delete_node_instance(instance_id)[source]
-
create_nodes(deployment_id, nodes)[source]
-
create_node_instances(deployment_id, node_instances)[source]
-
list_execution_schedules(**kwargs)[source]
-
update_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
create_execution_schedule(schedule_id, deployment_id, **kwargs)[source]
-
get_managers()[source]
-
list_idds(**kwargs)[source]
-
update_idds(deployment_id, idds)[source]
-
start_execution(deployment_id, workflow_id, **kwargs)[source]
-
evaluate_functions(deployment_id, ctx, payload)[source]
-
class cloudify.workflows.workflow_context.Modification(workflow_ctx, modification)[source]
Bases: object
-
property added
- Returns:
Added and related nodes
- Return type:
ModificationNodes
-
property removed
- Returns:
Removed and related nodes
- Return type:
ModificationNodes
-
property 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: WorkflowNodesAndInstancesContainer
-
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:
Modification
-
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.
-
cloudify.workflows.workflow_context.task_config(fn=None, **arguments)[source]