The heat.engine.resource ModuleΒΆ

class heat.engine.resource.Resource(name, definition, stack)[source]

Bases: object

ACTIONS = ('INIT', 'CREATE', 'DELETE', 'UPDATE', 'ROLLBACK', 'SUSPEND', 'RESUME', 'ADOPT', 'SNAPSHOT', 'CHECK')
ADOPT = 'ADOPT'
CHECK = 'CHECK'
COMPLETE = 'COMPLETE'
CREATE = 'CREATE'
DELETE = 'DELETE'
FAILED = 'FAILED'
FnBase64(data)[source]

For the instrinsic function Fn::Base64.

Parameters:data – the input data.
Returns:the Base64 representation of the input data.
FnGetAtt(key, *path)[source]

For the intrinsic function Fn::GetAtt.

Parameters:
  • key – the attribute key.
  • path – a list of path components to select from the attribute.
Returns:

the attribute value.

FnGetRefId()[source]

For the intrinsic function Ref.

Results:the id or name of the resource.
INIT = 'INIT'
IN_PROGRESS = 'IN_PROGRESS'
RESUME = 'RESUME'
ROLLBACK = 'ROLLBACK'
SNAPSHOT = 'SNAPSHOT'
STATUSES = ('IN_PROGRESS', 'FAILED', 'COMPLETE')
SUSPEND = 'SUSPEND'
UPDATE = 'UPDATE'
action_handler_task(action, args=, []action_prefix=None)[source]

A task to call the Resource subclass’s handler methods for an action.

Calls the handle_<ACTION>() method for the given action and then calls the check_<ACTION>_complete() method with the result in a loop until it returns True. If the methods are not provided, the call is omitted.

Any args provided are passed to the handler.

If a prefix is supplied, the handler method handle_<PREFIX>_<ACTION>() is called instead.

add_dependencies(deps)[source]
adopt(resource_data)[source]

Adopt the existing resource. Resource subclasses can provide a handle_adopt() method to customise adopt.

attributes_schema = {}
ceilometer()[source]
check()[source]

Checks that the physical resource is in its expected state

Gets the current status of the physical resource and updates the database accordingly. If check is not supported by the resource, default action is to fail and revert the resource’s status to its original state with the added message that check was not performed.

cinder()[source]
clear_hook(hook)[source]
client(name=None)[source]
client_plugin(name=None)[source]
create(*args, **kwargs)[source]

Create the resource. Subclasses should provide a handle_create() method to customise creation.

data()[source]

Resource data for this resource

Use methods data_set and data_delete to modify the resource data for this resource.

Returns:a dict representing the resource data for this resource.
data_delete(key)[source]

Remove a resource_data element associated to a resource.

Returns:True if the key existed to delete
data_set(key, value, redact=False)[source]

Save resource’s key/value pair to database.

default_client_name = None
delete(*args, **kwargs)[source]

Delete the resource. Subclasses should provide a handle_delete() method to customise deletion.

delete_snapshot(*args, **kwargs)[source]
dep_attrs(resource_name)[source]
destroy(*args, **kwargs)[source]

Delete the resource and remove it from the database.

frozen_definition()[source]
glance()[source]
handle_adopt(resource_data=None)[source]
handle_update(json_snippet=None, tmpl_diff=None, prop_diff=None)[source]
has_hook(hook)[source]
has_interface(resource_type)[source]

Check to see if this resource is either mapped to resource_type or is a “resource_type”.

heat()[source]
identifier()[source]

Return an identifier for this resource.

implementation_signature()[source]

Return a tuple defining the implementation.

This should be broken down into a definition and an implementation version.

is_using_neutron()[source]
keystone()[source]
metadata[source]

DEPRECATED. use method metadata_get instead.

metadata_get(refresh=False)[source]
metadata_set(metadata)[source]
metadata_update(new_metadata=None)[source]

No-op for resources which don’t explicitly override this method

neutron()[source]
nova()[source]
parsed_template(section=None, default=None)[source]

Return the parsed template data for the resource. May be limited to only one section of the data, in which case a default value may also be supplied.

physical_resource_name()[source]
physical_resource_name_limit = 255
physical_resource_name_or_FnGetRefId()[source]
prepare_abandon()[source]
preview()[source]

Default implementation of Resource.preview.

This method should be overridden by child classes for specific behavior.

static reduce_physical_resource_name(name, limit)[source]

Reduce length of physical resource name to a limit.

The reduced name will consist of the following:

  • the first 2 characters of the name
  • a hyphen
  • the end of the name, truncated on the left to bring the name length within the limit
Parameters:
  • name – The name to reduce the length of
  • limit – The max length limit
Returns:

A name whose length is less than or equal to the limit

regenerate_info_schema(definition)[source]

Default implementation; should be overridden by resources that would require schema refresh during update, ex. TemplateResource

Definition:Resource Definition
reparse()[source]
required_by()[source]

Returns a list of names of resources which directly require this resource as a dependency.

requires_deferred_auth = False
resource_id_set(inst)[source]
resource_priority = 1
classmethod resource_to_template(resource_type)[source]
Parameters:resource_type – The resource type to be displayed in the template
Returns:A template where the resource’s properties_schema is mapped as parameters, and the resource’s attributes_schema is mapped as outputs
resume()[source]

Resume the resource. Subclasses should provide a handle_resume() method to implement resume

rpc_client()[source]

Return a client for making engine RPC calls.

signal(details=None)[source]

signal the resource. Subclasses should provide a handle_signal() method to implement the signal, the base-class raise an exception if no handler is implemented.

snapshot()[source]

Snapshot the resource and return the created data, if any.

stack[source]
state[source]

Returns state, tuple of action, status.

state_reset()[source]

Reset state to (INIT, COMPLETE)

state_set(action, status, reason='state changed')[source]
strict_dependency = True
support_status = <heat.engine.support.SupportStatus object at 0x2b2908793f50>
suspend()[source]

Suspend the resource. Subclasses should provide a handle_suspend() method to implement suspend

swift()[source]
trigger_hook(hook)[source]
trove()[source]
type()[source]
update(*args, **kwargs)[source]

update the resource. Subclasses should provide a handle_update() method to customise update, the base-class handle_update will fail by default.

update_allowed_properties = ()
update_template_diff(after, before)[source]

Returns the difference between the before and after json snippets. If something has been removed in after which exists in before we set it to None.

update_template_diff_properties(after_props, before_props)[source]

Returns the changed Properties between the before and after properties. If any property having immutable as True is updated, raises NotSupported error. If any properties have changed which are not in update_allowed_properties, raises UpdateReplace.

validate()[source]
classmethod validate_deletion_policy(policy)[source]
exception heat.engine.resource.ResourceInError(status_reason=u'Unknown', **kwargs)[source]

Bases: heat.common.exception.HeatException

msg_fmt = u'Went to status %(resource_status)s due to "%(status_reason)s"'
exception heat.engine.resource.ResourceUnknownStatus(result=u'Resource failed', status_reason=u'Unknown', **kwargs)[source]

Bases: heat.common.exception.HeatException

msg_fmt = u'%(result)s - Unknown status %(resource_status)s due to "%(status_reason)s"'
exception heat.engine.resource.UpdateReplace(resource_name='Unknown')[source]

Bases: exceptions.Exception

Raised when resource update requires replacement.

Previous topic

The heat.engine.event Module

Next topic

The heat.engine.service_stack_watch Module

This Page