Enable flake8 H404 checking
This check indicates on comments in which multi line docstring should start without a leading new line. This change fixed all violators of said check. Change-Id: Ic7357b8c7420767dba611f6fcee07b7700f3aea8
This commit is contained in:
parent
b91b9bd0c8
commit
dd4032e9fb
@ -468,8 +468,7 @@ def exception_to_ec2code(ex):
|
||||
|
||||
|
||||
def ec2_error_ex(ex, req, code=None, message=None, unexpected=False):
|
||||
"""
|
||||
Return an EC2 error response based on passed exception and log
|
||||
"""Return an EC2 error response based on passed exception and log
|
||||
the exception on an appropriate log level:
|
||||
|
||||
* DEBUG: expected errors
|
||||
|
@ -172,8 +172,7 @@ class PlainMapper(APIMapper):
|
||||
|
||||
|
||||
class APIRouter(base_wsgi.Router):
|
||||
"""
|
||||
Routes requests on the OpenStack API to the appropriate controller
|
||||
"""Routes requests on the OpenStack API to the appropriate controller
|
||||
and method.
|
||||
"""
|
||||
ExtensionManager = None # override in subclasses
|
||||
@ -252,8 +251,7 @@ class APIRouter(base_wsgi.Router):
|
||||
|
||||
|
||||
class APIRouterV3(base_wsgi.Router):
|
||||
"""
|
||||
Routes requests on the OpenStack v3 API to the appropriate controller
|
||||
"""Routes requests on the OpenStack v3 API to the appropriate controller
|
||||
and method.
|
||||
"""
|
||||
|
||||
|
@ -476,8 +476,7 @@ class ViewBuilder(object):
|
||||
"""Model API responses as dictionaries."""
|
||||
|
||||
def _get_project_id(self, request):
|
||||
"""
|
||||
Get project id from request url if present or empty string
|
||||
"""Get project id from request url if present or empty string
|
||||
otherwise
|
||||
"""
|
||||
project_id = request.environ["nova.context"].project_id
|
||||
|
@ -42,8 +42,7 @@ CONF.register_opt(allow_instance_snapshots_opt)
|
||||
|
||||
|
||||
class APIRouter(nova.api.openstack.APIRouter):
|
||||
"""
|
||||
Routes requests on the OpenStack API to the appropriate controller
|
||||
"""Routes requests on the OpenStack API to the appropriate controller
|
||||
and method.
|
||||
"""
|
||||
ExtensionManager = extensions.ExtensionManager
|
||||
@ -130,8 +129,7 @@ class APIRouter(nova.api.openstack.APIRouter):
|
||||
|
||||
|
||||
class APIRouterV3(nova.api.openstack.APIRouterV3):
|
||||
"""
|
||||
Routes requests on the OpenStack API to the appropriate controller
|
||||
"""Routes requests on the OpenStack API to the appropriate controller
|
||||
and method.
|
||||
"""
|
||||
def __init__(self, init_only=None):
|
||||
|
@ -42,8 +42,7 @@ class AgentsIndexTemplate(xmlutil.TemplateBuilder):
|
||||
|
||||
|
||||
class AgentController(object):
|
||||
"""
|
||||
The agent is talking about guest agent.The host can use this for
|
||||
"""The agent is talking about guest agent.The host can use this for
|
||||
things like accessing files on the disk, configuring networking,
|
||||
or running other applications/scripts in the guest while it is
|
||||
running. Typically this uses some hypervisor-specific transport
|
||||
@ -66,9 +65,7 @@ class AgentController(object):
|
||||
"""
|
||||
@wsgi.serializers(xml=AgentsIndexTemplate)
|
||||
def index(self, req):
|
||||
"""
|
||||
Return a list of all agent builds. Filter by hypervisor.
|
||||
"""
|
||||
"""Return a list of all agent builds. Filter by hypervisor."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
hypervisor = None
|
||||
|
@ -59,8 +59,7 @@ class AggregateController(object):
|
||||
for a in aggregates]}
|
||||
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Creates an aggregate, given its name and
|
||||
"""Creates an aggregate, given its name and
|
||||
optional availability zone.
|
||||
"""
|
||||
context = _get_context(req)
|
||||
|
@ -133,8 +133,7 @@ class CellDeserializer(wsgi.XMLDeserializer):
|
||||
|
||||
|
||||
def _filter_keys(item, keys):
|
||||
"""
|
||||
Filters all model attributes except for keys
|
||||
"""Filters all model attributes except for keys
|
||||
item is a dict
|
||||
|
||||
"""
|
||||
@ -142,8 +141,7 @@ def _filter_keys(item, keys):
|
||||
|
||||
|
||||
def _fixup_cell_info(cell_info, keys):
|
||||
"""
|
||||
If the transport_url is present in the cell, derive username,
|
||||
"""If the transport_url is present in the cell, derive username,
|
||||
rpc_host, and rpc_port from it.
|
||||
"""
|
||||
|
||||
@ -294,8 +292,7 @@ class Controller(object):
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
def _normalize_cell(self, cell, existing=None):
|
||||
"""
|
||||
Normalize input cell data. Normalizations include:
|
||||
"""Normalize input cell data. Normalizations include:
|
||||
|
||||
* Converting cell['type'] to is_parent boolean.
|
||||
* Merging existing transport URL with transport information.
|
||||
|
@ -37,8 +37,7 @@ class Controller(wsgi.Controller):
|
||||
|
||||
@wsgi.action('evacuate')
|
||||
def _evacuate(self, req, id, body):
|
||||
"""
|
||||
Permit admins to evacuate a server from a failed host
|
||||
"""Permit admins to evacuate a server from a failed host
|
||||
to a new one.
|
||||
"""
|
||||
context = req.environ["nova.context"]
|
||||
|
@ -25,9 +25,7 @@ authorize = extensions.extension_authorizer('compute', 'flavormanage')
|
||||
|
||||
|
||||
class FlavorManageController(wsgi.Controller):
|
||||
"""
|
||||
The Flavor Lifecycle API controller for the OpenStack API.
|
||||
"""
|
||||
"""The Flavor Lifecycle API controller for the OpenStack API."""
|
||||
_view_builder_class = flavors_view.ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
@ -87,9 +85,7 @@ class FlavorManageController(wsgi.Controller):
|
||||
|
||||
|
||||
class Flavormanage(extensions.ExtensionDescriptor):
|
||||
"""
|
||||
Flavor create/delete API support
|
||||
"""
|
||||
"""Flavor create/delete API support."""
|
||||
|
||||
name = "FlavorManage"
|
||||
alias = "os-flavor-manage"
|
||||
|
@ -131,8 +131,7 @@ class FloatingIPBulkController(object):
|
||||
return {"floating_ips_bulk_delete": ip_range}
|
||||
|
||||
def _address_to_hosts(self, addresses):
|
||||
"""
|
||||
Iterate over hosts within an address range.
|
||||
"""Iterate over hosts within an address range.
|
||||
|
||||
If an explicit range specifier is missing, the parameter is
|
||||
interpreted as a specific individual address.
|
||||
|
@ -96,9 +96,7 @@ class HostController(object):
|
||||
|
||||
@wsgi.serializers(xml=HostIndexTemplate)
|
||||
def index(self, req):
|
||||
"""
|
||||
:returns: A dict in the format:
|
||||
|
||||
"""Returns a dict in the format:
|
||||
{'hosts': [{'host_name': 'some.host.name',
|
||||
'service': 'cells',
|
||||
'zone': 'internal'},
|
||||
@ -151,19 +149,20 @@ class HostController(object):
|
||||
@wsgi.serializers(xml=HostUpdateTemplate)
|
||||
@wsgi.deserializers(xml=HostUpdateDeserializer)
|
||||
def update(self, req, id, body):
|
||||
"""
|
||||
"""Updates a specified body.
|
||||
|
||||
:param body: example format {'status': 'enable',
|
||||
'maintenance_mode': 'enable'}
|
||||
:returns:
|
||||
"""
|
||||
def read_enabled(orig_val, msg):
|
||||
"""
|
||||
"""Checks a specified orig_val and returns True for 'enabled'
|
||||
and False for 'disabled'.
|
||||
|
||||
:param orig_val: A string with either 'enable' or 'disable'. May
|
||||
be surrounded by whitespace, and case doesn't
|
||||
matter
|
||||
:param msg: The message to be passed to HTTPBadRequest. A single
|
||||
%s will be replaced with orig_val.
|
||||
:returns: True for 'enabled' and False for 'disabled'
|
||||
"""
|
||||
val = orig_val.strip().lower()
|
||||
if val == "enable":
|
||||
|
@ -64,8 +64,7 @@ class KeypairController(object):
|
||||
|
||||
@wsgi.serializers(xml=KeypairTemplate)
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Create or import keypair.
|
||||
"""Create or import keypair.
|
||||
|
||||
Sending name will generate a key and return private_key
|
||||
and fingerprint.
|
||||
@ -112,9 +111,7 @@ class KeypairController(object):
|
||||
raise webob.exc.HTTPConflict(explanation=exc.format_message())
|
||||
|
||||
def delete(self, req, id):
|
||||
"""
|
||||
Delete a keypair with a given name
|
||||
"""
|
||||
"""Delete a keypair with a given name."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='delete')
|
||||
try:
|
||||
@ -137,9 +134,7 @@ class KeypairController(object):
|
||||
|
||||
@wsgi.serializers(xml=KeypairsTemplate)
|
||||
def index(self, req):
|
||||
"""
|
||||
List of keypairs for a user
|
||||
"""
|
||||
"""List of keypairs for a user."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='index')
|
||||
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
||||
|
@ -111,9 +111,7 @@ class SecurityGroupsTemplate(xmlutil.TemplateBuilder):
|
||||
|
||||
|
||||
class SecurityGroupXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
||||
"""
|
||||
Deserializer to handle xml-formatted security group requests.
|
||||
"""
|
||||
"""Deserializer to handle xml-formatted security group requests."""
|
||||
def default(self, string):
|
||||
"""Deserialize an xml-formatted security group create request."""
|
||||
dom = xmlutil.safe_minidom_parse_string(string)
|
||||
@ -131,9 +129,7 @@ class SecurityGroupXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
||||
|
||||
|
||||
class SecurityGroupRulesXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
||||
"""
|
||||
Deserializer to handle xml-formatted security group requests.
|
||||
"""
|
||||
"""Deserializer to handle xml-formatted security group requests."""
|
||||
|
||||
def default(self, string):
|
||||
"""Deserialize an xml-formatted security group create request."""
|
||||
|
@ -148,9 +148,7 @@ class ServiceController(object):
|
||||
|
||||
@wsgi.serializers(xml=ServicesIndexTemplate)
|
||||
def index(self, req):
|
||||
"""
|
||||
Return a list of all running services. Filter by host & service name.
|
||||
"""
|
||||
"""Return a list of all running services."""
|
||||
detailed = self.ext_mgr.is_loaded('os-extended-services')
|
||||
services = self._get_services_list(req, detailed)
|
||||
|
||||
|
@ -100,8 +100,7 @@ class Controller(wsgi.Controller):
|
||||
nova.image.glance.get_default_image_service())
|
||||
|
||||
def _get_filters(self, req):
|
||||
"""
|
||||
Return a dictionary of query param filters from the request
|
||||
"""Return a dictionary of query param filters from the request.
|
||||
|
||||
:param req: the Request object coming from the wsgi layer
|
||||
:retval a dict of key/value filters
|
||||
|
@ -128,15 +128,12 @@ def create_resource():
|
||||
|
||||
|
||||
class Limit(object):
|
||||
"""
|
||||
Stores information about a limit for HTTP requests.
|
||||
"""
|
||||
"""Stores information about a limit for HTTP requests."""
|
||||
|
||||
UNITS = dict([(v, k) for k, v in utils.TIME_UNITS.items()])
|
||||
|
||||
def __init__(self, verb, uri, regex, value, unit):
|
||||
"""
|
||||
Initialize a new `Limit`.
|
||||
"""Initialize a new `Limit`.
|
||||
|
||||
@param verb: HTTP verb (POST, PUT, etc.)
|
||||
@param uri: Human-readable URI
|
||||
@ -166,8 +163,7 @@ class Limit(object):
|
||||
self.error_message = msg % self.__dict__
|
||||
|
||||
def __call__(self, verb, url):
|
||||
"""
|
||||
Represents a call to this limit from a relevant request.
|
||||
"""Represents a call to this limit from a relevant request.
|
||||
|
||||
@param verb: string http verb (POST, GET, etc.)
|
||||
@param url: string URL
|
||||
@ -237,15 +233,14 @@ DEFAULT_LIMITS = [
|
||||
|
||||
|
||||
class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||
"""
|
||||
Rate-limits requests passing through this middleware. All limit information
|
||||
is stored in memory for this implementation.
|
||||
"""Rate-limits requests passing through this middleware. All limit
|
||||
information is stored in memory for this implementation.
|
||||
"""
|
||||
|
||||
def __init__(self, application, limits=None, limiter=None, **kwargs):
|
||||
"""
|
||||
Initialize new `RateLimitingMiddleware`, which wraps the given WSGI
|
||||
application and sets up the given limits.
|
||||
"""Initialize new `RateLimitingMiddleware`.
|
||||
|
||||
It wraps the given WSGI application and sets up the given limits.
|
||||
|
||||
@param application: WSGI application to wrap
|
||||
@param limits: String describing limits
|
||||
@ -269,10 +264,10 @@ class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||
|
||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||
def __call__(self, req):
|
||||
"""
|
||||
Represents a single call through this middleware. We should record the
|
||||
request if we have a limit relevant to it. If no limit is relevant to
|
||||
the request, ignore it.
|
||||
"""Represents a single call through this middleware.
|
||||
|
||||
We should record the request if we have a limit relevant to it.
|
||||
If no limit is relevant to the request, ignore it.
|
||||
|
||||
If the request should be rate limited, return a fault telling the user
|
||||
they are over the limit and need to retry later.
|
||||
@ -299,13 +294,10 @@ class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||
|
||||
|
||||
class Limiter(object):
|
||||
"""
|
||||
Rate-limit checking class which handles limits in memory.
|
||||
"""
|
||||
"""Rate-limit checking class which handles limits in memory."""
|
||||
|
||||
def __init__(self, limits, **kwargs):
|
||||
"""
|
||||
Initialize the new `Limiter`.
|
||||
"""Initialize the new `Limiter`.
|
||||
|
||||
@param limits: List of `Limit` objects
|
||||
"""
|
||||
@ -319,14 +311,11 @@ class Limiter(object):
|
||||
self.levels[username] = self.parse_limits(value)
|
||||
|
||||
def get_limits(self, username=None):
|
||||
"""
|
||||
Return the limits for a given user.
|
||||
"""
|
||||
"""Return the limits for a given user."""
|
||||
return [limit.display() for limit in self.levels[username]]
|
||||
|
||||
def check_for_delay(self, verb, url, username=None):
|
||||
"""
|
||||
Check the given verb/user/user triplet for limit.
|
||||
"""Check the given verb/user/user triplet for limit.
|
||||
|
||||
@return: Tuple of delay (in seconds) and error message (or None, None)
|
||||
"""
|
||||
@ -350,8 +339,7 @@ class Limiter(object):
|
||||
# default limit parsing.
|
||||
@staticmethod
|
||||
def parse_limits(limits):
|
||||
"""
|
||||
Convert a string into a list of Limit instances. This
|
||||
"""Convert a string into a list of Limit instances. This
|
||||
implementation expects a semicolon-separated sequence of
|
||||
parenthesized groups, where each group contains a
|
||||
comma-separated sequence consisting of HTTP method,
|
||||
@ -405,8 +393,8 @@ class Limiter(object):
|
||||
|
||||
|
||||
class WsgiLimiter(object):
|
||||
"""
|
||||
Rate-limit checking from a WSGI application. Uses an in-memory `Limiter`.
|
||||
"""Rate-limit checking from a WSGI application. Uses an in-memory
|
||||
`Limiter`.
|
||||
|
||||
To use, POST ``/<username>`` with JSON data such as::
|
||||
|
||||
@ -421,8 +409,7 @@ class WsgiLimiter(object):
|
||||
"""
|
||||
|
||||
def __init__(self, limits=None):
|
||||
"""
|
||||
Initialize the new `WsgiLimiter`.
|
||||
"""Initialize the new `WsgiLimiter`.
|
||||
|
||||
@param limits: List of `Limit` objects
|
||||
"""
|
||||
@ -430,10 +417,11 @@ class WsgiLimiter(object):
|
||||
|
||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||
def __call__(self, request):
|
||||
"""
|
||||
Handles a call to this application. Returns 204 if the request is
|
||||
acceptable to the limiter, else a 403 is returned with a relevant
|
||||
header indicating when the request *will* succeed.
|
||||
"""Handles a call to this application.
|
||||
|
||||
Returns 204 if the request is acceptable to the limiter, else a 403
|
||||
is returned with a relevant header indicating when the request *will*
|
||||
succeed.
|
||||
"""
|
||||
if request.method != "POST":
|
||||
raise webob.exc.HTTPMethodNotAllowed()
|
||||
@ -457,13 +445,10 @@ class WsgiLimiter(object):
|
||||
|
||||
|
||||
class WsgiLimiterProxy(object):
|
||||
"""
|
||||
Rate-limit requests based on answers from a remote source.
|
||||
"""
|
||||
"""Rate-limit requests based on answers from a remote source."""
|
||||
|
||||
def __init__(self, limiter_address):
|
||||
"""
|
||||
Initialize the new `WsgiLimiterProxy`.
|
||||
"""Initialize the new `WsgiLimiterProxy`.
|
||||
|
||||
@param limiter_address: IP/port combination of where to request limit
|
||||
"""
|
||||
@ -494,8 +479,7 @@ class WsgiLimiterProxy(object):
|
||||
# decisions are made by a remote server.
|
||||
@staticmethod
|
||||
def parse_limits(limits):
|
||||
"""
|
||||
Ignore a limits string--simply doesn't apply for the limit
|
||||
"""Ignore a limits string--simply doesn't apply for the limit
|
||||
proxy.
|
||||
|
||||
@return: Empty list.
|
||||
|
@ -28,8 +28,7 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||
|
||||
|
||||
class AgentController(object):
|
||||
"""
|
||||
The agent is talking about guest agent.The host can use this for
|
||||
"""The agent is talking about guest agent.The host can use this for
|
||||
things like accessing files on the disk, configuring networking,
|
||||
or running other applications/scripts in the guest while it is
|
||||
running. Typically this uses some hypervisor-specific transport
|
||||
@ -52,9 +51,7 @@ class AgentController(object):
|
||||
"""
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""
|
||||
Return a list of all agent builds. Filter by hypervisor.
|
||||
"""
|
||||
"""Return a list of all agent builds. Filter by hypervisor."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
hypervisor = None
|
||||
|
@ -73,8 +73,7 @@ class AggregateController(wsgi.Controller):
|
||||
@extensions.expected_errors((400, 409))
|
||||
@wsgi.response(201)
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Creates an aggregate, given its name and
|
||||
"""Creates an aggregate, given its name and
|
||||
optional availability zone.
|
||||
"""
|
||||
context = _get_context(req)
|
||||
|
@ -44,17 +44,14 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||
|
||||
|
||||
def _filter_keys(item, keys):
|
||||
"""
|
||||
Filters all model attributes except for keys
|
||||
"""Filters all model attributes except for keys
|
||||
item is a dict
|
||||
|
||||
"""
|
||||
return dict((k, v) for k, v in item.iteritems() if k in keys)
|
||||
|
||||
|
||||
def _fixup_cell_info(cell_info, keys):
|
||||
"""
|
||||
If the transport_url is present in the cell, derive username,
|
||||
"""If the transport_url is present in the cell, derive username,
|
||||
rpc_host, and rpc_port from it.
|
||||
"""
|
||||
|
||||
@ -202,8 +199,7 @@ class CellsController(object):
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
def _normalize_cell(self, cell, existing=None):
|
||||
"""
|
||||
Normalize input cell data. Normalizations include:
|
||||
"""Normalize input cell data. Normalizations include:
|
||||
|
||||
* Converting cell['type'] to is_parent boolean.
|
||||
* Merging existing transport URL with transport information.
|
||||
|
@ -42,8 +42,7 @@ class EvacuateController(wsgi.Controller):
|
||||
@wsgi.action('evacuate')
|
||||
@validation.schema(evacuate.evacuate)
|
||||
def _evacuate(self, req, id, body):
|
||||
"""
|
||||
Permit admins to evacuate a server from a failed host
|
||||
"""Permit admins to evacuate a server from a failed host
|
||||
to a new one.
|
||||
"""
|
||||
context = req.environ["nova.context"]
|
||||
|
@ -24,9 +24,7 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||
|
||||
|
||||
class FlavorManageController(wsgi.Controller):
|
||||
"""
|
||||
The Flavor Lifecycle API controller for the OpenStack API.
|
||||
"""
|
||||
"""The Flavor Lifecycle API controller for the OpenStack API."""
|
||||
_view_builder_class = flavors_view.V3ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
@ -90,9 +88,7 @@ class FlavorManageController(wsgi.Controller):
|
||||
|
||||
|
||||
class FlavorManage(extensions.V3APIExtensionBase):
|
||||
"""
|
||||
Flavor create/delete API support
|
||||
"""
|
||||
"""Flavor create/delete API support."""
|
||||
|
||||
name = "FlavorManage"
|
||||
alias = ALIAS
|
||||
|
@ -37,8 +37,7 @@ class HostController(wsgi.Controller):
|
||||
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""
|
||||
:returns: A dict in the format:
|
||||
""":returns: A dict in the format:
|
||||
|
||||
{'hosts': [{'host_name': 'some.host.name',
|
||||
'service': 'cells',
|
||||
@ -94,19 +93,17 @@ class HostController(wsgi.Controller):
|
||||
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
def update(self, req, id, body):
|
||||
"""
|
||||
:param body: example format {'host': {'status': 'enable',
|
||||
""":param body: example format {'host': {'status': 'enable',
|
||||
'maintenance_mode': 'enable'}}
|
||||
:returns:
|
||||
:returns:
|
||||
"""
|
||||
def read_enabled(orig_val, msg):
|
||||
"""
|
||||
:param orig_val: A string with either 'enable' or 'disable'. May
|
||||
be surrounded by whitespace, and case doesn't
|
||||
matter
|
||||
:param msg: The message to be passed to HTTPBadRequest. A single
|
||||
%s will be replaced with orig_val.
|
||||
:returns: True for 'enabled' and False for 'disabled'
|
||||
""":param orig_val: A string with either 'enable' or 'disable'. May
|
||||
be surrounded by whitespace, and case doesn't
|
||||
matter
|
||||
:param msg: The message to be passed to HTTPBadRequest. A single
|
||||
%s will be replaced with orig_val.
|
||||
:returns: True for 'enabled' and False for 'disabled'
|
||||
"""
|
||||
val = orig_val.strip().lower()
|
||||
if val == "enable":
|
||||
|
@ -52,8 +52,7 @@ class KeypairController(object):
|
||||
@wsgi.response(201)
|
||||
@validation.schema(keypairs.create)
|
||||
def create(self, req, body):
|
||||
"""
|
||||
Create or import keypair.
|
||||
"""Create or import keypair.
|
||||
|
||||
Sending name will generate a key and return private_key
|
||||
and fingerprint.
|
||||
@ -98,9 +97,7 @@ class KeypairController(object):
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
"""
|
||||
Delete a keypair with a given name
|
||||
"""
|
||||
"""Delete a keypair with a given name."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='delete')
|
||||
try:
|
||||
@ -122,9 +119,7 @@ class KeypairController(object):
|
||||
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""
|
||||
List of keypairs for a user
|
||||
"""
|
||||
"""List of keypairs for a user."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='index')
|
||||
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
||||
|
@ -44,8 +44,7 @@ class ServerPasswordController(object):
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.response(204)
|
||||
def clear(self, req, server_id):
|
||||
"""
|
||||
Removes the encrypted server password from the metadata server
|
||||
"""Removes the encrypted server password from the metadata server
|
||||
|
||||
Note that this does not actually change the instance server
|
||||
password.
|
||||
|
@ -101,8 +101,8 @@ class ServiceController(wsgi.Controller):
|
||||
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""
|
||||
Return a list of all running services. Filter by host & service name.
|
||||
"""Return a list of all running services. Filter by host & service
|
||||
name
|
||||
"""
|
||||
services = self._get_services_list(req)
|
||||
|
||||
|
@ -1218,8 +1218,7 @@ class Controller(wsgi.Controller):
|
||||
return image_uuid
|
||||
|
||||
def _image_from_req_data(self, data):
|
||||
"""
|
||||
Get image data from the request or raise appropriate
|
||||
"""Get image data from the request or raise appropriate
|
||||
exceptions
|
||||
|
||||
If no image is supplied - checks to see if there is
|
||||
|
@ -27,9 +27,7 @@ def get_view_builder(req):
|
||||
class ViewBuilder(common.ViewBuilder):
|
||||
|
||||
def __init__(self, base_url):
|
||||
"""
|
||||
:param base_url: url of the root wsgi application
|
||||
"""
|
||||
""":param base_url: url of the root wsgi application."""
|
||||
self.base_url = base_url
|
||||
|
||||
def build_choices(self, VERSIONS, req):
|
||||
|
@ -86,8 +86,7 @@ class Request(webob.Request):
|
||||
self._extension_data = {'db_items': {}}
|
||||
|
||||
def cache_db_items(self, key, items, item_key='id'):
|
||||
"""
|
||||
Allow API methods to store objects from a DB query to be
|
||||
"""Allow API methods to store objects from a DB query to be
|
||||
used by API extensions within the same API request.
|
||||
|
||||
An instance of this class only lives for the lifetime of a
|
||||
@ -99,8 +98,7 @@ class Request(webob.Request):
|
||||
db_items[item[item_key]] = item
|
||||
|
||||
def get_db_items(self, key):
|
||||
"""
|
||||
Allow an API extension to get previously stored objects within
|
||||
"""Allow an API extension to get previously stored objects within
|
||||
the same API request.
|
||||
|
||||
Note that the object data will be slightly stale.
|
||||
@ -108,8 +106,7 @@ class Request(webob.Request):
|
||||
return self._extension_data['db_items'][key]
|
||||
|
||||
def get_db_item(self, key, item_key):
|
||||
"""
|
||||
Allow an API extension to get a previously stored object
|
||||
"""Allow an API extension to get a previously stored object
|
||||
within the same API request.
|
||||
|
||||
Note that the object data will be slightly stale.
|
||||
@ -246,9 +243,8 @@ class JSONDeserializer(TextDeserializer):
|
||||
class XMLDeserializer(TextDeserializer):
|
||||
|
||||
def __init__(self, metadata=None):
|
||||
"""
|
||||
:param metadata: information needed to deserialize xml into
|
||||
a dictionary.
|
||||
""":param metadata: information needed to deserialize xml into
|
||||
a dictionary.
|
||||
"""
|
||||
super(XMLDeserializer, self).__init__()
|
||||
self.metadata = metadata or {}
|
||||
@ -365,10 +361,9 @@ class JSONDictSerializer(DictSerializer):
|
||||
class XMLDictSerializer(DictSerializer):
|
||||
|
||||
def __init__(self, metadata=None, xmlns=None):
|
||||
"""
|
||||
:param metadata: information needed to deserialize xml into
|
||||
a dictionary.
|
||||
:param xmlns: XML namespace to include with serialized xml
|
||||
""":param metadata: information needed to deserialize xml into
|
||||
a dictionary.
|
||||
:param xmlns: XML namespace to include with serialized xml
|
||||
"""
|
||||
super(XMLDictSerializer, self).__init__()
|
||||
self.metadata = metadata or {}
|
||||
@ -735,14 +730,15 @@ class Resource(wsgi.Application):
|
||||
|
||||
def __init__(self, controller, action_peek=None, inherits=None,
|
||||
**deserializers):
|
||||
"""
|
||||
:param controller: object that implement methods created by routes lib
|
||||
:param action_peek: dictionary of routines for peeking into an action
|
||||
request body to determine the desired action
|
||||
:param inherits: another resource object that this resource should
|
||||
inherit extensions from. Any action extensions that
|
||||
are applied to the parent resource will also apply
|
||||
to this resource.
|
||||
""":param controller: object that implement methods created by routes
|
||||
lib
|
||||
:param action_peek: dictionary of routines for peeking into an
|
||||
action request body to determine the
|
||||
desired action
|
||||
:param inherits: another resource object that this resource should
|
||||
inherit extensions from. Any action extensions that
|
||||
are applied to the parent resource will also apply
|
||||
to this resource.
|
||||
"""
|
||||
|
||||
self.controller = controller
|
||||
@ -1255,14 +1251,10 @@ class Fault(webob.exc.HTTPException):
|
||||
|
||||
|
||||
class RateLimitFault(webob.exc.HTTPException):
|
||||
"""
|
||||
Rate-limited request response.
|
||||
"""
|
||||
"""Rate-limited request response."""
|
||||
|
||||
def __init__(self, message, details, retry_time):
|
||||
"""
|
||||
Initialize new `RateLimitFault` with relevant information.
|
||||
"""
|
||||
"""Initialize new `RateLimitFault` with relevant information."""
|
||||
hdrs = RateLimitFault._retry_after(retry_time)
|
||||
self.wrapped_exc = webob.exc.HTTPTooManyRequests(headers=hdrs)
|
||||
self.content = {
|
||||
@ -1283,9 +1275,8 @@ class RateLimitFault(webob.exc.HTTPException):
|
||||
|
||||
@webob.dec.wsgify(RequestClass=Request)
|
||||
def __call__(self, request):
|
||||
"""
|
||||
Return the wrapped exception with a serialized body conforming to our
|
||||
error format.
|
||||
"""Return the wrapped exception with a serialized body conforming
|
||||
to our error format.
|
||||
"""
|
||||
user_locale = request.best_match_language()
|
||||
content_type = request.best_match_content_type()
|
||||
|
@ -888,9 +888,7 @@ class TemplateBuilder(object):
|
||||
|
||||
|
||||
def make_links(parent, selector=None):
|
||||
"""
|
||||
Attach an Atom <links> element to the parent.
|
||||
"""
|
||||
"""Attach an Atom <links> element to the parent."""
|
||||
|
||||
elem = SubTemplateElement(parent, '{%s}link' % XMLNS_ATOM,
|
||||
selector=selector)
|
||||
@ -905,8 +903,7 @@ def make_links(parent, selector=None):
|
||||
def make_flat_dict(name, selector=None, subselector=None,
|
||||
ns=None, colon_ns=False, root=None,
|
||||
ignore_sub_dicts=False):
|
||||
"""
|
||||
Utility for simple XML templates that traditionally used
|
||||
"""Utility for simple XML templates that traditionally used
|
||||
XMLDictSerializer with no metadata. Returns a template element
|
||||
where the top-level element has the given tag name, and where
|
||||
sub-elements have tag names derived from the object's keys and
|
||||
|
@ -37,9 +37,10 @@ CONF.register_opt(max_request_body_size_opt)
|
||||
class LimitingReader(object):
|
||||
"""Reader to limit the size of an incoming request."""
|
||||
def __init__(self, data, limit):
|
||||
"""
|
||||
:param data: Underlying data object
|
||||
:param limit: maximum number of bytes the reader should allow
|
||||
"""Initialize a new `LimitingReader`.
|
||||
|
||||
:param data: underlying data object
|
||||
:param limit: maximum number of bytes the reader should allow
|
||||
"""
|
||||
self.data = data
|
||||
self.limit = limit
|
||||
|
@ -22,8 +22,7 @@ from validators import _SchemaValidator
|
||||
|
||||
|
||||
def schema(request_body_schema):
|
||||
"""
|
||||
Register a schema to validate request body.
|
||||
"""Register a schema to validate request body.
|
||||
|
||||
Registered schema will be used for validating request body just before
|
||||
API method executing.
|
||||
|
@ -274,8 +274,7 @@ class CellsManager(manager.Manager):
|
||||
return service
|
||||
|
||||
def get_host_uptime(self, ctxt, host_name):
|
||||
"""
|
||||
Return host uptime for a compute host in a certain cell
|
||||
"""Return host uptime for a compute host in a certain cell
|
||||
|
||||
:param host_name: fully qualified hostname. It should be in format of
|
||||
parent!child@host_id
|
||||
@ -286,8 +285,7 @@ class CellsManager(manager.Manager):
|
||||
return response.value_or_raise()
|
||||
|
||||
def service_update(self, ctxt, host_name, binary, params_to_update):
|
||||
"""
|
||||
Used to enable/disable a service. For compute services, setting to
|
||||
"""Used to enable/disable a service. For compute services, setting to
|
||||
disabled stops new builds arriving on that host.
|
||||
|
||||
:param host_name: the name of the host machine that the service is
|
||||
|
@ -732,8 +732,7 @@ class _TargetedMessageMethods(_BaseMessageMethods):
|
||||
return jsonutils.to_primitive(service)
|
||||
|
||||
def service_update(self, message, host_name, binary, params_to_update):
|
||||
"""
|
||||
Used to enable/disable a service. For compute services, setting to
|
||||
"""Used to enable/disable a service. For compute services, setting to
|
||||
disabled stops new builds arriving on that host.
|
||||
|
||||
:param host_name: the name of the host machine that the service is
|
||||
@ -1509,8 +1508,7 @@ class MessageRunner(object):
|
||||
|
||||
def service_update(self, ctxt, cell_name, host_name, binary,
|
||||
params_to_update):
|
||||
"""
|
||||
Used to enable/disable a service. For compute services, setting to
|
||||
"""Used to enable/disable a service. For compute services, setting to
|
||||
disabled stops new builds arriving on that host.
|
||||
|
||||
:param host_name: the name of the host machine that the service is
|
||||
|
@ -244,8 +244,7 @@ class CellsAPI(object):
|
||||
return cctxt.call(context, 'get_host_uptime', host_name=host_name)
|
||||
|
||||
def service_update(self, ctxt, host_name, binary, params_to_update):
|
||||
"""
|
||||
Used to enable/disable a service. For compute services, setting to
|
||||
"""Used to enable/disable a service. For compute services, setting to
|
||||
disabled stops new builds arriving on that host.
|
||||
|
||||
:param host_name: the name of the host machine that the service is
|
||||
|
@ -421,8 +421,7 @@ class CellStateManager(base.Base):
|
||||
class CellStateManagerDB(CellStateManager):
|
||||
@utils.synchronized('cell-db-sync')
|
||||
def _cell_data_sync(self, force=False):
|
||||
"""
|
||||
Update cell status for all cells from the backing data store
|
||||
"""Update cell status for all cells from the backing data store
|
||||
when necessary.
|
||||
|
||||
:param force: If True, cell status will be updated regardless
|
||||
@ -456,8 +455,7 @@ class CellStateManagerFile(CellStateManager):
|
||||
super(CellStateManagerFile, self).__init__(cell_state_cls)
|
||||
|
||||
def _cell_data_sync(self, force=False):
|
||||
"""
|
||||
Update cell status for all cells from the backing data store
|
||||
"""Update cell status for all cells from the backing data store
|
||||
when necessary.
|
||||
|
||||
:param force: If True, cell status will be updated regardless
|
||||
|
@ -38,8 +38,7 @@ class RamByInstanceTypeWeigher(weights.BaseCellWeigher):
|
||||
return CONF.cells.ram_weight_multiplier
|
||||
|
||||
def _weigh_object(self, cell, weight_properties):
|
||||
"""
|
||||
Use the 'ram_free' for a particular instance_type advertised from a
|
||||
"""Use the 'ram_free' for a particular instance_type advertised from a
|
||||
child cell's capacity to compute a weight. We want to direct the
|
||||
build to a cell with a higher capacity. Since higher weights win,
|
||||
we just return the number of units available for the instance_type.
|
||||
|
@ -33,8 +33,7 @@ CONF.register_opts(weigher_opts, group='cells')
|
||||
|
||||
|
||||
class WeightOffsetWeigher(weights.BaseCellWeigher):
|
||||
"""
|
||||
Weight cell by weight_offset db field.
|
||||
"""Weight cell by weight_offset db field.
|
||||
Originally designed so you can set a default cell by putting
|
||||
its weight_offset to 999999999999999 (highest weight wins)
|
||||
"""
|
||||
|
@ -223,8 +223,7 @@ class ProjectCommands(object):
|
||||
@args('--key', metavar='<key>', help='Key')
|
||||
@args('--value', metavar='<value>', help='Value')
|
||||
def quota(self, project_id, user_id=None, key=None, value=None):
|
||||
"""
|
||||
Create, update or display quotas for project/user
|
||||
"""Create, update or display quotas for project/user
|
||||
|
||||
If no quota key is provided, the quota will be displayed.
|
||||
If a valid quota key is provided and it does not exist,
|
||||
@ -401,8 +400,7 @@ class FloatingIpCommands(object):
|
||||
|
||||
@staticmethod
|
||||
def address_to_hosts(addresses):
|
||||
"""
|
||||
Iterate over hosts within an address range.
|
||||
"""Iterate over hosts within an address range.
|
||||
|
||||
If an explicit range specifier is missing, the parameter is
|
||||
interpreted as a specific individual address.
|
||||
@ -679,8 +677,8 @@ class ServiceCommands(object):
|
||||
@args('--host', metavar='<host>', help='Host')
|
||||
@args('--service', metavar='<service>', help='Nova service')
|
||||
def list(self, host=None, service=None):
|
||||
"""
|
||||
Show a list of all running services. Filter by host & service name.
|
||||
"""Show a list of all running services. Filter by host & service
|
||||
name
|
||||
"""
|
||||
servicegroup_api = servicegroup.API()
|
||||
ctxt = context.get_admin_context()
|
||||
|
@ -40,9 +40,8 @@ def API(*args, **kwargs):
|
||||
|
||||
|
||||
def HostAPI(*args, **kwargs):
|
||||
"""
|
||||
Returns the 'HostAPI' class from the same module as the configured compute
|
||||
api
|
||||
"""Returns the 'HostAPI' class from the same module as the configured
|
||||
compute api
|
||||
"""
|
||||
importutils = nova.openstack.common.importutils
|
||||
compute_api_class_name = _get_compute_api_class_name()
|
||||
@ -52,8 +51,7 @@ def HostAPI(*args, **kwargs):
|
||||
|
||||
|
||||
def InstanceActionAPI(*args, **kwargs):
|
||||
"""
|
||||
Returns the 'InstanceActionAPI' class from the same module as the
|
||||
"""Returns the 'InstanceActionAPI' class from the same module as the
|
||||
configured compute api.
|
||||
"""
|
||||
importutils = nova.openstack.common.importutils
|
||||
|
@ -219,8 +219,7 @@ def check_instance_cell(fn):
|
||||
|
||||
|
||||
def _diff_dict(orig, new):
|
||||
"""
|
||||
Return a dict describing how to change orig to new. The keys
|
||||
"""Return a dict describing how to change orig to new. The keys
|
||||
correspond to values that have changed; the value will be a list
|
||||
of one or two elements. The first element of the list will be
|
||||
either '+' or '-', indicating whether the key was updated or
|
||||
@ -441,8 +440,7 @@ class API(base.Base):
|
||||
raise exception.InvalidMetadataSize(reason=msg)
|
||||
|
||||
def _check_requested_secgroups(self, context, secgroups):
|
||||
"""
|
||||
Check if the security group requested exists and belongs to
|
||||
"""Check if the security group requested exists and belongs to
|
||||
the project.
|
||||
"""
|
||||
for secgroup in secgroups:
|
||||
@ -455,8 +453,7 @@ class API(base.Base):
|
||||
|
||||
def _check_requested_networks(self, context, requested_networks,
|
||||
max_count):
|
||||
"""
|
||||
Check if the networks requested belongs to the project
|
||||
"""Check if the networks requested belongs to the project
|
||||
and the fixed IP address for each network provided is within
|
||||
same the network block
|
||||
"""
|
||||
@ -1267,8 +1264,7 @@ class API(base.Base):
|
||||
block_device_mapping=None, access_ip_v4=None,
|
||||
access_ip_v6=None, requested_networks=None, config_drive=None,
|
||||
auto_disk_config=None, scheduler_hints=None, legacy_bdm=True):
|
||||
"""
|
||||
Provision instances, sending instance information to the
|
||||
"""Provision instances, sending instance information to the
|
||||
scheduler. The scheduler will determine where the instance(s)
|
||||
go and will handle creating the DB entries.
|
||||
|
||||
@ -2110,8 +2106,7 @@ class API(base.Base):
|
||||
context, None, None, image)
|
||||
|
||||
def _reset_image_metadata():
|
||||
"""
|
||||
Remove old image properties that we're storing as instance
|
||||
"""Remove old image properties that we're storing as instance
|
||||
system metadata. These properties start with 'image_'.
|
||||
Then add the properties for the new image.
|
||||
"""
|
||||
@ -2234,8 +2229,7 @@ class API(base.Base):
|
||||
@staticmethod
|
||||
def _resize_quota_delta(context, new_flavor,
|
||||
old_flavor, sense, compare):
|
||||
"""
|
||||
Calculate any quota adjustment required at a particular point
|
||||
"""Calculate any quota adjustment required at a particular point
|
||||
in the resize cycle.
|
||||
|
||||
:param context: the request context
|
||||
@ -2261,15 +2255,13 @@ class API(base.Base):
|
||||
|
||||
@staticmethod
|
||||
def _upsize_quota_delta(context, new_flavor, old_flavor):
|
||||
"""
|
||||
Calculate deltas required to adjust quota for an instance upsize.
|
||||
"""Calculate deltas required to adjust quota for an instance upsize.
|
||||
"""
|
||||
return API._resize_quota_delta(context, new_flavor, old_flavor, 1, 1)
|
||||
|
||||
@staticmethod
|
||||
def _reverse_upsize_quota_delta(context, migration_ref):
|
||||
"""
|
||||
Calculate deltas required to reverse a prior upsizing
|
||||
"""Calculate deltas required to reverse a prior upsizing
|
||||
quota adjustment.
|
||||