heat.engine.service module¶
- class heat.engine.service.EngineListener(host, engine_id, thread_group_mgr)[source]¶
Bases:
object
Listen on an AMQP queue named for the engine.
Allows individual engines to communicate with each other for multi-engine support.
- ACTIONS = ('stop_stack', 'send')¶
- SEND = 'send'¶
- STOP_STACK = 'stop_stack'¶
- class heat.engine.service.EngineService(host, topic)[source]¶
Bases:
oslo_service.service.ServiceBase
Manages the running instances from creation to destruction.
All the methods in here are called from the RPC backend. This is all done dynamically so if a call is made via RPC that does not have a corresponding method here, an exception will be thrown when it attempts to call into this class. Arguments to these methods are also dynamically added and will be named as keyword arguments by the RPC caller.
- RPC_API_VERSION = '1.36'¶
- abandon_stack(cnxt, stack_identity, abandon=True)[source]¶
Abandon a given stack.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to abandon.
abandon – Delete Heat stack but not physical resources.
- authenticated_to_backend(cnxt)[source]¶
Validate the credentials in the RPC context.
Verify that the credentials in the RPC context are valid for the current cloud backend.
- count_stacks(cnxt, filters=None, tenant_safe=True, show_deleted=False, show_nested=False, show_hidden=False, tags=None, tags_any=None, not_tags=None, not_tags_any=None)[source]¶
Return the number of stacks that match the given filters.
- Parameters
cnxt – RPC context.
filters – a dict of ATTR:VALUE to match against stacks
tenant_safe – DEPRECATED, if true, scope the request by the current tenant
show_deleted – if true, count will include the deleted stacks
show_nested – if true, count will include nested stacks
show_hidden – if true, count will include hidden stacks
tags – count stacks containing these tags. If multiple tags are passed, they will be combined using the boolean AND expression
tags_any – count stacks containing these tags. If multiple tags are passed, they will be combined using the boolean OR expression
not_tags – count stacks not containing these tags. If multiple tags are passed, they will be combined using the boolean AND expression
not_tags_any – count stacks not containing these tags. If multiple tags are passed, they will be combined using the boolean OR expression
- Returns
an integer representing the number of matched stacks
- create_software_deployment(cnxt, server_id, config_id, input_values, action, status, status_reason, stack_user_project_id, deployment_id=None)[source]¶
- create_stack(cnxt, stack_name, template, params, files, args, environment_files=None, files_container=None, owner_id=None, nested_depth=0, user_creds_id=None, stack_user_project_id=None, parent_resource_name=None, template_id=None)[source]¶
Create a new stack using the template provided.
Note that at this stage the template has already been fetched from the heat-api process if using a template-url.
- Parameters
cnxt – RPC context.
stack_name – Name of the stack you want to create.
template – Template of stack you want to create.
params – Stack Input Params
files – Files referenced from the template
args – Request parameters/args passed from API
environment_files (list or None) – optional ordered list of environment file names included in the files dict
files_container – optional swift container name
owner_id – parent stack ID for nested stacks, only expected when called from another heat-engine (not a user option)
nested_depth – the nested depth for nested stacks, only expected when called from another heat-engine
user_creds_id – the parent user_creds record for nested stacks
stack_user_project_id – the parent stack_user_project_id for nested stacks
parent_resource_name – the parent resource name
template_id – the ID of a pre-stored template in the DB
- delete_stack(cnxt, stack_identity)[source]¶
Delete a given stack.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to delete.
- export_stack(cnxt, stack_identity)[source]¶
Exports the stack data json.
Intended to be used to safely retrieve the stack data before performing the abandon action.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to export.
- find_physical_resource(cnxt, physical_resource_id)[source]¶
Return an identifier for the specified resource.
- Parameters
cnxt – RPC context.
physical_resource_id – The physical resource ID to look up.
- generate_template(cnxt, type_name, template_type='cfn')[source]¶
Generate a template based on the specified type.
- Parameters
cnxt – RPC context.
type_name – Name of the resource type to generate a template for.
template_type – the template type to generate, cfn or hot.
- get_environment(cnxt, stack_identity)[source]¶
Returns the environment for an existing stack.
- Parameters
cnxt – RPC context
stack_identity – identifies the stack
- Return type
dict
- get_files(cnxt, stack_identity)[source]¶
Returns the files for an existing stack.
- Parameters
cnxt – RPC context
stack_identity – identifies the stack
- Return type
dict
- get_template(cnxt, stack_identity)[source]¶
Get the template.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to see.
- identify_stack(cnxt, stack_name)[source]¶
The full stack identifier for a single, live stack with stack_name.
- Parameters
cnxt – RPC context.
stack_name – Name or UUID of the stack to look up.
- list_events(cnxt, stack_identity, filters=None, limit=None, marker=None, sort_keys=None, sort_dir=None, nested_depth=None)[source]¶
Lists all events associated with a given stack.
It supports pagination (
limit
andmarker
), sorting (sort_keys
andsort_dir
) and filtering(filters) of the results.- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to get events for
filters – a dict with attribute:value to filter the list
limit – the number of events to list (integer or string)
marker – the ID of the last event in the previous page
sort_keys – an array of fields used to sort the list
sort_dir – the direction of the sort (‘asc’ or ‘desc’).
nested_depth – Levels of nested stacks to list events for.
- list_outputs(cntx, stack_identity)[source]¶
Get a list of stack outputs.
- Parameters
cntx – RPC context.
stack_identity – Name of the stack you want to see.
- Returns
list of stack outputs in defined format.
- list_resource_types(cnxt, support_status=None, type_name=None, heat_version=None, with_description=False)[source]¶
Get a list of supported resource types.
- Parameters
cnxt – RPC context.
support_status – Support status of resource type
type_name – Resource type’s name (regular expression allowed)
heat_version – Heat version
with_description – Either return resource type description or not
- list_stack_resources(cnxt, stack_identity, nested_depth=0, with_detail=False, filters=None)[source]¶
- list_stacks(cnxt, limit=None, marker=None, sort_keys=None, sort_dir=None, filters=None, tenant_safe=True, show_deleted=False, show_nested=False, show_hidden=False, tags=None, tags_any=None, not_tags=None, not_tags_any=None)[source]¶
Returns attributes of all stacks.
It supports pagination (
limit
andmarker
), sorting (sort_keys
andsort_dir
) and filtering (filters
) of the results.- Parameters
cnxt – RPC context
limit – the number of stacks to list (integer or string)
marker – the ID of the last item in the previous page
sort_keys – an array of fields used to sort the list
sort_dir – the direction of the sort (‘asc’ or ‘desc’)
filters – a dict with attribute:value to filter the list
tenant_safe – DEPRECATED, if true, scope the request by the current tenant
show_deleted – if true, show soft-deleted stacks
show_nested – if true, show nested stacks
show_hidden – if true, show hidden stacks
tags – show stacks containing these tags. If multiple tags are passed, they will be combined using the boolean AND expression
tags_any – show stacks containing these tags. If multiple tags are passed, they will be combined using the boolean OR expression
not_tags – show stacks not containing these tags. If multiple tags are passed, they will be combined using the boolean AND expression
not_tags_any – show stacks not containing these tags. If multiple tags are passed, they will be combined using the boolean OR expression
- Returns
a list of formatted stacks
- preview_stack(cnxt, stack_name, template, params, files, args, environment_files=None, files_container=None)[source]¶
Simulate a new stack using the provided template.
Note that at this stage the template has already been fetched from the heat-api process if using a template-url.
- Parameters
cnxt – RPC context.
stack_name – Name of the stack you want to create.
template – Template of stack you want to create.
params – Stack Input Params
files – Files referenced from the template
args – Request parameters/args passed from API
environment_files (list or None) – optional ordered list of environment file names included in the files dict
files_container – optional swift container name
- preview_update_stack(cnxt, stack_identity, template, params, files, args, environment_files=None, files_container=None)[source]¶
Shows the resources that would be updated.
The preview_update_stack method shows the resources that would be changed with an update to an existing stack based on the provided template and parameters. See update_stack for description of parameters.
This method cannot guarantee that an update will have the actions specified because resource plugins can influence changes/replacements at runtime.
Note that at this stage the template has already been fetched from the heat-api process if using a template-url.
- resource_mark_unhealthy(cnxt, stack_identity, resource_name, mark_unhealthy, resource_status_reason=None)[source]¶
Mark the resource as healthy or unhealthy.
Put the resource in CHECK_FAILED state if ‘mark_unhealthy’ is true. Put the resource in CHECK_COMPLETE if ‘mark_unhealthy’ is false and the resource is in CHECK_FAILED state. Otherwise, make no change.
- Parameters
resource_name – either the logical name of the resource or the physical resource ID.
mark_unhealthy – indicates whether the resource is unhealthy.
resource_status_reason – reason for health change.
- resource_schema(cnxt, type_name, with_description=False)[source]¶
Return the schema of the specified type.
- Parameters
cnxt – RPC context.
type_name – Name of the resource type to obtain the schema of.
with_description – Return result with description or not.
- resource_signal(cnxt, stack_identity, resource_name, details, sync_call=False)[source]¶
Calls resource’s signal for the specified resource.
- Parameters
sync_call – indicates whether a synchronized call behavior is expected. This is reserved for CFN WaitCondition implementation.
- show_output(cntx, stack_identity, output_key)[source]¶
Returns dict with specified output key, value and description.
- Parameters
cntx – RPC context.
stack_identity – Name of the stack you want to see.
output_key – key of desired stack output.
- Returns
dict with output key, value and description in defined format.
- show_stack(cnxt, stack_identity, resolve_outputs=True)[source]¶
Return detailed information about one or all stacks.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to show, or None to show all
resolve_outputs – If True, outputs for given stack/stacks will be resolved
- stack_cancel_update(cnxt, stack_identity, cancel_with_rollback=True)[source]¶
Cancel currently running stack update.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack for which to cancel update.
cancel_with_rollback – Force rollback when cancel update.
- update_software_deployment(cnxt, deployment_id, config_id, input_values, output_values, action, status, status_reason, updated_at)[source]¶
- update_stack(cnxt, stack_identity, template, params, files, args, environment_files=None, files_container=None, template_id=None)[source]¶
Update an existing stack based on the provided template and params.
Note that at this stage the template has already been fetched from the heat-api process if using a template-url.
- Parameters
cnxt – RPC context.
stack_identity – Name of the stack you want to create.
template – Template of stack you want to create.
params – Stack Input Params
files – Files referenced from the template
args – Request parameters/args passed from API
environment_files (list or None) – optional ordered list of environment file names included in the files dict
files_container – optional swift container name
template_id – the ID of a pre-stored template in the DB
- validate_template(cnxt, template, params=None, files=None, environment_files=None, files_container=None, show_nested=False, ignorable_errors=None)[source]¶
Check the validity of a template.
Checks, so far as we can, that a template is valid, and returns information about the parameters suitable for producing a user interface through which to specify the parameter values.
- Parameters
cnxt – RPC context.
template – Template of stack you want to create.
params – Stack Input Params
files – Files referenced from the template
environment_files (list or None) – optional ordered list of environment file names included in the files dict
files_container – optional swift container name
show_nested – if True, any nested templates will be checked
ignorable_errors – List of error_code to be ignored as part of validation
- class heat.engine.service.ThreadGroupManager[source]¶
Bases:
object
- add_timer(stack_id, func, *args, **kwargs)[source]¶
Define a periodic task in the stack threadgroups.
The task is run in a separate greenthread.
Periodicity is cfg.CONF.periodic_interval
- start_with_acquired_lock(stack, lock, func, *args, **kwargs)[source]¶
Run the given method in a sub-thread with an existing stack lock.
Release the provided lock when the thread finishes.
- Parameters
stack (heat.engine.parser.Stack) – Stack to be operated on
lock (heat.engine.stack_lock.StackLock) – The acquired stack lock
func (function or instancemethod) – Callable to be invoked in sub-thread
args – Args to be passed to func
kwargs – Keyword-args to be passed to func
- start_with_lock(cnxt, stack, engine_id, func, *args, **kwargs)[source]¶
Run the method in sub-thread after acquiring the stack lock.
Release the lock when the thread finishes.
- Parameters
cnxt – RPC context
stack (heat.engine.parser.Stack) – Stack to be operated on
engine_id – The UUID of the engine/worker acquiring the lock
func (function or instancemethod) – Callable to be invoked in sub-thread
args – Args to be passed to func
kwargs – Keyword-args to be passed to func.