Welcome to cloudify-plugin-common’s documentation!

This is the API reference to the cloudify-plugins-common module which is required when writing any cloudify plugin (and workflow).

Contents:

Context

class cloudify.context.ContextCapabilities(endpoint, instance)[source]

Bases: object

Maps from instance relationship target ids to their respective runtime properties

get_all()[source]

Returns all capabilities as dict.

class cloudify.context.CommonContext(ctx=None)[source]

Bases: object

class cloudify.context.BootstrapContext(bootstrap_context)[source]

Bases: object

Holds bootstrap context that was posted to the rest service. (usually during the bootstrap process).

class PolicyEngine(policy_engine)[source]

Bases: object

Cloudify policy engine related configuration

start_timeout

Returns the number of seconds to wait for the policy engine to start

class BootstrapContext.CloudifyAgent(cloudify_agent)[source]

Bases: object

Cloudify agent related bootstrap context properties.

min_workers

Returns the minimum number of workers for agent hosts.

max_workers

Returns the maximum number of workers for agent hosts.

user

Returns the username used when SSH-ing during agent installation.

remote_execution_port

Returns the port used when SSH-ing during agent installation.

agent_key_path

Returns the path to the key file on the management machine used when SSH-ing during agent installation.

broker_ip

Returns the IP for connecting to rabbit. An empty string should result in clients using the manager IP.

broker_user

Returns the username for connecting to rabbit.

broker_pass

Returns the password for connecting to rabbit.

broker_ssl_enabled

Returns whether SSL is enabled for connecting to rabbit.

broker_ssl_cert

Returns the SSL public cert for connecting to rabbit.

BootstrapContext.cloudify_agent

Returns Cloudify agent related bootstrap context data

Return type:CloudifyAgent
BootstrapContext.policy_engine

Returns Cloudify policy engine related bootstrap context data

Return type:PolicyEngine
BootstrapContext.resources_prefix

Returns the resources prefix that was configured during bootstrap. An empty string is returned if the resources prefix was not configured.

class cloudify.context.EntityContext(context, **_)[source]

Bases: object

class cloudify.context.BlueprintContext(context, **_)[source]

Bases: cloudify.context.EntityContext

id

The blueprint id the plugin invocation belongs to.

class cloudify.context.DeploymentContext(context, **_)[source]

Bases: cloudify.context.EntityContext

id

The deployment id the plugin invocation belongs to.

class cloudify.context.NodeContext(*args, **kwargs)[source]

Bases: cloudify.context.EntityContext

id

The node’s id

name

The node’s name

properties

The node properties as dict (read-only). These properties are the properties specified in the blueprint.

type

The node’s type

type_hierarchy

The node’s type hierarchy

class cloudify.context.NodeInstanceContext(*args, **kwargs)[source]

Bases: cloudify.context.EntityContext

id

The node instance id.

runtime_properties

The node instance runtime properties as a dict (read-only).

Runtime properties are properties set during the node instance’s lifecycle. Retrieving runtime properties involves a call to Cloudify’s storage.

update()[source]

Stores new/updated runtime properties for the node instance in context in Cloudify’s storage.

This method should be invoked only if its necessary to immediately update Cloudify’s storage with changes. Otherwise, the method is automatically invoked as soon as the task execution is over.

host_ip

Returns the node instance host ip address.

This values is derived by reading the host_id from the relevant node instance and then reading its ip runtime property or its node_state ip property.

relationships

Returns a list of this instance relationships

Returns:list of RelationshipContext
Return type:list
class cloudify.context.RelationshipContext(relationship_context, endpoint, node)[source]

Bases: cloudify.context.EntityContext

Holds relationship instance data

target

Returns a holder for target node and target instance

Return type:RelationshipSubjectContext
type

The relationship type

type_hierarchy

The relationship type hierarchy

class cloudify.context.RelationshipSubjectContext(context, endpoint, modifiable)[source]

Bases: object

Holds reference to node and node instance.

Obtained in relationship operations by ctx.source and ctx.target, and by iterating instance relationships and for each relationship, reading relationship.target

class cloudify.context.CloudifyContext(ctx=None)[source]

Bases: cloudify.context.CommonContext

A context object passed to plugins tasks invocations. The context object is used in plugins when interacting with the Cloudify environment:

from cloudify import ctx

@operation
def my_start(**kwargs):
    # port is a property that was configured on the current instance's
    # node
    port = ctx.node.properties['port']
    start_server(port=port)
instance

The node instance the operation is executed for.

This property is only relevant for NODE_INSTANCE context operations.

node

The node the operation is executed for.

This property is only relevant for NODE_INSTANCE context operations.

source

Provides access to the relationship’s operation source node and node instance.

This property is only relevant for relationship operations.

target

Provides access to the relationship’s operation target node and node instance.

This property is only relevant for relationship operations.

type

The type of this context.

Available values:

  • DEPLOYMENT
  • NODE_INSTANCE
  • RELATIONSHIP_INSTANCE
execution_id

The workflow execution id the plugin invocation was requested from. This is a unique value which identifies a specific workflow execution.

workflow_id

The workflow id the plugin invocation was requested from. For example:

install, uninstall etc...
task_id

The plugin’s task invocation unique id.

task_name

The full task name of the invoked task.

task_target

The task target (celery worker name).

task_queue

The task target (celery queue name).

plugin

The plugin name of the invoked task.

operation

The current operation context.

agent
capabilities

Maps from instance relationship target ids to their respective runtime properties

NOTE: This feature is deprecated, use ‘instance.relationships’ instead.

logger

A Cloudify context aware logger.

Use this logger in order to index logged messages in ElasticSearch using logstash.

bootstrap_context

System context provided during the bootstrap process

Return type:BootstrapContext
send_event(event)[source]

Send an event to rabbitmq

Parameters:event – the event message
provider_context

Gets provider context which contains provider specific metadata.

get_resource(resource_path)[source]

Retrieves a resource bundled with the blueprint as a string.

Parameters:resource_path – the path to the resource. Note that this path is relative to the blueprint file which was uploaded.
get_resource_and_render(resource_path, template_variables=None)[source]

Like get_resource, but also renders the resource according to template_variables. This context is added to template_variables.

Parameters:template_variables – according to this dict the resource will be rendered.
download_resource(resource_path, target_path=None)[source]

Retrieves a resource bundled with the blueprint and saves it under a local file.

Parameters:
  • resource_path – the path to the resource. Note that this path is relative to the blueprint file which was uploaded.
  • target_path – optional local path (including filename) to store the resource at on the local file system. If missing, the location will be a tempfile with a generated name.
Returns:

The path to the resource on the local file system (identical to target_path parameter if used).

raises an cloudify.exceptions.HttpException

Raises:

cloudify.exceptions.HttpException on any kind of HTTP Error.

Raises:

IOError if the resource failed to be written to the local file system.

download_resource_and_render(resource_path, target_path=None, template_variables=None)[source]

Like download_resource, but also renders the resource according to template_variables. This context is added to template_variables.

Parameters:template_variables – according to this dict the resource will be rendered.
class cloudify.context.OperationContext(operation_context)[source]

Bases: object

name

The name of the operation.

retry_number

The retry number (relevant for retries and recoverable errors).

max_retries

The maximum number of retries the operation can have.

retry(message=None, retry_after=None)[source]

Specifies that this operation should be retried.

Usage:
return ctx.operation.retry(message=’...’, retry_after=1000)
:param message A text message containing information about the reason
for retrying the operation.
:param retry_after How many seconds should the workflow engine wait
before re-executing the operation.
class cloudify.context.CloudifyAgentContext(context)[source]

Bases: object

init_script(agent_config=None)[source]

Decorators

cloudify.decorators.operation(func=None, **arguments)[source]

Decorate plugin operation function with this decorator. Internally, if celery is installed, will also wrap the function with a @celery.task decorator

The ctx injected to the function arguments is of type cloudify.context.CloudifyContext

The ctx object can also be accessed by importing cloudify.ctx

Example:

from cloudify import ctx

@operations
def start(**kwargs):
    pass
cloudify.decorators.workflow(func=None, system_wide=False, **arguments)[source]

Decorate workflow functions with this decorator. Internally, if celery is installed, @workflow will also wrap the function with a @celery.task decorator

The ctx injected to the function arguments is of type cloudify.workflows.workflow_context.CloudifyWorkflowContext or cloudify.workflows.workflow_context.CloudifySystemWideWorkflowContext if system_wide flag is set to True.

The ctx object can also be accessed by importing cloudify.workflows.ctx

system_wide flag turns this workflow into a system-wide workflow that is executed by the management worker and has access to an instance of cloudify.workflows.workflow_context.CloudifySystemWideWorkflowContext as its context.

Example:

from cloudify.workflows import ctx

@workflow
def reinstall(**kwargs):
    pass
exception cloudify.decorators.RequestSystemExit[source]

Bases: exceptions.SystemExit

Exceptions

exception cloudify.exceptions.NonRecoverableError[source]

Bases: exceptions.Exception

An error raised by plugins to denote that no retry should be attempted by by the executing workflow engine.

exception cloudify.exceptions.RecoverableError(message=None, retry_after=None)[source]

Bases: exceptions.Exception

An error raised by plugins to explicitly denote that this is a recoverable error (note that this is the default behavior). It is possible specifying how many seconds should pass before a retry is attempted thus overriding the bootstrap context configuration parameter: cloudify.workflows.retry_interval

Parameters:retry_after – How many seconds should the workflow engine wait before re-executing the task the raised this exception. (only applies when the workflow engine decides that this task should be retried)
exception cloudify.exceptions.OperationRetry(message=None, retry_after=None)[source]

Bases: cloudify.exceptions.RecoverableError

An error raised internally when an operation uses the ctx.operation.retry API for specifying that an operation should be retried.

exception cloudify.exceptions.HttpException(url, code, message)[source]

Bases: cloudify.exceptions.NonRecoverableError

Wraps HTTP based exceptions that may be raised.

Parameters:
  • url – The url the request was made to.
  • code – The response status code.
  • message – The underlying reason for the error.
exception cloudify.exceptions.CommandExecutionError(command, error=None)[source]

Bases: exceptions.RuntimeError

Indicates a command failed to execute. note that this is different than the CommandExecutionException in that in this case, the command execution did not even start, and therefore there is not return code or stdout output.

Parameters:
  • command – The command executed
  • error – the error preventing the command from executing
exception cloudify.exceptions.CommandExecutionException(command, error, output, code)[source]

Bases: exceptions.Exception

Indicates a command was executed, however some sort of error happened, resulting in a non-zero return value of the process.

Parameters:
  • command – The command executed
  • code – process exit code
  • error – process stderr output
  • output – process stdout output
exception cloudify.exceptions.TimeoutException(*args)[source]

Bases: exceptions.Exception

Indicates some kind of timeout happened.

exception cloudify.exceptions.ProcessExecutionError(message, error_type=None, traceback=None)[source]

Bases: exceptions.RuntimeError

Raised by the workflow engine when workflow execution fails.

Manager

class cloudify.manager.NodeInstance(node_instance_id, node_id, runtime_properties=None, state=None, version=None, host_id=None, relationships=None)[source]

Bases: object

Represents a deployment node instance. An instance of this class contains runtime information retrieved from Cloudify’s runtime storage as well as the node’s state.

delete(key)[source]
runtime_properties

The node instance runtime properties.

To update the properties, make changes on the returned dict and call update_node_instance with the modified instance.

state

The node instance state.

To update the node instance state, change this property value and call update_node_instance with the modified instance.

node_id
relationships
cloudify.manager.get_rest_client()[source]
Returns:A REST client configured to connect to the manager in context
Return type:cloudify_rest_client.CloudifyClient
cloudify.manager.download_resource(resource_path, logger, target_path=None)[source]

Download resource from the manager file server.

Parameters:
  • resource_path – path to resource on the file server
  • logger – logger to use for info output
  • target_path – optional target path for the resource
Returns:

path to the downloaded resource

cloudify.manager.download_blueprint_resource(blueprint_id, resource_path, logger, target_path=None)[source]

Download resource from the manager file server with path relative to the blueprint denoted by blueprint_id.

Parameters:
  • blueprint_id – the blueprint id of the blueprint to download the resource from
  • resource_path – path to resource relative to blueprint folder
  • logger – logger to use for info output
  • target_path – optional target path for the resource
Returns:

path to the downloaded resource

cloudify.manager.get_resource(resource_path, base_url=None)[source]

Get resource from the manager file server.

Parameters:resource_path – path to resource on the file server
Returns:resource content
cloudify.manager.get_blueprint_resource(blueprint_id, resource_path)[source]

Get resource from the manager file server with patch relative to the blueprint denoted by blueprint_id.

Parameters:
  • blueprint_id – the blueprint id of the blueprint to download the resource from
  • resource_path – path to resource relative to blueprint folder
Returns:

resource content

cloudify.manager.get_node_instance(node_instance_id)[source]

Read node instance data from the storage.

Parameters:node_instance_id – the node instance id
Return type:NodeInstance
cloudify.manager.update_node_instance(node_instance)[source]

Update node instance data changes in the storage.

Parameters:node_instance – the node instance with the updated data
cloudify.manager.get_node_instance_ip(node_instance_id)[source]

Get the IP address of the host the node instance denoted by node_instance_id is contained in.

cloudify.manager.update_execution_status(execution_id, status, error=None)[source]

Update the execution status of the execution denoted by execution_id.

Returns:The updated status
cloudify.manager.get_bootstrap_context()[source]

Read the manager bootstrap context.

cloudify.manager.get_provider_context()[source]

Read the manager provider context.

Mocks

class cloudify.mocks.MockNodeInstanceContext(id=None, runtime_properties=None)[source]

Bases: object

id
runtime_properties
update()[source]
class cloudify.mocks.MockNodeContext(id=None, properties=None)[source]

Bases: object

id
name
properties
class cloudify.mocks.MockContext(values=None)[source]

Bases: dict

class cloudify.mocks.MockCloudifyContext(node_id=None, node_name=None, blueprint_id=None, deployment_id=None, execution_id=None, properties=None, runtime_properties=None, capabilities=None, related=None, source=None, target=None, operation=None, resources=None, provider_context=None, bootstrap_context=None)[source]

Bases: cloudify.context.CloudifyContext

Cloudify context mock that can be used when testing Cloudify plugins.

execution_id
capabilities
logger
provider_context
bootstrap_context
download_resource(resource_path, target_path=None)[source]
get_resource(resource_path)[source]

Utils

cloudify.utils.get_manager_ip()[source]

Returns the IP address of manager inside the management network.

cloudify.utils.get_manager_file_server_blueprints_root_url()[source]

Returns the blueprints root url in the file server.

cloudify.utils.get_manager_file_server_url()[source]

Returns the manager file server base url.

cloudify.utils.get_manager_rest_service_port()[source]

Returns the port the manager REST service is running on.

cloudify.utils.id_generator(size=6, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')[source]

Generate and return a random string using upper case letters and digits.

class cloudify.utils.LocalCommandRunner(logger=None, host='localhost')[source]

Bases: object

run(command, exit_on_failure=True, stdout_pipe=True, stderr_pipe=True, cwd=None, execution_env=None)[source]

Runs local commands.

Parameters:
  • command – The command to execute.
  • exit_on_failure – False to ignore failures.
  • stdout_pipe – False to not pipe the standard output.
  • stderr_pipe – False to not pipe the standard error.
  • cwd – the working directory the command will run from.
  • execution_env – dictionary of environment variables that will be present in the command scope.
Returns:

A wrapper object for all valuable info from the execution.

Return type:

cloudify.utils.CommandExecutionResponse

class cloudify.utils.CommandExecutionResponse(command, std_out, std_err, return_code)[source]

Bases: object

Wrapper object for info returned when running commands.

Parameters:
  • command – The command that was executed.
  • std_out – The output from the execution.
  • std_err – The error message from the execution.
  • return_code – The return code from the execution.
cloudify.utils.setup_default_logger(logger_name, logger_level=20, handlers=None, remove_existing_handlers=True, logger_format=None, propagate=True)
Parameters:
  • logger_name – Name of the logger.
  • logger_level – Level for the logger (not for specific handler).
  • handlers – An optional list of handlers (formatter will be overridden); If None, only a StreamHandler for sys.stdout will be used.
  • remove_existing_handlers – Determines whether to remove existing handlers before adding new ones
  • logger_format – the format this logger will have.
  • propagate – propagate the message the parent logger.
Returns:

A logger instance.

Return type:

logging.Logger

class cloudify.utils.Internal[source]

Bases: object

static get_install_method(properties)[source]
static get_broker_ssl_and_port(ssl_enabled, cert_path)[source]
static get_broker_credentials(cloudify_agent)[source]

Get broker credentials or their defaults if not set.

Logs

cloudify.logs.message_context_from_cloudify_context(ctx)[source]

Build a message context from a CloudifyContext instance

cloudify.logs.message_context_from_workflow_context(ctx)[source]

Build a message context from a CloudifyWorkflowContext instance

cloudify.logs.message_context_from_sys_wide_wf_context(ctx)[source]

Build a message context from a CloudifyWorkflowContext instance

cloudify.logs.message_context_from_workflow_node_instance_context(ctx)[source]

Build a message context from a CloudifyWorkflowNode instance

class cloudify.logs.CloudifyBaseLoggingHandler(ctx, out_func, message_context_builder)[source]

Bases: logging.Handler

A base handler class for writing log messages to RabbitMQ

flush()[source]
emit(record)[source]
class cloudify.logs.CloudifyPluginLoggingHandler(ctx, out_func=None)[source]

Bases: cloudify.logs.CloudifyBaseLoggingHandler

A handler class for writing plugin log messages to RabbitMQ

class cloudify.logs.CloudifyWorkflowLoggingHandler(ctx, out_func=None)[source]

Bases: cloudify.logs.CloudifyBaseLoggingHandler

A Handler class for writing workflow log messages to RabbitMQ

class cloudify.logs.SystemWideWorkflowLoggingHandler(ctx, out_func=None)[source]

Bases: cloudify.logs.CloudifyBaseLoggingHandler

Class for writing system-wide workflow log messages to RabbitMQ

class cloudify.logs.CloudifyWorkflowNodeLoggingHandler(ctx, out_func=None)[source]

Bases: cloudify.logs.CloudifyBaseLoggingHandler

A Handler class for writing workflow nodes log messages to RabbitMQ

cloudify.logs.init_cloudify_logger(handler, logger_name, logging_level=20)[source]

Instantiate an amqp backed logger based on the provided handler for sending log messages to RabbitMQ

Parameters:
  • handler – A logger handler based on the context
  • logger_name – The logger name
  • logging_level – The logging level
Returns:

An amqp backed logger

cloudify.logs.send_workflow_event(ctx, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a workflow event to RabbitMQ

Parameters:
  • ctx – A CloudifyWorkflowContext instance
  • event_type – The event type
  • message – The message
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
cloudify.logs.send_sys_wide_wf_event(ctx, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a workflow event to RabbitMQ

Parameters:
  • ctx – A CloudifySystemWideWorkflowContext instance
  • event_type – The event type
  • message – The message
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
cloudify.logs.send_workflow_node_event(ctx, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a workflow node event to RabbitMQ

Parameters:
  • ctx – A CloudifyWorkflowNode instance
  • event_type – The event type
  • message – The message
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
cloudify.logs.send_plugin_event(ctx, message=None, args=None, additional_context=None, out_func=None)[source]

Send a plugin event to RabbitMQ

Parameters:
  • ctx – A CloudifyContext instance
  • message – The message
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
cloudify.logs.send_task_event(cloudify_context, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a task event to RabbitMQ

Parameters:
  • cloudify_context – a __cloudify_context struct as passed to operations
  • event_type – The event type
  • message – The message
  • args – additional arguments that may be added to the message
  • additional_context – additional context to be added to the context
cloudify.logs.populate_base_item(item, message_type)[source]
cloudify.logs.amqp_event_out(event, ctx)[source]
cloudify.logs.amqp_log_out(log, ctx)[source]
cloudify.logs.stdout_event_out(event, ctx=None)[source]
cloudify.logs.stdout_log_out(log, ctx=None)[source]
cloudify.logs.create_event_message_prefix(event)[source]

Workflows

Workflow Tasks Graph

class cloudify.workflows.tasks_graph.TaskDependencyGraph(workflow_context, default_subgraph_task_config=None)[source]

Bases: object

A task graph builder

Parameters:workflow_context – A WorkflowContext instance (used for logging)
add_task(task)[source]

Add a WorkflowTask to this graph

Parameters:task – The task
get_task(task_id)[source]

Get a task instance that was inserted to this graph by its id

Parameters:task_id – the task id
Returns:a WorkflowTask instance for the requested task if found. None, otherwise.
remove_task(task)[source]

Remove the provided task from the graph

Parameters:task – The task
add_dependency(src_task, dst_task)[source]

Add a dependency between tasks. The source task will only be executed after the target task terminates. A task may depend on several tasks, in which case it will only be executed after all its ‘destination’ tasks terminate

Parameters:
  • src_task – The source task
  • dst_task – The target task
sequence()[source]
Returns:a new TaskSequence for this graph
subgraph(name)[source]
execute()[source]

Start executing the graph based on tasks and dependencies between them. Calling this method will block until one of the following occurs:

  1. all tasks terminated
  2. a task failed
  3. an unhandled exception is raised
  4. the execution is cancelled

Note: This method will raise an api.ExecutionCancelled error if the execution has been cancelled. When catching errors raised from this method, make sure to re-raise the error if it’s api.ExecutionsCancelled in order to allow the execution to be set in cancelled mode properly.

Also note that for the time being, if such a cancelling event occurs, the method might return even while there’s some operations still being executed.

tasks_iter()[source]

An iterator on tasks added to the graph

class cloudify.workflows.tasks_graph.forkjoin(*tasks)[source]

Bases: object

A simple wrapper for tasks. Used in conjunction with TaskSequence. Defined to make the code easier to read (instead of passing a list) see TaskSequence.add for more details

class cloudify.workflows.tasks_graph.TaskSequence(graph)[source]

Bases: object

Helper class to add tasks in a sequential manner to a task dependency graph

Parameters:graph – The TaskDependencyGraph instance
add(*tasks)[source]

Add tasks to the sequence.

Parameters:tasks

Each task might be:

  • A WorkflowTask instance, in which case, it will be added to the graph with a dependency between it and the task previously inserted into the sequence
  • A forkjoin of tasks, in which case it will be treated as a “fork-join” task in the sequence, i.e. all the fork-join tasks will depend on the last task in the sequence (could be fork join) and the next added task will depend on all tasks in this fork-join task
class cloudify.workflows.tasks_graph.SubgraphTask(name, graph, task_id=None, info=None, on_success=None, on_failure=None, total_retries=0, retry_interval=30, send_task_events=True)[source]

Bases: cloudify.workflows.tasks.WorkflowTask

cloudify_context
is_local()[source]
name
sequence()[source]
subgraph(name)[source]
add_task(task)[source]
add_dependency(src_task, dst_task)[source]
apply_async()[source]
task_terminated(task, new_task=None)[source]

Workflow API

cloudify.workflows.workflow_api.has_cancel_request()[source]

Checks for requests to cancel the workflow execution. This should be used to allow graceful termination of workflow executions.

If this method is not used and acted upon, a simple ‘cancel’ request for the execution will have no effect - ‘force-cancel’ will have to be used to abruptly terminate the execution instead.

Note: When this method returns True, the workflow should make the appropriate cleanups and then it must raise an ExecutionCancelled error if the execution indeed gets cancelled (i.e. if it’s too late to cancel there is no need to raise this exception and the workflow should end normally).

Returns:whether there was a request to cancel the workflow execution
exception cloudify.workflows.workflow_api.ExecutionCancelled[source]

Bases: exceptions.Exception

This exception should be raised when a workflow has been cancelled, once appropriate cleanups have taken place.

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
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
class cloudify.workflows.workflow_context.CloudifyWorkflowContext(ctx)[source]

Bases: cloudify.workflows.workflow_context._WorkflowContextBase, cloudify.workflows.workflow_context.WorkflowNodesAndInstancesContainer

A context used in workflow operations

Parameters:ctx – a cloudify_context workflow dict
class cloudify.workflows.workflow_context.CloudifySystemWideWorkflowContext(ctx)[source]

Bases: cloudify.workflows.workflow_context._WorkflowContextBase

An instance of this class gets passed as the ctx parameter to a workflow method decorated with @workflow(system_wide=True). This context is not particularly bound to any specific deployment. It provides a deployments_contexts property, which is a lazily loaded dictionary, whose keys are deployment ids and values are lazily loaded (thanks to proxy_tools.proxy) deployment contexts corresponding to those deployments. For example, in order to make use of any functionality provided by the CloudifyWorkflowContext class for a deployment “dep1”, the code should look like this:

Example:

with ctx.deployments_contexts['dep1'] as dep:
    for node_instance in dep.node_instances:
        pass
deployments_contexts
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_task(workflow_task, queue=None, target=None)[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, additional_context=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.RemoteContextHandler(workflow_ctx)[source]

Bases: cloudify.workflows.workflow_context.CloudifyWorkflowContextHandler

bootstrap_context
get_send_task_event_func(task)[source]
get_update_execution_status_task(new_status)[source]
get_send_workflow_event_task(event, event_type, args, additional_context=None)[source]
get_task(workflow_task, queue=None, target=None)[source]
operation_cloudify_context
get_set_state_task(workflow_node_instance, state)[source]
get_get_state_task(workflow_node_instance)[source]
download_blueprint_resource(blueprint_id, resource_path, target_path=None)[source]
class cloudify.workflows.workflow_context.RemoteCloudifyWorkflowContextHandler(workflow_ctx)[source]

Bases: cloudify.workflows.workflow_context.RemoteContextHandler

get_node_logging_handler(workflow_node_instance)[source]
get_context_logging_handler()[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]
send_workflow_event(event_type, message=None, args=None, additional_context=None)[source]
get_send_node_event_task(workflow_node_instance, event, additional_context=None)[source]
class cloudify.workflows.workflow_context.SystemWideWfRemoteContextHandler(workflow_ctx)[source]

Bases: cloudify.workflows.workflow_context.RemoteContextHandler

get_context_logging_handler()[source]
send_workflow_event(event_type, message=None, args=None, additional_context=None)[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_task(workflow_task, queue=None, target=None)[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, additional_context=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]

Indices and tables