Bases: exceptions.Exception
Exception raised when a signal is ignored.
Resource subclasses should raise this exception from handle_signal() to suppress recording of an event corresponding to the signal.
Bases: exceptions.Exception
Exception to delay polling of the resource.
This exception may be raised by a Resource subclass’s check_*_complete() methods to indicate that it need not be polled again immediately. If this exception is raised, the check_*_complete() method will not be called again until the nth time that the resource becomes eligible for polling. A PollDelay period of 1 is equivalent to returning False.
Bases: object
For the intrinsic function Fn::Base64.
Parameters: | data – the input data. |
---|---|
Returns: | the Base64 representation of the input data. |
For the intrinsic function Fn::GetAtt.
Parameters: |
|
---|---|
Returns: | the attribute value. |
For the intrinsic function get_attr which returns all attributes.
Returns: | dict of all resource’s attributes exclude “show” attribute. |
---|
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.
Add implicit dependencies specific to the resource type.
Some resource types may have implicit dependencies on other resources in the same stack that are not linked by a property value (that would be set using get_resource or get_attr for example, thus creating an explicit dependency). Such dependencies are opaque to the user and should be avoided wherever possible, however in some circumstances they are required due to magic in the underlying API.
The deps parameter is a Dependencies object to which dependency pairs may be added.
Add all dependencies explicitly specified in the template.
The deps parameter is a Dependencies object to which dependency pairs are added.
Adopt the existing resource.
Resource subclasses can provide a handle_adopt() method to customise adopt.
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 the resource.
Subclasses should provide a handle_create() method to customise creation.
Creates the resource by invoking the scheduler TaskRunner.
Return the 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. |
---|
Remove a key from the resource data.
Returns: | True if the key existed to delete. |
---|
A task to delete the resource.
Subclasses should provide a handle_delete() method to customise deletion.
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.
Default implementation for function get_attr and Fn::GetAtt.
This may be overridden by resource plugins to add extra logic specific to the resource implementation.
Default implementation; can be overridden by resources.
Get resource data and handle it with exceptions.
Default implementation; should be overridden by resources.
Parameters: | resource_properties – resource’s object of Properties class. |
---|---|
Returns: | dict of resource’s real state of properties. |
Default implementation for function get_resource.
This may be overridden by resource plugins to add extra logic specific to the resource implementation.
Default implementation; should be overridden by resources.
Now we override this method to reset the metadata for scale-policy and scale-group resources, because their metadata might hang in a wrong state (‘scaling_in_progress’ is always True) if engine restarts while scaling.
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”.
Return True if the resource has an existing nested stack.
For most resource types, this will always return False. StackResource subclasses return True when appropriate. Resource subclasses that may return True must also provide a nested_identifier() method to return the identifier of the nested stack, and a nested() method to return a Stack object for the nested stack.
Write new metadata to the database.
The caller may optionally provide a merge_metadata() function, which takes two arguments - the metadata passed to metadata_set() and the current metadata of the resource - and returns the merged metadata to write. If merge_metadata is not provided, the metadata passed to metadata_set() is written verbatim, overwriting any existing metadata.
If a race condition is detected, the write will be retried with the new result of merge_metadata() (if it is supplied) or the verbatim data (if it is not).
No-op for resources which don’t explicitly override this method.
Needs replace based on prop_diff.
Default implementation; can be overridden by resources.
Parse resource data for using it in updating properties with live state. :param resource_properties: properties of stored resource plugin. :param resource_data: data from current live state of a resource.
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.
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.
Default implementation of Resource.preview.
This method should be overridden by child classes for specific behavior.
Simulates update without actually updating the resource.
Raises UpdateReplace, if replacement is required or returns True, if in-place update is required.
Reduce length of physical resource name to a limit.
The reduced name will consist of the following:
Parameters: |
|
---|---|
Returns: | A name whose length is less than or equal to the limit |
Default implementation; should be overridden by resources.
Should be overridden by resources that would require schema refresh during update, ex. TemplateResource.
Definition: | Resource Definition |
---|
Reparse the resource properties.
Optional translate flag for property translation and client_resolve flag for resolving properties by doing client lookup.
List of resources that require this one as a dependency.
Returns a list of names of resources that depend on this resource directly.
Generate a provider template that mirrors the resource.
Parameters: |
|
---|---|
Returns: | A template where the resource’s properties_schema is mapped as parameters, and the resource’s attributes_schema is mapped as outputs |
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.
Return a task to resume the resource.
Subclasses should provide a handle_resume() method to implement resume.
Signal the resource.
Returns True if the metadata for all resources in the stack needs to be regenerated as a result of the signal, False if it should not be.
Subclasses should provide a handle_signal() method to implement the signal. The base-class raise an exception if no handler is implemented.
Return a task to suspend the resource.
Subclasses should provide a handle_suspend() method to implement suspend.
Translates properties with resource specific rules.
The properties parameter is a properties object and the optional client_resolve flag is to specify whether to do ‘RESOLVE’ translation with client lookup.
Return a task to update the resource.
Subclasses should provide a handle_update() method to customise update, the base-class handle_update will fail by default.
Update the resource synchronously.
Persist the resource’s current_template_id to template_id and resource’s requires to list of the required resource ids from the given resource_data and existing resource’s requires, then updates the resource by invoking the scheduler TaskRunner.
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.
Return 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.