"""
WSGI controller for stacks resource in heat v1 API
-
+ Implements the API actions
"""
def __init__(self, options):
self.options = options
- # On valid non-error response, we add a host:port:stack prefix
- # This formats the StackId in the response more like the AWS spec
def _stackid_addprefix(self, resp):
+ """
+ Add a host:port:stack prefix, this formats the StackId in the response
+ more like the AWS spec
+ """
if 'StackId' in resp:
hostportprefix = ":".join([socket.gethostname(),
str(self.options.bind_port), "stack"])
return resp
def _format_response(self, action, response):
- '''
- Format response from engine into API format
- '''
+ """
+ Format response from engine into API format
+ """
return {'%sResponse' % action: {'%sResult' % action: response}}
def _remote_error(self, ex):
- '''
+ """
Map rpc_common.RemoteError exceptions returned by the engine
to HeatAPIException subclasses which can be used to return
properly formatted AWS error responses
- '''
+ """
if ex.exc_type == 'AttributeError':
# Attribute error, bad user data, ex.value should tell us why
return exception.HeatInvalidParameterValueError(detail=ex.value)
def list(self, req):
"""
- Returns the following information for all stacks:
+ Implements ListStacks API action
+ Lists summary information for all stacks
"""
con = req.context
parms = dict(req.params)
def describe(self, req):
"""
- Returns the following information for all stacks:
+ Implements DescribeStacks API action
+ Gets detailed information for a stack (or all stacks)
"""
con = req.context
parms = dict(req.params)
return self._format_response('DescribeStacks', res)
def _get_template(self, req):
+ """
+ Get template file contents, either from local file or URL
+ """
if 'TemplateBody' in req.params:
logger.info('TemplateBody ...')
return req.params['TemplateBody']
def create(self, req):
"""
- Returns the following information for all stacks:
+ Implements CreateStack API action
+ Create stack as defined in template file
"""
con = req.context
parms = dict(req.params)
self._stackid_addprefix(res))
def get_template(self, req):
+ """
+ Implements the GetTemplate API action
+ Get the template body for an existing stack
+ """
con = req.context
parms = dict(req.params)
return self._format_response('GetTemplate', {'TemplateBody': templ})
def estimate_template_cost(self, req):
+ """
+ Implements the EstimateTemplateCost API action
+ Get the estimated monthly cost of a template
+ """
return self._format_response('EstimateTemplateCost',
{'Url': 'http://en.wikipedia.org/wiki/Gratis'})
def validate_template(self, req):
+ """
+ Implements the ValidateTemplate API action
+ Validates the specified template
+ """
con = req.context
parms = dict(req.params)
def delete(self, req):
"""
- Returns the following information for all stacks:
+ Implements the DeleteStack API action
+ Deletes the specified stack
"""
con = req.context
parms = dict(req.params)
def events_list(self, req):
"""
- Returns the following information for all stacks:
+ Implements the DescribeStackEvents API action
+ Returns events related to a specified stack (or all stacks)
"""
con = req.context
parms = dict(req.params)
def describe_stack_resource(self, req):
"""
+ Implements the DescribeStackResource API action
Return the details of the given resource belonging to the given stack.
"""
con = req.context
def describe_stack_resources(self, req):
"""
+ Implements the DescribeStackResources API action
Return details of resources specified by the parameters.
`StackName`: returns all resources belonging to the stack
def list_stack_resources(self, req):
"""
+ Implements the ListStackResources API action
Return summary of the resources belonging to the specified stack.
-
"""
con = req.context