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):
|
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:
|
the exception on an appropriate log level:
|
||||||
|
|
||||||
* DEBUG: expected errors
|
* DEBUG: expected errors
|
||||||
|
|
|
@ -172,8 +172,7 @@ class PlainMapper(APIMapper):
|
||||||
|
|
||||||
|
|
||||||
class APIRouter(base_wsgi.Router):
|
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.
|
and method.
|
||||||
"""
|
"""
|
||||||
ExtensionManager = None # override in subclasses
|
ExtensionManager = None # override in subclasses
|
||||||
|
@ -252,8 +251,7 @@ class APIRouter(base_wsgi.Router):
|
||||||
|
|
||||||
|
|
||||||
class APIRouterV3(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.
|
and method.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -476,8 +476,7 @@ class ViewBuilder(object):
|
||||||
"""Model API responses as dictionaries."""
|
"""Model API responses as dictionaries."""
|
||||||
|
|
||||||
def _get_project_id(self, request):
|
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
|
otherwise
|
||||||
"""
|
"""
|
||||||
project_id = request.environ["nova.context"].project_id
|
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):
|
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.
|
and method.
|
||||||
"""
|
"""
|
||||||
ExtensionManager = extensions.ExtensionManager
|
ExtensionManager = extensions.ExtensionManager
|
||||||
|
@ -130,8 +129,7 @@ class APIRouter(nova.api.openstack.APIRouter):
|
||||||
|
|
||||||
|
|
||||||
class APIRouterV3(nova.api.openstack.APIRouterV3):
|
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.
|
and method.
|
||||||
"""
|
"""
|
||||||
def __init__(self, init_only=None):
|
def __init__(self, init_only=None):
|
||||||
|
|
|
@ -42,8 +42,7 @@ class AgentsIndexTemplate(xmlutil.TemplateBuilder):
|
||||||
|
|
||||||
|
|
||||||
class AgentController(object):
|
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,
|
things like accessing files on the disk, configuring networking,
|
||||||
or running other applications/scripts in the guest while it is
|
or running other applications/scripts in the guest while it is
|
||||||
running. Typically this uses some hypervisor-specific transport
|
running. Typically this uses some hypervisor-specific transport
|
||||||
|
@ -66,9 +65,7 @@ class AgentController(object):
|
||||||
"""
|
"""
|
||||||
@wsgi.serializers(xml=AgentsIndexTemplate)
|
@wsgi.serializers(xml=AgentsIndexTemplate)
|
||||||
def index(self, req):
|
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']
|
context = req.environ['nova.context']
|
||||||
authorize(context)
|
authorize(context)
|
||||||
hypervisor = None
|
hypervisor = None
|
||||||
|
|
|
@ -59,8 +59,7 @@ class AggregateController(object):
|
||||||
for a in aggregates]}
|
for a in aggregates]}
|
||||||
|
|
||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
"""
|
"""Creates an aggregate, given its name and
|
||||||
Creates an aggregate, given its name and
|
|
||||||
optional availability zone.
|
optional availability zone.
|
||||||
"""
|
"""
|
||||||
context = _get_context(req)
|
context = _get_context(req)
|
||||||
|
|
|
@ -133,8 +133,7 @@ class CellDeserializer(wsgi.XMLDeserializer):
|
||||||
|
|
||||||
|
|
||||||
def _filter_keys(item, keys):
|
def _filter_keys(item, keys):
|
||||||
"""
|
"""Filters all model attributes except for keys
|
||||||
Filters all model attributes except for keys
|
|
||||||
item is a dict
|
item is a dict
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -142,8 +141,7 @@ def _filter_keys(item, keys):
|
||||||
|
|
||||||
|
|
||||||
def _fixup_cell_info(cell_info, 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.
|
rpc_host, and rpc_port from it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -294,8 +292,7 @@ class Controller(object):
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
def _normalize_cell(self, cell, existing=None):
|
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.
|
* Converting cell['type'] to is_parent boolean.
|
||||||
* Merging existing transport URL with transport information.
|
* Merging existing transport URL with transport information.
|
||||||
|
|
|
@ -37,8 +37,7 @@ class Controller(wsgi.Controller):
|
||||||
|
|
||||||
@wsgi.action('evacuate')
|
@wsgi.action('evacuate')
|
||||||
def _evacuate(self, req, id, body):
|
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.
|
to a new one.
|
||||||
"""
|
"""
|
||||||
context = req.environ["nova.context"]
|
context = req.environ["nova.context"]
|
||||||
|
|
|
@ -25,9 +25,7 @@ authorize = extensions.extension_authorizer('compute', 'flavormanage')
|
||||||
|
|
||||||
|
|
||||||
class FlavorManageController(wsgi.Controller):
|
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
|
_view_builder_class = flavors_view.ViewBuilder
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -87,9 +85,7 @@ class FlavorManageController(wsgi.Controller):
|
||||||
|
|
||||||
|
|
||||||
class Flavormanage(extensions.ExtensionDescriptor):
|
class Flavormanage(extensions.ExtensionDescriptor):
|
||||||
"""
|
"""Flavor create/delete API support."""
|
||||||
Flavor create/delete API support
|
|
||||||
"""
|
|
||||||
|
|
||||||
name = "FlavorManage"
|
name = "FlavorManage"
|
||||||
alias = "os-flavor-manage"
|
alias = "os-flavor-manage"
|
||||||
|
|
|
@ -131,8 +131,7 @@ class FloatingIPBulkController(object):
|
||||||
return {"floating_ips_bulk_delete": ip_range}
|
return {"floating_ips_bulk_delete": ip_range}
|
||||||
|
|
||||||
def _address_to_hosts(self, addresses):
|
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
|
If an explicit range specifier is missing, the parameter is
|
||||||
interpreted as a specific individual address.
|
interpreted as a specific individual address.
|
||||||
|
|
|
@ -96,9 +96,7 @@ class HostController(object):
|
||||||
|
|
||||||
@wsgi.serializers(xml=HostIndexTemplate)
|
@wsgi.serializers(xml=HostIndexTemplate)
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
"""Returns a dict in the format:
|
||||||
:returns: A dict in the format:
|
|
||||||
|
|
||||||
{'hosts': [{'host_name': 'some.host.name',
|
{'hosts': [{'host_name': 'some.host.name',
|
||||||
'service': 'cells',
|
'service': 'cells',
|
||||||
'zone': 'internal'},
|
'zone': 'internal'},
|
||||||
|
@ -151,19 +149,20 @@ class HostController(object):
|
||||||
@wsgi.serializers(xml=HostUpdateTemplate)
|
@wsgi.serializers(xml=HostUpdateTemplate)
|
||||||
@wsgi.deserializers(xml=HostUpdateDeserializer)
|
@wsgi.deserializers(xml=HostUpdateDeserializer)
|
||||||
def update(self, req, id, body):
|
def update(self, req, id, body):
|
||||||
"""
|
"""Updates a specified body.
|
||||||
|
|
||||||
:param body: example format {'status': 'enable',
|
:param body: example format {'status': 'enable',
|
||||||
'maintenance_mode': 'enable'}
|
'maintenance_mode': 'enable'}
|
||||||
:returns:
|
|
||||||
"""
|
"""
|
||||||
def read_enabled(orig_val, msg):
|
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
|
:param orig_val: A string with either 'enable' or 'disable'. May
|
||||||
be surrounded by whitespace, and case doesn't
|
be surrounded by whitespace, and case doesn't
|
||||||
matter
|
matter
|
||||||
:param msg: The message to be passed to HTTPBadRequest. A single
|
:param msg: The message to be passed to HTTPBadRequest. A single
|
||||||
%s will be replaced with orig_val.
|
%s will be replaced with orig_val.
|
||||||
:returns: True for 'enabled' and False for 'disabled'
|
|
||||||
"""
|
"""
|
||||||
val = orig_val.strip().lower()
|
val = orig_val.strip().lower()
|
||||||
if val == "enable":
|
if val == "enable":
|
||||||
|
|
|
@ -64,8 +64,7 @@ class KeypairController(object):
|
||||||
|
|
||||||
@wsgi.serializers(xml=KeypairTemplate)
|
@wsgi.serializers(xml=KeypairTemplate)
|
||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
"""
|
"""Create or import keypair.
|
||||||
Create or import keypair.
|
|
||||||
|
|
||||||
Sending name will generate a key and return private_key
|
Sending name will generate a key and return private_key
|
||||||
and fingerprint.
|
and fingerprint.
|
||||||
|
@ -112,9 +111,7 @@ class KeypairController(object):
|
||||||
raise webob.exc.HTTPConflict(explanation=exc.format_message())
|
raise webob.exc.HTTPConflict(explanation=exc.format_message())
|
||||||
|
|
||||||
def delete(self, req, id):
|
def delete(self, req, id):
|
||||||
"""
|
"""Delete a keypair with a given name."""
|
||||||
Delete a keypair with a given name
|
|
||||||
"""
|
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context, action='delete')
|
authorize(context, action='delete')
|
||||||
try:
|
try:
|
||||||
|
@ -137,9 +134,7 @@ class KeypairController(object):
|
||||||
|
|
||||||
@wsgi.serializers(xml=KeypairsTemplate)
|
@wsgi.serializers(xml=KeypairsTemplate)
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
"""List of keypairs for a user."""
|
||||||
List of keypairs for a user
|
|
||||||
"""
|
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context, action='index')
|
authorize(context, action='index')
|
||||||
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
||||||
|
|
|
@ -111,9 +111,7 @@ class SecurityGroupsTemplate(xmlutil.TemplateBuilder):
|
||||||
|
|
||||||
|
|
||||||
class SecurityGroupXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
class SecurityGroupXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
||||||
"""
|
"""Deserializer to handle xml-formatted security group requests."""
|
||||||
Deserializer to handle xml-formatted security group requests.
|
|
||||||
"""
|
|
||||||
def default(self, string):
|
def default(self, string):
|
||||||
"""Deserialize an xml-formatted security group create request."""
|
"""Deserialize an xml-formatted security group create request."""
|
||||||
dom = xmlutil.safe_minidom_parse_string(string)
|
dom = xmlutil.safe_minidom_parse_string(string)
|
||||||
|
@ -131,9 +129,7 @@ class SecurityGroupXMLDeserializer(wsgi.MetadataXMLDeserializer):
|
||||||
|
|
||||||
|
|
||||||
class SecurityGroupRulesXMLDeserializer(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):
|
def default(self, string):
|
||||||
"""Deserialize an xml-formatted security group create request."""
|
"""Deserialize an xml-formatted security group create request."""
|
||||||
|
|
|
@ -148,9 +148,7 @@ class ServiceController(object):
|
||||||
|
|
||||||
@wsgi.serializers(xml=ServicesIndexTemplate)
|
@wsgi.serializers(xml=ServicesIndexTemplate)
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
"""Return a list of all running services."""
|
||||||
Return a list of all running services. Filter by host & service name.
|
|
||||||
"""
|
|
||||||
detailed = self.ext_mgr.is_loaded('os-extended-services')
|
detailed = self.ext_mgr.is_loaded('os-extended-services')
|
||||||
services = self._get_services_list(req, detailed)
|
services = self._get_services_list(req, detailed)
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,7 @@ class Controller(wsgi.Controller):
|
||||||
nova.image.glance.get_default_image_service())
|
nova.image.glance.get_default_image_service())
|
||||||
|
|
||||||
def _get_filters(self, req):
|
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
|
:param req: the Request object coming from the wsgi layer
|
||||||
:retval a dict of key/value filters
|
:retval a dict of key/value filters
|
||||||
|
|
|
@ -128,15 +128,12 @@ def create_resource():
|
||||||
|
|
||||||
|
|
||||||
class Limit(object):
|
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()])
|
UNITS = dict([(v, k) for k, v in utils.TIME_UNITS.items()])
|
||||||
|
|
||||||
def __init__(self, verb, uri, regex, value, unit):
|
def __init__(self, verb, uri, regex, value, unit):
|
||||||
"""
|
"""Initialize a new `Limit`.
|
||||||
Initialize a new `Limit`.
|
|
||||||
|
|
||||||
@param verb: HTTP verb (POST, PUT, etc.)
|
@param verb: HTTP verb (POST, PUT, etc.)
|
||||||
@param uri: Human-readable URI
|
@param uri: Human-readable URI
|
||||||
|
@ -166,8 +163,7 @@ class Limit(object):
|
||||||
self.error_message = msg % self.__dict__
|
self.error_message = msg % self.__dict__
|
||||||
|
|
||||||
def __call__(self, verb, url):
|
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 verb: string http verb (POST, GET, etc.)
|
||||||
@param url: string URL
|
@param url: string URL
|
||||||
|
@ -237,15 +233,14 @@ DEFAULT_LIMITS = [
|
||||||
|
|
||||||
|
|
||||||
class RateLimitingMiddleware(base_wsgi.Middleware):
|
class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||||
"""
|
"""Rate-limits requests passing through this middleware. All limit
|
||||||
Rate-limits requests passing through this middleware. All limit information
|
information is stored in memory for this implementation.
|
||||||
is stored in memory for this implementation.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, application, limits=None, limiter=None, **kwargs):
|
def __init__(self, application, limits=None, limiter=None, **kwargs):
|
||||||
"""
|
"""Initialize new `RateLimitingMiddleware`.
|
||||||
Initialize new `RateLimitingMiddleware`, which wraps the given WSGI
|
|
||||||
application and sets up the given limits.
|
It wraps the given WSGI application and sets up the given limits.
|
||||||
|
|
||||||
@param application: WSGI application to wrap
|
@param application: WSGI application to wrap
|
||||||
@param limits: String describing limits
|
@param limits: String describing limits
|
||||||
|
@ -269,10 +264,10 @@ class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||||
|
|
||||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||||
def __call__(self, req):
|
def __call__(self, req):
|
||||||
"""
|
"""Represents a single call through this middleware.
|
||||||
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
|
We should record the request if we have a limit relevant to it.
|
||||||
the request, ignore it.
|
If no limit is relevant to the request, ignore it.
|
||||||
|
|
||||||
If the request should be rate limited, return a fault telling the user
|
If the request should be rate limited, return a fault telling the user
|
||||||
they are over the limit and need to retry later.
|
they are over the limit and need to retry later.
|
||||||
|
@ -299,13 +294,10 @@ class RateLimitingMiddleware(base_wsgi.Middleware):
|
||||||
|
|
||||||
|
|
||||||
class Limiter(object):
|
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):
|
def __init__(self, limits, **kwargs):
|
||||||
"""
|
"""Initialize the new `Limiter`.
|
||||||
Initialize the new `Limiter`.
|
|
||||||
|
|
||||||
@param limits: List of `Limit` objects
|
@param limits: List of `Limit` objects
|
||||||
"""
|
"""
|
||||||
|
@ -319,14 +311,11 @@ class Limiter(object):
|
||||||
self.levels[username] = self.parse_limits(value)
|
self.levels[username] = self.parse_limits(value)
|
||||||
|
|
||||||
def get_limits(self, username=None):
|
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]]
|
return [limit.display() for limit in self.levels[username]]
|
||||||
|
|
||||||
def check_for_delay(self, verb, url, username=None):
|
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)
|
@return: Tuple of delay (in seconds) and error message (or None, None)
|
||||||
"""
|
"""
|
||||||
|
@ -350,8 +339,7 @@ class Limiter(object):
|
||||||
# default limit parsing.
|
# default limit parsing.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_limits(limits):
|
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
|
implementation expects a semicolon-separated sequence of
|
||||||
parenthesized groups, where each group contains a
|
parenthesized groups, where each group contains a
|
||||||
comma-separated sequence consisting of HTTP method,
|
comma-separated sequence consisting of HTTP method,
|
||||||
|
@ -405,8 +393,8 @@ class Limiter(object):
|
||||||
|
|
||||||
|
|
||||||
class WsgiLimiter(object):
|
class WsgiLimiter(object):
|
||||||
"""
|
"""Rate-limit checking from a WSGI application. Uses an in-memory
|
||||||
Rate-limit checking from a WSGI application. Uses an in-memory `Limiter`.
|
`Limiter`.
|
||||||
|
|
||||||
To use, POST ``/<username>`` with JSON data such as::
|
To use, POST ``/<username>`` with JSON data such as::
|
||||||
|
|
||||||
|
@ -421,8 +409,7 @@ class WsgiLimiter(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, limits=None):
|
def __init__(self, limits=None):
|
||||||
"""
|
"""Initialize the new `WsgiLimiter`.
|
||||||
Initialize the new `WsgiLimiter`.
|
|
||||||
|
|
||||||
@param limits: List of `Limit` objects
|
@param limits: List of `Limit` objects
|
||||||
"""
|
"""
|
||||||
|
@ -430,10 +417,11 @@ class WsgiLimiter(object):
|
||||||
|
|
||||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
"""
|
"""Handles a call to this application.
|
||||||
Handles a call to this application. Returns 204 if the request is
|
|
||||||
acceptable to the limiter, else a 403 is returned with a relevant
|
Returns 204 if the request is acceptable to the limiter, else a 403
|
||||||
header indicating when the request *will* succeed.
|
is returned with a relevant header indicating when the request *will*
|
||||||
|
succeed.
|
||||||
"""
|
"""
|
||||||
if request.method != "POST":
|
if request.method != "POST":
|
||||||
raise webob.exc.HTTPMethodNotAllowed()
|
raise webob.exc.HTTPMethodNotAllowed()
|
||||||
|
@ -457,13 +445,10 @@ class WsgiLimiter(object):
|
||||||
|
|
||||||
|
|
||||||
class WsgiLimiterProxy(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):
|
def __init__(self, limiter_address):
|
||||||
"""
|
"""Initialize the new `WsgiLimiterProxy`.
|
||||||
Initialize the new `WsgiLimiterProxy`.
|
|
||||||
|
|
||||||
@param limiter_address: IP/port combination of where to request limit
|
@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.
|
# decisions are made by a remote server.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_limits(limits):
|
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.
|
proxy.
|
||||||
|
|
||||||
@return: Empty list.
|
@return: Empty list.
|
||||||
|
|
|
@ -28,8 +28,7 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||||
|
|
||||||
|
|
||||||
class AgentController(object):
|
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,
|
things like accessing files on the disk, configuring networking,
|
||||||
or running other applications/scripts in the guest while it is
|
or running other applications/scripts in the guest while it is
|
||||||
running. Typically this uses some hypervisor-specific transport
|
running. Typically this uses some hypervisor-specific transport
|
||||||
|
@ -52,9 +51,7 @@ class AgentController(object):
|
||||||
"""
|
"""
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
def index(self, req):
|
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']
|
context = req.environ['nova.context']
|
||||||
authorize(context)
|
authorize(context)
|
||||||
hypervisor = None
|
hypervisor = None
|
||||||
|
|
|
@ -73,8 +73,7 @@ class AggregateController(wsgi.Controller):
|
||||||
@extensions.expected_errors((400, 409))
|
@extensions.expected_errors((400, 409))
|
||||||
@wsgi.response(201)
|
@wsgi.response(201)
|
||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
"""
|
"""Creates an aggregate, given its name and
|
||||||
Creates an aggregate, given its name and
|
|
||||||
optional availability zone.
|
optional availability zone.
|
||||||
"""
|
"""
|
||||||
context = _get_context(req)
|
context = _get_context(req)
|
||||||
|
|
|
@ -44,17 +44,14 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||||
|
|
||||||
|
|
||||||
def _filter_keys(item, keys):
|
def _filter_keys(item, keys):
|
||||||
"""
|
"""Filters all model attributes except for keys
|
||||||
Filters all model attributes except for keys
|
|
||||||
item is a dict
|
item is a dict
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return dict((k, v) for k, v in item.iteritems() if k in keys)
|
return dict((k, v) for k, v in item.iteritems() if k in keys)
|
||||||
|
|
||||||
|
|
||||||
def _fixup_cell_info(cell_info, 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.
|
rpc_host, and rpc_port from it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -202,8 +199,7 @@ class CellsController(object):
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
def _normalize_cell(self, cell, existing=None):
|
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.
|
* Converting cell['type'] to is_parent boolean.
|
||||||
* Merging existing transport URL with transport information.
|
* Merging existing transport URL with transport information.
|
||||||
|
|
|
@ -42,8 +42,7 @@ class EvacuateController(wsgi.Controller):
|
||||||
@wsgi.action('evacuate')
|
@wsgi.action('evacuate')
|
||||||
@validation.schema(evacuate.evacuate)
|
@validation.schema(evacuate.evacuate)
|
||||||
def _evacuate(self, req, id, body):
|
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.
|
to a new one.
|
||||||
"""
|
"""
|
||||||
context = req.environ["nova.context"]
|
context = req.environ["nova.context"]
|
||||||
|
|
|
@ -24,9 +24,7 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
|
||||||
|
|
||||||
|
|
||||||
class FlavorManageController(wsgi.Controller):
|
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
|
_view_builder_class = flavors_view.V3ViewBuilder
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -90,9 +88,7 @@ class FlavorManageController(wsgi.Controller):
|
||||||
|
|
||||||
|
|
||||||
class FlavorManage(extensions.V3APIExtensionBase):
|
class FlavorManage(extensions.V3APIExtensionBase):
|
||||||
"""
|
"""Flavor create/delete API support."""
|
||||||
Flavor create/delete API support
|
|
||||||
"""
|
|
||||||
|
|
||||||
name = "FlavorManage"
|
name = "FlavorManage"
|
||||||
alias = ALIAS
|
alias = ALIAS
|
||||||
|
|
|
@ -37,8 +37,7 @@ class HostController(wsgi.Controller):
|
||||||
|
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
""":returns: A dict in the format:
|
||||||
:returns: A dict in the format:
|
|
||||||
|
|
||||||
{'hosts': [{'host_name': 'some.host.name',
|
{'hosts': [{'host_name': 'some.host.name',
|
||||||
'service': 'cells',
|
'service': 'cells',
|
||||||
|
@ -94,14 +93,12 @@ class HostController(wsgi.Controller):
|
||||||
|
|
||||||
@extensions.expected_errors((400, 404, 501))
|
@extensions.expected_errors((400, 404, 501))
|
||||||
def update(self, req, id, body):
|
def update(self, req, id, body):
|
||||||
"""
|
""":param body: example format {'host': {'status': 'enable',
|
||||||
:param body: example format {'host': {'status': 'enable',
|
|
||||||
'maintenance_mode': 'enable'}}
|
'maintenance_mode': 'enable'}}
|
||||||
:returns:
|
:returns:
|
||||||
"""
|
"""
|
||||||
def read_enabled(orig_val, msg):
|
def read_enabled(orig_val, msg):
|
||||||
"""
|
""":param orig_val: A string with either 'enable' or 'disable'. May
|
||||||
:param orig_val: A string with either 'enable' or 'disable'. May
|
|
||||||
be surrounded by whitespace, and case doesn't
|
be surrounded by whitespace, and case doesn't
|
||||||
matter
|
matter
|
||||||
:param msg: The message to be passed to HTTPBadRequest. A single
|
:param msg: The message to be passed to HTTPBadRequest. A single
|
||||||
|
|
|
@ -52,8 +52,7 @@ class KeypairController(object):
|
||||||
@wsgi.response(201)
|
@wsgi.response(201)
|
||||||
@validation.schema(keypairs.create)
|
@validation.schema(keypairs.create)
|
||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
"""
|
"""Create or import keypair.
|
||||||
Create or import keypair.
|
|
||||||
|
|
||||||
Sending name will generate a key and return private_key
|
Sending name will generate a key and return private_key
|
||||||
and fingerprint.
|
and fingerprint.
|
||||||
|
@ -98,9 +97,7 @@ class KeypairController(object):
|
||||||
@wsgi.response(204)
|
@wsgi.response(204)
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
def delete(self, req, id):
|
def delete(self, req, id):
|
||||||
"""
|
"""Delete a keypair with a given name."""
|
||||||
Delete a keypair with a given name
|
|
||||||
"""
|
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context, action='delete')
|
authorize(context, action='delete')
|
||||||
try:
|
try:
|
||||||
|
@ -122,9 +119,7 @@ class KeypairController(object):
|
||||||
|
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
"""List of keypairs for a user."""
|
||||||
List of keypairs for a user
|
|
||||||
"""
|
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context, action='index')
|
authorize(context, action='index')
|
||||||
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
key_pairs = self.api.get_key_pairs(context, context.user_id)
|
||||||
|
|
|
@ -44,8 +44,7 @@ class ServerPasswordController(object):
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
@wsgi.response(204)
|
@wsgi.response(204)
|
||||||
def clear(self, req, server_id):
|
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
|
Note that this does not actually change the instance server
|
||||||
password.
|
password.
|
||||||
|
|
|
@ -101,8 +101,8 @@ class ServiceController(wsgi.Controller):
|
||||||
|
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""
|
"""Return a list of all running services. Filter by host & service
|
||||||
Return a list of all running services. Filter by host & service name.
|
name
|
||||||
"""
|
"""
|
||||||
services = self._get_services_list(req)
|
services = self._get_services_list(req)
|
||||||
|
|
||||||
|
|
|
@ -1218,8 +1218,7 @@ class Controller(wsgi.Controller):
|
||||||
return image_uuid
|
return image_uuid
|
||||||
|
|
||||||
def _image_from_req_data(self, data):
|
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
|
exceptions
|
||||||
|
|
||||||
If no image is supplied - checks to see if there is
|
If no image is supplied - checks to see if there is
|
||||||
|
|
|
@ -27,9 +27,7 @@ def get_view_builder(req):
|
||||||
class ViewBuilder(common.ViewBuilder):
|
class ViewBuilder(common.ViewBuilder):
|
||||||
|
|
||||||
def __init__(self, base_url):
|
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
|
self.base_url = base_url
|
||||||
|
|
||||||
def build_choices(self, VERSIONS, req):
|
def build_choices(self, VERSIONS, req):
|
||||||
|
|
|
@ -86,8 +86,7 @@ class Request(webob.Request):
|
||||||
self._extension_data = {'db_items': {}}
|
self._extension_data = {'db_items': {}}
|
||||||
|
|
||||||
def cache_db_items(self, key, items, item_key='id'):
|
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.
|
used by API extensions within the same API request.
|
||||||
|
|
||||||
An instance of this class only lives for the lifetime of a
|
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
|
db_items[item[item_key]] = item
|
||||||
|
|
||||||
def get_db_items(self, key):
|
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.
|
the same API request.
|
||||||
|
|
||||||
Note that the object data will be slightly stale.
|
Note that the object data will be slightly stale.
|
||||||
|
@ -108,8 +106,7 @@ class Request(webob.Request):
|
||||||
return self._extension_data['db_items'][key]
|
return self._extension_data['db_items'][key]
|
||||||
|
|
||||||
def get_db_item(self, key, item_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.
|
within the same API request.
|
||||||
|
|
||||||
Note that the object data will be slightly stale.
|
Note that the object data will be slightly stale.
|
||||||
|
@ -246,8 +243,7 @@ class JSONDeserializer(TextDeserializer):
|
||||||
class XMLDeserializer(TextDeserializer):
|
class XMLDeserializer(TextDeserializer):
|
||||||
|
|
||||||
def __init__(self, metadata=None):
|
def __init__(self, metadata=None):
|
||||||
"""
|
""":param metadata: information needed to deserialize xml into
|
||||||
:param metadata: information needed to deserialize xml into
|
|
||||||
a dictionary.
|
a dictionary.
|
||||||
"""
|
"""
|
||||||
super(XMLDeserializer, self).__init__()
|
super(XMLDeserializer, self).__init__()
|
||||||
|
@ -365,8 +361,7 @@ class JSONDictSerializer(DictSerializer):
|
||||||
class XMLDictSerializer(DictSerializer):
|
class XMLDictSerializer(DictSerializer):
|
||||||
|
|
||||||
def __init__(self, metadata=None, xmlns=None):
|
def __init__(self, metadata=None, xmlns=None):
|
||||||
"""
|
""":param metadata: information needed to deserialize xml into
|
||||||
:param metadata: information needed to deserialize xml into
|
|
||||||
a dictionary.
|
a dictionary.
|
||||||
:param xmlns: XML namespace to include with serialized xml
|
:param xmlns: XML namespace to include with serialized xml
|
||||||
"""
|
"""
|
||||||
|
@ -735,10 +730,11 @@ class Resource(wsgi.Application):
|
||||||
|
|
||||||
def __init__(self, controller, action_peek=None, inherits=None,
|
def __init__(self, controller, action_peek=None, inherits=None,
|
||||||
**deserializers):
|
**deserializers):
|
||||||
"""
|
""":param controller: object that implement methods created by routes
|
||||||
:param controller: object that implement methods created by routes lib
|
lib
|
||||||
:param action_peek: dictionary of routines for peeking into an action
|
:param action_peek: dictionary of routines for peeking into an
|
||||||
request body to determine the desired action
|
action request body to determine the
|
||||||
|
desired action
|
||||||
:param inherits: another resource object that this resource should
|
:param inherits: another resource object that this resource should
|
||||||
inherit extensions from. Any action extensions that
|
inherit extensions from. Any action extensions that
|
||||||
are applied to the parent resource will also apply
|
are applied to the parent resource will also apply
|
||||||
|
@ -1255,14 +1251,10 @@ class Fault(webob.exc.HTTPException):
|
||||||
|
|
||||||
|
|
||||||
class RateLimitFault(webob.exc.HTTPException):
|
class RateLimitFault(webob.exc.HTTPException):
|
||||||
"""
|
"""Rate-limited request response."""
|
||||||
Rate-limited request response.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, message, details, retry_time):
|
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)
|
hdrs = RateLimitFault._retry_after(retry_time)
|
||||||
self.wrapped_exc = webob.exc.HTTPTooManyRequests(headers=hdrs)
|
self.wrapped_exc = webob.exc.HTTPTooManyRequests(headers=hdrs)
|
||||||
self.content = {
|
self.content = {
|
||||||
|
@ -1283,9 +1275,8 @@ class RateLimitFault(webob.exc.HTTPException):
|
||||||
|
|
||||||
@webob.dec.wsgify(RequestClass=Request)
|
@webob.dec.wsgify(RequestClass=Request)
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
"""
|
"""Return the wrapped exception with a serialized body conforming
|
||||||
Return the wrapped exception with a serialized body conforming to our
|
to our error format.
|
||||||
error format.
|
|
||||||
"""
|
"""
|
||||||
user_locale = request.best_match_language()
|
user_locale = request.best_match_language()
|
||||||
content_type = request.best_match_content_type()
|
content_type = request.best_match_content_type()
|
||||||
|
|
|
@ -888,9 +888,7 @@ class TemplateBuilder(object):
|
||||||
|
|
||||||
|
|
||||||
def make_links(parent, selector=None):
|
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,
|
elem = SubTemplateElement(parent, '{%s}link' % XMLNS_ATOM,
|
||||||
selector=selector)
|
selector=selector)
|
||||||
|
@ -905,8 +903,7 @@ def make_links(parent, selector=None):
|
||||||
def make_flat_dict(name, selector=None, subselector=None,
|
def make_flat_dict(name, selector=None, subselector=None,
|
||||||
ns=None, colon_ns=False, root=None,
|
ns=None, colon_ns=False, root=None,
|
||||||
ignore_sub_dicts=False):
|
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
|
XMLDictSerializer with no metadata. Returns a template element
|
||||||
where the top-level element has the given tag name, and where
|
where the top-level element has the given tag name, and where
|
||||||
sub-elements have tag names derived from the object's keys and
|
sub-elements have tag names derived from the object's keys and
|
||||||
|
|
|
@ -37,8 +37,9 @@ CONF.register_opt(max_request_body_size_opt)
|
||||||
class LimitingReader(object):
|
class LimitingReader(object):
|
||||||
"""Reader to limit the size of an incoming request."""
|
"""Reader to limit the size of an incoming request."""
|
||||||
def __init__(self, data, limit):
|
def __init__(self, data, limit):
|
||||||
"""
|
"""Initialize a new `LimitingReader`.
|
||||||
:param data: Underlying data object
|
|
||||||
|
:param data: underlying data object
|
||||||
:param limit: maximum number of bytes the reader should allow
|
:param limit: maximum number of bytes the reader should allow
|
||||||
"""
|
"""
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
|
@ -22,8 +22,7 @@ from validators import _SchemaValidator
|
||||||
|
|
||||||
|
|
||||||
def schema(request_body_schema):
|
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
|
Registered schema will be used for validating request body just before
|
||||||
API method executing.
|
API method executing.
|
||||||
|
|
|
@ -274,8 +274,7 @@ class CellsManager(manager.Manager):
|
||||||
return service
|
return service
|
||||||
|
|
||||||
def get_host_uptime(self, ctxt, host_name):
|
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
|
:param host_name: fully qualified hostname. It should be in format of
|
||||||
parent!child@host_id
|
parent!child@host_id
|
||||||
|
@ -286,8 +285,7 @@ class CellsManager(manager.Manager):
|
||||||
return response.value_or_raise()
|
return response.value_or_raise()
|
||||||
|
|
||||||
def service_update(self, ctxt, host_name, binary, params_to_update):
|
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.
|
disabled stops new builds arriving on that host.
|
||||||
|
|
||||||
:param host_name: the name of the host machine that the service is
|
: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)
|
return jsonutils.to_primitive(service)
|
||||||
|
|
||||||
def service_update(self, message, host_name, binary, params_to_update):
|
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.
|
disabled stops new builds arriving on that host.
|
||||||
|
|
||||||
:param host_name: the name of the host machine that the service is
|
: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,
|
def service_update(self, ctxt, cell_name, host_name, binary,
|
||||||
params_to_update):
|
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.
|
disabled stops new builds arriving on that host.
|
||||||
|
|
||||||
:param host_name: the name of the host machine that the service is
|
: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)
|
return cctxt.call(context, 'get_host_uptime', host_name=host_name)
|
||||||
|
|
||||||
def service_update(self, ctxt, host_name, binary, params_to_update):
|
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.
|
disabled stops new builds arriving on that host.
|
||||||
|
|
||||||
:param host_name: the name of the host machine that the service is
|
:param host_name: the name of the host machine that the service is
|
||||||
|
|
|
@ -421,8 +421,7 @@ class CellStateManager(base.Base):
|
||||||
class CellStateManagerDB(CellStateManager):
|
class CellStateManagerDB(CellStateManager):
|
||||||
@utils.synchronized('cell-db-sync')
|
@utils.synchronized('cell-db-sync')
|
||||||
def _cell_data_sync(self, force=False):
|
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.
|
when necessary.
|
||||||
|
|
||||||
:param force: If True, cell status will be updated regardless
|
:param force: If True, cell status will be updated regardless
|
||||||
|
@ -456,8 +455,7 @@ class CellStateManagerFile(CellStateManager):
|
||||||
super(CellStateManagerFile, self).__init__(cell_state_cls)
|
super(CellStateManagerFile, self).__init__(cell_state_cls)
|
||||||
|
|
||||||
def _cell_data_sync(self, force=False):
|
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.
|
when necessary.
|
||||||
|
|
||||||
:param force: If True, cell status will be updated regardless
|
:param force: If True, cell status will be updated regardless
|
||||||
|
|
|
@ -38,8 +38,7 @@ class RamByInstanceTypeWeigher(weights.BaseCellWeigher):
|
||||||
return CONF.cells.ram_weight_multiplier
|
return CONF.cells.ram_weight_multiplier
|
||||||
|
|
||||||
def _weigh_object(self, cell, weight_properties):
|
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
|
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,
|
build to a cell with a higher capacity. Since higher weights win,
|
||||||
we just return the number of units available for the instance_type.
|
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):
|
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
|
Originally designed so you can set a default cell by putting
|
||||||
its weight_offset to 999999999999999 (highest weight wins)
|
its weight_offset to 999999999999999 (highest weight wins)
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -223,8 +223,7 @@ class ProjectCommands(object):
|
||||||
@args('--key', metavar='<key>', help='Key')
|
@args('--key', metavar='<key>', help='Key')
|
||||||
@args('--value', metavar='<value>', help='Value')
|
@args('--value', metavar='<value>', help='Value')
|
||||||
def quota(self, project_id, user_id=None, key=None, value=None):
|
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 no quota key is provided, the quota will be displayed.
|
||||||
If a valid quota key is provided and it does not exist,
|
If a valid quota key is provided and it does not exist,
|
||||||
|
@ -401,8 +400,7 @@ class FloatingIpCommands(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def address_to_hosts(addresses):
|
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
|
If an explicit range specifier is missing, the parameter is
|
||||||
interpreted as a specific individual address.
|
interpreted as a specific individual address.
|
||||||
|
@ -679,8 +677,8 @@ class ServiceCommands(object):
|
||||||
@args('--host', metavar='<host>', help='Host')
|
@args('--host', metavar='<host>', help='Host')
|
||||||
@args('--service', metavar='<service>', help='Nova service')
|
@args('--service', metavar='<service>', help='Nova service')
|
||||||
def list(self, host=None, service=None):
|
def list(self, host=None, service=None):
|
||||||
"""
|
"""Show a list of all running services. Filter by host & service
|
||||||
Show a list of all running services. Filter by host & service name.
|
name
|
||||||
"""
|
"""
|
||||||
servicegroup_api = servicegroup.API()
|
servicegroup_api = servicegroup.API()
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
|
|
|
@ -40,9 +40,8 @@ def API(*args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def HostAPI(*args, **kwargs):
|
def HostAPI(*args, **kwargs):
|
||||||
"""
|
"""Returns the 'HostAPI' class from the same module as the configured
|
||||||
Returns the 'HostAPI' class from the same module as the configured compute
|
compute api
|
||||||
api
|
|
||||||
"""
|
"""
|
||||||
importutils = nova.openstack.common.importutils
|
importutils = nova.openstack.common.importutils
|
||||||
compute_api_class_name = _get_compute_api_class_name()
|
compute_api_class_name = _get_compute_api_class_name()
|
||||||
|
@ -52,8 +51,7 @@ def HostAPI(*args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def InstanceActionAPI(*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.
|
configured compute api.
|
||||||
"""
|
"""
|
||||||
importutils = nova.openstack.common.importutils
|
importutils = nova.openstack.common.importutils
|
||||||
|
|
|
@ -219,8 +219,7 @@ def check_instance_cell(fn):
|
||||||
|
|
||||||
|
|
||||||
def _diff_dict(orig, new):
|
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
|
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
|
of one or two elements. The first element of the list will be
|
||||||
either '+' or '-', indicating whether the key was updated or
|
either '+' or '-', indicating whether the key was updated or
|
||||||
|
@ -441,8 +440,7 @@ class API(base.Base):
|
||||||
raise exception.InvalidMetadataSize(reason=msg)
|
raise exception.InvalidMetadataSize(reason=msg)
|
||||||
|
|
||||||
def _check_requested_secgroups(self, context, secgroups):
|
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.
|
the project.
|
||||||
"""
|
"""
|
||||||
for secgroup in secgroups:
|
for secgroup in secgroups:
|
||||||
|
@ -455,8 +453,7 @@ class API(base.Base):
|
||||||
|
|
||||||
def _check_requested_networks(self, context, requested_networks,
|
def _check_requested_networks(self, context, requested_networks,
|
||||||
max_count):
|
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
|
and the fixed IP address for each network provided is within
|
||||||
same the network block
|
same the network block
|
||||||
"""
|
"""
|
||||||
|
@ -1267,8 +1264,7 @@ class API(base.Base):
|
||||||
block_device_mapping=None, access_ip_v4=None,
|
block_device_mapping=None, access_ip_v4=None,
|
||||||
access_ip_v6=None, requested_networks=None, config_drive=None,
|
access_ip_v6=None, requested_networks=None, config_drive=None,
|
||||||
auto_disk_config=None, scheduler_hints=None, legacy_bdm=True):
|
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)
|
scheduler. The scheduler will determine where the instance(s)
|
||||||
go and will handle creating the DB entries.
|
go and will handle creating the DB entries.
|
||||||
|
|
||||||
|
@ -2110,8 +2106,7 @@ class API(base.Base):
|
||||||
context, None, None, image)
|
context, None, None, image)
|
||||||
|
|
||||||
def _reset_image_metadata():
|
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_'.
|
system metadata. These properties start with 'image_'.
|
||||||
Then add the properties for the new image.
|
Then add the properties for the new image.
|
||||||
"""
|
"""
|
||||||
|
@ -2234,8 +2229,7 @@ class API(base.Base):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _resize_quota_delta(context, new_flavor,
|
def _resize_quota_delta(context, new_flavor,
|
||||||
old_flavor, sense, compare):
|
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.
|
in the resize cycle.
|
||||||
|
|
||||||
:param context: the request context
|
:param context: the request context
|
||||||
|
@ -2261,15 +2255,13 @@ class API(base.Base):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _upsize_quota_delta(context, new_flavor, old_flavor):
|
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)
|
return API._resize_quota_delta(context, new_flavor, old_flavor, 1, 1)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _reverse_upsize_quota_delta(context, migration_ref):
|
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.
|
quota adjustment.
|
||||||
"""
|
"""
|
||||||
old_flavor = flavor_obj.Flavor.get_by_id(
|
old_flavor = flavor_obj.Flavor.get_by_id(
|
||||||
|
@ -2281,8 +2273,7 @@ class API(base.Base):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _downsize_quota_delta(context, instance):
|
def _downsize_quota_delta(context, instance):
|
||||||
"""
|
"""Calculate deltas required to adjust quota for an instance downsize.
|
||||||
Calculate deltas required to adjust quota for an instance downsize.
|
|
||||||
"""
|
"""
|
||||||
old_flavor = instance.get_flavor('old')
|
old_flavor = instance.get_flavor('old')
|
||||||
new_flavor = instance.get_flavor('new')
|
new_flavor = instance.get_flavor('new')
|
||||||
|
@ -3478,8 +3469,7 @@ class KeypairAPI(base.Base):
|
||||||
|
|
||||||
|
|
||||||
class SecurityGroupAPI(base.Base, security_group_base.SecurityGroupBase):
|
class SecurityGroupAPI(base.Base, security_group_base.SecurityGroupBase):
|
||||||
"""
|
"""Sub-set of the Compute API related to managing security groups
|
||||||
Sub-set of the Compute API related to managing security groups
|
|
||||||
and security group rules
|
and security group rules
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -3491,8 +3481,7 @@ class SecurityGroupAPI(base.Base, security_group_base.SecurityGroupBase):
|
||||||
self.security_group_rpcapi = compute_rpcapi.SecurityGroupAPI()
|
self.security_group_rpcapi = compute_rpcapi.SecurityGroupAPI()
|
||||||
|
|
||||||
def validate_property(self, value, property, allowed):
|
def validate_property(self, value, property, allowed):
|
||||||
"""
|
"""Validate given security group property.
|
||||||
Validate given security group property.
|
|
||||||
|
|
||||||
:param value: the value to validate, as a string or unicode
|
:param value: the value to validate, as a string or unicode
|
||||||
:param property: the property, either 'name' or 'description'
|
:param property: the property, either 'name' or 'description'
|
||||||
|
|
|
@ -536,8 +536,7 @@ class HostAPI(compute_api.HostAPI):
|
||||||
db_service)
|
db_service)
|
||||||
|
|
||||||
def service_update(self, context, host_name, binary, params_to_update):
|
def service_update(self, context, 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.
|
disabled stops new builds arriving on that host.
|
||||||
|
|
||||||
:param host_name: the name of the host machine that the service is
|
:param host_name: the name of the host machine that the service is
|
||||||
|
|
|
@ -588,8 +588,7 @@ class ComputeManager(manager.Manager):
|
||||||
return shared_storage
|
return shared_storage
|
||||||
|
|
||||||
def _complete_partial_deletion(self, context, instance):
|
def _complete_partial_deletion(self, context, instance):
|
||||||
"""
|
"""Complete deletion for instances in DELETED status but not marked as
|
||||||
Complete deletion for instances in DELETED status but not marked as
|
|
||||||
deleted in the DB
|
deleted in the DB
|
||||||
"""
|
"""
|
||||||
instance.destroy()
|
instance.destroy()
|
||||||
|
@ -2698,8 +2697,7 @@ class ComputeManager(manager.Manager):
|
||||||
@reverts_task_state
|
@reverts_task_state
|
||||||
@wrap_instance_event
|
@wrap_instance_event
|
||||||
def rescue_instance(self, context, instance, rescue_password):
|
def rescue_instance(self, context, instance, rescue_password):
|
||||||
"""
|
"""Rescue an instance on this host.
|
||||||
Rescue an instance on this host.
|
|
||||||
:param rescue_password: password to set on rescue instance
|
:param rescue_password: password to set on rescue instance
|
||||||
"""
|
"""
|
||||||
context = context.elevated()
|
context = context.elevated()
|
||||||
|
|
|
@ -295,8 +295,7 @@ def notify_usage_exists(notifier, context, instance_ref, current_period=False,
|
||||||
def notify_about_instance_usage(notifier, context, instance, event_suffix,
|
def notify_about_instance_usage(notifier, context, instance, event_suffix,
|
||||||
network_info=None, system_metadata=None,
|
network_info=None, system_metadata=None,
|
||||||
extra_usage_info=None):
|
extra_usage_info=None):
|
||||||
"""
|
"""Send a notification about an instance.
|
||||||
Send a notification about an instance.
|
|
||||||
|
|
||||||
:param notifier: a messaging.Notifier
|
:param notifier: a messaging.Notifier
|
||||||
:param event_suffix: Event type like "delete.start" or "exists"
|
:param event_suffix: Event type like "delete.start" or "exists"
|
||||||
|
@ -321,8 +320,7 @@ def notify_about_instance_usage(notifier, context, instance, event_suffix,
|
||||||
|
|
||||||
|
|
||||||
def notify_about_aggregate_update(context, event_suffix, aggregate_payload):
|
def notify_about_aggregate_update(context, event_suffix, aggregate_payload):
|
||||||
"""
|
"""Send a notification about aggregate update.
|
||||||
Send a notification about aggregate update.
|
|
||||||
|
|
||||||
:param event_suffix: Event type like "create.start" or "create.end"
|
:param event_suffix: Event type like "create.start" or "create.end"
|
||||||
:param aggregate_payload: payload for aggregate update
|
:param aggregate_payload: payload for aggregate update
|
||||||
|
@ -342,8 +340,7 @@ def notify_about_aggregate_update(context, event_suffix, aggregate_payload):
|
||||||
|
|
||||||
|
|
||||||
def notify_about_host_update(context, event_suffix, host_payload):
|
def notify_about_host_update(context, event_suffix, host_payload):
|
||||||
"""
|
"""Send a notification about host update.
|
||||||
Send a notification about host update.
|
|
||||||
|
|
||||||
:param event_suffix: Event type like "create.start" or "create.end"
|
:param event_suffix: Event type like "create.start" or "create.end"
|
||||||
:param host_payload: payload for host update. It is a dict and there
|
:param host_payload: payload for host update. It is a dict and there
|
||||||
|
|
|
@ -38,9 +38,7 @@ class NovaWebSocketProxy(websockify.WebSocketProxy):
|
||||||
ssl_target=None, *args, **kwargs)
|
ssl_target=None, *args, **kwargs)
|
||||||
|
|
||||||
def new_client(self):
|
def new_client(self):
|
||||||
"""
|
"""Called after a new WebSocket connection has been established."""
|
||||||
Called after a new WebSocket connection has been established.
|
|
||||||
"""
|
|
||||||
# Reopen the eventlet hub to make sure we don't share an epoll
|
# Reopen the eventlet hub to make sure we don't share an epoll
|
||||||
# fd with parent and/or siblings, which would be bad
|
# fd with parent and/or siblings, which would be bad
|
||||||
from eventlet import hubs
|
from eventlet import hubs
|
||||||
|
|
|
@ -49,10 +49,10 @@ class RequestContext(object):
|
||||||
request_id=None, auth_token=None, overwrite=True,
|
request_id=None, auth_token=None, overwrite=True,
|
||||||
quota_class=None, user_name=None, project_name=None,
|
quota_class=None, user_name=None, project_name=None,
|
||||||
service_catalog=None, instance_lock_checked=False, **kwargs):
|
service_catalog=None, instance_lock_checked=False, **kwargs):
|
||||||
"""
|
""":param read_deleted: 'no' indicates deleted records are hidden,
|
||||||
:param read_deleted: 'no' indicates deleted records are hidden, 'yes'
|
'yes' indicates deleted records are visible,
|
||||||
indicates deleted records are visible, 'only' indicates that
|
'only' indicates that *only* deleted records are visible.
|
||||||
*only* deleted records are visible.
|
|
||||||
|
|
||||||
:param overwrite: Set to False to ensure that the greenthread local
|
:param overwrite: Set to False to ensure that the greenthread local
|
||||||
copy of the index is not overwritten.
|
copy of the index is not overwritten.
|
||||||
|
|
|
@ -442,8 +442,7 @@ def migration_get_by_instance_and_status(context, instance_uuid, status):
|
||||||
|
|
||||||
def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
|
def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
|
||||||
dest_compute, use_slave=False):
|
dest_compute, use_slave=False):
|
||||||
"""
|
"""Finds all unconfirmed migrations within the confirmation window for
|
||||||
Finds all unconfirmed migrations within the confirmation window for
|
|
||||||
a specific destination compute host.
|
a specific destination compute host.
|
||||||
"""
|
"""
|
||||||
return IMPL.migration_get_unconfirmed_by_dest_compute(context,
|
return IMPL.migration_get_unconfirmed_by_dest_compute(context,
|
||||||
|
|
|
@ -1271,8 +1271,7 @@ def _fixed_ip_get_by_address(context, address, session=None,
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def fixed_ip_get_by_address_detailed(context, address):
|
def fixed_ip_get_by_address_detailed(context, address):
|
||||||
"""
|
""":returns: a tuple of (models.FixedIp, models.Network, models.Instance)
|
||||||
:returns: a tuple of (models.FixedIp, models.Network, models.Instance)
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
result = model_query(context, models.FixedIp,
|
result = model_query(context, models.FixedIp,
|
||||||
|
@ -3439,8 +3438,7 @@ def _block_device_mapping_get_query(context, session=None,
|
||||||
|
|
||||||
|
|
||||||
def _scrub_empty_str_values(dct, keys_to_scrub):
|
def _scrub_empty_str_values(dct, keys_to_scrub):
|
||||||
"""
|
"""Remove any keys found in sequence keys_to_scrub from the dict
|
||||||
Remove any keys found in sequence keys_to_scrub from the dict
|
|
||||||
if they have the value ''.
|
if they have the value ''.
|
||||||
"""
|
"""
|
||||||
for key in keys_to_scrub:
|
for key in keys_to_scrub:
|
||||||
|
@ -3579,8 +3577,7 @@ def _security_group_get_query(context, session=None, read_deleted=None,
|
||||||
|
|
||||||
|
|
||||||
def _security_group_get_by_names(context, session, project_id, group_names):
|
def _security_group_get_by_names(context, session, project_id, group_names):
|
||||||
"""
|
"""Get security group models for a project by a list of names.
|
||||||
Get security group models for a project by a list of names.
|
|
||||||
Raise SecurityGroupNotFoundForProject for a name not found.
|
Raise SecurityGroupNotFoundForProject for a name not found.
|
||||||
"""
|
"""
|
||||||
query = _security_group_get_query(context, session=session,
|
query = _security_group_get_query(context, session=session,
|
||||||
|
@ -4241,8 +4238,7 @@ def _flavor_get_query(context, session=None, read_deleted=None):
|
||||||
def flavor_get_all(context, inactive=False, filters=None,
|
def flavor_get_all(context, inactive=False, filters=None,
|
||||||
sort_key='flavorid', sort_dir='asc', limit=None,
|
sort_key='flavorid', sort_dir='asc', limit=None,
|
||||||
marker=None):
|
marker=None):
|
||||||
"""
|
"""Returns all flavors.
|
||||||
Returns all flavors.
|
|
||||||
"""
|
"""
|
||||||
filters = filters or {}
|
filters = filters or {}
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,7 @@ class Instance(BASE, NovaBase):
|
||||||
|
|
||||||
|
|
||||||
class InstanceInfoCache(BASE, NovaBase):
|
class InstanceInfoCache(BASE, NovaBase):
|
||||||
"""
|
"""Represents a cache of information about an instance
|
||||||
Represents a cache of information about an instance
|
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'instance_info_caches'
|
__tablename__ = 'instance_info_caches'
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -1349,8 +1348,7 @@ class InstanceGroup(BASE, NovaBase):
|
||||||
|
|
||||||
|
|
||||||
class PciDevice(BASE, NovaBase):
|
class PciDevice(BASE, NovaBase):
|
||||||
"""
|
"""Represents a PCI host device that can be passed through to instances.
|
||||||
Represents a PCI host device that can be passed through to instances.
|
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'pci_devices'
|
__tablename__ = 'pci_devices'
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
|
|
@ -183,10 +183,9 @@ def _drop_unique_constraint_in_sqlite(migrate_engine, table_name, uc_name,
|
||||||
|
|
||||||
def drop_unique_constraint(migrate_engine, table_name, uc_name, *columns,
|
def drop_unique_constraint(migrate_engine, table_name, uc_name, *columns,
|
||||||
**col_name_col_instance):
|
**col_name_col_instance):
|
||||||
"""
|
"""This method drops UC from table and works for mysql, postgresql and
|
||||||
This method drops UC from table and works for mysql, postgresql and sqlite.
|
sqlite. In mysql and postgresql we are able to use "alter table"
|
||||||
In mysql and postgresql we are able to use "alter table" construction. In
|
construction. In sqlite is only one way to drop UC:
|
||||||
sqlite is only one way to drop UC:
|
|
||||||
1) Create new table with same columns, indexes and constraints
|
1) Create new table with same columns, indexes and constraints
|
||||||
(except one that we want to drop).
|
(except one that we want to drop).
|
||||||
2) Copy data from old table to new.
|
2) Copy data from old table to new.
|
||||||
|
@ -215,8 +214,7 @@ def drop_unique_constraint(migrate_engine, table_name, uc_name, *columns,
|
||||||
|
|
||||||
def drop_old_duplicate_entries_from_table(migrate_engine, table_name,
|
def drop_old_duplicate_entries_from_table(migrate_engine, table_name,
|
||||||
use_soft_delete, *uc_column_names):
|
use_soft_delete, *uc_column_names):
|
||||||
"""
|
"""This method is used to drop all old rows that have the same values for
|
||||||
This method is used to drop all old rows that have the same values for
|
|
||||||
columns in uc_columns.
|
columns in uc_columns.
|
||||||
"""
|
"""
|
||||||
meta = MetaData()
|
meta = MetaData()
|
||||||
|
@ -257,9 +255,8 @@ def drop_old_duplicate_entries_from_table(migrate_engine, table_name,
|
||||||
|
|
||||||
|
|
||||||
def check_shadow_table(migrate_engine, table_name):
|
def check_shadow_table(migrate_engine, table_name):
|
||||||
"""
|
"""This method checks that table with ``table_name`` and
|
||||||
This method checks that table with ``table_name`` and corresponding shadow
|
corresponding shadow table have same columns.
|
||||||
table have same columns.
|
|
||||||
"""
|
"""
|
||||||
meta = MetaData()
|
meta = MetaData()
|
||||||
meta.bind = migrate_engine
|
meta.bind = migrate_engine
|
||||||
|
@ -296,9 +293,8 @@ def check_shadow_table(migrate_engine, table_name):
|
||||||
|
|
||||||
def create_shadow_table(migrate_engine, table_name=None, table=None,
|
def create_shadow_table(migrate_engine, table_name=None, table=None,
|
||||||
**col_name_col_instance):
|
**col_name_col_instance):
|
||||||
"""
|
"""This method create shadow table for table with name ``table_name``
|
||||||
This method create shadow table for table with name ``table_name`` or table
|
or table instance ``table``.
|
||||||
instance ``table``.
|
|
||||||
:param table_name: Autoload table with this name and create shadow table
|
:param table_name: Autoload table with this name and create shadow table
|
||||||
:param table: Autoloaded table, so just create corresponding shadow table.
|
:param table: Autoloaded table, so just create corresponding shadow table.
|
||||||
:param col_name_col_instance: contains pair column_name=column_instance.
|
:param col_name_col_instance: contains pair column_name=column_instance.
|
||||||
|
|
|
@ -142,8 +142,7 @@ def _create_glance_client(context, host, port, use_ssl, version=1):
|
||||||
|
|
||||||
|
|
||||||
def get_api_servers():
|
def get_api_servers():
|
||||||
"""
|
"""Shuffle a list of CONF.glance_api_servers and return an iterator
|
||||||
Shuffle a list of CONF.glance_api_servers and return an iterator
|
|
||||||
that will cycle through the list, looping around to the beginning
|
that will cycle through the list, looping around to the beginning
|
||||||
if necessary.
|
if necessary.
|
||||||
"""
|
"""
|
||||||
|
@ -195,8 +194,7 @@ class GlanceClientWrapper(object):
|
||||||
self.use_ssl, version)
|
self.use_ssl, version)
|
||||||
|
|
||||||
def call(self, context, version, method, *args, **kwargs):
|
def call(self, context, version, method, *args, **kwargs):
|
||||||
"""
|
"""Call a glance client method. If we get a connection error,
|
||||||
Call a glance client method. If we get a connection error,
|
|
||||||
retry the request according to CONF.glance_num_retries.
|
retry the request according to CONF.glance_num_retries.
|
||||||
"""
|
"""
|
||||||
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
||||||
|
|
|
@ -46,11 +46,11 @@ CONF.register_opts(key_mgr_opts, group='keymgr')
|
||||||
|
|
||||||
|
|
||||||
class ConfKeyManager(single_key_mgr.SingleKeyManager):
|
class ConfKeyManager(single_key_mgr.SingleKeyManager):
|
||||||
"""
|
"""This key manager implementation supports all the methods specified by
|
||||||
This key manager implementation supports all the methods specified by the
|
the key manager interface. This implementation creates a single key in
|
||||||
key manager interface. This implementation creates a single key in response
|
response to all invocations of create_key. Side effects
|
||||||
to all invocations of create_key. Side effects (e.g., raising exceptions)
|
(e.g., raising exceptions) for each method are handled
|
||||||
for each method are handled as specified by the key manager interface.
|
as specified by the key manager interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -54,9 +54,7 @@ class Key(object):
|
||||||
|
|
||||||
|
|
||||||
class SymmetricKey(Key):
|
class SymmetricKey(Key):
|
||||||
"""
|
"""This class represents symmetric keys."""
|
||||||
This class represents symmetric keys
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, alg, key):
|
def __init__(self, alg, key):
|
||||||
"""Create a new SymmetricKey object.
|
"""Create a new SymmetricKey object.
|
||||||
|
|
|
@ -41,8 +41,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MockKeyManager(key_mgr.KeyManager):
|
class MockKeyManager(key_mgr.KeyManager):
|
||||||
"""
|
"""This mock key manager implementation supports all the methods specified
|
||||||
This mock key manager implementation supports all the methods specified
|
|
||||||
by the key manager interface. This implementation stores keys within a
|
by the key manager interface. This implementation stores keys within a
|
||||||
dictionary, and as a result, it is not acceptable for use across different
|
dictionary, and as a result, it is not acceptable for use across different
|
||||||
services. Side effects (e.g., raising exceptions) for each method are
|
services. Side effects (e.g., raising exceptions) for each method are
|
||||||
|
|
|
@ -29,11 +29,11 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SingleKeyManager(mock_key_mgr.MockKeyManager):
|
class SingleKeyManager(mock_key_mgr.MockKeyManager):
|
||||||
"""
|
"""This key manager implementation supports all the methods specified by
|
||||||
This key manager implementation supports all the methods specified by the
|
the key manager interface. This implementation creates a single key in
|
||||||
key manager interface. This implementation creates a single key in response
|
response to all invocations of create_key. Side effects
|
||||||
to all invocations of create_key. Side effects (e.g., raising exceptions)
|
(e.g., raising exceptions) for each method are handled as specified by
|
||||||
for each method are handled as specified by the key manager interface.
|
the key manager interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -25,8 +25,7 @@ CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def _get_my_ip():
|
def _get_my_ip():
|
||||||
"""
|
"""Returns the actual ip of the local machine.
|
||||||
Returns the actual ip of the local machine.
|
|
||||||
|
|
||||||
This code figures out what source address would be used if some traffic
|
This code figures out what source address would be used if some traffic
|
||||||
were to be sent out to some well known address on the Internet. In this
|
were to be sent out to some well known address on the Internet. In this
|
||||||
|
|
|
@ -36,8 +36,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def refresh_cache(f):
|
def refresh_cache(f):
|
||||||
"""
|
"""Decorator to update the instance_info_cache
|
||||||
Decorator to update the instance_info_cache
|
|
||||||
|
|
||||||
Requires context and instance as function args
|
Requires context and instance as function args
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1388,8 +1388,7 @@ def get_dev(network):
|
||||||
|
|
||||||
|
|
||||||
class LinuxNetInterfaceDriver(object):
|
class LinuxNetInterfaceDriver(object):
|
||||||
"""
|
"""Abstract class that defines generic network host API
|
||||||
Abstract class that defines generic network host API
|
|
||||||
for for all Linux interface drivers.
|
for for all Linux interface drivers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MiniDNS(dns_driver.DNSDriver):
|
class MiniDNS(dns_driver.DNSDriver):
|
||||||
"""
|
"""Trivial DNS driver. This will read/write to a local, flat file
|
||||||
Trivial DNS driver. This will read/write to a local, flat file
|
|
||||||
and have no effect on your actual DNS system. This class is
|
and have no effect on your actual DNS system. This class is
|
||||||
strictly for testing purposes, and should keep you out of dependency
|
strictly for testing purposes, and should keep you out of dependency
|
||||||
hell.
|
hell.
|
||||||
|
|
|
@ -46,8 +46,7 @@ def pci_device_prop_match(pci_dev, specs):
|
||||||
|
|
||||||
|
|
||||||
def parse_address(address):
|
def parse_address(address):
|
||||||
"""
|
"""Returns (domain, bus, slot, function) from PCI address that is stored in
|
||||||
Returns (domain, bus, slot, function) from PCI address that is stored in
|
|
||||||
PciDevice DB table.
|
PciDevice DB table.
|
||||||
"""
|
"""
|
||||||
m = _PCI_ADDRESS_REGEX.match(address)
|
m = _PCI_ADDRESS_REGEX.match(address)
|
||||||
|
|
|
@ -88,8 +88,7 @@ CONF.register_opts(quota_opts)
|
||||||
|
|
||||||
|
|
||||||
class DbQuotaDriver(object):
|
class DbQuotaDriver(object):
|
||||||
"""
|
"""Driver to perform necessary checks to enforce quotas and obtain
|
||||||
Driver to perform necessary checks to enforce quotas and obtain
|
|
||||||
quota information. The default driver utilizes the local
|
quota information. The default driver utilizes the local
|
||||||
database.
|
database.
|
||||||
"""
|
"""
|
||||||
|
@ -127,8 +126,7 @@ class DbQuotaDriver(object):
|
||||||
|
|
||||||
def get_class_quotas(self, context, resources, quota_class,
|
def get_class_quotas(self, context, resources, quota_class,
|
||||||
defaults=True):
|
defaults=True):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
quota class.
|
quota class.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -201,8 +199,7 @@ class DbQuotaDriver(object):
|
||||||
quota_class=None, defaults=True,
|
quota_class=None, defaults=True,
|
||||||
usages=True, project_quotas=None,
|
usages=True, project_quotas=None,
|
||||||
user_quotas=None):
|
user_quotas=None):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
user and project.
|
user and project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -244,8 +241,7 @@ class DbQuotaDriver(object):
|
||||||
def get_project_quotas(self, context, resources, project_id,
|
def get_project_quotas(self, context, resources, project_id,
|
||||||
quota_class=None, defaults=True,
|
quota_class=None, defaults=True,
|
||||||
usages=True, remains=False, project_quotas=None):
|
usages=True, remains=False, project_quotas=None):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
project.
|
project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -279,8 +275,7 @@ class DbQuotaDriver(object):
|
||||||
|
|
||||||
def get_settable_quotas(self, context, resources, project_id,
|
def get_settable_quotas(self, context, resources, project_id,
|
||||||
user_id=None):
|
user_id=None):
|
||||||
"""
|
"""Given a list of resources, retrieve the range of settable quotas for
|
||||||
Given a list of resources, retrieve the range of settable quotas for
|
|
||||||
the given user or project.
|
the given user or project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -317,8 +312,7 @@ class DbQuotaDriver(object):
|
||||||
|
|
||||||
def _get_quotas(self, context, resources, keys, has_sync, project_id=None,
|
def _get_quotas(self, context, resources, keys, has_sync, project_id=None,
|
||||||
user_id=None, project_quotas=None):
|
user_id=None, project_quotas=None):
|
||||||
"""
|
"""A helper method which retrieves the quotas for the specific
|
||||||
A helper method which retrieves the quotas for the specific
|
|
||||||
resources identified by keys, and which apply to the current
|
resources identified by keys, and which apply to the current
|
||||||
context.
|
context.
|
||||||
|
|
||||||
|
@ -565,8 +559,7 @@ class DbQuotaDriver(object):
|
||||||
user_id=user_id)
|
user_id=user_id)
|
||||||
|
|
||||||
def usage_reset(self, context, resources):
|
def usage_reset(self, context, resources):
|
||||||
"""
|
"""Reset the usage records for a particular user on a list of
|
||||||
Reset the usage records for a particular user on a list of
|
|
||||||
resources. This will force that user's usage records to be
|
resources. This will force that user's usage records to be
|
||||||
refreshed the next time a reservation is made.
|
refreshed the next time a reservation is made.
|
||||||
|
|
||||||
|
@ -595,8 +588,7 @@ class DbQuotaDriver(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project and user.
|
project and user.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -607,8 +599,7 @@ class DbQuotaDriver(object):
|
||||||
db.quota_destroy_all_by_project_and_user(context, project_id, user_id)
|
db.quota_destroy_all_by_project_and_user(context, project_id, user_id)
|
||||||
|
|
||||||
def destroy_all_by_project(self, context, project_id):
|
def destroy_all_by_project(self, context, project_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project.
|
project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -665,8 +656,7 @@ class NoopQuotaDriver(object):
|
||||||
|
|
||||||
def get_class_quotas(self, context, resources, quota_class,
|
def get_class_quotas(self, context, resources, quota_class,
|
||||||
defaults=True):
|
defaults=True):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
quota class.
|
quota class.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -697,8 +687,7 @@ class NoopQuotaDriver(object):
|
||||||
def get_user_quotas(self, context, resources, project_id, user_id,
|
def get_user_quotas(self, context, resources, project_id, user_id,
|
||||||
quota_class=None, defaults=True,
|
quota_class=None, defaults=True,
|
||||||
usages=True):
|
usages=True):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
user and project.
|
user and project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -722,8 +711,7 @@ class NoopQuotaDriver(object):
|
||||||
def get_project_quotas(self, context, resources, project_id,
|
def get_project_quotas(self, context, resources, project_id,
|
||||||
quota_class=None, defaults=True,
|
quota_class=None, defaults=True,
|
||||||
usages=True, remains=False):
|
usages=True, remains=False):
|
||||||
"""
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
Given a list of resources, retrieve the quotas for the given
|
|
||||||
project.
|
project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -747,8 +735,7 @@ class NoopQuotaDriver(object):
|
||||||
|
|
||||||
def get_settable_quotas(self, context, resources, project_id,
|
def get_settable_quotas(self, context, resources, project_id,
|
||||||
user_id=None):
|
user_id=None):
|
||||||
"""
|
"""Given a list of resources, retrieve the range of settable quotas for
|
||||||
Given a list of resources, retrieve the range of settable quotas for
|
|
||||||
the given user or project.
|
the given user or project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -862,8 +849,7 @@ class NoopQuotaDriver(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def usage_reset(self, context, resources):
|
def usage_reset(self, context, resources):
|
||||||
"""
|
"""Reset the usage records for a particular user on a list of
|
||||||
Reset the usage records for a particular user on a list of
|
|
||||||
resources. This will force that user's usage records to be
|
resources. This will force that user's usage records to be
|
||||||
refreshed the next time a reservation is made.
|
refreshed the next time a reservation is made.
|
||||||
|
|
||||||
|
@ -878,8 +864,7 @@ class NoopQuotaDriver(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project and user.
|
project and user.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -889,8 +874,7 @@ class NoopQuotaDriver(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def destroy_all_by_project(self, context, project_id):
|
def destroy_all_by_project(self, context, project_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project.
|
project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -913,8 +897,7 @@ class BaseResource(object):
|
||||||
"""Describe a single resource for quota checking."""
|
"""Describe a single resource for quota checking."""
|
||||||
|
|
||||||
def __init__(self, name, flag=None):
|
def __init__(self, name, flag=None):
|
||||||
"""
|
"""Initializes a Resource.
|
||||||
Initializes a Resource.
|
|
||||||
|
|
||||||
:param name: The name of the resource, i.e., "instances".
|
:param name: The name of the resource, i.e., "instances".
|
||||||
:param flag: The name of the flag or configuration option
|
:param flag: The name of the flag or configuration option
|
||||||
|
@ -926,8 +909,7 @@ class BaseResource(object):
|
||||||
self.flag = flag
|
self.flag = flag
|
||||||
|
|
||||||
def quota(self, driver, context, **kwargs):
|
def quota(self, driver, context, **kwargs):
|
||||||
"""
|
"""Given a driver and context, obtain the quota for this
|
||||||
Given a driver and context, obtain the quota for this
|
|
||||||
resource.
|
resource.
|
||||||
|
|
||||||
:param driver: A quota driver.
|
:param driver: A quota driver.
|
||||||
|
@ -1023,14 +1005,12 @@ class AbsoluteResource(BaseResource):
|
||||||
|
|
||||||
|
|
||||||
class CountableResource(AbsoluteResource):
|
class CountableResource(AbsoluteResource):
|
||||||
"""
|
"""Describe a resource where the counts aren't based solely on the
|
||||||
Describe a resource where the counts aren't based solely on the
|
|
||||||
project ID.
|
project ID.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, count, flag=None):
|
def __init__(self, name, count, flag=None):
|
||||||
"""
|
"""Initializes a CountableResource.
|
||||||
Initializes a CountableResource.
|
|
||||||
|
|
||||||
Countable resources are those resources which directly
|
Countable resources are those resources which directly
|
||||||
correspond to objects in the database, i.e., instances, cores,
|
correspond to objects in the database, i.e., instances, cores,
|
||||||
|
@ -1185,8 +1165,7 @@ class QuotaEngine(object):
|
||||||
remains=remains)
|
remains=remains)
|
||||||
|
|
||||||
def get_settable_quotas(self, context, project_id, user_id=None):
|
def get_settable_quotas(self, context, project_id, user_id=None):
|
||||||
"""
|
"""Given a list of resources, retrieve the range of settable quotas for
|
||||||
Given a list of resources, retrieve the range of settable quotas for
|
|
||||||
the given user or project.
|
the given user or project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -1342,8 +1321,7 @@ class QuotaEngine(object):
|
||||||
LOG.debug(_("Rolled back reservations %s"), reservations)
|
LOG.debug(_("Rolled back reservations %s"), reservations)
|
||||||
|
|
||||||
def usage_reset(self, context, resources):
|
def usage_reset(self, context, resources):
|
||||||
"""
|
"""Reset the usage records for a particular user on a list of
|
||||||
Reset the usage records for a particular user on a list of
|
|
||||||
resources. This will force that user's usage records to be
|
resources. This will force that user's usage records to be
|
||||||
refreshed the next time a reservation is made.
|
refreshed the next time a reservation is made.
|
||||||
|
|
||||||
|
@ -1359,8 +1337,7 @@ class QuotaEngine(object):
|
||||||
self._driver.usage_reset(context, resources)
|
self._driver.usage_reset(context, resources)
|
||||||
|
|
||||||
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
def destroy_all_by_project_and_user(self, context, project_id, user_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project and user.
|
project and user.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
@ -1372,8 +1349,7 @@ class QuotaEngine(object):
|
||||||
project_id, user_id)
|
project_id, user_id)
|
||||||
|
|
||||||
def destroy_all_by_project(self, context, project_id):
|
def destroy_all_by_project(self, context, project_id):
|
||||||
"""
|
"""Destroy all quotas, usages, and reservations associated with a
|
||||||
Destroy all quotas, usages, and reservations associated with a
|
|
||||||
project.
|
project.
|
||||||
|
|
||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
|
|
|
@ -40,8 +40,7 @@ class IsolatedHostsFilter(filters.BaseHostFilter):
|
||||||
run_filter_once_per_request = True
|
run_filter_once_per_request = True
|
||||||
|
|
||||||
def host_passes(self, host_state, filter_properties):
|
def host_passes(self, host_state, filter_properties):
|
||||||
"""
|
"""Result Matrix with 'restrict_isolated_hosts_to_isolated_images' set
|
||||||
Result Matrix with 'restrict_isolated_hosts_to_isolated_images' set
|
|
||||||
to True:
|
to True:
|
||||||
| isolated_image | non_isolated_image
|
| isolated_image | non_isolated_image
|
||||||
-------------+----------------+-------------------
|
-------------+----------------+-------------------
|
||||||
|
|
|
@ -83,8 +83,7 @@ CONF.register_opts(trusted_opts, group=trust_group)
|
||||||
|
|
||||||
|
|
||||||
class HTTPSClientAuthConnection(httplib.HTTPSConnection):
|
class HTTPSClientAuthConnection(httplib.HTTPSConnection):
|
||||||
"""
|
"""Class to make a HTTPS connection, with support for full client-based
|
||||||
Class to make a HTTPS connection, with support for full client-based
|
|
||||||
SSL Authentication
|
SSL Authentication
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -100,8 +99,7 @@ class HTTPSClientAuthConnection(httplib.HTTPSConnection):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""
|
"""Connect to a host on a given (SSL) port.
|
||||||
Connect to a host on a given (SSL) port.
|
|
||||||
If ca_file is pointing somewhere, use it to check Server Certificate.
|
If ca_file is pointing somewhere, use it to check Server Certificate.
|
||||||
|
|
||||||
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
|
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
|
||||||
|
|
|
@ -44,8 +44,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerOptions(object):
|
class SchedulerOptions(object):
|
||||||
"""
|
"""SchedulerOptions monitors a local .json file for changes and loads it
|
||||||
SchedulerOptions monitors a local .json file for changes and loads it
|
|
||||||
if needed. This file is converted to a data structure and passed into
|
if needed. This file is converted to a data structure and passed into
|
||||||
the filtering and weighing functions which can use it for dynamic
|
the filtering and weighing functions which can use it for dynamic
|
||||||
configuration.
|
configuration.
|
||||||
|
|
|
@ -72,8 +72,7 @@ class DbDriver(api.ServiceGroupDriver):
|
||||||
return abs(elapsed) <= CONF.service_down_time
|
return abs(elapsed) <= CONF.service_down_time
|
||||||
|
|
||||||
def get_all(self, group_id):
|
def get_all(self, group_id):
|
||||||
"""
|
"""Returns ALL members of the given group
|
||||||
Returns ALL members of the given group
|
|
||||||
"""
|
"""
|
||||||
LOG.debug(_('DB_Driver: get_all members of the %s group') % group_id)
|
LOG.debug(_('DB_Driver: get_all members of the %s group') % group_id)
|
||||||
rs = []
|
rs = []
|
||||||
|
|
|
@ -70,8 +70,7 @@ class MemcachedDriver(api.ServiceGroupDriver):
|
||||||
return self.mc.get(str(key)) is not None
|
return self.mc.get(str(key)) is not None
|
||||||
|
|
||||||
def get_all(self, group_id):
|
def get_all(self, group_id):
|
||||||
"""
|
"""Returns ALL members of the given group
|
||||||
Returns ALL members of the given group
|
|
||||||
"""
|
"""
|
||||||
LOG.debug(_('Memcached_Driver: get_all members of the %s group') %
|
LOG.debug(_('Memcached_Driver: get_all members of the %s group') %
|
||||||
group_id)
|
group_id)
|
||||||
|
|
|
@ -321,8 +321,7 @@ class TimeOverride(fixtures.Fixture):
|
||||||
|
|
||||||
|
|
||||||
class NoDBTestCase(TestCase):
|
class NoDBTestCase(TestCase):
|
||||||
"""
|
"""`NoDBTestCase` differs from TestCase in that DB access is not supported.
|
||||||
`NoDBTestCase` differs from TestCase in that DB access is not supported.
|
|
||||||
This makes tests run significantly faster. If possible, all new tests
|
This makes tests run significantly faster. If possible, all new tests
|
||||||
should derive from this class.
|
should derive from this class.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -282,8 +282,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||||
return self.http
|
return self.http
|
||||||
|
|
||||||
def test_return_valid_isoformat(self):
|
def test_return_valid_isoformat(self):
|
||||||
"""
|
"""Ensure that the ec2 api returns datetime in xs:dateTime
|
||||||
Ensure that the ec2 api returns datetime in xs:dateTime
|
|
||||||
(which apparently isn't datetime.isoformat())
|
(which apparently isn't datetime.isoformat())
|
||||||
NOTE(ken-pepple): https://bugs.launchpad.net/nova/+bug/721297
|
NOTE(ken-pepple): https://bugs.launchpad.net/nova/+bug/721297
|
||||||
"""
|
"""
|
||||||
|
@ -438,8 +437,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||||
'test group')
|
'test group')
|
||||||
|
|
||||||
def test_authorize_revoke_security_group_cidr(self):
|
def test_authorize_revoke_security_group_cidr(self):
|
||||||
"""
|
"""Test that we can add and remove CIDR based rules
|
||||||
Test that we can add and remove CIDR based rules
|
|
||||||
to a security group
|
to a security group
|
||||||
"""
|
"""
|
||||||
self.expect_http()
|
self.expect_http()
|
||||||
|
@ -542,8 +540,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||||
self.assertEqual(rv[0].name, 'default')
|
self.assertEqual(rv[0].name, 'default')
|
||||||
|
|
||||||
def test_authorize_revoke_security_group_cidr_v6(self):
|
def test_authorize_revoke_security_group_cidr_v6(self):
|
||||||
"""
|
"""Test that we can add and remove CIDR based rules
|
||||||
Test that we can add and remove CIDR based rules
|
|
||||||
to a security group for IPv6
|
to a security group for IPv6
|
||||||
"""
|
"""
|
||||||
self.expect_http()
|
self.expect_http()
|
||||||
|
@ -594,8 +591,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||||
self.assertEqual(rv[0].name, 'default')
|
self.assertEqual(rv[0].name, 'default')
|
||||||
|
|
||||||
def test_authorize_revoke_security_group_foreign_group(self):
|
def test_authorize_revoke_security_group_foreign_group(self):
|
||||||
"""
|
"""Test that we can grant and revoke another security group access
|
||||||
Test that we can grant and revoke another security group access
|
|
||||||
to a security group
|
to a security group
|
||||||
"""
|
"""
|
||||||
self.expect_http()
|
self.expect_http()
|
||||||
|
|
|
@ -2439,8 +2439,7 @@ class CloudTestCase(test.TestCase):
|
||||||
self._do_test_create_image(False)
|
self._do_test_create_image(False)
|
||||||
|
|
||||||
def test_create_image_instance_store(self):
|
def test_create_image_instance_store(self):
|
||||||
"""
|
"""Ensure CreateImage fails as expected for an instance-store-backed
|
||||||
Ensure CreateImage fails as expected for an instance-store-backed
|
|
||||||
instance
|
instance
|
||||||
"""
|
"""
|
||||||
# enforce periodic tasks run in short time to avoid wait for 60s.
|
# enforce periodic tasks run in short time to avoid wait for 60s.
|
||||||
|
|
|
@ -39,8 +39,7 @@ class TestServerExceptionEC2(Exception):
|
||||||
|
|
||||||
|
|
||||||
class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
||||||
"""
|
"""Test EC2 error responses.
|
||||||
Test EC2 error responses.
|
|
||||||
|
|
||||||
This deals mostly with api/ec2/__init__.py code, especially
|
This deals mostly with api/ec2/__init__.py code, especially
|
||||||
the ec2_error_ex helper.
|
the ec2_error_ex helper.
|
||||||
|
@ -85,17 +84,14 @@ class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(requestid_e.text, self.context.request_id)
|
self.assertEqual(requestid_e.text, self.context.request_id)
|
||||||
|
|
||||||
def test_exception_ec2_4xx(self):
|
def test_exception_ec2_4xx(self):
|
||||||
"""
|
"""Test response to EC2 exception with code = 400."""
|
||||||
Test response to EC2 exception with code = 400.
|
|
||||||
"""
|
|
||||||
msg = "Test client failure."
|
msg = "Test client failure."
|
||||||
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req)
|
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req)
|
||||||
self._validate_ec2_error(err, TestClientExceptionEC2.code,
|
self._validate_ec2_error(err, TestClientExceptionEC2.code,
|
||||||
TestClientExceptionEC2.ec2_code, msg)
|
TestClientExceptionEC2.ec2_code, msg)
|
||||||
|
|
||||||
def test_exception_ec2_5xx(self):
|
def test_exception_ec2_5xx(self):
|
||||||
"""
|
"""Test response to EC2 exception with code = 500.
|
||||||
Test response to EC2 exception with code = 500.
|
|
||||||
|
|
||||||
Expected errors are treated as client ones even with 5xx code.
|
Expected errors are treated as client ones even with 5xx code.
|
||||||
"""
|
"""
|
||||||
|
@ -105,9 +101,7 @@ class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
||||||
msg)
|
msg)
|
||||||
|
|
||||||
def test_unexpected_exception_ec2_4xx(self):
|
def test_unexpected_exception_ec2_4xx(self):
|
||||||
"""
|
"""Test response to unexpected EC2 exception with code = 400."""
|
||||||
Test response to unexpected EC2 exception with code = 400.
|
|
||||||
"""
|
|
||||||
msg = "Test unexpected client failure."
|
msg = "Test unexpected client failure."
|
||||||
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req,
|
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req,
|
||||||
unexpected=True)
|
unexpected=True)
|
||||||
|
@ -115,8 +109,7 @@ class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
||||||
TestClientExceptionEC2.ec2_code, msg)
|
TestClientExceptionEC2.ec2_code, msg)
|
||||||
|
|
||||||
def test_unexpected_exception_ec2_5xx(self):
|
def test_unexpected_exception_ec2_5xx(self):
|
||||||
"""
|
"""Test response to unexpected EC2 exception with code = 500.
|
||||||
Test response to unexpected EC2 exception with code = 500.
|
|
||||||
|
|
||||||
Server exception messages (with code >= 500 or without code) should
|
Server exception messages (with code >= 500 or without code) should
|
||||||
be filtered as they might contain sensitive information.
|
be filtered as they might contain sensitive information.
|
||||||
|
@ -129,8 +122,7 @@ class Ec2ErrorResponseTestCase(test.NoDBTestCase):
|
||||||
unknown_msg=True)
|
unknown_msg=True)
|
||||||
|
|
||||||
def test_unexpected_exception_builtin(self):
|
def test_unexpected_exception_builtin(self):
|
||||||
"""
|
"""Test response to builtin unexpected exception.
|
||||||
Test response to builtin unexpected exception.
|
|
||||||
|
|
||||||
Server exception messages (with code >= 500 or without code) should
|
Server exception messages (with code >= 500 or without code) should
|
||||||
be filtered as they might contain sensitive information.
|
be filtered as they might contain sensitive information.
|
||||||
|
|
|
@ -41,8 +41,7 @@ floating_ip_id = '1'
|
||||||
|
|
||||||
|
|
||||||
def _quote_domain(domain):
|
def _quote_domain(domain):
|
||||||
"""
|
"""Domain names tend to have .'s in them. Urllib doesn't quote dots,
|
||||||
Domain names tend to have .'s in them. Urllib doesn't quote dots,
|
|
||||||
but Routes tends to choke on them, so we need an extra level of
|
but Routes tends to choke on them, so we need an extra level of
|
||||||
by-hand quoting here. This function needs to duplicate the one in
|
by-hand quoting here. This function needs to duplicate the one in
|
||||||
python-novaclient/novaclient/v1_1/floating_ip_dns.py
|
python-novaclient/novaclient/v1_1/floating_ip_dns.py
|
||||||
|
|
|
@ -39,9 +39,8 @@ def stub_service_get_by_host_and_topic(context, host_name, topic):
|
||||||
|
|
||||||
|
|
||||||
def stub_set_host_enabled(context, host_name, enabled):
|
def stub_set_host_enabled(context, host_name, enabled):
|
||||||
"""
|
"""Simulates three possible behaviours for VM drivers or compute
|
||||||
Simulates three possible behaviours for VM drivers or compute drivers when
|
drivers when enabling or disabling a host.
|
||||||
enabling or disabling a host.
|
|
||||||
|
|
||||||
'enabled' means new instances can go to this host
|
'enabled' means new instances can go to this host
|
||||||
'disabled' means they can't
|
'disabled' means they can't
|
||||||
|
|
|
@ -102,8 +102,7 @@ class BlockDeviceMappingTest(test.TestCase):
|
||||||
override_controller=self.no_volumes_controller)
|
override_controller=self.no_volumes_controller)
|
||||||
|
|
||||||
def test_create_instance_with_volumes_enabled_no_image(self):
|
def test_create_instance_with_volumes_enabled_no_image(self):
|
||||||
"""
|
"""Test that the create will fail if there is no image
|
||||||
Test that the create will fail if there is no image
|
|
||||||
and no bdms supplied in the request
|
and no bdms supplied in the request
|
||||||
"""
|
"""
|
||||||
old_create = compute_api.API.create
|
old_create = compute_api.API.create
|
||||||
|
|
|
@ -525,9 +525,7 @@ class FlavorDisabledTest(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class DisabledFlavorsWithRealDBTest(test.TestCase):
|
class DisabledFlavorsWithRealDBTest(test.TestCase):
|
||||||
"""
|
"""Tests that disabled flavors should not be shown nor listed."""
|
||||||
Tests that disabled flavors should not be shown nor listed.
|
|
||||||
"""
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DisabledFlavorsWithRealDBTest, self).setUp()
|
super(DisabledFlavorsWithRealDBTest, self).setUp()
|
||||||
self.controller = flavors.FlavorsController()
|
self.controller = flavors.FlavorsController()
|
||||||
|
@ -588,12 +586,11 @@ class DisabledFlavorsWithRealDBTest(test.TestCase):
|
||||||
self.assertEqual(db_flavorids, api_flavorids)
|
self.assertEqual(db_flavorids, api_flavorids)
|
||||||
|
|
||||||
def test_show_should_include_disabled_flavor_for_user(self):
|
def test_show_should_include_disabled_flavor_for_user(self):
|
||||||
"""
|
"""Counterintuitively we should show disabled flavors to all users
|
||||||
Counterintuitively we should show disabled flavors to all users and not
|
and not just admins. The reason is that, when a user performs a
|
||||||
just admins. The reason is that, when a user performs a server-show
|
server-show request, we want to be able to display the pretty
|
||||||
request, we want to be able to display the pretty flavor name ('512 MB
|
flavor name ('512 MB Instance') and not just the flavor-id even if
|
||||||
Instance') and not just the flavor-id even if the flavor id has been
|
the flavor id has been marked disabled.
|
||||||
marked disabled.
|
|
||||||
"""
|
"""
|
||||||
self.context.is_admin = False
|
self.context.is_admin = False
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,8 @@ def stub_service_get_by_host_and_topic(context, host_name, topic):
|
||||||
|
|
||||||
|
|
||||||
def stub_set_host_enabled(context, host_name, enabled):
|
def stub_set_host_enabled(context, host_name, enabled):
|
||||||
"""
|
"""Simulates three possible behaviours for VM drivers or compute
|
||||||
Simulates three possible behaviours for VM drivers or compute drivers when
|
drivers when enabling or disabling a host.
|
||||||
enabling or disabling a host.
|
|
||||||
|
|
||||||
'enabled' means new instances can go to this host
|
'enabled' means new instances can go to this host
|
||||||
'disabled' means they can't
|
'disabled' means they can't
|
||||||
|
|
|
@ -407,8 +407,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self.assertTrue(len(reservation_id) > 1)
|
self.assertTrue(len(reservation_id) > 1)
|
||||||
|
|
||||||
def test_create_multiple_instances_with_multiple_volume_bdm(self):
|
def test_create_multiple_instances_with_multiple_volume_bdm(self):
|
||||||
"""
|
"""Test that a BadRequest is raised if multiple instances
|
||||||
Test that a BadRequest is raised if multiple instances
|
|
||||||
are requested with a list of block device mappings for volumes.
|
are requested with a list of block device mappings for volumes.
|
||||||
"""
|
"""
|
||||||
min_count = 2
|
min_count = 2
|
||||||
|
@ -431,8 +430,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self._test_create_extra, params, no_image=True)
|
self._test_create_extra, params, no_image=True)
|
||||||
|
|
||||||
def test_create_multiple_instances_with_single_volume_bdm(self):
|
def test_create_multiple_instances_with_single_volume_bdm(self):
|
||||||
"""
|
"""Test that a BadRequest is raised if multiple instances
|
||||||
Test that a BadRequest is raised if multiple instances
|
|
||||||
are requested to boot from a single volume.
|
are requested to boot from a single volume.
|
||||||
"""
|
"""
|
||||||
min_count = 2
|
min_count = 2
|
||||||
|
|
|
@ -1229,12 +1229,11 @@ class ServersControllerTest(ControllerTest):
|
||||||
self.assertEqual(s['metadata']['seq'], str(i + 1))
|
self.assertEqual(s['metadata']['seq'], str(i + 1))
|
||||||
|
|
||||||
def test_get_all_server_details_with_host(self):
|
def test_get_all_server_details_with_host(self):
|
||||||
'''
|
"""We want to make sure that if two instances are on the same host,
|
||||||
We want to make sure that if two instances are on the same host, then
|
then they return the same host_id. If two instances are on different
|
||||||
they return the same host_id. If two instances are on different hosts,
|
hosts, they should return different host_ids. In this test,
|
||||||
they should return different host_ids. In this test, there are 5
|
there are 5 instances - 2 on one host and 3 on another.
|
||||||
instances - 2 on one host and 3 on another.
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
def return_servers_with_host(context, *args, **kwargs):
|
def return_servers_with_host(context, *args, **kwargs):
|
||||||
return [fakes.stub_instance(i + 1, 'fake', 'fake', host=i % 2,
|
return [fakes.stub_instance(i + 1, 'fake', 'fake', host=i % 2,
|
||||||
|
@ -2896,8 +2895,7 @@ class ServersViewBuilderTest(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ServersAllExtensionsTestCase(test.TestCase):
|
class ServersAllExtensionsTestCase(test.TestCase):
|
||||||
"""
|
"""Servers tests using default API router with all extensions enabled.
|
||||||
Servers tests using default API router with all extensions enabled.
|
|
||||||
|
|
||||||
The intent here is to catch cases where extensions end up throwing
|
The intent here is to catch cases where extensions end up throwing
|
||||||
an exception because of a malformed request before the core API
|
an exception because of a malformed request before the core API
|
||||||
|
@ -2957,9 +2955,7 @@ class ServersAllExtensionsTestCase(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ServersInvalidRequestTestCase(test.TestCase):
|
class ServersInvalidRequestTestCase(test.TestCase):
|
||||||
"""
|
"""Tests of places we throw 400 Bad Request from."""
|
||||||
Tests of places we throw 400 Bad Request from
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ServersInvalidRequestTestCase, self).setUp()
|
super(ServersInvalidRequestTestCase, self).setUp()
|
||||||
|
|
|
@ -695,9 +695,7 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class DisabledFlavorsWithRealDBTest(test.TestCase):
|
class DisabledFlavorsWithRealDBTest(test.TestCase):
|
||||||
"""
|
"""Tests that disabled flavors should not be shown nor listed."""
|
||||||
Tests that disabled flavors should not be shown nor listed.
|
|
||||||
"""
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DisabledFlavorsWithRealDBTest, self).setUp()
|
super(DisabledFlavorsWithRealDBTest, self).setUp()
|
||||||
self.controller = flavors.Controller()
|
self.controller = flavors.Controller()
|
||||||
|
@ -759,9 +757,8 @@ class DisabledFlavorsWithRealDBTest(test.TestCase):
|
||||||
self.assertEqual(db_flavorids, api_flavorids)
|
self.assertEqual(db_flavorids, api_flavorids)
|
||||||
|
|
||||||
def test_show_should_include_disabled_flavor_for_user(self):
|
def test_show_should_include_disabled_flavor_for_user(self):
|
||||||
"""
|
"""Counterintuitively we should show disabled flavors to all users and
|
||||||
Counterintuitively we should show disabled flavors to all users and not
|
not just admins. The reason is that, when a user performs a server-show
|
||||||
just admins. The reason is that, when a user performs a server-show
|
|
||||||
request, we want to be able to display the pretty flavor name ('512 MB
|
request, we want to be able to display the pretty flavor name ('512 MB
|
||||||
Instance') and not just the flavor-id even if the flavor id has been
|
Instance') and not just the flavor-id even if the flavor id has been
|
||||||
marked disabled.
|
marked disabled.
|
||||||
|
|
|
@ -39,8 +39,7 @@ NOW_API_FORMAT = "2010-10-11T10:30:22Z"
|
||||||
|
|
||||||
|
|
||||||
class ImagesControllerTest(test.NoDBTestCase):
|
class ImagesControllerTest(test.NoDBTestCase):
|
||||||
"""
|
"""Test of the OpenStack API /images application controller w/Glance.
|
||||||
Test of the OpenStack API /images application controller w/Glance.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -73,9 +73,7 @@ class BaseLimitTestSuite(test.NoDBTestCase):
|
||||||
|
|
||||||
|
|
||||||
class LimitsControllerTest(BaseLimitTestSuite):
|
class LimitsControllerTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for `limits.LimitsController` class."""
|
||||||
Tests for `limits.LimitsController` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Run before each test."""
|
"""Run before each test."""
|
||||||
|
@ -321,9 +319,7 @@ class MockLimiter(limits.Limiter):
|
||||||
|
|
||||||
|
|
||||||
class LimitMiddlewareTest(BaseLimitTestSuite):
|
class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for the `limits.RateLimitingMiddleware` class."""
|
||||||
Tests for the `limits.RateLimitingMiddleware` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@webob.dec.wsgify
|
@webob.dec.wsgify
|
||||||
def _empty_app(self, request):
|
def _empty_app(self, request):
|
||||||
|
@ -397,9 +393,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||||
|
|
||||||
|
|
||||||
class LimitTest(BaseLimitTestSuite):
|
class LimitTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for the `limits.Limit` class."""
|
||||||
Tests for the `limits.Limit` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_GET_no_delay(self):
|
def test_GET_no_delay(self):
|
||||||
# Test a limit handles 1 GET per second.
|
# Test a limit handles 1 GET per second.
|
||||||
|
@ -429,8 +423,7 @@ class LimitTest(BaseLimitTestSuite):
|
||||||
|
|
||||||
|
|
||||||
class ParseLimitsTest(BaseLimitTestSuite):
|
class ParseLimitsTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for the default limits parser in the in-memory
|
||||||
Tests for the default limits parser in the in-memory
|
|
||||||
`limits.Limiter` class.
|
`limits.Limiter` class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -495,9 +488,7 @@ class ParseLimitsTest(BaseLimitTestSuite):
|
||||||
|
|
||||||
|
|
||||||
class LimiterTest(BaseLimitTestSuite):
|
class LimiterTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for the in-memory `limits.Limiter` class."""
|
||||||
Tests for the in-memory `limits.Limiter` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Run before each test."""
|
"""Run before each test."""
|
||||||
|
@ -518,8 +509,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
return sum(item for item in results if item)
|
return sum(item for item in results if item)
|
||||||
|
|
||||||
def test_no_delay_GET(self):
|
def test_no_delay_GET(self):
|
||||||
"""
|
"""Simple test to ensure no delay on a single call for a limit verb we
|
||||||
Simple test to ensure no delay on a single call for a limit verb we
|
|
||||||
didn"t set.
|
didn"t set.
|
||||||
"""
|
"""
|
||||||
delay = self.limiter.check_for_delay("GET", "/anything")
|
delay = self.limiter.check_for_delay("GET", "/anything")
|
||||||
|
@ -531,8 +521,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
self.assertEqual(delay, (None, None))
|
self.assertEqual(delay, (None, None))
|
||||||
|
|
||||||
def test_delay_PUT(self):
|
def test_delay_PUT(self):
|
||||||
"""
|
"""Ensure the 11th PUT will result in a delay of 6.0 seconds until
|
||||||
Ensure the 11th PUT will result in a delay of 6.0 seconds until
|
|
||||||
the next request will be granced.
|
the next request will be granced.
|
||||||
"""
|
"""
|
||||||
expected = [None] * 10 + [6.0]
|
expected = [None] * 10 + [6.0]
|
||||||
|
@ -541,8 +530,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
self.assertEqual(expected, results)
|
self.assertEqual(expected, results)
|
||||||
|
|
||||||
def test_delay_POST(self):
|
def test_delay_POST(self):
|
||||||
"""
|
"""Ensure the 8th POST will result in a delay of 6.0 seconds until
|
||||||
Ensure the 8th POST will result in a delay of 6.0 seconds until
|
|
||||||
the next request will be granced.
|
the next request will be granced.
|
||||||
"""
|
"""
|
||||||
expected = [None] * 7
|
expected = [None] * 7
|
||||||
|
@ -564,10 +552,9 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
self.assertEqual(expected, results)
|
self.assertEqual(expected, results)
|
||||||
|
|
||||||
def test_delay_PUT_servers(self):
|
def test_delay_PUT_servers(self):
|
||||||
"""
|
"""Ensure PUT on /servers limits at 5 requests, and PUT elsewhere is
|
||||||
Ensure PUT on /servers limits at 5 requests, and PUT elsewhere is still
|
still OK after 5 requests...but then after 11 total requests, PUT
|
||||||
OK after 5 requests...but then after 11 total requests, PUT limiting
|
limiting kicks in.
|
||||||
kicks in.
|
|
||||||
"""
|
"""
|
||||||
# First 6 requests on PUT /servers
|
# First 6 requests on PUT /servers
|
||||||
expected = [None] * 5 + [12.0]
|
expected = [None] * 5 + [12.0]
|
||||||
|
@ -580,8 +567,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
self.assertEqual(expected, results)
|
self.assertEqual(expected, results)
|
||||||
|
|
||||||
def test_delay_PUT_wait(self):
|
def test_delay_PUT_wait(self):
|
||||||
"""
|
"""Ensure after hitting the limit and then waiting for the correct
|
||||||
Ensure after hitting the limit and then waiting for the correct
|
|
||||||
amount of time, the limit will be lifted.
|
amount of time, the limit will be lifted.
|
||||||
"""
|
"""
|
||||||
expected = [None] * 10 + [6.0]
|
expected = [None] * 10 + [6.0]
|
||||||
|
@ -665,9 +651,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||||
|
|
||||||
|
|
||||||
class WsgiLimiterTest(BaseLimitTestSuite):
|
class WsgiLimiterTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for `limits.WsgiLimiter` class."""
|
||||||
Tests for `limits.WsgiLimiter` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Run before each test."""
|
"""Run before each test."""
|
||||||
|
@ -736,9 +720,7 @@ class WsgiLimiterTest(BaseLimitTestSuite):
|
||||||
|
|
||||||
|
|
||||||
class FakeHttplibSocket(object):
|
class FakeHttplibSocket(object):
|
||||||
"""
|
"""Fake `httplib.HTTPResponse` replacement."""
|
||||||
Fake `httplib.HTTPResponse` replacement.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, response_string):
|
def __init__(self, response_string):
|
||||||
"""Initialize new `FakeHttplibSocket`."""
|
"""Initialize new `FakeHttplibSocket`."""
|
||||||
|
@ -750,20 +732,15 @@ class FakeHttplibSocket(object):
|
||||||
|
|
||||||
|
|
||||||
class FakeHttplibConnection(object):
|
class FakeHttplibConnection(object):
|
||||||
"""
|
"""Fake `httplib.HTTPConnection`."""
|
||||||
Fake `httplib.HTTPConnection`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, app, host):
|
def __init__(self, app, host):
|
||||||
"""
|
"""Initialize `FakeHttplibConnection`."""
|
||||||
Initialize `FakeHttplibConnection`.
|
|
||||||
"""
|
|
||||||
self.app = app
|
self.app = app
|
||||||
self.host = host
|
self.host = host
|
||||||
|
|
||||||
def request(self, method, path, body="", headers=None):
|
def request(self, method, path, body="", headers=None):
|
||||||
"""
|
"""Requests made via this connection actually get translated and routed
|
||||||
Requests made via this connection actually get translated and routed
|
|
||||||
into our WSGI app, we then wait for the response and turn it back into
|
into our WSGI app, we then wait for the response and turn it back into
|
||||||
an `httplib.HTTPResponse`.
|
an `httplib.HTTPResponse`.
|
||||||
"""
|
"""
|
||||||
|
@ -826,13 +803,10 @@ def wire_HTTPConnection_to_WSGI(host, app):
|
||||||
|
|
||||||
|
|
||||||
class WsgiLimiterProxyTest(BaseLimitTestSuite):
|
class WsgiLimiterProxyTest(BaseLimitTestSuite):
|
||||||
"""
|
"""Tests for the `limits.WsgiLimiterProxy` class."""
|
||||||
Tests for the `limits.WsgiLimiterProxy` class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""Do some nifty HTTP/WSGI magic which allows for WSGI to be called
|
||||||
Do some nifty HTTP/WSGI magic which allows for WSGI to be called
|
|
||||||
directly by something like the `httplib` library.
|
directly by something like the `httplib` library.
|
||||||
"""
|
"""
|
||||||
super(WsgiLimiterProxyTest, self).setUp()
|
super(WsgiLimiterProxyTest, self).setUp()
|
||||||
|
|
|
@ -1141,12 +1141,11 @@ class ServersControllerTest(ControllerTest):
|
||||||
self.assertEqual(s['metadata']['seq'], str(i + 1))
|
self.assertEqual(s['metadata']['seq'], str(i + 1))
|
||||||
|
|
||||||
def test_get_all_server_details_with_host(self):
|
def test_get_all_server_details_with_host(self):
|
||||||
'''
|
"""We want to make sure that if two instances are on the same host,
|
||||||
We want to make sure that if two instances are on the same host, then
|
then they return the same hostId. If two instances are on different
|
||||||
they return the same hostId. If two instances are on different hosts,
|
hosts, they should return different hostId's. In this test, there
|
||||||
they should return different hostId's. In this test, there are 5
|
are 5 instances - 2 on one host and 3 on another.
|
||||||
instances - 2 on one host and 3 on another.
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
def return_servers_with_host(context, *args, **kwargs):
|
def return_servers_with_host(context, *args, **kwargs):
|
||||||
return [fakes.stub_instance(i + 1, 'fake', 'fake', host=i % 2,
|
return [fakes.stub_instance(i + 1, 'fake', 'fake', host=i % 2,
|
||||||
|
@ -2002,8 +2001,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self.assertTrue(len(reservation_id) > 1)
|
self.assertTrue(len(reservation_id) > 1)
|
||||||
|
|
||||||
def test_create_multiple_instances_with_multiple_volume_bdm(self):
|
def test_create_multiple_instances_with_multiple_volume_bdm(self):
|
||||||
"""
|
"""Test that a BadRequest is raised if multiple instances
|
||||||
Test that a BadRequest is raised if multiple instances
|
|
||||||
are requested with a list of block device mappings for volumes.
|
are requested with a list of block device mappings for volumes.
|
||||||
"""
|
"""
|
||||||
self.ext_mgr.extensions = {'os-multiple-create': 'fake'}
|
self.ext_mgr.extensions = {'os-multiple-create': 'fake'}
|
||||||
|
@ -2027,8 +2025,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self._test_create_extra, params, no_image=True)
|
self._test_create_extra, params, no_image=True)
|
||||||
|
|
||||||
def test_create_multiple_instances_with_single_volume_bdm(self):
|
def test_create_multiple_instances_with_single_volume_bdm(self):
|
||||||
"""
|
"""Test that a BadRequest is raised if multiple instances
|
||||||
Test that a BadRequest is raised if multiple instances
|
|
||||||
are requested to boot from a single volume.
|
are requested to boot from a single volume.
|
||||||
"""
|
"""
|
||||||
self.ext_mgr.extensions = {'os-multiple-create': 'fake'}
|
self.ext_mgr.extensions = {'os-multiple-create': 'fake'}
|
||||||
|
@ -2505,8 +2502,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self._test_create_extra(params)
|
self._test_create_extra(params)
|
||||||
|
|
||||||
def test_create_instance_with_volumes_enabled_no_image(self):
|
def test_create_instance_with_volumes_enabled_no_image(self):
|
||||||
"""
|
"""Test that the create will fail if there is no image
|
||||||
Test that the create will fail if there is no image
|
|
||||||
and no bdms supplied in the request
|
and no bdms supplied in the request
|
||||||
"""
|
"""
|
||||||
self.ext_mgr.extensions = {'os-volumes': 'fake'}
|
self.ext_mgr.extensions = {'os-volumes': 'fake'}
|
||||||
|
@ -2533,8 +2529,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||||
self._test_create_extra, {}, no_image=True)
|
self._test_create_extra, {}, no_image=True)
|
||||||
|
|
||||||
def test_create_instance_with_volumes_enabled_and_bdms_no_image(self):
|
def test_create_instance_with_volumes_enabled_and_bdms_no_image(self):
|
||||||
"""
|
"""Test that the create works if there is no image supplied but
|
||||||
Test that the create works if there is no image supplied but
|
|
||||||
os-volumes extension is enabled and bdms are supplied
|
os-volumes extension is enabled and bdms are supplied
|
||||||
"""
|
"""
|
||||||
self.ext_mgr.extensions = {'os-volumes': 'fake'}
|
self.ext_mgr.extensions = {'os-volumes': 'fake'}
|
||||||
|
@ -4657,8 +4652,7 @@ class ServerXMLSerializationTest(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ServersAllExtensionsTestCase(test.TestCase):
|
class ServersAllExtensionsTestCase(test.TestCase):
|
||||||
"""
|
"""Servers tests using default API router with all extensions enabled.
|
||||||
Servers tests using default API router with all extensions enabled.
|
|
||||||
|
|
||||||
The intent here is to catch cases where extensions end up throwing
|
The intent here is to catch cases where extensions end up throwing
|
||||||
an exception because of a malformed request before the core API
|
an exception because of a malformed request before the core API
|
||||||
|
@ -4717,9 +4711,7 @@ class ServersAllExtensionsTestCase(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ServersUnprocessableEntityTestCase(test.TestCase):
|
class ServersUnprocessableEntityTestCase(test.TestCase):
|
||||||
"""
|
"""Tests of places we throw 422 Unprocessable Entity from."""
|
||||||
Tests of places we throw 422 Unprocessable Entity from
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ServersUnprocessableEntityTestCase, self).setUp()
|
super(ServersUnprocessableEntityTestCase, self).setUp()
|
||||||
|
|
|
@ -435,8 +435,7 @@ class VersionsTest(test.NoDBTestCase):
|
||||||
[{'rel': 'self', 'href': 'http://localhost/v3/images/1'}]))
|
[{'rel': 'self', 'href': 'http://localhost/v3/images/1'}]))
|
||||||
|
|
||||||
def test_multi_choice_server_atom(self):
|
def test_multi_choice_server_atom(self):
|
||||||
"""
|
"""Make sure multi choice responses do not have content-type
|
||||||
Make sure multi choice responses do not have content-type
|
|
||||||
application/atom+xml (should use default of json)
|
application/atom+xml (should use default of json)
|
||||||
"""
|
"""
|
||||||
req = webob.Request.blank('/servers')
|
req = webob.Request.blank('/servers')
|
||||||
|
|
|
@ -288,9 +288,8 @@ def _make_image_fixtures():
|
||||||
|
|
||||||
|
|
||||||
def stub_out_glanceclient_create(stubs, sent_to_glance):
|
def stub_out_glanceclient_create(stubs, sent_to_glance):
|
||||||
"""
|
"""We return the metadata sent to glance by modifying the sent_to_glance
|
||||||
We return the metadata sent to glance by modifying the sent_to_glance dict
|
dict in place
|
||||||
in place.
|
|
||||||
"""
|
"""
|
||||||
orig_add_image = glanceclient.v1.images.ImageManager.create
|
orig_add_image = glanceclient.v1.images.ImageManager.create
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,9 @@ ATOMNS = "{http://www.w3.org/2005/Atom}"
|
||||||
|
|
||||||
|
|
||||||
class LimiterTest(test.TestCase):
|
class LimiterTest(test.TestCase):
|
||||||
"""
|
"""Unit tests for the `nova.api.openstack.common.limited` method which
|
||||||
Unit tests for the `nova.api.openstack.common.limited` method which takes
|
takes in a list of items and, depending on the 'offset' and 'limit' GET
|
||||||
in a list of items and, depending on the 'offset' and 'limit' GET params,
|
params, returns a subset or complete set of the given items.
|
||||||
returns a subset or complete set of the given items.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -160,8 +159,7 @@ class LimiterTest(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class PaginationParamsTest(test.TestCase):
|
class PaginationParamsTest(test.TestCase):
|
||||||
"""
|
"""Unit tests for the `nova.api.openstack.common.get_pagination_params`
|
||||||
Unit tests for the `nova.api.openstack.common.get_pagination_params`
|
|
||||||
method which takes in a request object and returns 'marker' and 'limit'
|
method which takes in a request object and returns 'marker' and 'limit'
|
||||||
GET params.
|
GET params.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -106,8 +106,7 @@ def fake_not_implemented(*args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def get_primitive_instance_by_uuid(context, instance_uuid):
|
def get_primitive_instance_by_uuid(context, instance_uuid):
|
||||||
"""
|
"""Helper method to get an instance and then convert it to
|
||||||
Helper method to get an instance and then convert it to
|
|
||||||
a primitive form using jsonutils.
|
a primitive form using jsonutils.
|
||||||
"""
|
"""
|
||||||
instance = db.instance_get_by_uuid(context, instance_uuid)
|
instance = db.instance_get_by_uuid(context, instance_uuid)
|
||||||
|
@ -1670,8 +1669,7 @@ class ComputeTestCase(BaseTestCase):
|
||||||
self.assertEqual(len(bdms), 0)
|
self.assertEqual(len(bdms), 0)
|
||||||
|
|
||||||
def test_run_terminate_no_image(self):
|
def test_run_terminate_no_image(self):
|
||||||
"""
|
"""Make sure instance started without image (from volume)
|
||||||
Make sure instance started without image (from volume)
|
|
||||||
can be termintad without issues
|
can be termintad without issues
|
||||||
"""
|
"""
|
||||||
params = {'image_ref': ''}
|
params = {'image_ref': ''}
|
||||||
|
@ -2604,8 +2602,7 @@ class ComputeTestCase(BaseTestCase):
|
||||||
self._objectify(inst_ref), [], [])
|
self._objectify(inst_ref), [], [])
|
||||||
|
|
||||||
def test_set_admin_password_driver_not_authorized(self):
|
def test_set_admin_password_driver_not_authorized(self):
|
||||||
"""
|
"""Ensure expected exception is raised if set_admin_password not
|
||||||
Ensure expected exception is raised if set_admin_password not
|
|
||||||
authorized.
|
authorized.
|
||||||
"""
|
"""
|
||||||
exc = exception.NotAuthorized(_('Internal error'))
|
exc = exception.NotAuthorized(_('Internal error'))
|
||||||
|
@ -2616,8 +2613,7 @@ class ComputeTestCase(BaseTestCase):
|
||||||
expected_exception)
|
expected_exception)
|
||||||
|
|
||||||
def test_set_admin_password_driver_not_implemented(self):
|
def test_set_admin_password_driver_not_implemented(self):
|
||||||
"""
|
"""Ensure expected exception is raised if set_admin_password not
|
||||||
Ensure expected exception is raised if set_admin_password not
|
|
||||||
implemented by driver.
|
implemented by driver.
|
||||||
"""
|
"""
|
||||||
exc = NotImplementedError()
|
exc = NotImplementedError()
|
||||||
|
@ -4664,8 +4660,7 @@ class ComputeTestCase(BaseTestCase):
|
||||||
|
|
||||||
def _test_finish_revert_resize(self, power_on,
|
def _test_finish_revert_resize(self, power_on,
|
||||||
remove_old_vm_state=False):
|
remove_old_vm_state=False):
|
||||||
"""
|
"""Convenience method that does most of the work for the
|
||||||
Convenience method that does most of the work for the
|
|
||||||
test_finish_revert_resize tests.
|
test_finish_revert_resize tests.
|
||||||
:param power_on -- True if testing resize from ACTIVE state, False if
|
:param power_on -- True if testing resize from ACTIVE state, False if
|
||||||
testing resize from STOPPED state.
|
testing resize from STOPPED state.
|
||||||
|
@ -9731,8 +9726,7 @@ class ComputePolicyTestCase(BaseTestCase):
|
||||||
|
|
||||||
|
|
||||||
class DisabledInstanceTypesTestCase(BaseTestCase):
|
class DisabledInstanceTypesTestCase(BaseTestCase):
|
||||||
"""
|
"""Some instance-types are marked 'disabled' which means that they will not
|
||||||
Some instance-types are marked 'disabled' which means that they will not
|
|
||||||
show up in customer-facing listings. We do, however, want those
|
show up in customer-facing listings. We do, however, want those
|
||||||
instance-types to be available for emergency migrations and for rebuilding
|
instance-types to be available for emergency migrations and for rebuilding
|
||||||
of existing instances.
|
of existing instances.
|
||||||
|
|
|
@ -6386,9 +6386,7 @@ class ArchiveTestCase(test.TestCase):
|
||||||
self.uuid_tablenames_to_cleanup.add(tablename)
|
self.uuid_tablenames_to_cleanup.add(tablename)
|
||||||
|
|
||||||
def _test_archive_deleted_rows_for_one_uuid_table(self, tablename):
|
def _test_archive_deleted_rows_for_one_uuid_table(self, tablename):
|
||||||
"""
|
""":returns: 0 on success, 1 if no uuid column, 2 if insert failed."""
|
||||||
:returns: 0 on success, 1 if no uuid column, 2 if insert failed
|
|
||||||
"""
|
|
||||||
main_table = db_utils.get_table(self.engine, tablename)
|
main_table = db_utils.get_table(self.engine, tablename)
|
||||||
if not hasattr(main_table.c, "uuid"):
|
if not hasattr(main_table.c, "uuid"):
|
||||||
# Not a uuid table, so skip it.
|
# Not a uuid table, so skip it.
|
||||||
|
|
|
@ -64,8 +64,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _get_connect_string(backend, user, passwd, database):
|
def _get_connect_string(backend, user, passwd, database):
|
||||||
"""
|
"""Try to get a connection with a very specific set of values, if we get
|
||||||
Try to get a connection with a very specific set of values, if we get
|
|
||||||
these then we'll run the tests, otherwise they are skipped
|
these then we'll run the tests, otherwise they are skipped
|
||||||
"""
|
"""
|
||||||
if backend == "postgres":
|
if backend == "postgres":
|
||||||
|
@ -154,8 +153,7 @@ class CommonTestsMixIn(object):
|
||||||
self._test_mysql_opportunistically()
|
self._test_mysql_opportunistically()
|
||||||
|
|
||||||
def test_mysql_connect_fail(self):
|
def test_mysql_connect_fail(self):
|
||||||
"""
|
"""Test that we can trigger a mysql connection failure and we fail
|
||||||
Test that we can trigger a mysql connection failure and we fail
|
|
||||||
gracefully to ensure we don't break people without mysql
|
gracefully to ensure we don't break people without mysql
|
||||||
"""
|
"""
|
||||||
if _is_backend_avail('mysql', "openstack_cifail", self.PASSWD,
|
if _is_backend_avail('mysql', "openstack_cifail", self.PASSWD,
|
||||||
|
@ -166,8 +164,7 @@ class CommonTestsMixIn(object):
|
||||||
self._test_postgresql_opportunistically()
|
self._test_postgresql_opportunistically()
|
||||||
|
|
||||||
def test_postgresql_connect_fail(self):
|
def test_postgresql_connect_fail(self):
|
||||||
"""
|
"""Test that we can trigger a postgres connection failure and we fail
|
||||||
Test that we can trigger a postgres connection failure and we fail
|
|
||||||
gracefully to ensure we don't break people without postgres
|
gracefully to ensure we don't break people without postgres
|
||||||
"""
|
"""
|
||||||
if _is_backend_avail('postgres', "openstack_cifail", self.PASSWD,
|
if _is_backend_avail('postgres', "openstack_cifail", self.PASSWD,
|
||||||
|
|
|
@ -88,8 +88,7 @@ class TestGlanceSerializer(test.NoDBTestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestGlanceImageService(test.NoDBTestCase):
|
class TestGlanceImageService(test.NoDBTestCase):
|
||||||
"""
|
"""Tests the Glance image service.
|
||||||
Tests the Glance image service.
|
|
||||||
|
|
||||||
At a high level, the translations involved are:
|
At a high level, the translations involved are:
|
||||||
|
|
||||||
|
@ -191,8 +190,7 @@ class TestGlanceImageService(test.NoDBTestCase):
|
||||||
self.assertThat(image_metas[0], matchers.DictMatches(expected))
|
self.assertThat(image_metas[0], matchers.DictMatches(expected))
|
||||||
|
|
||||||
def test_create_without_instance_id(self):
|
def test_create_without_instance_id(self):
|
||||||
"""
|
"""Ensure we can create an image without having to specify an
|
||||||
Ensure we can create an image without having to specify an
|
|
||||||
instance_id. Public images are an example of an image not tied to an
|
instance_id. Public images are an example of an image not tied to an
|
||||||
instance.
|
instance.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1690,8 +1690,7 @@ class ServicesJsonTest(ApiSampleTestBaseV2):
|
||||||
self._verify_response('service-disable-put-resp', subs, response, 200)
|
self._verify_response('service-disable-put-resp', subs, response, 200)
|
||||||
|
|
||||||
def test_service_detail(self):
|
def test_service_detail(self):
|
||||||
"""
|
"""Return a list of all running services with the disable reason
|
||||||
Return a list of all running services with the disable reason
|
|
||||||
information if that exists.
|
information if that exists.
|
||||||
"""
|
"""
|
||||||
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
|
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
|
||||||
|
@ -1725,8 +1724,7 @@ class ServicesXmlTest(ServicesJsonTest):
|
||||||
|
|
||||||
|
|
||||||
class ExtendedServicesJsonTest(ApiSampleTestBaseV2):
|
class ExtendedServicesJsonTest(ApiSampleTestBaseV2):
|
||||||
"""
|
"""This extension is extending the functionalities of the
|
||||||
This extension is extending the functionalities of the
|
|
||||||
Services extension so the funcionalities introduced by this extension
|
Services extension so the funcionalities introduced by this extension
|
||||||
are tested in the ServicesJsonTest and ServicesXmlTest classes.
|
are tested in the ServicesJsonTest and ServicesXmlTest classes.
|
||||||
"""
|
"""
|
||||||
|
@ -1758,8 +1756,7 @@ class ExtendedServicesDeleteJsonTest(ApiSampleTestBaseV2):
|
||||||
timeutils.clear_time_override()
|
timeutils.clear_time_override()
|
||||||
|
|
||||||
def test_service_detail(self, *mocks):
|
def test_service_detail(self, *mocks):
|
||||||
"""
|
"""Return a list of all running services with the disable reason
|
||||||
Return a list of all running services with the disable reason
|
|
||||||
information if that exists.
|
information if that exists.
|
||||||
"""
|
"""
|
||||||
response = self._do_get('os-services')
|
response = self._do_get('os-services')
|
||||||
|
|
|
@ -316,8 +316,7 @@ class XMLExpectedChild(XMLMismatch):
|
||||||
|
|
||||||
|
|
||||||
class XMLMatchState(object):
|
class XMLMatchState(object):
|
||||||
"""
|
"""Maintain some state for matching.
|
||||||
Maintain some state for matching.
|
|
||||||
|
|
||||||
Tracks the XML node path and saves the expected and actual full
|
Tracks the XML node path and saves the expected and actual full
|
||||||
XML text, for use by the XMLMismatch subclasses.
|
XML text, for use by the XMLMismatch subclasses.
|
||||||
|
@ -339,8 +338,7 @@ class XMLMatchState(object):
|
||||||
return '/' + '/'.join(self.path)
|
return '/' + '/'.join(self.path)
|
||||||
|
|
||||||
def node(self, tag, idx):
|
def node(self, tag, idx):
|
||||||
"""
|
"""Adds tag and index to the path; they will be popped off when
|
||||||
Adds tag and index to the path; they will be popped off when
|
|
||||||
the corresponding 'with' statement exits.
|
the corresponding 'with' statement exits.
|
||||||
|
|
||||||
:param tag: The element tag
|
:param tag: The element tag
|
||||||
|
|
|
@ -216,8 +216,7 @@ class InstanceTypeTestCase(test.TestCase):
|
||||||
self.assertEqual(inst_type_name, deleted_inst_type["name"])
|
self.assertEqual(inst_type_name, deleted_inst_type["name"])
|
||||||
|
|
||||||
def test_read_deleted_false_converting_flavorid(self):
|
def test_read_deleted_false_converting_flavorid(self):
|
||||||
"""
|
"""Ensure deleted flavors are not returned when not needed (for
|
||||||
Ensure deleted flavors are not returned when not needed (for
|
|
||||||
example when creating a server and attempting to translate from
|
example when creating a server and attempting to translate from
|
||||||
flavorid to instance_type_id.
|
flavorid to instance_type_id.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -6209,9 +6209,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||||
self.assertTrue(conn._is_storage_shared_with('foo', '/path'))
|
self.assertTrue(conn._is_storage_shared_with('foo', '/path'))
|
||||||
|
|
||||||
def test_create_domain_define_xml_fails(self):
|
def test_create_domain_define_xml_fails(self):
|
||||||
"""
|
"""Tests that the xml is logged when defining the domain fails."""
|
||||||
Tests that the xml is logged when defining the domain fails.
|
|
||||||
"""
|
|
||||||
fake_xml = "<test>this is a test</test>"
|
fake_xml = "<test>this is a test</test>"
|
||||||
|
|
||||||
def fake_defineXML(xml):
|
def fake_defineXML(xml):
|
||||||
|
@ -6234,8 +6232,8 @@ class LibvirtConnTestCase(test.TestCase):
|
||||||
self.assertTrue(self.log_error_called)
|
self.assertTrue(self.log_error_called)
|
||||||
|
|
||||||
def test_create_domain_with_flags_fails(self):
|
def test_create_domain_with_flags_fails(self):
|
||||||
"""
|
"""Tests that the xml is logged when creating the domain with flags
|
||||||
Tests that the xml is logged when creating the domain with flags fails.
|
fails
|
||||||
"""
|
"""
|
||||||
fake_xml = "<test>this is a test</test>"
|
fake_xml = "<test>this is a test</test>"
|
||||||
fake_domain = FakeVirtDomain(fake_xml)
|
fake_domain = FakeVirtDomain(fake_xml)
|
||||||
|
@ -6261,9 +6259,8 @@ class LibvirtConnTestCase(test.TestCase):
|
||||||
self.assertTrue(self.log_error_called)
|
self.assertTrue(self.log_error_called)
|
||||||
|
|
||||||
def test_create_domain_enable_hairpin_fails(self):
|
def test_create_domain_enable_hairpin_fails(self):
|
||||||
"""
|
"""Tests that the xml is logged when enabling hairpin mode for the
|
||||||
Tests that the xml is logged when enabling hairpin mode for the domain
|
domain fails.
|
||||||
fails.
|
|
||||||
"""
|
"""
|
||||||
utils.reset_is_neutron()
|
utils.reset_is_neutron()
|
||||||
fake_xml = "<test>this is a test</test>"
|
fake_xml = "<test>this is a test</test>"
|
||||||
|
@ -6372,8 +6369,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||||
conn.get_spice_console, self.context, instance)
|
conn.get_spice_console, self.context, instance)
|
||||||
|
|
||||||
def _test_attach_detach_interface_get_config(self, method_name):
|
def _test_attach_detach_interface_get_config(self, method_name):
|
||||||
"""
|
"""Tests that the get_config() method is properly called in
|
||||||
Tests that the get_config() method is properly called in
|
|
||||||
attach_interface() and detach_interface().
|
attach_interface() and detach_interface().
|
||||||
|
|
||||||
method_name: either \"attach_interface\" or \"detach_interface\"
|
method_name: either \"attach_interface\" or \"detach_interface\"
|
||||||
|
@ -6416,15 +6412,13 @@ class LibvirtConnTestCase(test.TestCase):
|
||||||
raise ValueError("Unhandled method %" % method_name)
|
raise ValueError("Unhandled method %" % method_name)
|
||||||
|
|
||||||
def test_attach_interface_get_config(self):
|
def test_attach_interface_get_config(self):
|
||||||
"""
|
"""Tests that the get_config() method is properly called in
|
||||||
Tests that the get_config() method is properly called in
|
|
||||||
attach_interface().
|
attach_interface().
|
||||||
"""
|
"""
|
||||||
self._test_attach_detach_interface_get_config("attach_interface")
|
self._test_attach_detach_interface_get_config("attach_interface")
|
||||||
|
|
||||||
def test_detach_interface_get_config(self):
|
def test_detach_interface_get_config(self):
|
||||||
"""
|
"""Tests that the get_config() method is properly called in
|
||||||
Tests that the get_config() method is properly called in
|
|
||||||
detach_interface().
|
detach_interface().
|
||||||
"""
|
"""
|
||||||
self._test_attach_detach_interface_get_config("detach_interface")
|
self._test_attach_detach_interface_get_config("detach_interface")
|
||||||
|
|
|
@ -389,8 +389,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||||
self.assertIsNotNone(vm_util.vm_ref_cache_get(self.uuid))
|
self.assertIsNotNone(vm_util.vm_ref_cache_get(self.uuid))
|
||||||
|
|
||||||
def _check_vm_record(self, num_instances=1):
|
def _check_vm_record(self, num_instances=1):
|
||||||
"""
|
"""Check if the spawned VM's properties correspond to the instance in
|
||||||
Check if the spawned VM's properties correspond to the instance in
|
|
||||||
the db.
|
the db.
|
||||||
"""
|
"""
|
||||||
instances = self.conn.list_instances()
|
instances = self.conn.list_instances()
|
||||||
|
@ -436,8 +435,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||||
self.assertTrue(found_iface_id)
|
self.assertTrue(found_iface_id)
|
||||||
|
|
||||||
def _check_vm_info(self, info, pwr_state=power_state.RUNNING):
|
def _check_vm_info(self, info, pwr_state=power_state.RUNNING):
|
||||||
"""
|
"""Check if the get_info returned values correspond to the instance
|
||||||
Check if the get_info returned values correspond to the instance
|
|
||||||
object in the db.
|
object in the db.
|
||||||
"""
|
"""
|
||||||
mem_kib = long(self.type_data['memory_mb']) << 10
|
mem_kib = long(self.type_data['memory_mb']) << 10
|
||||||
|
@ -1129,9 +1127,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||||
None, None)
|
None, None)
|
||||||
|
|
||||||
def _test_finish_migration(self, power_on, resize_instance=False):
|
def _test_finish_migration(self, power_on, resize_instance=False):
|
||||||
"""
|
"""Tests the finish_migration method on vmops."""
|
||||||
Tests the finish_migration method on vmops
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.power_on_called = False
|
self.power_on_called = False
|
||||||
|
|
||||||
|
@ -1178,9 +1174,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||||
self.instance, None)
|
self.instance, None)
|
||||||
|
|
||||||
def _test_finish_revert_migration(self, power_on):
|
def _test_finish_revert_migration(self, power_on):
|
||||||
"""
|
"""Tests the finish_revert_migration method on vmops."""
|
||||||
Tests the finish_revert_migration method on vmops
|
|
||||||
"""
|
|
||||||
|
|
||||||
# setup the test instance in the database
|
# setup the test instance in the database
|
||||||
self._create_vm()
|
self._create_vm()
|
||||||
|
|
|
@ -165,8 +165,7 @@ def get_fake_device_info():
|
||||||
|
|
||||||
|
|
||||||
def stub_vm_utils_with_vdi_attached_here(function):
|
def stub_vm_utils_with_vdi_attached_here(function):
|
||||||
"""
|
"""vm_utils.with_vdi_attached_here needs to be stubbed out because it
|
||||||
vm_utils.with_vdi_attached_here needs to be stubbed out because it
|
|
||||||
calls down to the filesystem to attach a vdi. This provides a
|
calls down to the filesystem to attach a vdi. This provides a
|
||||||
decorator to handle that.
|
decorator to handle that.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -458,8 +458,7 @@ def check_isinstance(obj, cls):
|
||||||
|
|
||||||
|
|
||||||
def parse_server_string(server_str):
|
def parse_server_string(server_str):
|
||||||
"""
|
"""Parses the given server_string and returns a list of host and port.
|
||||||
Parses the given server_string and returns a list of host and port.
|
|
||||||
If it's not a combination of host part and port, the port element
|
If it's not a combination of host part and port, the port element
|
||||||
is a null string. If the input is invalid expression, return a null
|
is a null string. If the input is invalid expression, return a null
|
||||||
list.
|
list.
|
||||||
|
@ -989,8 +988,7 @@ def spawn_n(func, *args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def is_none_string(val):
|
def is_none_string(val):
|
||||||
"""
|
"""Check if a string represents a None value.
|
||||||
Check if a string represents a None value.
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(val, six.string_types):
|
if not isinstance(val, six.string_types):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -81,8 +81,7 @@ def get_partition_sizes(instance):
|
||||||
|
|
||||||
|
|
||||||
def get_tftp_image_info(instance):
|
def get_tftp_image_info(instance):
|
||||||
"""
|
"""Generate the paths for tftp files for this instance.
|
||||||
Generate the paths for tftp files for this instance.
|
|
||||||
|
|
||||||
Raises NovaException if
|
Raises NovaException if
|
||||||
- instance does not contain kernel_id
|
- instance does not contain kernel_id
|
||||||
|
@ -297,8 +296,7 @@ class Tilera(base.NodeDriver):
|
||||||
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
|
os.path.join(CONF.baremetal.tftp_root, instance['uuid']))
|
||||||
|
|
||||||
def _iptables_set(self, node_ip, user_data):
|
def _iptables_set(self, node_ip, user_data):
|
||||||
"""
|
"""Sets security setting (iptables:port) if needed.
|
||||||
Sets security setting (iptables:port) if needed.
|
|
||||||
|
|
||||||
iptables -A INPUT -p tcp ! -s $IP --dport $PORT -j DROP
|
iptables -A INPUT -p tcp ! -s $IP --dport $PORT -j DROP
|
||||||
/tftpboot/iptables_rule script sets iptables rule on the given node.
|
/tftpboot/iptables_rule script sets iptables rule on the given node.
|
||||||
|
|
|
@ -93,8 +93,7 @@ class Pdu(base.PowerManager):
|
||||||
"to PDU"))
|
"to PDU"))
|
||||||
|
|
||||||
def _exec_pdutool(self, mode):
|
def _exec_pdutool(self, mode):
|
||||||
"""
|
"""Changes power state of the given node.
|
||||||
Changes power state of the given node.
|
|
||||||
|
|
||||||
According to the mode (1-ON, 2-OFF, 3-REBOOT), power state can be
|
According to the mode (1-ON, 2-OFF, 3-REBOOT), power state can be
|
||||||
changed. /tftpboot/pdu_mgr script handles power management of
|
changed. /tftpboot/pdu_mgr script handles power management of
|
||||||
|
|
|
@ -289,13 +289,9 @@ class LibvirtVolumeDriver(VolumeDriver):
|
||||||
instance=instance)
|
instance=instance)
|
||||||
|
|
||||||
def get_all_block_devices(self):
|
def get_all_block_devices(self):
|
||||||
"""
|
"""Return all block devices in use on this node."""
|
||||||
Return all block devices in use on this node.
|
|
||||||
"""
|
|
||||||
return _list_backingstore_path()
|
return _list_backingstore_path()
|
||||||
|
|
||||||
def get_hypervisor_version(self):
|
def get_hypervisor_version(self):
|
||||||
"""
|
"""A dummy method for LibvirtBaseVolumeDriver.connect_volume."""
|
||||||
A dummy method for LibvirtBaseVolumeDriver.connect_volume.
|
|
||||||
"""
|
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -123,8 +123,7 @@ class DriverBlockDevice(dict):
|
||||||
return dict((key, self.get(key)) for key in self._legacy_fields)
|
return dict((key, self.get(key)) for key in self._legacy_fields)
|
||||||
|
|
||||||
def attach(self, **kwargs):
|
def attach(self, **kwargs):
|
||||||
"""
|
"""Make the device available to be used by VMs.
|
||||||
Make the device available to be used by VMs.
|
|
||||||
|
|
||||||
To be overriden in subclasses with the connecting logic for
|
To be overriden in subclasses with the connecting logic for
|
||||||
the type of device the subclass represents.
|
the type of device the subclass represents.
|
||||||
|
|
|
@ -33,8 +33,7 @@ CONF.register_opts(virt_cpu_opts)
|
||||||
|
|
||||||
|
|
||||||
def get_cpuset_ids():
|
def get_cpuset_ids():
|
||||||
"""
|
"""Parsing vcpu_pin_set config.
|
||||||
Parsing vcpu_pin_set config.
|
|
||||||
|
|
||||||
Returns a list of pcpu ids can be used by instances.
|
Returns a list of pcpu ids can be used by instances.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -28,8 +28,7 @@ guestfs = None
|
||||||
|
|
||||||
class VFSGuestFS(vfs.VFS):
|
class VFSGuestFS(vfs.VFS):
|
||||||
|
|
||||||
"""
|
"""This class implements a VFS module that uses the libguestfs APIs
|
||||||
This class implements a VFS module that uses the libguestfs APIs
|
|
||||||
to access the disk image. The disk image is never mapped into
|
to access the disk image. The disk image is never mapped into
|
||||||
the host filesystem, thus avoiding any potential for symlink
|
the host filesystem, thus avoiding any potential for symlink
|
||||||
attacks from the guest filesystem.
|
attacks from the guest filesystem.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue