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'¶
-
BASE_ATTRIBUTES
= ('show',)¶
-
CHECK
= 'CHECK'¶
-
COMPLETE
= 'COMPLETE'¶
-
CREATE
= 'CREATE'¶
-
DELETE
= 'DELETE'¶
-
FAILED
= 'FAILED'¶
-
FnBase64
(data)[source]¶ For the intrinsic 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.
-
FnGetAtts
()[source]¶ For the intrinsic function get_attr which returns all attributes.
Returns: dict of all resource’s attributes exclude “show” attribute.
-
INIT
= 'INIT'¶
-
IN_PROGRESS
= 'IN_PROGRESS'¶
-
RESUME
= 'RESUME'¶
-
ROLLBACK
= 'ROLLBACK'¶
-
SHOW
= 'show'¶
-
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 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.
-
adopt
(resource_data)[source]¶ Adopt the existing resource.
Resource subclasses can provide a handle_adopt() method to customise adopt.
-
attributes_schema
= {}¶
-
base_attributes_schema
= {'show': <heat.engine.attributes.Schema object at 0x7f9fb7e40f90>}¶
-
static
build_template_dict
(res_name, res_type, tmpl_type, params, props, outputs, description)[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.
-
create
(*args, **kwargs)[source]¶ Create the resource.
Subclasses should provide a handle_create() method to customise creation.
-
create_convergence
(template_id, resource_data, engine_id, timeout)[source]¶ Creates the resource by invoking the scheduler TaskRunner.
-
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.
-
default_client_name
= None¶
-
delete
(*args, **kwargs)[source]¶ Delete the resource.
Subclasses should provide a handle_delete() method to customise deletion.
-
delete_convergence
(template_id, input_data, engine_id, timeout)[source]¶ Destroys the resource if it doesn’t belong to given template.
The given template is suppose to be the current template being provisioned.
Also, since this resource is visited as part of clean-up phase, the needed_by should be updated. If this resource was replaced by more recent resource, then delete this and update the replacement resource’s needed_by and replaces fields.
-
entity
= None¶
-
has_interface
(resource_type)[source]¶ Check if resource is mapped to resource_type or is “resource_type”.
Check to see if this resource is either mapped to resource_type or is a “resource_type”.
-
implementation_signature
()[source]¶ Return a tuple defining the implementation.
This should be broken down into a definition and an implementation version.
-
metadata_update
(new_metadata=None)[source]¶ No-op for resources which don’t explicitly override this method.
-
no_signal_actions
= ('SUSPEND', 'DELETE')¶
-
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_limit
= 255¶
-
prepare_for_replace
()[source]¶ Prepare resource for replacing.
Some resources requires additional actions before replace them. If resource need to be changed before replacing, this method should be implemented in resource class.
-
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.
Should be overridden by resources that would require schema refresh during update, ex. TemplateResource.
Definition: Resource Definition
-
required_by
()[source]¶ List of resources’ names which require the resource as dependency.
Returns a list of resources’ names which directly require this resource as a dependency.
-
requires_deferred_auth
= False¶
-
classmethod
resource_to_template
(resource_type, template_type='cfn')[source]¶ Template where resource’s properties mapped as parameters.
Parameters: - resource_type – The resource type to be displayed in the template
- template_type – the template type to generate, cfn or hot.
Returns: A template where the resource’s properties_schema is mapped as parameters, and the resource’s attributes_schema is mapped as outputs
-
restore_after_rollback
()[source]¶ Restore resource after rollback.
Some resources requires additional actions after rollback. If resource need to be changed during rollback, this method should be implemented in resource class.
-
resume
()[source]¶ Resume the resource.
Subclasses should provide a handle_resume() method to implement resume.
-
signal
(details=None, need_check=True)[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.
-
signal_needs_metadata_updates
= True¶
-
stack
¶
-
state
¶ Returns state, tuple of action, status.
-
strict_dependency
= True¶
-
support_status
= <heat.engine.support.SupportStatus object>¶
-
suspend
()[source]¶ Suspend the resource.
Subclasses should provide a handle_suspend() method to implement suspend.
-
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_convergence
(template_id, resource_data, engine_id, timeout)[source]¶ Updates the resource.
Updates the resource by invoking the scheduler TaskRunner and it persists the resource’s current_template_id to template_id and resource’s requires to list of the required resource id from the given resource_data and existing resource’s requires.
-
update_policy_schema
= {}¶
-
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]¶ 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.
-