Context¶
- class cloudify.context.ContextCapabilities(endpoint, instance)[source]¶
Bases: object
Maps from instance relationship target ids to their respective runtime properties
- 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
- class BootstrapContext.CloudifyAgent(cloudify_agent)[source]¶
Bases: object
Cloudify agent related bootstrap context properties.
- BootstrapContext.cloudify_agent[source]¶
Returns Cloudify agent related bootstrap context data
Return type: CloudifyAgent
- class cloudify.context.NodeInstanceContext(*args, **kwargs)[source]¶
Bases: cloudify.context.EntityContext
- runtime_properties[source]¶
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.
- class cloudify.context.RelationshipContext(relationship_context, endpoint, node)[source]¶
Bases: cloudify.context.EntityContext
Holds relationship instance data
- 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[source]¶
The node instance the operation is executed for.
This property is only relevant for NODE_INSTANCE context operations.
- node[source]¶
The node the operation is executed for.
This property is only relevant for NODE_INSTANCE context operations.
- source[source]¶
Provides access to the relationship’s operation source node and node instance.
This property is only relevant for relationship operations.
- target[source]¶
Provides access to the relationship’s operation target node and node instance.
This property is only relevant for relationship operations.
- type[source]¶
The type of this context.
Available values:
- DEPLOYMENT
- NODE_INSTANCE
- RELATIONSHIP_INSTANCE
- execution_id[source]¶
The workflow execution id the plugin invocation was requested from. This is a unique value which identifies a specific workflow execution.
- workflow_id[source]¶
The workflow id the plugin invocation was requested from. For example:
install, uninstall etc...
- operation[source]¶
The node operation name which is mapped to this task invocation. For example: cloudify.interfaces.lifecycle.start
- capabilities[source]¶
Maps from instance relationship target ids to their respective runtime properties
NOTE: This feature is deprecated, use ‘instance.relationships’ instead.
- logger[source]¶
A Cloudify context aware logger.
Use this logger in order to index logged messages in ElasticSearch using logstash.
- bootstrap_context[source]¶
System context provided during the bootstrap process
Return type: BootstrapContext
- 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.
- 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.