Fix [H405] pep rule in heat/api
Implements bp docstring-improvements Change-Id: Ia482c090b3368bc0531e213365a49287bc575824
This commit is contained in:
parent
8f1ff524f8
commit
8912efaf23
@ -102,9 +102,11 @@ class EC2Token(wsgi.Middleware):
|
||||
return '%s/ec2tokens' % auth_uri
|
||||
|
||||
def _get_signature(self, req):
|
||||
"""
|
||||
Extract the signature from the request, this can be a get/post
|
||||
variable or for v4 also in a header called 'Authorization'
|
||||
"""Extract the signature from the request.
|
||||
|
||||
This can be a get/post variable or for v4 also in a header called
|
||||
'Authorization'.
|
||||
|
||||
- params['Signature'] == version 0,1,2,3
|
||||
- params['X-Amz-Signature'] == version 4
|
||||
- header 'Authorization' == version 4
|
||||
@ -117,11 +119,11 @@ class EC2Token(wsgi.Middleware):
|
||||
return sig
|
||||
|
||||
def _get_access(self, req):
|
||||
"""
|
||||
Extract the access key identifier, for v 0/1/2/3 this is passed
|
||||
as the AccessKeyId parameter, for version4 it is either and
|
||||
X-Amz-Credential parameter or a Credential= field in the
|
||||
'Authorization' header string
|
||||
"""Extract the access key identifier.
|
||||
|
||||
For v 0/1/2/3 this is passed as the AccessKeyId parameter,
|
||||
for version4 it is either and X-Amz-Credential parameter or a
|
||||
Credential= field in the 'Authorization' header string.
|
||||
"""
|
||||
access = req.params.get('AWSAccessKeyId')
|
||||
if access is None:
|
||||
@ -266,9 +268,7 @@ class EC2Token(wsgi.Middleware):
|
||||
|
||||
|
||||
def EC2Token_filter_factory(global_conf, **local_conf):
|
||||
"""
|
||||
Factory method for paste.deploy
|
||||
"""
|
||||
"""Factory method for paste.deploy."""
|
||||
conf = global_conf.copy()
|
||||
conf.update(local_conf)
|
||||
|
||||
|
@ -30,7 +30,7 @@ class HeatAPIException(webob.exc.HTTPError):
|
||||
Subclass webob HTTPError so we can correctly serialize the wsgi response
|
||||
into the http response body, using the format specified by the request.
|
||||
Note this should not be used directly, instead use the subclasses
|
||||
defined below which map to AWS API errors
|
||||
defined below which map to AWS API errors.
|
||||
"""
|
||||
|
||||
code = 400
|
||||
@ -189,7 +189,7 @@ class HeatOptInRequiredError(HeatAPIException):
|
||||
|
||||
class HeatRequestExpiredError(HeatAPIException):
|
||||
|
||||
"""Request expired or more than 15mins in the future.
|
||||
"""Request expired or more than 15 minutes in the future.
|
||||
|
||||
Request is past expires date or the request date (either with 15 minute
|
||||
padding), or the request date occurs more than 15 minutes in the future.
|
||||
|
@ -21,9 +21,7 @@ from heat.common import wsgi
|
||||
|
||||
class API(wsgi.Router):
|
||||
|
||||
"""
|
||||
WSGI router for Heat CloudFormation v1 API requests.
|
||||
"""
|
||||
"""WSGI router for Heat CloudFormation v1 API requests."""
|
||||
|
||||
_actions = {
|
||||
'list': 'ListStacks',
|
||||
|
@ -51,8 +51,6 @@ class SignalController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Signal resource factory method.
|
||||
"""
|
||||
"""Signal resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
return wsgi.Resource(SignalController(options), deserializer)
|
||||
|
@ -11,9 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Stack endpoint for Heat CloudFormation v1 API.
|
||||
"""
|
||||
"""Stack endpoint for Heat CloudFormation v1 API."""
|
||||
|
||||
import socket
|
||||
|
||||
@ -38,9 +36,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class StackController(object):
|
||||
|
||||
"""
|
||||
WSGI controller for stacks resource in Heat CloudFormation v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for stacks resource in Heat CloudFormation v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
|
||||
def __init__(self, options):
|
||||
@ -68,9 +66,9 @@ class StackController(object):
|
||||
|
||||
@staticmethod
|
||||
def _id_format(resp):
|
||||
"""
|
||||
Format the StackId field in the response as an ARN, and process other
|
||||
IDs into the correct format.
|
||||
"""Format the StackId field in the response as an ARN.
|
||||
|
||||
Also, process other IDs into the correct format.
|
||||
"""
|
||||
if 'StackId' in resp:
|
||||
identity = identifier.HeatIdentifier(**resp['StackId'])
|
||||
@ -82,8 +80,7 @@ class StackController(object):
|
||||
|
||||
@staticmethod
|
||||
def _extract_user_params(params):
|
||||
"""
|
||||
Extract a dictionary of user input parameters for the stack
|
||||
"""Extract a dictionary of user input parameters for the stack.
|
||||
|
||||
In the AWS API parameters, each user parameter appears as two key-value
|
||||
pairs with keys of the form below::
|
||||
@ -97,8 +94,7 @@ class StackController(object):
|
||||
valuename='ParameterValue')
|
||||
|
||||
def _get_identity(self, con, stack_name):
|
||||
"""
|
||||
Generate a stack identifier from the given stack name or ARN.
|
||||
"""Generate a stack identifier from the given stack name or ARN.
|
||||
|
||||
In the case of a stack name, the identifier will be looked up in the
|
||||
engine over RPC.
|
||||
@ -109,16 +105,14 @@ class StackController(object):
|
||||
return self.rpc_client.identify_stack(con, stack_name)
|
||||
|
||||
def list(self, req):
|
||||
"""
|
||||
Implements ListStacks API action
|
||||
Lists summary information for all stacks
|
||||
"""Implements ListStacks API action.
|
||||
|
||||
Lists summary information for all stacks.
|
||||
"""
|
||||
self._enforce(req, 'ListStacks')
|
||||
|
||||
def format_stack_summary(s):
|
||||
"""
|
||||
Reformat engine output into the AWS "StackSummary" format
|
||||
"""
|
||||
"""Reformat engine output into the AWS "StackSummary" format."""
|
||||
# Map the engine-api format to the AWS StackSummary datatype
|
||||
keymap = {
|
||||
rpc_api.STACK_CREATION_TIME: 'CreationTime',
|
||||
@ -154,9 +148,9 @@ class StackController(object):
|
||||
return api_utils.format_response('ListStacks', res)
|
||||
|
||||
def describe(self, req):
|
||||
"""
|
||||
Implements DescribeStacks API action
|
||||
Gets detailed information for a stack (or all stacks)
|
||||
"""Implements DescribeStacks API action.
|
||||
|
||||
Gets detailed information for a stack (or all stacks).
|
||||
"""
|
||||
self._enforce(req, 'DescribeStacks')
|
||||
|
||||
@ -172,9 +166,9 @@ class StackController(object):
|
||||
d.items()))
|
||||
|
||||
def transform(attrs):
|
||||
"""
|
||||
Recursively replace all : with . in dict keys
|
||||
so that they are not interpreted as xml namespaces.
|
||||
"""Recursively replace all : with . in dict keys.
|
||||
|
||||
After that they are not interpreted as xml namespaces.
|
||||
"""
|
||||
new = replacecolon(attrs)
|
||||
for key, value in new.items():
|
||||
@ -185,9 +179,7 @@ class StackController(object):
|
||||
return api_utils.reformat_dict_keys(keymap, transform(o))
|
||||
|
||||
def format_stack(s):
|
||||
"""
|
||||
Reformat engine output into the AWS "StackSummary" format
|
||||
"""
|
||||
"""Reformat engine output into the AWS "StackSummary" format."""
|
||||
keymap = {
|
||||
rpc_api.STACK_CAPABILITIES: 'Capabilities',
|
||||
rpc_api.STACK_CREATION_TIME: 'CreationTime',
|
||||
@ -247,9 +239,7 @@ class StackController(object):
|
||||
return api_utils.format_response('DescribeStacks', res)
|
||||
|
||||
def _get_template(self, req):
|
||||
"""
|
||||
Get template file contents, either from local file or URL
|
||||
"""
|
||||
"""Get template file contents, either from local file or URL."""
|
||||
if 'TemplateBody' in req.params:
|
||||
LOG.debug('TemplateBody ...')
|
||||
return req.params['TemplateBody']
|
||||
@ -279,14 +269,14 @@ class StackController(object):
|
||||
return self.create_or_update(req, self.UPDATE_STACK)
|
||||
|
||||
def create_or_update(self, req, action=None):
|
||||
"""
|
||||
Implements CreateStack and UpdateStack API actions.
|
||||
"""Implements CreateStack and UpdateStack API actions.
|
||||
|
||||
Create or update stack as defined in template file.
|
||||
"""
|
||||
def extract_args(params):
|
||||
"""
|
||||
Extract request parameters/arguments and reformat them to match
|
||||
the engine API. FIXME: we currently only support a subset of
|
||||
"""Extract request params and reformat them to match engine API.
|
||||
|
||||
FIXME: we currently only support a subset of
|
||||
the AWS defined parameters (both here and in the engine)
|
||||
"""
|
||||
# TODO(shardy) : Capabilities, NotificationARNs
|
||||
@ -384,8 +374,8 @@ class StackController(object):
|
||||
return api_utils.format_response(action, {})
|
||||
|
||||
def get_template(self, req):
|
||||
"""
|
||||
Implements the GetTemplate API action.
|
||||
"""Implements the GetTemplate API action.
|
||||
|
||||
Get the template body for an existing stack.
|
||||
"""
|
||||
self._enforce(req, 'GetTemplate')
|
||||
@ -405,9 +395,9 @@ class StackController(object):
|
||||
{'TemplateBody': templ})
|
||||
|
||||
def estimate_template_cost(self, req):
|
||||
"""
|
||||
Implements the EstimateTemplateCost API action
|
||||
Get the estimated monthly cost of a template
|
||||
"""Implements the EstimateTemplateCost API action.
|
||||
|
||||
Get the estimated monthly cost of a template.
|
||||
"""
|
||||
self._enforce(req, 'EstimateTemplateCost')
|
||||
|
||||
@ -418,8 +408,8 @@ class StackController(object):
|
||||
)
|
||||
|
||||
def validate_template(self, req):
|
||||
"""
|
||||
Implements the ValidateTemplate API action.
|
||||
"""Implements the ValidateTemplate API action.
|
||||
|
||||
Validates the specified template.
|
||||
"""
|
||||
self._enforce(req, 'ValidateTemplate')
|
||||
@ -443,9 +433,7 @@ class StackController(object):
|
||||
LOG.info(_LI('validate_template'))
|
||||
|
||||
def format_validate_parameter(key, value):
|
||||
"""
|
||||
Reformat engine output into the AWS "ValidateTemplate" format
|
||||
"""
|
||||
"""Reformat engine output into AWS "ValidateTemplate" format."""
|
||||
|
||||
return {
|
||||
'ParameterKey': key,
|
||||
@ -467,8 +455,8 @@ class StackController(object):
|
||||
return exception.map_remote_error(ex)
|
||||
|
||||
def delete(self, req):
|
||||
"""
|
||||
Implements the DeleteStack API action.
|
||||
"""Implements the DeleteStack API action.
|
||||
|
||||
Deletes the specified stack.
|
||||
"""
|
||||
self._enforce(req, 'DeleteStack')
|
||||
@ -487,16 +475,14 @@ class StackController(object):
|
||||
return api_utils.format_response('DeleteStack', res['Error'])
|
||||
|
||||
def events_list(self, req):
|
||||
"""
|
||||
Implements the DescribeStackEvents API action.
|
||||
"""Implements the DescribeStackEvents API action.
|
||||
|
||||
Returns events related to a specified stack (or all stacks).
|
||||
"""
|
||||
self._enforce(req, 'DescribeStackEvents')
|
||||
|
||||
def format_stack_event(e):
|
||||
"""
|
||||
Reformat engine output into the AWS "StackEvent" format
|
||||
"""
|
||||
"""Reformat engine output into AWS "StackEvent" format."""
|
||||
keymap = {
|
||||
rpc_api.EVENT_ID: 'EventId',
|
||||
rpc_api.EVENT_RES_NAME: 'LogicalResourceId',
|
||||
@ -538,8 +524,8 @@ class StackController(object):
|
||||
return '_'.join((action, status))
|
||||
|
||||
def describe_stack_resource(self, req):
|
||||
"""
|
||||
Implements the DescribeStackResource API action.
|
||||
"""Implements the DescribeStackResource API action.
|
||||
|
||||
Return the details of the given resource belonging to the given stack.
|
||||
"""
|
||||
self._enforce(req, 'DescribeStackResource')
|
||||
@ -582,8 +568,8 @@ class StackController(object):
|
||||
{'StackResourceDetail': result})
|
||||
|
||||
def describe_stack_resources(self, req):
|
||||
"""
|
||||
Implements the DescribeStackResources API action
|
||||
"""Implements the DescribeStackResources API action.
|
||||
|
||||
Return details of resources specified by the parameters.
|
||||
|
||||
`StackName`: returns all resources belonging to the stack.
|
||||
@ -601,9 +587,7 @@ class StackController(object):
|
||||
self._enforce(req, 'DescribeStackResources')
|
||||
|
||||
def format_stack_resource(r):
|
||||
"""
|
||||
Reformat engine output into the AWS "StackResource" format
|
||||
"""
|
||||
"""Reformat engine output into AWS "StackResource" format."""
|
||||
keymap = {
|
||||
rpc_api.RES_DESCRIPTION: 'Description',
|
||||
rpc_api.RES_NAME: 'LogicalResourceId',
|
||||
@ -649,16 +633,14 @@ class StackController(object):
|
||||
{'StackResources': result})
|
||||
|
||||
def list_stack_resources(self, req):
|
||||
"""
|
||||
Implements the ListStackResources API action
|
||||
"""Implements the ListStackResources API action.
|
||||
|
||||
Return summary of the resources belonging to the specified stack.
|
||||
"""
|
||||
self._enforce(req, 'ListStackResources')
|
||||
|
||||
def format_resource_summary(r):
|
||||
"""
|
||||
Reformat engine output into the AWS "StackResourceSummary" format
|
||||
"""
|
||||
"""Reformat engine output to AWS "StackResourceSummary" format."""
|
||||
keymap = {
|
||||
rpc_api.RES_UPDATED_TIME: 'LastUpdatedTimestamp',
|
||||
rpc_api.RES_NAME: 'LogicalResourceId',
|
||||
@ -690,8 +672,6 @@ class StackController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Stacks resource factory method.
|
||||
"""
|
||||
"""Stacks resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
return wsgi.Resource(StackController(options), deserializer)
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
"""Controller that returns information on the heat API versions.
|
||||
|
||||
Now it's an subclass of module versions, because of identity with openstack
|
||||
Now it's an subclass of module versions, because of identity with OpenStack
|
||||
module versions.
|
||||
"""
|
||||
from heat.api import versions
|
||||
|
@ -22,9 +22,7 @@ from heat.common import wsgi
|
||||
|
||||
class API(wsgi.Router):
|
||||
|
||||
"""
|
||||
WSGI router for Heat CloudWatch API
|
||||
"""
|
||||
"""WSGI router for Heat CloudWatch API."""
|
||||
|
||||
_actions = {
|
||||
'delete_alarms': 'DeleteAlarms',
|
||||
|
@ -14,8 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""A middleware that turns exceptions into parsable string. Inspired by
|
||||
Cinder's faultwrapper
|
||||
"""A middleware that turns exceptions into parsable string.
|
||||
|
||||
Inspired by Cinder's faultwrapper.
|
||||
"""
|
||||
import six
|
||||
|
||||
|
@ -26,7 +26,9 @@ cfg.CONF.register_opts(ssl_middleware_opts)
|
||||
|
||||
|
||||
class SSLMiddleware(wsgi.Middleware):
|
||||
"""A middleware that replaces the request wsgi.url_scheme environment
|
||||
"""Replaces request wsgi.url_scheme env variable with value of HTTP header.
|
||||
|
||||
A middleware that replaces the request wsgi.url_scheme environment
|
||||
variable with the value of HTTP header configured in
|
||||
secure_proxy_ssl_header if exists in the incoming request.
|
||||
This is useful if the server is behind a SSL termination proxy.
|
||||
|
@ -11,10 +11,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
A filter middleware that inspects the requested URI for a version string
|
||||
and/or Accept headers and attempts to negotiate an API controller to
|
||||
return
|
||||
"""Inspects the requested URI for a version string and/or Accept headers.
|
||||
|
||||
Also attempts to negotiate an API controller to return.
|
||||
"""
|
||||
|
||||
import re
|
||||
@ -36,8 +35,9 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
||||
super(VersionNegotiationFilter, self).__init__(app)
|
||||
|
||||
def process_request(self, req):
|
||||
"""
|
||||
If there is a version identifier in the URI, simply
|
||||
"""Process Accept header or simply return correct API controller.
|
||||
|
||||
If there is a version identifier in the URI,
|
||||
return the correct API controller, otherwise, if we
|
||||
find an Accept: header, process it
|
||||
"""
|
||||
@ -103,10 +103,10 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
||||
return None
|
||||
|
||||
def _match_version_string(self, subject, req):
|
||||
"""
|
||||
Given a subject string, tries to match a major and/or
|
||||
minor version number. If found, sets the api.major_version
|
||||
and api.minor_version environ variables.
|
||||
"""Given a subject, tries to match a major and/or minor version number.
|
||||
|
||||
If found, sets the api.major_version and api.minor_version environ
|
||||
variables.
|
||||
|
||||
Returns True if there was a match, false otherwise.
|
||||
|
||||
|
@ -27,9 +27,7 @@ from heat.common import wsgi
|
||||
|
||||
class API(wsgi.Router):
|
||||
|
||||
"""
|
||||
WSGI router for Heat v1 REST API requests.
|
||||
"""
|
||||
"""WSGI router for Heat v1 REST API requests."""
|
||||
|
||||
def __init__(self, conf, **local_conf):
|
||||
self.conf = conf
|
||||
@ -38,7 +36,8 @@ class API(wsgi.Router):
|
||||
wsgi.JSONRequestDeserializer())
|
||||
|
||||
def connect(controller, path_prefix, routes):
|
||||
"""
|
||||
"""Connects list of routes to given controller with path_prefix.
|
||||
|
||||
This function connects the list of routes to the given
|
||||
controller, prepending the given path_prefix. Then for each URL it
|
||||
finds which request methods aren't handled and configures those
|
||||
|
@ -22,8 +22,8 @@ from heat.rpc import client as rpc_client
|
||||
|
||||
|
||||
class ActionController(object):
|
||||
"""
|
||||
WSGI controller for Actions in Heat v1 API
|
||||
"""WSGI controller for Actions in Heat v1 API.
|
||||
|
||||
Implements the API for stack actions
|
||||
"""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
@ -41,9 +41,10 @@ class ActionController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def action(self, req, identity, body=None):
|
||||
"""
|
||||
Performs a specified action on a stack, the body is expecting to
|
||||
contain exactly one item whose key specifies the action
|
||||
"""Performs a specified action on a stack.
|
||||
|
||||
The body is expecting to contain exactly one item whose key specifies
|
||||
the action.
|
||||
"""
|
||||
body = body or {}
|
||||
if len(body) < 1:
|
||||
@ -69,9 +70,7 @@ class ActionController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Actions action factory method.
|
||||
"""
|
||||
"""Actions action factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(ActionController(options), deserializer, serializer)
|
||||
|
@ -20,9 +20,9 @@ from heat.rpc import client as rpc_client
|
||||
|
||||
|
||||
class BuildInfoController(object):
|
||||
"""
|
||||
WSGI controller for BuildInfo in Heat v1 API
|
||||
Returns build information for current app
|
||||
"""WSGI controller for BuildInfo in Heat v1 API.
|
||||
|
||||
Returns build information for current app.
|
||||
"""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
REQUEST_SCOPE = 'build_info'
|
||||
@ -43,9 +43,7 @@ class BuildInfoController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
BuildInfo factory method.
|
||||
"""
|
||||
"""BuildInfo factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(BuildInfoController(options), deserializer,
|
||||
|
@ -74,9 +74,9 @@ def format_event(req, event, keys=None):
|
||||
|
||||
|
||||
class EventController(object):
|
||||
"""
|
||||
WSGI controller for Events in Heat v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for Events in Heat v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
REQUEST_SCOPE = 'events'
|
||||
@ -101,9 +101,7 @@ class EventController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def index(self, req, identity, resource_name=None):
|
||||
"""
|
||||
Lists summary information for all events
|
||||
"""
|
||||
"""Lists summary information for all events."""
|
||||
whitelist = {
|
||||
'limit': 'single',
|
||||
'marker': 'single',
|
||||
@ -148,9 +146,7 @@ class EventController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def show(self, req, identity, resource_name, event_id):
|
||||
"""
|
||||
Gets detailed information for an event
|
||||
"""
|
||||
"""Gets detailed information for an event."""
|
||||
|
||||
def event_match(ev):
|
||||
identity = identifier.EventIdentifier(**ev[rpc_api.EVENT_ID])
|
||||
@ -165,9 +161,7 @@ class EventController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Events resource factory method.
|
||||
"""
|
||||
"""Events resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(EventController(options), deserializer, serializer)
|
||||
|
@ -70,9 +70,9 @@ def format_resource(req, res, keys=None):
|
||||
|
||||
|
||||
class ResourceController(object):
|
||||
"""
|
||||
WSGI controller for Resources in Heat v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for Resources in Heat v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
REQUEST_SCOPE = 'resource'
|
||||
@ -93,9 +93,7 @@ class ResourceController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def index(self, req, identity):
|
||||
"""
|
||||
Lists information for all resources
|
||||
"""
|
||||
"""Lists information for all resources."""
|
||||
nested_depth = self._extract_to_param(req,
|
||||
rpc_api.PARAM_NESTED_DEPTH,
|
||||
param_utils.extract_int,
|
||||
@ -114,9 +112,7 @@ class ResourceController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def show(self, req, identity, resource_name):
|
||||
"""
|
||||
Gets detailed information for a resource
|
||||
"""
|
||||
"""Gets detailed information for a resource."""
|
||||
|
||||
whitelist = {'with_attr': 'multi'}
|
||||
params = util.get_allowed_params(req.params, whitelist)
|
||||
@ -129,9 +125,7 @@ class ResourceController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def metadata(self, req, identity, resource_name):
|
||||
"""
|
||||
Gets metadata information for a resource
|
||||
"""
|
||||
"""Gets metadata information for a resource."""
|
||||
|
||||
res = self.rpc_client.describe_stack_resource(req.context,
|
||||
identity,
|
||||
@ -148,9 +142,7 @@ class ResourceController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Resources resource factory method.
|
||||
"""
|
||||
"""Resources resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(ResourceController(options), deserializer, serializer)
|
||||
|
@ -24,9 +24,7 @@ from heat.rpc import client as rpc_client
|
||||
|
||||
|
||||
class ServiceController(object):
|
||||
"""
|
||||
WSGI controller for reporting the heat engine status in Heat v1 API
|
||||
"""
|
||||
"""WSGI controller for reporting the heat engine status in Heat v1 API."""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
REQUEST_SCOPE = 'service'
|
||||
|
||||
|
@ -23,9 +23,9 @@ from heat.rpc import client as rpc_client
|
||||
|
||||
|
||||
class SoftwareConfigController(object):
|
||||
"""
|
||||
WSGI controller for Software config in Heat v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for Software config in Heat v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
|
||||
REQUEST_SCOPE = 'software_configs'
|
||||
@ -60,9 +60,7 @@ class SoftwareConfigController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def index(self, req):
|
||||
"""
|
||||
Lists summary information for all software configs
|
||||
"""
|
||||
"""Lists summary information for all software configs."""
|
||||
global_tenant = False
|
||||
name = rpc_api.PARAM_GLOBAL_TENANT
|
||||
if name in req.params:
|
||||
@ -77,18 +75,14 @@ class SoftwareConfigController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def show(self, req, config_id):
|
||||
"""
|
||||
Gets detailed information for a software config
|
||||
"""
|
||||
"""Gets detailed information for a software config."""
|
||||
sc = self.rpc_client.show_software_config(
|
||||
req.context, config_id)
|
||||
return {'software_config': sc}
|
||||
|
||||
@util.policy_enforce
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Create a new software config
|
||||
"""
|
||||
"""Create a new software config."""
|
||||
create_data = {
|
||||
'name': body.get('name'),
|
||||
'group': body.get('group'),
|
||||
@ -103,9 +97,7 @@ class SoftwareConfigController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def delete(self, req, config_id):
|
||||
"""
|
||||
Delete an existing software config
|
||||
"""
|
||||
"""Delete an existing software config."""
|
||||
res = self.rpc_client.delete_software_config(req.context, config_id)
|
||||
|
||||
if res is not None:
|
||||
@ -115,9 +107,7 @@ class SoftwareConfigController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Software configs resource factory method.
|
||||
"""
|
||||
"""Software configs resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(
|
||||
|
@ -20,9 +20,9 @@ from heat.rpc import client as rpc_client
|
||||
|
||||
|
||||
class SoftwareDeploymentController(object):
|
||||
"""
|
||||
WSGI controller for Software deployments in Heat v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for Software deployments in Heat v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
|
||||
REQUEST_SCOPE = 'software_deployments'
|
||||
@ -36,9 +36,7 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def index(self, req):
|
||||
"""
|
||||
List software deployments.
|
||||
"""
|
||||
"""List software deployments."""
|
||||
whitelist = {
|
||||
'server_id': 'single',
|
||||
}
|
||||
@ -48,9 +46,9 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def metadata(self, req, server_id):
|
||||
"""
|
||||
List software deployments grouped by the group name for the requested
|
||||
server.
|
||||
"""List software deployments grouped by the group name.
|
||||
|
||||
This is done for the requested server.
|
||||
"""
|
||||
sds = self.rpc_client.metadata_software_deployments(
|
||||
req.context, server_id=server_id)
|
||||
@ -58,18 +56,14 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def show(self, req, deployment_id):
|
||||
"""
|
||||
Gets detailed information for a software deployment
|
||||
"""
|
||||
"""Gets detailed information for a software deployment."""
|
||||
sd = self.rpc_client.show_software_deployment(req.context,
|
||||
deployment_id)
|
||||
return {'software_deployment': sd}
|
||||
|
||||
@util.policy_enforce
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Create a new software deployment
|
||||
"""
|
||||
"""Create a new software deployment."""
|
||||
create_data = dict((k, body.get(k)) for k in (
|
||||
'config_id', 'server_id', 'input_values',
|
||||
'action', 'status', 'status_reason', 'stack_user_project_id'))
|
||||
@ -80,9 +74,7 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def update(self, req, deployment_id, body):
|
||||
"""
|
||||
Update an existing software deployment
|
||||
"""
|
||||
"""Update an existing software deployment."""
|
||||
update_data = dict((k, body.get(k)) for k in (
|
||||
'config_id', 'input_values', 'output_values', 'action',
|
||||
'status', 'status_reason')
|
||||
@ -94,9 +86,7 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def delete(self, req, deployment_id):
|
||||
"""
|
||||
Delete an existing software deployment
|
||||
"""
|
||||
"""Delete an existing software deployment."""
|
||||
res = self.rpc_client.delete_software_deployment(req.context,
|
||||
deployment_id)
|
||||
|
||||
@ -107,9 +97,7 @@ class SoftwareDeploymentController(object):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Software deployments resource factory method.
|
||||
"""
|
||||
"""Software deployments resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = serializers.JSONResponseSerializer()
|
||||
return wsgi.Resource(
|
||||
|
@ -11,9 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Stack endpoint for Heat v1 REST API.
|
||||
"""
|
||||
"""Stack endpoint for Heat v1 REST API."""
|
||||
|
||||
import contextlib
|
||||
from oslo_log import log as logging
|
||||
@ -39,8 +37,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InstantiationData(object):
|
||||
"""
|
||||
The data accompanying a PUT or POST request to create or update a stack.
|
||||
"""The data to create or update a stack.
|
||||
|
||||
The data accompanying a PUT or POST request.
|
||||
"""
|
||||
|
||||
PARAMS = (
|
||||
@ -60,8 +59,8 @@ class InstantiationData(object):
|
||||
)
|
||||
|
||||
def __init__(self, data, patch=False):
|
||||
"""
|
||||
Initialise from the request object.
|
||||
"""Initialise from the request object.
|
||||
|
||||
If called from the PATCH api, insert a flag for the engine code
|
||||
to distinguish.
|
||||
"""
|
||||
@ -81,15 +80,14 @@ class InstantiationData(object):
|
||||
raise exc.HTTPBadRequest(msg)
|
||||
|
||||
def stack_name(self):
|
||||
"""
|
||||
Return the stack name.
|
||||
"""
|
||||
"""Return the stack name."""
|
||||
if self.PARAM_STACK_NAME not in self.data:
|
||||
raise exc.HTTPBadRequest(_("No stack name specified"))
|
||||
return self.data[self.PARAM_STACK_NAME]
|
||||
|
||||
def template(self):
|
||||
"""
|
||||
"""Get template file contents.
|
||||
|
||||
Get template file contents, either inline, from stack adopt data or
|
||||
from a URL, in JSON or YAML format.
|
||||
"""
|
||||
@ -125,8 +123,8 @@ class InstantiationData(object):
|
||||
return template_format.parse(template_data)
|
||||
|
||||
def environment(self):
|
||||
"""
|
||||
Get the user-supplied environment for the stack in YAML format.
|
||||
"""Get the user-supplied environment for the stack in YAML format.
|
||||
|
||||
If the user supplied Parameters then merge these into the
|
||||
environment global options.
|
||||
"""
|
||||
@ -148,17 +146,15 @@ class InstantiationData(object):
|
||||
return self.data.get(self.PARAM_FILES, {})
|
||||
|
||||
def args(self):
|
||||
"""
|
||||
Get any additional arguments supplied by the user.
|
||||
"""
|
||||
"""Get any additional arguments supplied by the user."""
|
||||
params = self.data.items()
|
||||
return dict((k, v) for k, v in params if k not in self.PARAMS)
|
||||
|
||||
|
||||
class StackController(object):
|
||||
"""
|
||||
WSGI controller for stacks resource in Heat v1 API
|
||||
Implements the API actions
|
||||
"""WSGI controller for stacks resource in Heat v1 API.
|
||||
|
||||
Implements the API actions.
|
||||
"""
|
||||
# Define request scope (must match what is in policy.json)
|
||||
REQUEST_SCOPE = 'stacks'
|
||||
@ -324,9 +320,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def index(self, req):
|
||||
"""
|
||||
Lists summary information for all stacks
|
||||
"""
|
||||
"""Lists summary information for all stacks."""
|
||||
global_tenant = False
|
||||
name = rpc_api.PARAM_GLOBAL_TENANT
|
||||
if name in req.params:
|
||||
@ -341,18 +335,14 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def detail(self, req):
|
||||
"""
|
||||
Lists detailed information for all stacks
|
||||
"""
|
||||
"""Lists detailed information for all stacks."""
|
||||
stacks = self.rpc_client.list_stacks(req.context)
|
||||
|
||||
return {'stacks': [stacks_view.format_stack(req, s) for s in stacks]}
|
||||
|
||||
@util.policy_enforce
|
||||
def preview(self, req, body):
|
||||
"""
|
||||
Preview the outcome of a template and its params
|
||||
"""
|
||||
"""Preview the outcome of a template and its params."""
|
||||
|
||||
data = InstantiationData(body)
|
||||
args = self.prepare_args(data)
|
||||
@ -378,9 +368,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Create a new stack
|
||||
"""
|
||||
"""Create a new stack."""
|
||||
data = InstantiationData(body)
|
||||
|
||||
args = self.prepare_args(data)
|
||||
@ -399,9 +387,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def lookup(self, req, stack_name, path='', body=None):
|
||||
"""
|
||||
Redirect to the canonical URL for a stack
|
||||
"""
|
||||
"""Redirect to the canonical URL for a stack."""
|
||||
try:
|
||||
identity = dict(identifier.HeatIdentifier.from_arn(stack_name))
|
||||
except ValueError:
|
||||
@ -420,9 +406,7 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def show(self, req, identity):
|
||||
"""
|
||||
Gets detailed information for a stack
|
||||
"""
|
||||
"""Gets detailed information for a stack."""
|
||||
|
||||
stack_list = self.rpc_client.show_stack(req.context,
|
||||
identity)
|
||||
@ -436,9 +420,7 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def template(self, req, identity):
|
||||
"""
|
||||
Get the template body for an existing stack
|
||||
"""
|
||||
"""Get the template body for an existing stack."""
|
||||
|
||||
templ = self.rpc_client.get_template(req.context,
|
||||
identity)
|
||||
@ -451,9 +433,7 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def update(self, req, identity, body):
|
||||
"""
|
||||
Update an existing stack with a new template and/or parameters
|
||||
"""
|
||||
"""Update an existing stack with a new template and/or parameters."""
|
||||
data = InstantiationData(body)
|
||||
|
||||
args = self.prepare_args(data)
|
||||
@ -468,7 +448,8 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def update_patch(self, req, identity, body):
|
||||
"""
|
||||
"""Update an existing stack with a new template.
|
||||
|
||||
Update an existing stack with a new template by patching the parameters
|
||||
Add the flag patch to the args so the engine code can distinguish
|
||||
"""
|
||||
@ -486,9 +467,7 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def preview_update(self, req, identity, body):
|
||||
"""
|
||||
Preview an update to an existing stack with a new template/parameters
|
||||
"""
|
||||
"""Preview update for existing stack with a new template/parameters."""
|
||||
data = InstantiationData(body)
|
||||
|
||||
args = self.prepare_args(data)
|
||||
@ -504,9 +483,7 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def delete(self, req, identity):
|
||||
"""
|
||||
Delete the specified stack
|
||||
"""
|
||||
"""Delete the specified stack."""
|
||||
|
||||
res = self.rpc_client.delete_stack(req.context,
|
||||
identity,
|
||||
@ -519,7 +496,8 @@ class StackController(object):
|
||||
|
||||
@util.identified_stack
|
||||
def abandon(self, req, identity):
|
||||
"""
|
||||
"""Abandons specified stack.
|
||||
|
||||
Abandons specified stack by deleting the stack and it's resources
|
||||
from the database, but underlying resources will not be deleted.
|
||||
"""
|
||||
@ -528,9 +506,9 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def validate_template(self, req, body):
|
||||
"""
|
||||
Implements the ValidateTemplate API action
|
||||
Validates the specified template
|
||||
"""Implements the ValidateTemplate API action.
|
||||
|
||||
Validates the specified template.
|
||||
"""
|
||||
|
||||
data = InstantiationData(body)
|
||||
@ -557,9 +535,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def list_resource_types(self, req):
|
||||
"""
|
||||
Returns a list of valid resource types that may be used in a template.
|
||||
"""
|
||||
"""Returns a resource types list which may be used in template."""
|
||||
support_status = req.params.get('support_status')
|
||||
type_name = req.params.get('name')
|
||||
version = req.params.get('version')
|
||||
@ -572,9 +548,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def list_template_versions(self, req):
|
||||
"""
|
||||
Returns a list of available template versions
|
||||
"""
|
||||
"""Returns a list of available template versions."""
|
||||
return {
|
||||
'template_versions':
|
||||
self.rpc_client.list_template_versions(req.context)
|
||||
@ -582,9 +556,7 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def list_template_functions(self, req, template_version):
|
||||
"""
|
||||
Returns a list of available functions in a given template
|
||||
"""
|
||||
"""Returns a list of available functions in a given template."""
|
||||
return {
|
||||
'template_functions':
|
||||
self.rpc_client.list_template_functions(req.context,
|
||||
@ -593,16 +565,12 @@ class StackController(object):
|
||||
|
||||
@util.policy_enforce
|
||||
def resource_schema(self, req, type_name):
|
||||
"""
|
||||
Returns the schema of the given resource type.
|
||||
"""
|
||||
"""Returns the schema of the given resource type."""
|
||||
return self.rpc_client.resource_schema(req.context, type_name)
|
||||
|
||||
@util.policy_enforce
|
||||
def generate_template(self, req, type_name):
|
||||
"""
|
||||
Generates a template based on the specified type.
|
||||
"""
|
||||
"""Generates a template based on the specified type."""
|
||||
template_type = 'cfn'
|
||||
if rpc_api.TEMPLATE_TYPE in req.params:
|
||||
try:
|
||||
@ -663,9 +631,7 @@ class StackSerializer(serializers.JSONResponseSerializer):
|
||||
|
||||
|
||||
def create_resource(options):
|
||||
"""
|
||||
Stacks resource factory method.
|
||||
"""
|
||||
"""Stacks resource factory method."""
|
||||
deserializer = wsgi.JSONRequestDeserializer()
|
||||
serializer = StackSerializer()
|
||||
return wsgi.Resource(StackController(options), deserializer, serializer)
|
||||
|
Loading…
Reference in New Issue
Block a user