Merge "Ensure controllers all call super"
This commit is contained in:
commit
ea7293c7be
@ -30,8 +30,8 @@ state_map = dict(active=vm_states.ACTIVE, error=vm_states.ERROR)
|
||||
|
||||
|
||||
class AdminActionsController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AdminActionsController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(AdminActionsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -26,8 +26,8 @@ from nova.policies import admin_password as ap_policies
|
||||
|
||||
class AdminPasswordController(wsgi.Controller):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AdminPasswordController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(AdminPasswordController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
# TODO(eliqiao): Here should be 204(No content) instead of 202 by v2.1+
|
||||
|
@ -24,7 +24,7 @@ from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import aggregates
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import api as compute_api
|
||||
from nova.compute import api as compute
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.policies import aggregates as aggr_policies
|
||||
@ -37,7 +37,8 @@ def _get_context(req):
|
||||
class AggregateController(wsgi.Controller):
|
||||
"""The Host Aggregates API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
self.api = compute_api.AggregateAPI()
|
||||
super(AggregateController, self).__init__()
|
||||
self.api = compute.AggregateAPI()
|
||||
|
||||
@wsgi.expected_errors(())
|
||||
def index(self, req):
|
||||
|
@ -32,8 +32,8 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
||||
"""The Assisted volume snapshots API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
super(AssistedVolumeSnapshotsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.expected_errors(400)
|
||||
@validation.schema(assisted_volume_snapshots.snapshots_create)
|
||||
|
@ -59,9 +59,9 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
"""The interface attachment API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
super(InterfaceAttachmentController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(InterfaceAttachmentController, self).__init__()
|
||||
|
||||
@wsgi.expected_errors((404, 501))
|
||||
def index(self, req, server_id):
|
||||
|
@ -27,9 +27,9 @@ CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class ConsoleAuthTokensController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self):
|
||||
super(ConsoleAuthTokensController, self).__init__()
|
||||
self._consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
|
||||
super(ConsoleAuthTokensController, self).__init__(*args, **kwargs)
|
||||
|
||||
def _show(self, req, id, rdp_only):
|
||||
"""Checks a console auth token and returns the related connect info."""
|
||||
|
@ -28,8 +28,8 @@ from nova.policies import console_output as co_policies
|
||||
|
||||
|
||||
class ConsoleOutputController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConsoleOutputController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(ConsoleOutputController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.expected_errors((404, 409, 501))
|
||||
|
@ -45,6 +45,7 @@ class ConsolesController(wsgi.Controller):
|
||||
"""The Consoles controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
super(ConsolesController, self).__init__()
|
||||
self.console_api = console_api.API()
|
||||
|
||||
@wsgi.expected_errors(())
|
||||
|
@ -26,8 +26,8 @@ from nova.policies import create_backup as cb_policies
|
||||
|
||||
|
||||
class CreateBackupController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CreateBackupController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(CreateBackupController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -25,8 +25,8 @@ from nova.policies import deferred_delete as dd_policies
|
||||
|
||||
|
||||
class DeferredDeleteController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DeferredDeleteController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(DeferredDeleteController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -33,8 +33,8 @@ CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class EvacuateController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EvacuateController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(EvacuateController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.host_api = compute.HostAPI()
|
||||
self.network_api = network.API()
|
||||
|
@ -28,9 +28,6 @@ class FlavorManageController(wsgi.Controller):
|
||||
"""The Flavor Lifecycle API controller for the OpenStack API."""
|
||||
_view_builder_class = flavors_view.ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
super(FlavorManageController, self).__init__()
|
||||
|
||||
# NOTE(oomichi): Return 202 for backwards compatibility but should be
|
||||
# 204 as this operation complete the deletion of aggregate resource and
|
||||
# return no response body.
|
||||
|
@ -36,8 +36,8 @@ class FloatingIPPoolsController(wsgi.Controller):
|
||||
"""The Floating IP Pool API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPPoolsController, self).__init__()
|
||||
self.network_api = network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.expected_errors(())
|
||||
|
@ -106,9 +106,9 @@ class FloatingIPController(wsgi.Controller):
|
||||
"""The Floating IPs API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
super(FloatingIPController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.expected_errors((400, 404))
|
||||
@ -204,8 +204,8 @@ class FloatingIPController(wsgi.Controller):
|
||||
class FloatingIPActionController(wsgi.Controller):
|
||||
"""This API is deprecated from the Microversion '2.44'."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FloatingIPActionController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(FloatingIPActionController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
|
||||
|
@ -35,8 +35,8 @@ LOG = logging.getLogger(__name__)
|
||||
class HostController(wsgi.Controller):
|
||||
"""The Hosts API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
self.api = compute.HostAPI()
|
||||
super(HostController, self).__init__()
|
||||
self.api = compute.HostAPI()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.42")
|
||||
@validation.query_schema(hosts.index_query)
|
||||
|
@ -45,9 +45,9 @@ class HypervisorsController(wsgi.Controller):
|
||||
_view_builder_class = hyper_view.ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
super(HypervisorsController, self).__init__()
|
||||
self.host_api = compute.HostAPI()
|
||||
self.servicegroup_api = servicegroup.API()
|
||||
super(HypervisorsController, self).__init__()
|
||||
|
||||
def _view_hypervisor(self, hypervisor, service, detail, req, servers=None,
|
||||
**kwargs):
|
||||
|
@ -31,6 +31,7 @@ class ImageMetadataController(wsgi.Controller):
|
||||
"""The image metadata API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
super(ImageMetadataController, self).__init__()
|
||||
self.image_api = nova.image.API()
|
||||
|
||||
def _get_image(self, context, image_id):
|
||||
|
@ -42,8 +42,8 @@ class ImagesController(wsgi.Controller):
|
||||
|
||||
_view_builder_class = views_images.ViewBuilder
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(ImagesController, self).__init__(**kwargs)
|
||||
def __init__(self):
|
||||
super(ImagesController, self).__init__()
|
||||
self._image_api = nova.image.API()
|
||||
|
||||
def _get_filters(self, req):
|
||||
|
@ -27,7 +27,9 @@ from nova import utils
|
||||
|
||||
|
||||
class InstanceUsageAuditLogController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(InstanceUsageAuditLogController, self).__init__()
|
||||
self.host_api = compute.HostAPI()
|
||||
|
||||
@wsgi.expected_errors(())
|
||||
|
@ -31,8 +31,8 @@ class IPsController(wsgi.Controller):
|
||||
# microversion by using V2.1 view builder.
|
||||
_view_builder_class = views_addresses.ViewBuilder
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(IPsController, self).__init__(**kwargs)
|
||||
def __init__(self):
|
||||
super(IPsController, self).__init__()
|
||||
self._compute_api = compute.API()
|
||||
|
||||
@wsgi.expected_errors(404)
|
||||
|
@ -38,8 +38,8 @@ class KeypairController(wsgi.Controller):
|
||||
_view_builder_class = keypairs_view.ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
self.api = compute_api.KeypairAPI()
|
||||
super(KeypairController, self).__init__()
|
||||
self.api = compute_api.KeypairAPI()
|
||||
|
||||
def _filter_keypair(self, keypair, **attrs):
|
||||
# TODO(claudiub): After v2 and v2.1 is no longer supported,
|
||||
|
@ -23,8 +23,8 @@ from nova.policies import lock_server as ls_policies
|
||||
|
||||
|
||||
class LockServerController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LockServerController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(LockServerController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -33,8 +33,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MigrateServerController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MigrateServerController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(MigrateServerController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
|
||||
|
@ -29,8 +29,8 @@ from nova.policies import multinic as multinic_policies
|
||||
class MultinicController(wsgi.Controller):
|
||||
"""This API is deprecated from Microversion '2.44'."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MultinicController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(MultinicController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.43")
|
||||
|
@ -79,6 +79,8 @@ def network_dict(context, network):
|
||||
class NetworkController(wsgi.Controller):
|
||||
|
||||
def __init__(self, network_api=None):
|
||||
super(NetworkController, self).__init__()
|
||||
# TODO(stephenfin): 'network_api' is only being passed for use by tests
|
||||
self.network_api = network_api or network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
|
@ -28,6 +28,8 @@ class NetworkAssociateActionController(wsgi.Controller):
|
||||
"""Network Association API Controller."""
|
||||
|
||||
def __init__(self, network_api=None):
|
||||
super(NetworkAssociateActionController, self).__init__()
|
||||
# TODO(stephenfin): 'network_api' is only being passed for use by tests
|
||||
self.network_api = network_api or network.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
|
@ -23,8 +23,8 @@ from nova.policies import pause_server as ps_policies
|
||||
|
||||
|
||||
class PauseServerController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PauseServerController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(PauseServerController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -47,7 +47,8 @@ class QuotaClassSetsController(wsgi.Controller):
|
||||
|
||||
supported_quotas = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
def __init__(self):
|
||||
super(QuotaClassSetsController, self).__init__()
|
||||
self.supported_quotas = QUOTAS.resources
|
||||
|
||||
def _format_quota_set(self, quota_class, quota_set, filtered_quotas=None,
|
||||
|
@ -24,14 +24,14 @@ from nova.policies import remote_consoles as rc_policies
|
||||
|
||||
|
||||
class RemoteConsolesController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self):
|
||||
super(RemoteConsolesController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.handlers = {'vnc': self.compute_api.get_vnc_console,
|
||||
'spice': self.compute_api.get_spice_console,
|
||||
'rdp': self.compute_api.get_rdp_console,
|
||||
'serial': self.compute_api.get_serial_console,
|
||||
'mks': self.compute_api.get_mks_console}
|
||||
super(RemoteConsolesController, self).__init__(*args, **kwargs)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.5")
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
|
@ -30,8 +30,8 @@ CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class RescueController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RescueController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(RescueController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
# TODO(cyeoh): Should be responding here with 202 Accept
|
||||
|
@ -28,6 +28,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase,
|
||||
wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(SecurityGroupDefaultRulesController, self).__init__()
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
|
||||
|
@ -47,6 +47,7 @@ class SecurityGroupControllerBase(object):
|
||||
"""Base class for Security Group controllers."""
|
||||
|
||||
def __init__(self):
|
||||
super(SecurityGroupControllerBase, self).__init__()
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
self.compute_api = compute.API(
|
||||
@ -405,8 +406,8 @@ class ServerSecurityGroupController(SecurityGroupControllerBase):
|
||||
|
||||
|
||||
class SecurityGroupActionController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SecurityGroupActionController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(SecurityGroupActionController, self).__init__()
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
self.compute_api = compute.API(
|
||||
|
@ -27,8 +27,8 @@ from nova.policies import server_diagnostics as sd_policies
|
||||
class ServerDiagnosticsController(wsgi.Controller):
|
||||
_view_builder_class = server_diagnostics.ViewBuilder
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ServerDiagnosticsController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(ServerDiagnosticsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.expected_errors((400, 404, 409, 501))
|
||||
|
@ -31,8 +31,8 @@ LOG = logging.getLogger(__name__)
|
||||
class ServerExternalEventsController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
super(ServerExternalEventsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@staticmethod
|
||||
def _is_event_tag_present_when_required(event):
|
||||
|
@ -30,8 +30,8 @@ class ServerMetadataController(wsgi.Controller):
|
||||
"""The server metadata API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
super(ServerMetadataController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
def _get_metadata(self, context, server_id):
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
|
@ -59,8 +59,8 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
"""The server migrations API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
super(ServerMigrationsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.22")
|
||||
@wsgi.response(202)
|
||||
|
@ -25,6 +25,7 @@ from nova.policies import server_password as sp_policies
|
||||
class ServerPasswordController(wsgi.Controller):
|
||||
"""The Server Password API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
super(ServerPasswordController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.expected_errors(404)
|
||||
|
@ -45,8 +45,8 @@ class ServerTagsController(wsgi.Controller):
|
||||
_view_builder_class = server_tags.ViewBuilder
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
super(ServerTagsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
def _check_instance_in_valid_state(self, context, server_id, action):
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
@ -104,9 +104,8 @@ class ServersController(wsgi.Controller):
|
||||
# Convenience return
|
||||
return robj
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
super(ServersController, self).__init__(**kwargs)
|
||||
def __init__(self):
|
||||
super(ServersController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network_api.API()
|
||||
|
||||
|
@ -37,6 +37,7 @@ PARTIAL_CONSTRUCT_FOR_CELL_DOWN_MIN_VERSION = '2.69'
|
||||
class ServiceController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(ServiceController, self).__init__()
|
||||
self.host_api = compute.HostAPI()
|
||||
self.aggregate_api = compute.AggregateAPI()
|
||||
self.servicegroup_api = servicegroup.API()
|
||||
|
@ -27,8 +27,8 @@ from nova.policies import shelve as shelve_policies
|
||||
|
||||
|
||||
class ShelveController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ShelveController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(ShelveController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
|
||||
|
@ -22,8 +22,8 @@ from nova.policies import suspend_server as ss_policies
|
||||
|
||||
|
||||
class SuspendServerController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SuspendServerController, self).__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super(SuspendServerController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -52,6 +52,8 @@ def network_dict(network):
|
||||
|
||||
class TenantNetworkController(wsgi.Controller):
|
||||
def __init__(self, network_api=None):
|
||||
super(TenantNetworkController, self).__init__()
|
||||
# TODO(stephenfin): 'network_api' is only being passed for use by tests
|
||||
self.network_api = nova.network.API()
|
||||
self._default_networks = []
|
||||
|
||||
|
@ -96,8 +96,8 @@ class VolumeController(wsgi.Controller):
|
||||
"""The Volumes API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.volume_api = cinder.API()
|
||||
super(VolumeController, self).__init__()
|
||||
self.volume_api = cinder.API()
|
||||
|
||||
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
|
||||
@wsgi.expected_errors(404)
|
||||
|
@ -756,11 +756,9 @@ class Controller(object):
|
||||
|
||||
_view_builder_class = None
|
||||
|
||||
def __init__(self, view_builder=None):
|
||||
def __init__(self):
|
||||
"""Initialize controller with a view builder instance."""
|
||||
if view_builder:
|
||||
self._view_builder = view_builder
|
||||
elif self._view_builder_class:
|
||||
if self._view_builder_class:
|
||||
self._view_builder = self._view_builder_class()
|
||||
else:
|
||||
self._view_builder = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user