Remove extensions module
The most of objects are removed from the extensions module. The last thing is the expected_errors decorator, but that decorator is nothing about the extensions. So move the decorator to the wsgi module where is the place put the other decorator also. Then we can remove the extensions module entirely. Partial implement bp api-extensions-merge-queens Change-Id: I4802c5b38001a756448d4feb9ca336908821f591
This commit is contained in:
@@ -16,7 +16,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import reset_server_state
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -36,7 +35,7 @@ class AdminActionsController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('resetNetwork')
|
||||
def _reset_network(self, req, id, body):
|
||||
"""Permit admins to reset networking on a server."""
|
||||
@@ -51,7 +50,7 @@ class AdminActionsController(wsgi.Controller):
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('injectNetworkInfo')
|
||||
def _inject_network_info(self, req, id, body):
|
||||
"""Permit admins to inject network info into a server."""
|
||||
@@ -66,7 +65,7 @@ class AdminActionsController(wsgi.Controller):
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@wsgi.action('os-resetState')
|
||||
@validation.schema(reset_server_state.reset_state)
|
||||
def _reset_state(self, req, id, body):
|
||||
|
||||
@@ -16,7 +16,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import admin_password
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -36,7 +35,7 @@ class AdminPasswordController(wsgi.Controller):
|
||||
# a response.
|
||||
@wsgi.action('changePassword')
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
@validation.schema(admin_password.change_password)
|
||||
def change_password(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack.compute.schemas import agents as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -48,7 +47,7 @@ class AgentController(wsgi.Controller):
|
||||
http://wiki.openstack.org/GuestAgentXenStoreCommunication
|
||||
"""
|
||||
@validation.query_schema(schema.index_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return a list of all agent builds. Filter by hypervisor."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -70,7 +69,7 @@ class AgentController(wsgi.Controller):
|
||||
|
||||
return {'agents': agents}
|
||||
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(schema.update)
|
||||
def update(self, req, id, body):
|
||||
"""Update an existing agent build."""
|
||||
@@ -113,7 +112,7 @@ class AgentController(wsgi.Controller):
|
||||
# TODO(oomichi): Here should be 204(No Content) instead of 200 by v2.1
|
||||
# +microversions because the resource agent has been deleted completely
|
||||
# when returning a response.
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@wsgi.response(200)
|
||||
def delete(self, req, id):
|
||||
"""Deletes an existing agent build."""
|
||||
@@ -134,7 +133,7 @@ class AgentController(wsgi.Controller):
|
||||
# TODO(oomichi): Here should be 201(Created) instead of 200 by v2.1
|
||||
# +microversions because the creation of a resource agent finishes
|
||||
# when returning a response.
|
||||
@extensions.expected_errors(409)
|
||||
@wsgi.expected_errors(409)
|
||||
@wsgi.response(200)
|
||||
@validation.schema(schema.create)
|
||||
def create(self, req, body):
|
||||
|
||||
@@ -22,7 +22,6 @@ from webob import exc
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import aggregates
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import api as compute_api
|
||||
@@ -40,7 +39,7 @@ class AggregateController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
self.api = compute_api.AggregateAPI()
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Returns a list a host aggregate's id, name, availability_zone."""
|
||||
context = _get_context(req)
|
||||
@@ -51,7 +50,7 @@ class AggregateController(wsgi.Controller):
|
||||
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 201
|
||||
# as this operation complete the creation of aggregates resource.
|
||||
@extensions.expected_errors((400, 409))
|
||||
@wsgi.expected_errors((400, 409))
|
||||
@validation.schema(aggregates.create_v20, '2.0', '2.0')
|
||||
@validation.schema(aggregates.create, '2.1')
|
||||
def create(self, req, body):
|
||||
@@ -85,7 +84,7 @@ class AggregateController(wsgi.Controller):
|
||||
|
||||
return agg
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Shows the details of an aggregate, hosts and metadata included."""
|
||||
context = _get_context(req)
|
||||
@@ -96,7 +95,7 @@ class AggregateController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
return self._marshall_aggregate(req, aggregate)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(aggregates.update_v20, '2.0', '2.0')
|
||||
@validation.schema(aggregates.update, '2.1')
|
||||
def update(self, req, id, body):
|
||||
@@ -121,7 +120,7 @@ class AggregateController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 204
|
||||
# as this operation complete the deletion of aggregate resource and return
|
||||
# no response body.
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def delete(self, req, id):
|
||||
"""Removes an aggregate by id."""
|
||||
context = _get_context(req)
|
||||
@@ -136,7 +135,7 @@ class AggregateController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 202
|
||||
# for representing async API as this API just accepts the request and
|
||||
# request hypervisor driver to complete the same in async mode.
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('add_host')
|
||||
@validation.schema(aggregates.add_host)
|
||||
def _add_host(self, req, id, body):
|
||||
@@ -159,7 +158,7 @@ class AggregateController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 202
|
||||
# for representing async API as this API just accepts the request and
|
||||
# request hypervisor driver to complete the same in async mode.
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('remove_host')
|
||||
@validation.schema(aggregates.remove_host)
|
||||
def _remove_host(self, req, id, body):
|
||||
@@ -181,7 +180,7 @@ class AggregateController(wsgi.Controller):
|
||||
raise exc.HTTPConflict(explanation=msg)
|
||||
return self._marshall_aggregate(req, aggregate)
|
||||
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@wsgi.action('set_metadata')
|
||||
@validation.schema(aggregates.set_metadata)
|
||||
def _set_metadata(self, req, id, body):
|
||||
|
||||
@@ -21,7 +21,6 @@ import six
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute.schemas import assisted_volume_snapshots
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -36,7 +35,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
super(AssistedVolumeSnapshotsController, self).__init__()
|
||||
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(assisted_volume_snapshots.snapshots_create)
|
||||
def create(self, req, body):
|
||||
"""Creates a new snapshot."""
|
||||
@@ -64,7 +63,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
||||
|
||||
@wsgi.response(204)
|
||||
@validation.query_schema(assisted_volume_snapshots.delete_query)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def delete(self, req, id):
|
||||
"""Delete a snapshot."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -20,7 +20,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import attach_interfaces
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -49,7 +48,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
self.network_api = network.API()
|
||||
super(InterfaceAttachmentController, self).__init__()
|
||||
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def index(self, req, server_id):
|
||||
"""Returns the list of interface attachments for a given instance."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -71,7 +70,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
|
||||
return {'interfaceAttachments': results}
|
||||
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
def show(self, req, server_id, id):
|
||||
"""Return data about the given interface attachment."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -98,7 +97,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
return {'interfaceAttachment': _translate_interface_attachment_view(
|
||||
port_info['port'])}
|
||||
|
||||
@extensions.expected_errors((400, 404, 409, 500, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 500, 501))
|
||||
@validation.schema(attach_interfaces.create, '2.0', '2.48')
|
||||
@validation.schema(attach_interfaces.create_v249, '2.49')
|
||||
def create(self, req, server_id, body):
|
||||
@@ -157,7 +156,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
return self.show(req, server_id, vif['id'])
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
def delete(self, req, server_id, id):
|
||||
"""Detach an interface from an instance."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# under the License.
|
||||
|
||||
from nova.api.openstack.compute.schemas import availability_zone as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import availability_zones
|
||||
from nova import compute
|
||||
@@ -103,7 +102,7 @@ class AvailabilityZoneController(wsgi.Controller):
|
||||
"hosts": None})
|
||||
return {'availabilityZoneInfo': result}
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Returns a summary list of availability zone."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -111,7 +110,7 @@ class AvailabilityZoneController(wsgi.Controller):
|
||||
|
||||
return self._describe_availability_zones(context)
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def detail(self, req):
|
||||
"""Returns a detailed list of availability zone."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -22,7 +22,6 @@ import webob
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
import nova.conf
|
||||
from nova.i18n import _
|
||||
@@ -85,7 +84,7 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
return d
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(bn_policies.BASE_POLICY_NAME)
|
||||
@@ -106,7 +105,7 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
return {'nodes': nodes}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(bn_policies.BASE_POLICY_NAME)
|
||||
@@ -132,23 +131,23 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
return {'node': node}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def create(self, req, body):
|
||||
_no_ironic_proxy("node-create")
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def delete(self, req, id):
|
||||
_no_ironic_proxy("node-delete")
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.action('add_interface')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def _add_interface(self, req, id, body):
|
||||
_no_ironic_proxy("port-create")
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.action('remove_interface')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def _remove_interface(self, req, id, body):
|
||||
_no_ironic_proxy("port-delete")
|
||||
|
||||
@@ -23,7 +23,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import cells
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.cells import rpcapi as cells_rpcapi
|
||||
@@ -101,7 +100,7 @@ class CellsController(wsgi.Controller):
|
||||
items = [_scrub_cell(item, detail=detail) for item in items]
|
||||
return dict(cells=items)
|
||||
|
||||
@extensions.expected_errors(501)
|
||||
@wsgi.expected_errors(501)
|
||||
@common.check_cells_enabled
|
||||
def index(self, req):
|
||||
"""Return all cells in brief."""
|
||||
@@ -109,7 +108,7 @@ class CellsController(wsgi.Controller):
|
||||
ctxt.can(cells_policies.BASE_POLICY_NAME)
|
||||
return self._get_cells(ctxt, req)
|
||||
|
||||
@extensions.expected_errors(501)
|
||||
@wsgi.expected_errors(501)
|
||||
@common.check_cells_enabled
|
||||
def detail(self, req):
|
||||
"""Return all cells in detail."""
|
||||
@@ -117,7 +116,7 @@ class CellsController(wsgi.Controller):
|
||||
ctxt.can(cells_policies.BASE_POLICY_NAME)
|
||||
return self._get_cells(ctxt, req, detail=True)
|
||||
|
||||
@extensions.expected_errors(501)
|
||||
@wsgi.expected_errors(501)
|
||||
@common.check_cells_enabled
|
||||
def info(self, req):
|
||||
"""Return name and capabilities for this cell."""
|
||||
@@ -136,7 +135,7 @@ class CellsController(wsgi.Controller):
|
||||
'capabilities': cell_capabs}
|
||||
return dict(cell=cell)
|
||||
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@common.check_cells_enabled
|
||||
def capacities(self, req, id=None):
|
||||
"""Return capacities for a given cell or all cells."""
|
||||
@@ -152,7 +151,7 @@ class CellsController(wsgi.Controller):
|
||||
|
||||
return dict(cell={"capacities": capacities})
|
||||
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@common.check_cells_enabled
|
||||
def show(self, req, id):
|
||||
"""Return data about the given cell name. 'id' is a cell name."""
|
||||
@@ -167,7 +166,7 @@ class CellsController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 204
|
||||
# as this operation complete the deletion of aggregate resource and return
|
||||
# no response body.
|
||||
@extensions.expected_errors((403, 404, 501))
|
||||
@wsgi.expected_errors((403, 404, 501))
|
||||
@common.check_cells_enabled
|
||||
def delete(self, req, id):
|
||||
"""Delete a child or parent cell entry. 'id' is a cell name."""
|
||||
@@ -232,7 +231,7 @@ class CellsController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 201
|
||||
# as this operation complete the creation of aggregates resource when
|
||||
# returning a response.
|
||||
@extensions.expected_errors((400, 403, 501))
|
||||
@wsgi.expected_errors((400, 403, 501))
|
||||
@common.check_cells_enabled
|
||||
@validation.schema(cells.create_v20, '2.0', '2.0')
|
||||
@validation.schema(cells.create, '2.1')
|
||||
@@ -250,7 +249,7 @@ class CellsController(wsgi.Controller):
|
||||
raise exc.HTTPForbidden(explanation=e.format_message())
|
||||
return dict(cell=_scrub_cell(cell))
|
||||
|
||||
@extensions.expected_errors((400, 403, 404, 501))
|
||||
@wsgi.expected_errors((400, 403, 404, 501))
|
||||
@common.check_cells_enabled
|
||||
@validation.schema(cells.update_v20, '2.0', '2.0')
|
||||
@validation.schema(cells.update, '2.1')
|
||||
@@ -285,7 +284,7 @@ class CellsController(wsgi.Controller):
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 204
|
||||
# as this operation complete the sync instance info and return
|
||||
# no response body.
|
||||
@extensions.expected_errors((400, 501))
|
||||
@wsgi.expected_errors((400, 501))
|
||||
@common.check_cells_enabled
|
||||
@validation.schema(cells.sync_instances)
|
||||
def sync_instances(self, req, body):
|
||||
|
||||
@@ -14,19 +14,18 @@
|
||||
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
|
||||
|
||||
class CertificatesController(wsgi.Controller):
|
||||
"""The x509 Certificates API controller for the OpenStack API."""
|
||||
|
||||
@extensions.expected_errors(410)
|
||||
@wsgi.expected_errors(410)
|
||||
def show(self, req, id):
|
||||
"""Return certificate information."""
|
||||
raise webob.exc.HTTPGone()
|
||||
|
||||
@extensions.expected_errors((410))
|
||||
@wsgi.expected_errors((410))
|
||||
def create(self, req, body=None):
|
||||
"""Create a certificate."""
|
||||
raise webob.exc.HTTPGone()
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
|
||||
|
||||
class CloudpipeController(wsgi.Controller):
|
||||
"""Handle creating and listing cloudpipe instances."""
|
||||
|
||||
@extensions.expected_errors((410))
|
||||
@wsgi.expected_errors((410))
|
||||
def create(self, req, body):
|
||||
"""Create a new cloudpipe instance, if none exists.
|
||||
|
||||
@@ -31,12 +30,12 @@ class CloudpipeController(wsgi.Controller):
|
||||
"""
|
||||
raise exc.HTTPGone()
|
||||
|
||||
@extensions.expected_errors((410))
|
||||
@wsgi.expected_errors((410))
|
||||
def index(self, req):
|
||||
"""List running cloudpipe instances."""
|
||||
raise exc.HTTPGone()
|
||||
|
||||
@extensions.expected_errors(410)
|
||||
@wsgi.expected_errors(410)
|
||||
def update(self, req, id, body):
|
||||
"""Configure cloudpipe parameters for the project."""
|
||||
raise exc.HTTPGone()
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.consoleauth import rpcapi as consoleauth_rpcapi
|
||||
from nova.i18n import _
|
||||
@@ -55,11 +54,11 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
||||
if i in connect_info}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.30")
|
||||
@extensions.expected_errors((400, 401, 404))
|
||||
@wsgi.expected_errors((400, 401, 404))
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, True)
|
||||
|
||||
@wsgi.Controller.api_version("2.31") # noqa
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, False)
|
||||
|
||||
@@ -20,7 +20,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import console_output
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -33,7 +32,7 @@ class ConsoleOutputController(wsgi.Controller):
|
||||
super(ConsoleOutputController, self).__init__(*args, **kwargs)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
@wsgi.action('os-getConsoleOutput')
|
||||
@validation.schema(console_output.get_console_output)
|
||||
def get_console_output(self, req, id, body):
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.console import api as console_api
|
||||
from nova import exception
|
||||
@@ -48,7 +47,7 @@ class ConsolesController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
self.console_api = console_api.API()
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req, server_id):
|
||||
"""Returns a list of consoles for this instance."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -62,7 +61,7 @@ class ConsolesController(wsgi.Controller):
|
||||
# NOTE(gmann): Here should be 201 instead of 200 by v2.1
|
||||
# +microversions because the console has been created
|
||||
# completely when returning a response.
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def create(self, req, server_id, body):
|
||||
"""Creates a new console."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -74,7 +73,7 @@ class ConsolesController(wsgi.Controller):
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
"""Shows in-depth information on a specific console."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -90,7 +89,7 @@ class ConsolesController(wsgi.Controller):
|
||||
return _translate_detail_keys(console)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, server_id, id):
|
||||
"""Deletes a console."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import create_backup
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -32,7 +31,7 @@ class CreateBackupController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('createBackup')
|
||||
@validation.schema(create_backup.create_backup_v20, '2.0', '2.0')
|
||||
@validation.schema(create_backup.create_backup, '2.1')
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -31,7 +30,7 @@ class DeferredDeleteController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((403, 404, 409))
|
||||
@wsgi.expected_errors((403, 404, 409))
|
||||
@wsgi.action('restore')
|
||||
def _restore(self, req, id, body):
|
||||
"""Restore a previously deleted instance."""
|
||||
@@ -49,7 +48,7 @@ class DeferredDeleteController(wsgi.Controller):
|
||||
'restore', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('forceDelete')
|
||||
def _force_delete(self, req, id, body):
|
||||
"""Force delete of instance before deferred cleanup."""
|
||||
|
||||
@@ -19,7 +19,6 @@ from webob import exc
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import evacuate
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -70,7 +69,7 @@ class EvacuateController(wsgi.Controller):
|
||||
# TODO(eliqiao): Should be responding here with 202 Accept
|
||||
# because evacuate is an async call, but keep to 200 for
|
||||
# backwards compatibility reasons.
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.action('evacuate')
|
||||
@validation.schema(evacuate.evacuate, "2.0", "2.13")
|
||||
@validation.schema(evacuate.evacuate_v214, "2.14", "2.28")
|
||||
|
||||
@@ -16,7 +16,6 @@ from oslo_log import log as logging
|
||||
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
||||
from nova.policies import extensions as ext_policies
|
||||
@@ -865,7 +864,7 @@ class ExtensionInfoController(wsgi.Controller):
|
||||
' to the virtual interface list.'}
|
||||
all_extensions.append(vif_extension_info)
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(ext_policies.BASE_POLICY_NAME)
|
||||
@@ -877,7 +876,7 @@ class ExtensionInfoController(wsgi.Controller):
|
||||
|
||||
return dict(extensions=EXTENSION_LIST)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(ext_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob.exc
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute.schemas import fixed_ips
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -40,7 +39,7 @@ class FixedIPController(wsgi.Controller):
|
||||
fixed_ip_info['fixed_ip']['reserved'] = fixed_ip.reserved
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""Return data about the given fixed IP."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -76,7 +75,7 @@ class FixedIPController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(fixed_ips.reserve)
|
||||
@wsgi.action('reserve')
|
||||
def reserve(self, req, id, body):
|
||||
@@ -87,7 +86,7 @@ class FixedIPController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(fixed_ips.unreserve)
|
||||
@wsgi.action('unreserve')
|
||||
def unreserve(self, req, id, body):
|
||||
|
||||
@@ -20,7 +20,6 @@ import webob
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import flavor_access
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import identity
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
@@ -40,7 +39,7 @@ def _marshall_flavor_access(flavor):
|
||||
|
||||
class FlavorAccessController(wsgi.Controller):
|
||||
"""The flavor access API controller for the OpenStack API."""
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, flavor_id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(fa_policies.BASE_POLICY_NAME)
|
||||
@@ -59,7 +58,7 @@ class FlavorAccessController(wsgi.Controller):
|
||||
class FlavorActionController(wsgi.Controller):
|
||||
"""The flavor access API controller for the OpenStack API."""
|
||||
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action("addTenantAccess")
|
||||
@validation.schema(flavor_access.add_tenant_access)
|
||||
def _add_tenant_access(self, req, id, body):
|
||||
@@ -84,7 +83,7 @@ class FlavorActionController(wsgi.Controller):
|
||||
raise webob.exc.HTTPConflict(explanation=err.format_message())
|
||||
return _marshall_flavor_access(flavor)
|
||||
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@wsgi.action("removeTenantAccess")
|
||||
@validation.schema(flavor_access.remove_tenant_access)
|
||||
def _remove_tenant_access(self, req, id, body):
|
||||
|
||||
@@ -17,7 +17,6 @@ from oslo_log import log as logging
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute.schemas import flavor_manage
|
||||
from nova.api.openstack.compute.views import flavors as flavors_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import flavors
|
||||
@@ -43,7 +42,7 @@ class FlavorManageController(wsgi.Controller):
|
||||
# 204 as this operation complete the deletion of aggregate resource and
|
||||
# return no response body.
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404))
|
||||
@wsgi.expected_errors((404))
|
||||
@wsgi.action("delete")
|
||||
def _delete(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
@@ -66,7 +65,7 @@ class FlavorManageController(wsgi.Controller):
|
||||
# NOTE(oomichi): Return 200 for backwards compatibility but should be 201
|
||||
# as this operation complete the creation of flavor resource.
|
||||
@wsgi.action("create")
|
||||
@extensions.expected_errors((400, 409))
|
||||
@wsgi.expected_errors((400, 409))
|
||||
@validation.schema(flavor_manage.create_v20, '2.0', '2.0')
|
||||
@validation.schema(flavor_manage.create, '2.1', '2.54')
|
||||
@validation.schema(flavor_manage.create_v2_55,
|
||||
@@ -118,7 +117,7 @@ class FlavorManageController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version(flavors_view.FLAVOR_DESCRIPTION_MICROVERSION)
|
||||
@wsgi.action('update')
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(flavor_manage.update_v2_55,
|
||||
flavors_view.FLAVOR_DESCRIPTION_MICROVERSION)
|
||||
def _update(self, req, id, body):
|
||||
|
||||
@@ -20,7 +20,6 @@ from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import flavors as schema
|
||||
from nova.api.openstack.compute.views import flavors as flavors_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import flavors
|
||||
@@ -38,21 +37,21 @@ class FlavorsController(wsgi.Controller):
|
||||
_view_builder_class = flavors_view.ViewBuilder
|
||||
|
||||
@validation.query_schema(schema.index_query)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def index(self, req):
|
||||
"""Return all flavors in brief."""
|
||||
limited_flavors = self._get_flavors(req)
|
||||
return self._view_builder.index(req, limited_flavors)
|
||||
|
||||
@validation.query_schema(schema.index_query)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def detail(self, req):
|
||||
"""Return all flavors in detail."""
|
||||
limited_flavors = self._get_flavors(req)
|
||||
req.cache_db_flavors(limited_flavors)
|
||||
return self._view_builder.detail(req, limited_flavors)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return data about the given flavor id."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import flavors_extraspecs
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -46,7 +45,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPBadRequest(
|
||||
explanation=error.format_message())
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, flavor_id):
|
||||
"""Returns the list of extra specs for a given flavor."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -56,7 +55,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
# NOTE(gmann): Here should be 201 instead of 200 by v2.1
|
||||
# +microversions because the flavor extra specs has been created
|
||||
# completely when returning a response.
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(flavors_extraspecs.create)
|
||||
def create(self, req, flavor_id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -74,7 +73,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
return body
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(flavors_extraspecs.update)
|
||||
def update(self, req, flavor_id, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -94,7 +93,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
return body
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, flavor_id, id):
|
||||
"""Return a single extra spec item."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -111,7 +110,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
# NOTE(gmann): Here should be 204(No Content) instead of 200 by v2.1
|
||||
# +microversions because the flavor extra specs has been deleted
|
||||
# completely when returning a response.
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, flavor_id, id):
|
||||
"""Deletes an existing extra spec."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -20,7 +20,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import floating_ip_dns
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -86,7 +85,7 @@ class FloatingIPDNSDomainController(wsgi.Controller):
|
||||
self.network_api = network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(501)
|
||||
@wsgi.expected_errors(501)
|
||||
def index(self, req):
|
||||
"""Return a list of available DNS domains."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -106,7 +105,7 @@ class FloatingIPDNSDomainController(wsgi.Controller):
|
||||
return _translate_domain_entries_view(domainlist)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 501))
|
||||
@wsgi.expected_errors((400, 501))
|
||||
@validation.schema(floating_ip_dns.domain_entry_update)
|
||||
def update(self, req, id, body):
|
||||
"""Add or modify domain entry."""
|
||||
@@ -142,7 +141,7 @@ class FloatingIPDNSDomainController(wsgi.Controller):
|
||||
area_name: area})
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, id):
|
||||
"""Delete the domain identified by id."""
|
||||
@@ -167,7 +166,7 @@ class FloatingIPDNSEntryController(wsgi.Controller):
|
||||
self.network_api = network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def show(self, req, domain_id, id):
|
||||
"""Return the DNS entry that corresponds to domain_id and id."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -205,7 +204,7 @@ class FloatingIPDNSEntryController(wsgi.Controller):
|
||||
return _translate_dns_entry_view(entry)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(501)
|
||||
@wsgi.expected_errors(501)
|
||||
@validation.schema(floating_ip_dns.dns_entry_update)
|
||||
def update(self, req, domain_id, id, body):
|
||||
"""Add or modify dns entry."""
|
||||
@@ -237,7 +236,7 @@ class FloatingIPDNSEntryController(wsgi.Controller):
|
||||
'domain': domain})
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, domain_id, id):
|
||||
"""Delete the entry identified by req and id."""
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import network
|
||||
from nova.policies import floating_ip_pools as fip_policies
|
||||
@@ -41,7 +40,7 @@ class FloatingIPPoolsController(wsgi.Controller):
|
||||
super(FloatingIPPoolsController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return a list of pools."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -24,7 +24,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import floating_ips
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -112,7 +111,7 @@ class FloatingIPController(wsgi.Controller):
|
||||
super(FloatingIPController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""Return data about the given floating IP."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -129,7 +128,7 @@ class FloatingIPController(wsgi.Controller):
|
||||
return _translate_floating_ip_view(floating_ip)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return a list of floating IPs allocated to a project."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -140,7 +139,7 @@ class FloatingIPController(wsgi.Controller):
|
||||
return _translate_floating_ips_view(floating_ips)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
def create(self, req, body=None):
|
||||
context = req.environ['nova.context']
|
||||
context.can(fi_policies.BASE_POLICY_NAME)
|
||||
@@ -172,7 +171,7 @@ class FloatingIPController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
def delete(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(fi_policies.BASE_POLICY_NAME)
|
||||
@@ -211,7 +210,7 @@ class FloatingIPActionController(wsgi.Controller):
|
||||
self.network_api = network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@wsgi.action('addFloatingIp')
|
||||
@validation.schema(floating_ips.add_floating_ip)
|
||||
def _add_floating_ip(self, req, id, body):
|
||||
@@ -292,7 +291,7 @@ class FloatingIPActionController(wsgi.Controller):
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('removeFloatingIp')
|
||||
@validation.schema(floating_ips.remove_floating_ip)
|
||||
def _remove_floating_ip(self, req, id, body):
|
||||
|
||||
@@ -19,7 +19,6 @@ import webob.exc
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute.schemas import floating_ips_bulk
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
import nova.conf
|
||||
@@ -34,7 +33,7 @@ CONF = nova.conf.CONF
|
||||
class FloatingIPBulkController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req):
|
||||
"""Return a list of all floating IPs."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -43,7 +42,7 @@ class FloatingIPBulkController(wsgi.Controller):
|
||||
return self._get_floating_ip_info(context)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return a list of all floating IPs for a given host."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -84,7 +83,7 @@ class FloatingIPBulkController(wsgi.Controller):
|
||||
return floating_ip_info
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 409))
|
||||
@wsgi.expected_errors((400, 409))
|
||||
@validation.schema(floating_ips_bulk.create)
|
||||
def create(self, req, body):
|
||||
"""Bulk create floating IPs."""
|
||||
@@ -113,7 +112,7 @@ class FloatingIPBulkController(wsgi.Controller):
|
||||
"interface": interface}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(floating_ips_bulk.delete)
|
||||
def update(self, req, id, body):
|
||||
"""Bulk delete floating IPs."""
|
||||
|
||||
@@ -24,7 +24,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import fping as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -71,7 +70,7 @@ class FpingController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(schema.index_query)
|
||||
@extensions.expected_errors(503)
|
||||
@wsgi.expected_errors(503)
|
||||
def index(self, req):
|
||||
context = req.environ["nova.context"]
|
||||
search_opts = dict(deleted=False)
|
||||
@@ -122,7 +121,7 @@ class FpingController(wsgi.Controller):
|
||||
return {"servers": res}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 503))
|
||||
@wsgi.expected_errors((404, 503))
|
||||
def show(self, req, id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(fping_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -21,7 +21,6 @@ import webob.exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import hosts
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -41,7 +40,7 @@ class HostController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@validation.query_schema(hosts.index_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Returns a dict in the format
|
||||
|
||||
@@ -98,7 +97,7 @@ class HostController(wsgi.Controller):
|
||||
return {'hosts': hosts}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
@validation.schema(hosts.update)
|
||||
def update(self, req, id, body):
|
||||
"""Return booleanized version of body dict.
|
||||
@@ -190,17 +189,17 @@ class HostController(wsgi.Controller):
|
||||
return {"host": host_name, "power_action": result}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
def startup(self, req, id):
|
||||
return self._host_power_action(req, host_name=id, action="startup")
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
def shutdown(self, req, id):
|
||||
return self._host_power_action(req, host_name=id, action="shutdown")
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
def reboot(self, req, id):
|
||||
return self._host_power_action(req, host_name=id, action="reboot")
|
||||
|
||||
@@ -254,7 +253,7 @@ class HostController(wsgi.Controller):
|
||||
return project_map
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Shows the physical/usage resource given by hosts.
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import hypervisors as hyper_schema
|
||||
from nova.api.openstack.compute.views import hypervisors as hyper_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.cells import utils as cells_utils
|
||||
@@ -192,7 +191,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def index(self, req):
|
||||
"""Starting with the 2.53 microversion, the id field in the response
|
||||
is the compute_nodes.uuid value. Also, the search and servers routes
|
||||
@@ -205,13 +204,13 @@ class HypervisorsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.33", "2.52") # noqa
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v233)
|
||||
@extensions.expected_errors((400))
|
||||
@wsgi.expected_errors((400))
|
||||
def index(self, req):
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
return self._index(req, limit=limit, marker=marker, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.32") # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
return self._index(req)
|
||||
|
||||
@@ -222,7 +221,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def detail(self, req):
|
||||
"""Starting with the 2.53 microversion, the id field in the response
|
||||
is the compute_nodes.uuid value. Also, the search and servers routes
|
||||
@@ -235,13 +234,13 @@ class HypervisorsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.33", "2.52") # noqa
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v233)
|
||||
@extensions.expected_errors((400))
|
||||
@wsgi.expected_errors((400))
|
||||
def detail(self, req):
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
return self._detail(req, limit=limit, marker=marker, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.32") # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def detail(self, req):
|
||||
return self._detail(req)
|
||||
|
||||
@@ -283,7 +282,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.show_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""The 2.53 microversion requires that the id is a uuid and as a result
|
||||
it can also return a 400 response if an invalid uuid is passed.
|
||||
@@ -296,7 +295,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
return self._show(req, id, with_servers)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.52") # noqa F811
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id)
|
||||
|
||||
@@ -321,7 +320,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
return dict(hypervisor=self._view_hypervisor(
|
||||
hyp, service, True, req, instances))
|
||||
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
def uptime(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
@@ -354,7 +353,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
uptime=uptime))
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.52')
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def search(self, req, id):
|
||||
"""Prior to microversion 2.53 you could search for hypervisors by a
|
||||
hostname pattern on a dedicated route. Starting with 2.53, searching
|
||||
@@ -377,7 +376,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.52')
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def servers(self, req, id):
|
||||
"""Prior to microversion 2.53 you could search for hypervisors by a
|
||||
hostname pattern and include servers on those hosts in the response on
|
||||
@@ -402,7 +401,7 @@ class HypervisorsController(wsgi.Controller):
|
||||
hypervisors.append(hyp)
|
||||
return dict(hypervisors=hypervisors)
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def statistics(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -20,7 +20,6 @@ from nova.api.openstack.api_version_request import \
|
||||
MAX_IMAGE_META_PROXY_API_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import image_metadata
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -44,7 +43,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
def index(self, req, image_id):
|
||||
"""Returns the list of metadata for a given instance."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -52,7 +51,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
return dict(metadata=metadata)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
def show(self, req, image_id, id):
|
||||
context = req.environ['nova.context']
|
||||
metadata = self._get_image(context, image_id)['properties']
|
||||
@@ -62,7 +61,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@validation.schema(image_metadata.create)
|
||||
def create(self, req, image_id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -79,7 +78,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
return dict(metadata=image['properties'])
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@validation.schema(image_metadata.update)
|
||||
def update(self, req, image_id, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -102,7 +101,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
return dict(meta=meta)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@validation.schema(image_metadata.update_all)
|
||||
def update_all(self, req, image_id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -118,7 +117,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
return dict(metadata=metadata)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_IMAGE_META_PROXY_API_VERSION)
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
@wsgi.response(204)
|
||||
def delete(self, req, image_id, id):
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -19,7 +19,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.views import images as views_images
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
@@ -75,7 +74,7 @@ class ImagesController(wsgi.Controller):
|
||||
return filters
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return detailed information about a specific image.
|
||||
|
||||
@@ -94,7 +93,7 @@ class ImagesController(wsgi.Controller):
|
||||
return self._view_builder.show(req, image)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
@wsgi.response(204)
|
||||
def delete(self, req, id):
|
||||
"""Delete an image, if allowed.
|
||||
@@ -115,7 +114,7 @@ class ImagesController(wsgi.Controller):
|
||||
raise webob.exc.HTTPForbidden(explanation=explanation)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def index(self, req):
|
||||
"""Return an index listing of images available to the request.
|
||||
|
||||
@@ -134,7 +133,7 @@ class ImagesController(wsgi.Controller):
|
||||
return self._view_builder.index(req, images)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def detail(self, req):
|
||||
"""Return a detailed index listing of images available to the request.
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ from nova.api.openstack.compute.schemas \
|
||||
import instance_actions as schema_instance_actions
|
||||
from nova.api.openstack.compute.views \
|
||||
import instance_actions as instance_actions_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -73,7 +72,7 @@ class InstanceActionsController(wsgi.Controller):
|
||||
return common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.57")
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
"""Returns the list of actions recorded for a given instance."""
|
||||
context = req.environ["nova.context"]
|
||||
@@ -85,7 +84,7 @@ class InstanceActionsController(wsgi.Controller):
|
||||
return {'instanceActions': actions}
|
||||
|
||||
@wsgi.Controller.api_version("2.58") # noqa
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.query_schema(schema_instance_actions.list_query_params_v258,
|
||||
"2.58")
|
||||
def index(self, req, server_id):
|
||||
@@ -115,7 +114,7 @@ class InstanceActionsController(wsgi.Controller):
|
||||
actions_dict['links'] = actions_links
|
||||
return actions_dict
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
"""Return data about the given instance action."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -18,7 +18,6 @@ import datetime
|
||||
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
@@ -34,14 +33,14 @@ class InstanceUsageAuditLogController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
self.host_api = compute.HostAPI()
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(iual_policies.BASE_POLICY_NAME)
|
||||
task_log = self._get_audit_task_logs(context)
|
||||
return {'instance_usage_audit_logs': task_log}
|
||||
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(iual_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -18,7 +18,6 @@ from webob import exc
|
||||
import nova
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.views import addresses as views_addresses
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.i18n import _
|
||||
from nova.policies import ips as ips_policies
|
||||
@@ -36,7 +35,7 @@ class IPsController(wsgi.Controller):
|
||||
super(IPsController, self).__init__(**kwargs)
|
||||
self._compute_api = nova.compute.API()
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(ips_policies.POLICY_ROOT % 'index')
|
||||
@@ -44,7 +43,7 @@ class IPsController(wsgi.Controller):
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
return self._view_builder.index(networks)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(ips_policies.POLICY_ROOT % 'show')
|
||||
|
||||
@@ -22,7 +22,6 @@ from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import keypairs
|
||||
from nova.api.openstack.compute.views import keypairs as keypairs_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import api as compute_api
|
||||
@@ -56,7 +55,7 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.10")
|
||||
@wsgi.response(201)
|
||||
@extensions.expected_errors((400, 403, 409))
|
||||
@wsgi.expected_errors((400, 403, 409))
|
||||
@validation.schema(keypairs.create_v210)
|
||||
def create(self, req, body):
|
||||
"""Create or import keypair.
|
||||
@@ -75,7 +74,7 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.2", "2.9") # noqa
|
||||
@wsgi.response(201)
|
||||
@extensions.expected_errors((400, 403, 409))
|
||||
@wsgi.expected_errors((400, 403, 409))
|
||||
@validation.schema(keypairs.create_v22)
|
||||
def create(self, req, body):
|
||||
"""Create or import keypair.
|
||||
@@ -95,7 +94,7 @@ class KeypairController(wsgi.Controller):
|
||||
return self._create(req, body, type=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.1") # noqa
|
||||
@extensions.expected_errors((400, 403, 409))
|
||||
@wsgi.expected_errors((400, 403, 409))
|
||||
@validation.schema(keypairs.create_v20, "2.0", "2.0")
|
||||
@validation.schema(keypairs.create, "2.1", "2.1")
|
||||
def create(self, req, body):
|
||||
@@ -149,21 +148,21 @@ class KeypairController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", "2.1")
|
||||
@validation.query_schema(keypairs.delete_query_schema_v20)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
self._delete(req, id)
|
||||
|
||||
@wsgi.Controller.api_version("2.2", "2.9") # noqa
|
||||
@validation.query_schema(keypairs.delete_query_schema_v20)
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
self._delete(req, id)
|
||||
|
||||
@wsgi.Controller.api_version("2.10") # noqa
|
||||
@validation.query_schema(keypairs.delete_query_schema_v210)
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
# handle optional user-id for admin only
|
||||
user_id = self._get_user_id(req)
|
||||
@@ -189,7 +188,7 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.10")
|
||||
@validation.query_schema(keypairs.show_query_schema_v210)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
# handle optional user-id for admin only
|
||||
user_id = self._get_user_id(req)
|
||||
@@ -197,13 +196,13 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.2", "2.9") # noqa
|
||||
@validation.query_schema(keypairs.show_query_schema_v20)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, type=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.1") # noqa
|
||||
@validation.query_schema(keypairs.show_query_schema_v20)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id)
|
||||
|
||||
@@ -232,14 +231,14 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.35")
|
||||
@validation.query_schema(keypairs.index_query_schema_v235)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def index(self, req):
|
||||
user_id = self._get_user_id(req)
|
||||
return self._index(req, links=True, type=True, user_id=user_id)
|
||||
|
||||
@wsgi.Controller.api_version("2.10", "2.34") # noqa
|
||||
@validation.query_schema(keypairs.index_query_schema_v210)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
# handle optional user-id for admin only
|
||||
user_id = self._get_user_id(req)
|
||||
@@ -247,13 +246,13 @@ class KeypairController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.2", "2.9") # noqa
|
||||
@validation.query_schema(keypairs.index_query_schema_v20)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
return self._index(req, type=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.1") # noqa
|
||||
@validation.query_schema(keypairs.index_query_schema_v20)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
return self._index(req)
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MIN_WITHOUT_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute.schemas import limits
|
||||
from nova.api.openstack.compute.views import limits as limits_views
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.policies import limits as limits_policies
|
||||
@@ -46,27 +45,27 @@ class LimitsController(wsgi.Controller):
|
||||
"""Controller for accessing limits in the OpenStack API."""
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(limits.limits_query_schema)
|
||||
def index(self, req):
|
||||
return self._index(req)
|
||||
|
||||
@wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, # noqa
|
||||
MAX_IMAGE_META_PROXY_API_VERSION) # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(limits.limits_query_schema)
|
||||
def index(self, req):
|
||||
return self._index(req, FILTERED_LIMITS_2_36)
|
||||
|
||||
@wsgi.Controller.api_version( # noqa
|
||||
MIN_WITHOUT_IMAGE_META_PROXY_API_VERSION, '2.56') # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(limits.limits_query_schema)
|
||||
def index(self, req):
|
||||
return self._index(req, FILTERED_LIMITS_2_36, max_image_meta=False)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(limits.limits_query_schema)
|
||||
def index(self, req):
|
||||
return self._index(req, FILTERED_LIMITS_2_57, max_image_meta=False)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova.policies import lock_server as ls_policies
|
||||
@@ -26,7 +25,7 @@ class LockServerController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@wsgi.action('lock')
|
||||
def _lock(self, req, id, body):
|
||||
"""Lock a server instance."""
|
||||
@@ -38,7 +37,7 @@ class LockServerController(wsgi.Controller):
|
||||
self.compute_api.lock(context, instance)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@wsgi.action('unlock')
|
||||
def _unlock(self, req, id, body):
|
||||
"""Unlock a server instance."""
|
||||
|
||||
@@ -21,7 +21,6 @@ from webob import exc
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import migrate_server
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -38,7 +37,7 @@ class MigrateServerController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('migrate')
|
||||
@validation.schema(migrate_server.migrate_v2_56, "2.56")
|
||||
def _migrate(self, req, id, body):
|
||||
@@ -70,7 +69,7 @@ class MigrateServerController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.action('os-migrateLive')
|
||||
@validation.schema(migrate_server.migrate_live, "2.0", "2.24")
|
||||
@validation.schema(migrate_server.migrate_live_v2_25, "2.25", "2.29")
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import migrations as schema_migrations
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -69,7 +68,7 @@ class MigrationsController(wsgi.Controller):
|
||||
|
||||
return objects
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(schema_migrations.list_query_schema_v20)
|
||||
def index(self, req):
|
||||
"""Return all migrations using the query parameters as filters."""
|
||||
|
||||
@@ -19,7 +19,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import multinic
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -37,7 +36,7 @@ class MultinicController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
@wsgi.response(202)
|
||||
@wsgi.action('addFixedIp')
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(multinic.add_fixed_ip)
|
||||
def _add_fixed_ip(self, req, id, body):
|
||||
"""Adds an IP on a given network to an instance."""
|
||||
@@ -56,7 +55,7 @@ class MultinicController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
@wsgi.response(202)
|
||||
@wsgi.action('removeFixedIp')
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(multinic.remove_fixed_ip)
|
||||
def _remove_fixed_ip(self, req, id, body):
|
||||
"""Removes an IP from an instance."""
|
||||
|
||||
@@ -21,7 +21,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import networks as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -83,7 +82,7 @@ class NetworkController(wsgi.Controller):
|
||||
self.network_api = network_api or network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(net_policies.POLICY_ROOT % 'view')
|
||||
@@ -93,7 +92,7 @@ class NetworkController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@wsgi.action("disassociate")
|
||||
def _disassociate_host_and_project(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -108,7 +107,7 @@ class NetworkController(wsgi.Controller):
|
||||
common.raise_feature_not_supported()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(net_policies.POLICY_ROOT % 'view')
|
||||
@@ -122,7 +121,7 @@ class NetworkController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
def delete(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(net_policies.BASE_POLICY_NAME)
|
||||
@@ -136,7 +135,7 @@ class NetworkController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 409, 501))
|
||||
@wsgi.expected_errors((400, 409, 501))
|
||||
@validation.schema(schema.create)
|
||||
def create(self, req, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -163,7 +162,7 @@ class NetworkController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 501))
|
||||
@wsgi.expected_errors((400, 501))
|
||||
@validation.schema(schema.add_network_to_project)
|
||||
def add(self, req, body):
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -16,7 +16,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import networks_associate
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -34,7 +33,7 @@ class NetworkAssociateActionController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.action("disassociate_host")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def _disassociate_host_only(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
context.can(na_policies.BASE_POLICY_NAME)
|
||||
@@ -49,7 +48,7 @@ class NetworkAssociateActionController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.action("disassociate_project")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def _disassociate_project_only(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
context.can(na_policies.BASE_POLICY_NAME)
|
||||
@@ -64,7 +63,7 @@ class NetworkAssociateActionController(wsgi.Controller):
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.action("associate_host")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
@validation.schema(networks_associate.associate_host)
|
||||
def _associate_host(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -29,7 +28,7 @@ class PauseServerController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
@wsgi.action('pause')
|
||||
def _pause(self, req, id, body):
|
||||
"""Permit Admins to pause the server."""
|
||||
@@ -52,7 +51,7 @@ class PauseServerController(wsgi.Controller):
|
||||
common.raise_feature_not_supported()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
@wsgi.action('unpause')
|
||||
def _unpause(self, req, id, body):
|
||||
"""Permit Admins to unpause the server."""
|
||||
|
||||
@@ -17,7 +17,6 @@ import copy
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.schemas import quota_classes
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import exception
|
||||
@@ -76,17 +75,17 @@ class QuotaClassSetsController(wsgi.Controller):
|
||||
return dict(quota_class_set=result)
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.49')
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, exclude_server_groups=True)
|
||||
|
||||
@wsgi.Controller.api_version('2.50', '2.56') # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, FILTERED_QUOTAS_2_50)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, FILTERED_QUOTAS_2_57)
|
||||
|
||||
@@ -99,19 +98,19 @@ class QuotaClassSetsController(wsgi.Controller):
|
||||
exclude_server_groups)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.49") # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_classes.update)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, exclude_server_groups=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.50", "2.56") # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_classes.update_v250)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, FILTERED_QUOTAS_2_50)
|
||||
|
||||
@wsgi.Controller.api_version("2.57") # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_classes.update_v257)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, FILTERED_QUOTAS_2_57)
|
||||
|
||||
@@ -23,7 +23,6 @@ from nova.api.openstack.api_version_request \
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MIN_WITHOUT_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute.schemas import quota_sets
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import identity
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
@@ -106,18 +105,18 @@ class QuotaSetsController(wsgi.Controller):
|
||||
return {k: v['limit'] for k, v in values.items()}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, [])
|
||||
|
||||
@wsgi.Controller.api_version( # noqa
|
||||
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, FILTERED_QUOTAS_2_36)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, FILTERED_QUOTAS_2_57)
|
||||
|
||||
@@ -134,18 +133,18 @@ class QuotaSetsController(wsgi.Controller):
|
||||
filtered_quotas=filtered_quotas)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def detail(self, req, id):
|
||||
return self._detail(req, id, [])
|
||||
|
||||
@wsgi.Controller.api_version( # noqa
|
||||
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def detail(self, req, id):
|
||||
return self._detail(req, id, FILTERED_QUOTAS_2_36)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def detail(self, req, id):
|
||||
return self._detail(req, id, FILTERED_QUOTAS_2_57)
|
||||
|
||||
@@ -162,20 +161,20 @@ class QuotaSetsController(wsgi.Controller):
|
||||
filtered_quotas=filtered_quotas)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_sets.update)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, [])
|
||||
|
||||
@wsgi.Controller.api_version( # noqa
|
||||
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_sets.update_v236)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, FILTERED_QUOTAS_2_36)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(quota_sets.update_v257)
|
||||
def update(self, req, id, body):
|
||||
return self._update(req, id, body, FILTERED_QUOTAS_2_57)
|
||||
@@ -240,18 +239,18 @@ class QuotaSetsController(wsgi.Controller):
|
||||
filtered_quotas=filtered_quotas)
|
||||
|
||||
@wsgi.Controller.api_version("2.0", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def defaults(self, req, id):
|
||||
return self._defaults(req, id, [])
|
||||
|
||||
@wsgi.Controller.api_version( # noqa
|
||||
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def defaults(self, req, id):
|
||||
return self._defaults(req, id, FILTERED_QUOTAS_2_36)
|
||||
|
||||
@wsgi.Controller.api_version('2.57') # noqa
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def defaults(self, req, id):
|
||||
return self._defaults(req, id, FILTERED_QUOTAS_2_57)
|
||||
|
||||
@@ -267,7 +266,7 @@ class QuotaSetsController(wsgi.Controller):
|
||||
# TODO(oomichi): Here should be 204(No Content) instead of 202 by v2.1
|
||||
# +microversions because the resource quota-set has been deleted completely
|
||||
# when returning a response.
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(quota_sets.query_schema)
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, id):
|
||||
|
||||
@@ -16,7 +16,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import remote_consoles
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -35,7 +34,7 @@ class RemoteConsolesController(wsgi.Controller):
|
||||
super(RemoteConsolesController, self).__init__(*args, **kwargs)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.5")
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.action('os-getVNCConsole')
|
||||
@validation.schema(remote_consoles.get_vnc_console)
|
||||
def get_vnc_console(self, req, id, body):
|
||||
@@ -64,7 +63,7 @@ class RemoteConsolesController(wsgi.Controller):
|
||||
return {'console': {'type': console_type, 'url': output['url']}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.5")
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.action('os-getSPICEConsole')
|
||||
@validation.schema(remote_consoles.get_spice_console)
|
||||
def get_spice_console(self, req, id, body):
|
||||
@@ -93,7 +92,7 @@ class RemoteConsolesController(wsgi.Controller):
|
||||
return {'console': {'type': console_type, 'url': output['url']}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.5")
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.action('os-getRDPConsole')
|
||||
@validation.schema(remote_consoles.get_rdp_console)
|
||||
def get_rdp_console(self, req, id, body):
|
||||
@@ -124,7 +123,7 @@ class RemoteConsolesController(wsgi.Controller):
|
||||
return {'console': {'type': console_type, 'url': output['url']}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.5")
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.action('os-getSerialConsole')
|
||||
@validation.schema(remote_consoles.get_serial_console)
|
||||
def get_serial_console(self, req, id, body):
|
||||
@@ -155,7 +154,7 @@ class RemoteConsolesController(wsgi.Controller):
|
||||
return {'console': {'type': console_type, 'url': output['url']}}
|
||||
|
||||
@wsgi.Controller.api_version("2.6")
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@validation.schema(remote_consoles.create_v26, "2.6", "2.7")
|
||||
@validation.schema(remote_consoles.create_v28, "2.8")
|
||||
def create(self, req, server_id, body):
|
||||
|
||||
@@ -18,7 +18,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import rescue
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -38,7 +37,7 @@ class RescueController(wsgi.Controller):
|
||||
# TODO(cyeoh): Should be responding here with 202 Accept
|
||||
# because rescue is an async call, but keep to 200
|
||||
# for backwards compatibility reasons.
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.action('rescue')
|
||||
@validation.schema(rescue.rescue)
|
||||
def _rescue(self, req, id, body):
|
||||
@@ -81,7 +80,7 @@ class RescueController(wsgi.Controller):
|
||||
return {}
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
@wsgi.action('unrescue')
|
||||
def _unrescue(self, req, id, body):
|
||||
"""Unrescue an instance."""
|
||||
|
||||
@@ -17,7 +17,6 @@ from webob import exc
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute import security_groups as sg
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
@@ -33,7 +32,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase,
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 409, 501))
|
||||
@wsgi.expected_errors((400, 409, 501))
|
||||
def create(self, req, body):
|
||||
context = req.environ['nova.context']
|
||||
context.can(sgdr_policies.BASE_POLICY_NAME)
|
||||
@@ -71,7 +70,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase,
|
||||
cidr, ip_protocol, from_port, to_port)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(sgdr_policies.BASE_POLICY_NAME)
|
||||
@@ -90,7 +89,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase,
|
||||
return {"security_group_default_rule": fmt_rule}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
@wsgi.expected_errors((400, 404, 501))
|
||||
@wsgi.response(204)
|
||||
def delete(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
@@ -108,7 +107,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase,
|
||||
raise exc.HTTPNotFound(explanation=ex.format_message())
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((404, 501))
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(sgdr_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -24,7 +24,6 @@ from nova.api.openstack.api_version_request \
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import security_groups as \
|
||||
schema_security_groups
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -157,7 +156,7 @@ class SecurityGroupController(SecurityGroupControllerBase, wsgi.Controller):
|
||||
"""The Security group API controller for the OpenStack API."""
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""Return data about the given security group."""
|
||||
context = _authorize_context(req)
|
||||
@@ -175,7 +174,7 @@ class SecurityGroupController(SecurityGroupControllerBase, wsgi.Controller):
|
||||
security_group)}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, id):
|
||||
"""Delete a security group."""
|
||||
@@ -193,7 +192,7 @@ class SecurityGroupController(SecurityGroupControllerBase, wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(schema_security_groups.index_query)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req):
|
||||
"""Returns a list of security groups."""
|
||||
context = _authorize_context(req)
|
||||
@@ -215,7 +214,7 @@ class SecurityGroupController(SecurityGroupControllerBase, wsgi.Controller):
|
||||
key=lambda k: (k['tenant_id'], k['name'])))}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403))
|
||||
@wsgi.expected_errors((400, 403))
|
||||
def create(self, req, body):
|
||||
"""Creates a new security group."""
|
||||
context = _authorize_context(req)
|
||||
@@ -240,7 +239,7 @@ class SecurityGroupController(SecurityGroupControllerBase, wsgi.Controller):
|
||||
group_ref)}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def update(self, req, id, body):
|
||||
"""Update a security group."""
|
||||
context = _authorize_context(req)
|
||||
@@ -277,7 +276,7 @@ class SecurityGroupRulesController(SecurityGroupControllerBase,
|
||||
wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
def create(self, req, body):
|
||||
context = _authorize_context(req)
|
||||
|
||||
@@ -352,7 +351,7 @@ class SecurityGroupRulesController(SecurityGroupControllerBase,
|
||||
cidr, ip_protocol, from_port, to_port)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, id):
|
||||
context = _authorize_context(req)
|
||||
@@ -376,7 +375,7 @@ class SecurityGroupRulesController(SecurityGroupControllerBase,
|
||||
|
||||
class ServerSecurityGroupController(SecurityGroupControllerBase):
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
"""Returns a list of security groups for the given instance."""
|
||||
context = _authorize_context(req)
|
||||
@@ -436,7 +435,7 @@ class SecurityGroupActionController(wsgi.Controller):
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
method(context, instance, group_name)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.response(202)
|
||||
@wsgi.action('addSecurityGroup')
|
||||
def _addSecurityGroup(self, req, id, body):
|
||||
@@ -456,7 +455,7 @@ class SecurityGroupActionController(wsgi.Controller):
|
||||
exception.SecurityGroupExistsForInstance) as exp:
|
||||
raise exc.HTTPBadRequest(explanation=exp.format_message())
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.response(202)
|
||||
@wsgi.action('removeSecurityGroup')
|
||||
def _removeSecurityGroup(self, req, id, body):
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.views import server_diagnostics
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -33,7 +32,7 @@ class ServerDiagnosticsController(wsgi.Controller):
|
||||
super(ServerDiagnosticsController, self).__init__(*args, **kwargs)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors((400, 404, 409, 501))
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
def index(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(sd_policies.BASE_POLICY_NAME)
|
||||
|
||||
@@ -16,7 +16,6 @@ from oslo_log import log as logging
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.schemas import server_external_events
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -63,7 +62,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
||||
|
||||
return instances
|
||||
|
||||
@extensions.expected_errors((403, 404))
|
||||
@wsgi.expected_errors((403, 404))
|
||||
@wsgi.response(200)
|
||||
@validation.schema(server_external_events.create, '2.1', '2.50')
|
||||
@validation.schema(server_external_events.create_v251, '2.51')
|
||||
|
||||
@@ -24,7 +24,6 @@ from webob import exc
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import server_groups as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
import nova.conf
|
||||
@@ -106,7 +105,7 @@ class ServerGroupController(wsgi.Controller):
|
||||
server_group['user_id'] = group.user_id
|
||||
return server_group
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return data about the given server group."""
|
||||
context = _authorize_context(req, 'show')
|
||||
@@ -117,7 +116,7 @@ class ServerGroupController(wsgi.Controller):
|
||||
return {'server_group': self._format_server_group(context, sg, req)}
|
||||
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
"""Delete a server group."""
|
||||
context = _authorize_context(req, 'delete')
|
||||
@@ -130,7 +129,7 @@ class ServerGroupController(wsgi.Controller):
|
||||
except nova.exception.InstanceGroupNotFound as e:
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
@validation.query_schema(schema.server_groups_query_param)
|
||||
def index(self, req):
|
||||
"""Returns a list of server groups."""
|
||||
@@ -147,7 +146,7 @@ class ServerGroupController(wsgi.Controller):
|
||||
return {'server_groups': result}
|
||||
|
||||
@wsgi.Controller.api_version("2.1")
|
||||
@extensions.expected_errors((400, 403))
|
||||
@wsgi.expected_errors((400, 403))
|
||||
@validation.schema(schema.create, "2.0", "2.14")
|
||||
@validation.schema(schema.create_v215, "2.15")
|
||||
def create(self, req, body):
|
||||
|
||||
@@ -18,7 +18,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import server_metadata
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -49,14 +48,14 @@ class ServerMetadataController(wsgi.Controller):
|
||||
meta_dict[key] = value
|
||||
return meta_dict
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
"""Returns the list of metadata for a given instance."""
|
||||
context = req.environ['nova.context']
|
||||
context.can(sm_policies.POLICY_ROOT % 'index')
|
||||
return {'metadata': self._get_metadata(context, server_id)}
|
||||
|
||||
@extensions.expected_errors((403, 404, 409))
|
||||
@wsgi.expected_errors((403, 404, 409))
|
||||
# NOTE(gmann): Returns 200 for backwards compatibility but should be 201
|
||||
# as this operation complete the creation of metadata.
|
||||
@validation.schema(server_metadata.create)
|
||||
@@ -71,7 +70,7 @@ class ServerMetadataController(wsgi.Controller):
|
||||
|
||||
return {'metadata': new_metadata}
|
||||
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@validation.schema(server_metadata.update)
|
||||
def update(self, req, server_id, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -88,7 +87,7 @@ class ServerMetadataController(wsgi.Controller):
|
||||
|
||||
return {'meta': meta_item}
|
||||
|
||||
@extensions.expected_errors((403, 404, 409))
|
||||
@wsgi.expected_errors((403, 404, 409))
|
||||
@validation.schema(server_metadata.update_all)
|
||||
def update_all(self, req, server_id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -123,7 +122,7 @@ class ServerMetadataController(wsgi.Controller):
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'update metadata', server_id)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
"""Return a single metadata item."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -136,7 +135,7 @@ class ServerMetadataController(wsgi.Controller):
|
||||
msg = _("Metadata item was not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.response(204)
|
||||
def delete(self, req, server_id, id):
|
||||
"""Deletes an existing metadata."""
|
||||
|
||||
@@ -17,7 +17,6 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import server_migrations
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -61,7 +60,7 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.22")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('force_complete')
|
||||
@validation.schema(server_migrations.force_complete)
|
||||
def _force_complete(self, req, id, server_id, body):
|
||||
@@ -84,7 +83,7 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
state_error, 'force_complete', server_id)
|
||||
|
||||
@wsgi.Controller.api_version("2.23")
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
"""Return all migrations of an instance in progress."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -100,7 +99,7 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
return {'migrations': [output(migration) for migration in migrations]}
|
||||
|
||||
@wsgi.Controller.api_version("2.23")
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
"""Return the migration of an instance in progress by id."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -134,7 +133,7 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.24")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
def delete(self, req, server_id, id):
|
||||
"""Abort an in progress migration of an instance."""
|
||||
context = req.environ['nova.context']
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
from nova.api.metadata import password
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova.policies import server_password as sp_policies
|
||||
@@ -28,7 +27,7 @@ class ServerPasswordController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(sp_policies.BASE_POLICY_NAME)
|
||||
@@ -37,7 +36,7 @@ class ServerPasswordController(wsgi.Controller):
|
||||
passw = password.extract_password(instance)
|
||||
return {'password': passw or ''}
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@wsgi.response(204)
|
||||
def clear(self, req, server_id):
|
||||
"""Removes the encrypted server password from the metadata server
|
||||
|
||||
@@ -16,7 +16,6 @@ import webob
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import server_tags as schema
|
||||
from nova.api.openstack.compute.views import server_tags
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.api.validation import parameter_types
|
||||
@@ -63,7 +62,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(st_policies.POLICY_ROOT % 'show')
|
||||
@@ -83,7 +82,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(st_policies.POLICY_ROOT % 'index')
|
||||
@@ -100,7 +99,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
return {'tags': _get_tags_names(tags)}
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(schema.update)
|
||||
def update(self, req, server_id, id, body):
|
||||
context = req.environ["nova.context"]
|
||||
@@ -152,7 +151,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
return response
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@validation.schema(schema.update_all)
|
||||
def update_all(self, req, server_id, body):
|
||||
context = req.environ["nova.context"]
|
||||
@@ -177,7 +176,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
def delete(self, req, server_id, id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(st_policies.POLICY_ROOT % 'delete')
|
||||
@@ -201,7 +200,7 @@ class ServerTagsController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.26")
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
def delete_all(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
context.can(st_policies.POLICY_ROOT % 'delete_all')
|
||||
|
||||
@@ -39,7 +39,6 @@ from nova.api.openstack.compute.schemas import servers as schema_servers
|
||||
from nova.api.openstack.compute import security_groups
|
||||
from nova.api.openstack.compute import user_data
|
||||
from nova.api.openstack.compute.views import servers as views_servers
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -145,7 +144,7 @@ class ServersController(wsgi.Controller):
|
||||
self._create_schema(self.schema_server_create, '2.1')
|
||||
self._create_schema(self.schema_server_create_v20, '2.0')
|
||||
|
||||
@extensions.expected_errors((400, 403))
|
||||
@wsgi.expected_errors((400, 403))
|
||||
@validation.query_schema(schema_servers.query_params_v226, '2.26')
|
||||
@validation.query_schema(schema_servers.query_params_v21, '2.1', '2.25')
|
||||
def index(self, req):
|
||||
@@ -158,7 +157,7 @@ class ServersController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(explanation=err.format_message())
|
||||
return servers
|
||||
|
||||
@extensions.expected_errors((400, 403))
|
||||
@wsgi.expected_errors((400, 403))
|
||||
@validation.query_schema(schema_servers.query_params_v226, '2.26')
|
||||
@validation.query_schema(schema_servers.query_params_v21, '2.1', '2.25')
|
||||
def detail(self, req):
|
||||
@@ -434,7 +433,7 @@ class ServersController(wsgi.Controller):
|
||||
|
||||
return objects.NetworkRequestList(objects=networks)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Returns server details by server id."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -443,7 +442,7 @@ class ServersController(wsgi.Controller):
|
||||
return self._view_builder.show(req, instance)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 409))
|
||||
@wsgi.expected_errors((400, 403, 409))
|
||||
@validation.schema(schema_server_create_v20, '2.0', '2.0')
|
||||
@validation.schema(schema_server_create, '2.1', '2.18')
|
||||
@validation.schema(schema_server_create_v219, '2.19', '2.31')
|
||||
@@ -685,7 +684,7 @@ class ServersController(wsgi.Controller):
|
||||
else:
|
||||
self.compute_api.delete(context, instance)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@validation.schema(schema_server_update_v20, '2.0', '2.0')
|
||||
@validation.schema(schema_server_update, '2.1', '2.18')
|
||||
@validation.schema(schema_server_update_v219, '2.19')
|
||||
@@ -724,7 +723,7 @@ class ServersController(wsgi.Controller):
|
||||
# for representing async API as this API just accepts the request and
|
||||
# request hypervisor driver to complete the same in async mode.
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.action('confirmResize')
|
||||
def _action_confirm_resize(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -744,7 +743,7 @@ class ServersController(wsgi.Controller):
|
||||
'confirmResize', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.action('revertResize')
|
||||
def _action_revert_resize(self, req, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -767,7 +766,7 @@ class ServersController(wsgi.Controller):
|
||||
'revertResize', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('reboot')
|
||||
@validation.schema(schema_servers.reboot)
|
||||
def _action_reboot(self, req, id, body):
|
||||
@@ -825,7 +824,7 @@ class ServersController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
def delete(self, req, id):
|
||||
"""Destroys a server."""
|
||||
try:
|
||||
@@ -863,7 +862,7 @@ class ServersController(wsgi.Controller):
|
||||
return common.get_id_from_href(flavor_ref)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 401, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 401, 403, 404, 409))
|
||||
@wsgi.action('resize')
|
||||
@validation.schema(schema_servers.resize)
|
||||
def _action_resize(self, req, id, body):
|
||||
@@ -877,7 +876,7 @@ class ServersController(wsgi.Controller):
|
||||
self._resize(req, id, flavor_ref, **kwargs)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('rebuild')
|
||||
@validation.schema(schema_server_rebuild_v20, '2.0', '2.0')
|
||||
@validation.schema(schema_server_rebuild, '2.1', '2.18')
|
||||
@@ -981,7 +980,7 @@ class ServersController(wsgi.Controller):
|
||||
return self._add_location(robj)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.action('createImage')
|
||||
@common.check_snapshots_enabled
|
||||
@validation.schema(schema_servers.create_image, '2.0', '2.0')
|
||||
@@ -1079,7 +1078,7 @@ class ServersController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('os-start')
|
||||
def _start_server(self, req, id, body):
|
||||
"""Start an instance."""
|
||||
@@ -1097,7 +1096,7 @@ class ServersController(wsgi.Controller):
|
||||
'start', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('os-stop')
|
||||
def _stop_server(self, req, id, body):
|
||||
"""Stop an instance."""
|
||||
@@ -1118,7 +1117,7 @@ class ServersController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.17")
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@wsgi.action('trigger_crash_dump')
|
||||
@validation.schema(schema_servers.trigger_crash_dump)
|
||||
def _action_trigger_crash_dump(self, req, id, body):
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob.exc
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute.schemas import services
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import availability_zones
|
||||
@@ -190,7 +189,7 @@ class ServiceController(wsgi.Controller):
|
||||
return action(body, context)
|
||||
|
||||
@wsgi.response(204)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def delete(self, req, id):
|
||||
"""Deletes the specified service."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -228,7 +227,7 @@ class ServiceController(wsgi.Controller):
|
||||
raise webob.exc.HTTPBadRequest(explanation=explanation)
|
||||
|
||||
@validation.query_schema(services.index_query_schema)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return a list of all running services. Filter by host & service
|
||||
name
|
||||
@@ -241,7 +240,7 @@ class ServiceController(wsgi.Controller):
|
||||
return {'services': _services}
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.52')
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(services.service_update, '2.0', '2.10')
|
||||
@validation.schema(services.service_update_v211, '2.11', '2.52')
|
||||
def update(self, req, id, body):
|
||||
@@ -261,7 +260,7 @@ class ServiceController(wsgi.Controller):
|
||||
return self._perform_action(req, id, body, actions)
|
||||
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION) # noqa F811
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@validation.schema(services.service_update_v2_53, UUID_FOR_ID_MIN_VERSION)
|
||||
def update(self, req, id, body):
|
||||
"""Perform service update
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions as exts
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -30,7 +29,7 @@ class ShelveController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@exts.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('shelve')
|
||||
def _shelve(self, req, id, body):
|
||||
"""Move an instance into shelved mode."""
|
||||
@@ -51,7 +50,7 @@ class ShelveController(wsgi.Controller):
|
||||
'shelve', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@exts.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('shelveOffload')
|
||||
def _shelve_offload(self, req, id, body):
|
||||
"""Force removal of a shelved instance from the compute node."""
|
||||
@@ -71,7 +70,7 @@ class ShelveController(wsgi.Controller):
|
||||
id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@exts.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('unshelve')
|
||||
def _unshelve(self, req, id, body):
|
||||
"""Restore an instance from shelved mode."""
|
||||
|
||||
@@ -24,7 +24,6 @@ from webob import exc
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import simple_tenant_usage as schema
|
||||
from nova.api.openstack.compute.views import usages as usages_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
import nova.conf
|
||||
@@ -264,28 +263,28 @@ class SimpleTenantUsageController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.40")
|
||||
@validation.query_schema(schema.index_query_v240)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def index(self, req):
|
||||
"""Retrieve tenant_usage for all tenants."""
|
||||
return self._index(req, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.39") # noqa
|
||||
@validation.query_schema(schema.index_query)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def index(self, req):
|
||||
"""Retrieve tenant_usage for all tenants."""
|
||||
return self._index(req)
|
||||
|
||||
@wsgi.Controller.api_version("2.40")
|
||||
@validation.query_schema(schema.show_query_v240)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
"""Retrieve tenant_usage for a specified tenant."""
|
||||
return self._show(req, id, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.39") # noqa
|
||||
@validation.query_schema(schema.show_query)
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def show(self, req, id):
|
||||
"""Retrieve tenant_usage for a specified tenant."""
|
||||
return self._show(req, id)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -28,7 +27,7 @@ class SuspendServerController(wsgi.Controller):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('suspend')
|
||||
def _suspend(self, req, id, body):
|
||||
"""Permit admins to suspend the server."""
|
||||
@@ -48,7 +47,7 @@ class SuspendServerController(wsgi.Controller):
|
||||
'suspend', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((404, 409))
|
||||
@wsgi.expected_errors((404, 409))
|
||||
@wsgi.action('resume')
|
||||
def _resume(self, req, id, body):
|
||||
"""Permit admins to resume the server from suspend."""
|
||||
|
||||
@@ -23,7 +23,6 @@ from webob import exc
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack.compute.schemas import tenant_networks as schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
import nova.conf
|
||||
@@ -74,7 +73,7 @@ class TenantNetworkController(wsgi.Controller):
|
||||
return [{'id': k, 'label': v} for k, v in networks.items()]
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
context = req.environ['nova.context']
|
||||
context.can(tn_policies.BASE_POLICY_NAME)
|
||||
@@ -85,7 +84,7 @@ class TenantNetworkController(wsgi.Controller):
|
||||
return {'networks': [network_dict(n) for n in networks]}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(tn_policies.BASE_POLICY_NAME)
|
||||
@@ -97,7 +96,7 @@ class TenantNetworkController(wsgi.Controller):
|
||||
return {'network': network_dict(network)}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((403, 404, 409))
|
||||
@wsgi.expected_errors((403, 404, 409))
|
||||
@wsgi.response(202)
|
||||
def delete(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
@@ -115,7 +114,7 @@ class TenantNetworkController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403, 409, 503))
|
||||
@wsgi.expected_errors((400, 403, 409, 503))
|
||||
@validation.schema(schema.create)
|
||||
def create(self, req, body):
|
||||
context = req.environ["nova.context"]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.api_version_request \
|
||||
import MIN_WITHOUT_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.policies import used_limits as ul_policies
|
||||
from nova import quota
|
||||
@@ -28,7 +27,7 @@ QUOTAS = quota.QUOTAS
|
||||
class UsedLimitsController(wsgi.Controller):
|
||||
|
||||
@wsgi.extends
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req, resp_obj):
|
||||
context = req.environ['nova.context']
|
||||
project_id = self._project_id(context, req)
|
||||
|
||||
@@ -17,12 +17,11 @@ import webob.exc
|
||||
|
||||
from nova.api.openstack.compute import versions
|
||||
from nova.api.openstack.compute.views import versions as views_versions
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
|
||||
|
||||
class VersionsController(wsgi.Controller):
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id='v2.1'):
|
||||
builder = views_versions.get_view_builder(req)
|
||||
if req.is_legacy_v2():
|
||||
|
||||
@@ -19,7 +19,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova.i18n import _
|
||||
@@ -69,7 +68,7 @@ class ServerVirtualInterfaceController(wsgi.Controller):
|
||||
return {'virtual_interfaces': res}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def index(self, req, server_id):
|
||||
"""Returns the list of VIFs for a given instance."""
|
||||
return self._items(req, server_id,
|
||||
|
||||
@@ -23,7 +23,6 @@ from nova.api.openstack.api_version_request \
|
||||
import MAX_PROXY_API_SUPPORT_VERSION
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import volumes as volumes_schema
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova import compute
|
||||
@@ -103,7 +102,7 @@ class VolumeController(wsgi.Controller):
|
||||
super(VolumeController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return data about the given volume."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -118,7 +117,7 @@ class VolumeController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404))
|
||||
@wsgi.expected_errors((400, 404))
|
||||
def delete(self, req, id):
|
||||
"""Delete a volume."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -133,14 +132,14 @@ class VolumeController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(volumes_schema.index_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Returns a summary list of volumes."""
|
||||
return self._items(req, entity_maker=_translate_volume_summary_view)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(volumes_schema.detail_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def detail(self, req):
|
||||
"""Returns a detailed list of volumes."""
|
||||
return self._items(req, entity_maker=_translate_volume_detail_view)
|
||||
@@ -156,7 +155,7 @@ class VolumeController(wsgi.Controller):
|
||||
return {'volumes': res}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.expected_errors((400, 403, 404))
|
||||
@validation.schema(volumes_schema.create)
|
||||
def create(self, req, body):
|
||||
"""Creates a new volume."""
|
||||
@@ -263,7 +262,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
self.volume_api = cinder.API()
|
||||
super(VolumeAttachmentController, self).__init__()
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
@validation.query_schema(volumes_schema.index_query)
|
||||
def index(self, req, server_id):
|
||||
"""Returns the list of volume attachments for a given instance."""
|
||||
@@ -286,7 +285,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
|
||||
return {'volumeAttachments': results}
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
"""Return data about the given volume attachment."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -311,7 +310,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
assigned_mountpoint)}
|
||||
|
||||
# TODO(mriedem): This API should return a 202 instead of a 200 response.
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(volumes_schema.create_volume_attachment, '2.0', '2.48')
|
||||
@validation.schema(volumes_schema.create_volume_attachment_v249, '2.49')
|
||||
def create(self, req, server_id, body):
|
||||
@@ -357,7 +356,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
return {'volumeAttachment': attachment}
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.expected_errors((400, 404, 409))
|
||||
@validation.schema(volumes_schema.update_volume_attachment)
|
||||
def update(self, req, server_id, id, body):
|
||||
context = req.environ['nova.context']
|
||||
@@ -398,7 +397,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
'swap_volume', server_id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
@wsgi.expected_errors((400, 403, 404, 409))
|
||||
def delete(self, req, server_id, id):
|
||||
"""Detach a volume from an instance."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -477,7 +476,7 @@ class SnapshotController(wsgi.Controller):
|
||||
super(SnapshotController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
"""Return data about the given snapshot."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -492,7 +491,7 @@ class SnapshotController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.response(202)
|
||||
@extensions.expected_errors(404)
|
||||
@wsgi.expected_errors(404)
|
||||
def delete(self, req, id):
|
||||
"""Delete a snapshot."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -505,14 +504,14 @@ class SnapshotController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(volumes_schema.index_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Returns a summary list of snapshots."""
|
||||
return self._items(req, entity_maker=_translate_snapshot_summary_view)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@validation.query_schema(volumes_schema.detail_query)
|
||||
@extensions.expected_errors(())
|
||||
@wsgi.expected_errors(())
|
||||
def detail(self, req):
|
||||
"""Returns a detailed list of snapshots."""
|
||||
return self._items(req, entity_maker=_translate_snapshot_detail_view)
|
||||
@@ -528,7 +527,7 @@ class SnapshotController(wsgi.Controller):
|
||||
return {'snapshots': res}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@extensions.expected_errors((400, 403))
|
||||
@wsgi.expected_errors((400, 403))
|
||||
@validation.schema(volumes_schema.snapshot_create)
|
||||
def create(self, req, body):
|
||||
"""Creates a new snapshot."""
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
# Copyright 2011 OpenStack Foundation
|
||||
# Copyright 2011 Justin Santa Barbara
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
|
||||
from oslo_log import log as logging
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def expected_errors(errors):
|
||||
"""Decorator for v2.1 API methods which specifies expected exceptions.
|
||||
|
||||
Specify which exceptions may occur when an API method is called. If an
|
||||
unexpected exception occurs then return a 500 instead and ask the user
|
||||
of the API to file a bug report.
|
||||
"""
|
||||
def decorator(f):
|
||||
@functools.wraps(f)
|
||||
def wrapped(*args, **kwargs):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except Exception as exc:
|
||||
if isinstance(exc, webob.exc.WSGIHTTPException):
|
||||
if isinstance(errors, int):
|
||||
t_errors = (errors,)
|
||||
else:
|
||||
t_errors = errors
|
||||
if exc.code in t_errors:
|
||||
raise
|
||||
elif isinstance(exc, exception.Forbidden):
|
||||
# Note(cyeoh): Special case to handle
|
||||
# Forbidden exceptions so every
|
||||
# extension method does not need to wrap authorize
|
||||
# calls. ResourceExceptionHandler silently
|
||||
# converts NotAuthorized to HTTPForbidden
|
||||
raise
|
||||
elif isinstance(exc, exception.ValidationError):
|
||||
# Note(oomichi): Handle a validation error, which
|
||||
# happens due to invalid API parameters, as an
|
||||
# expected error.
|
||||
raise
|
||||
elif isinstance(exc, exception.Unauthorized):
|
||||
# Handle an authorized exception, will be
|
||||
# automatically converted to a HTTP 401, clients
|
||||
# like python-novaclient handle this error to
|
||||
# generate new token and do another attempt.
|
||||
raise
|
||||
|
||||
LOG.exception("Unexpected exception in API method")
|
||||
msg = _('Unexpected API Error. Please report this at '
|
||||
'http://bugs.launchpad.net/nova/ and attach the Nova '
|
||||
'API log if possible.\n%s') % type(exc)
|
||||
raise webob.exc.HTTPInternalServerError(explanation=msg)
|
||||
|
||||
return wrapped
|
||||
|
||||
return decorator
|
||||
@@ -789,6 +789,56 @@ def extends(*args, **kwargs):
|
||||
return decorator
|
||||
|
||||
|
||||
def expected_errors(errors):
|
||||
"""Decorator for v2.1 API methods which specifies expected exceptions.
|
||||
|
||||
Specify which exceptions may occur when an API method is called. If an
|
||||
unexpected exception occurs then return a 500 instead and ask the user
|
||||
of the API to file a bug report.
|
||||
"""
|
||||
def decorator(f):
|
||||
@functools.wraps(f)
|
||||
def wrapped(*args, **kwargs):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except Exception as exc:
|
||||
if isinstance(exc, webob.exc.WSGIHTTPException):
|
||||
if isinstance(errors, int):
|
||||
t_errors = (errors,)
|
||||
else:
|
||||
t_errors = errors
|
||||
if exc.code in t_errors:
|
||||
raise
|
||||
elif isinstance(exc, exception.Forbidden):
|
||||
# Note(cyeoh): Special case to handle
|
||||
# Forbidden exceptions so every
|
||||
# extension method does not need to wrap authorize
|
||||
# calls. ResourceExceptionHandler silently
|
||||
# converts NotAuthorized to HTTPForbidden
|
||||
raise
|
||||
elif isinstance(exc, exception.ValidationError):
|
||||
# Note(oomichi): Handle a validation error, which
|
||||
# happens due to invalid API parameters, as an
|
||||
# expected error.
|
||||
raise
|
||||
elif isinstance(exc, exception.Unauthorized):
|
||||
# Handle an authorized exception, will be
|
||||
# automatically converted to a HTTP 401, clients
|
||||
# like python-novaclient handle this error to
|
||||
# generate new token and do another attempt.
|
||||
raise
|
||||
|
||||
LOG.exception("Unexpected exception in API method")
|
||||
msg = _('Unexpected API Error. Please report this at '
|
||||
'http://bugs.launchpad.net/nova/ and attach the Nova '
|
||||
'API log if possible.\n%s') % type(exc)
|
||||
raise webob.exc.HTTPInternalServerError(explanation=msg)
|
||||
|
||||
return wrapped
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
class ControllerMetaclass(type):
|
||||
"""Controller metaclass.
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# Copyright 2013 IBM Corp.
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack.compute import extension_info
|
||||
from nova.api.openstack import extensions
|
||||
from nova import exception
|
||||
from nova import test
|
||||
|
||||
|
||||
class fake_bad_extension(object):
|
||||
name = "fake_bad_extension"
|
||||
alias = "fake-bad"
|
||||
|
||||
|
||||
class ExtensionLoadingTestCase(test.NoDBTestCase):
|
||||
|
||||
def test_check_bad_extension(self):
|
||||
loaded_ext_info = extension_info.LoadedExtensionInfo()
|
||||
self.assertFalse(loaded_ext_info._check_extension(fake_bad_extension))
|
||||
|
||||
def test_extensions_expected_error(self):
|
||||
@extensions.expected_errors(404)
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound, fake_func)
|
||||
|
||||
def test_extensions_expected_error_from_list(self):
|
||||
@extensions.expected_errors((404, 403))
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound, fake_func)
|
||||
|
||||
def test_extensions_unexpected_error(self):
|
||||
@extensions.expected_errors(404)
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPConflict()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPInternalServerError, fake_func)
|
||||
|
||||
def test_extensions_unexpected_error_from_list(self):
|
||||
@extensions.expected_errors((404, 413))
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPConflict()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPInternalServerError, fake_func)
|
||||
|
||||
def test_extensions_unexpected_policy_not_authorized_error(self):
|
||||
@extensions.expected_errors(404)
|
||||
def fake_func():
|
||||
raise exception.PolicyNotAuthorized(action="foo")
|
||||
|
||||
self.assertRaises(exception.PolicyNotAuthorized, fake_func)
|
||||
@@ -17,7 +17,6 @@ import testscenarios
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import api_version_request as api_version
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import versioned_method
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
||||
@@ -329,7 +328,7 @@ class ResourceTest(MicroversionedTest):
|
||||
|
||||
def test_resource_call_with_method_post(self):
|
||||
class Controller(object):
|
||||
@extensions.expected_errors(400)
|
||||
@wsgi.expected_errors(400)
|
||||
def create(self, req, body):
|
||||
if expected_body != body:
|
||||
msg = "The request body invalid"
|
||||
@@ -1018,3 +1017,41 @@ class TestController(test.NoDBTestCase):
|
||||
result = wsgi.Controller.check_for_versions_intersection(func_list=
|
||||
func_list)
|
||||
self.assertTrue(result)
|
||||
|
||||
|
||||
class ExpectedErrorTestCase(test.NoDBTestCase):
|
||||
|
||||
def test_expected_error(self):
|
||||
@wsgi.expected_errors(404)
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound, fake_func)
|
||||
|
||||
def test_expected_error_from_list(self):
|
||||
@wsgi.expected_errors((404, 403))
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound, fake_func)
|
||||
|
||||
def test_unexpected_error(self):
|
||||
@wsgi.expected_errors(404)
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPConflict()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPInternalServerError, fake_func)
|
||||
|
||||
def test_unexpected_error_from_list(self):
|
||||
@wsgi.expected_errors((404, 413))
|
||||
def fake_func():
|
||||
raise webob.exc.HTTPConflict()
|
||||
|
||||
self.assertRaises(webob.exc.HTTPInternalServerError, fake_func)
|
||||
|
||||
def test_unexpected_policy_not_authorized_error(self):
|
||||
@wsgi.expected_errors(404)
|
||||
def fake_func():
|
||||
raise exception.PolicyNotAuthorized(action="foo")
|
||||
|
||||
self.assertRaises(exception.PolicyNotAuthorized, fake_func)
|
||||
|
||||
Reference in New Issue
Block a user