Remove the skip_policy_check flags
The skip_policy_check flag is used to skip the legacy v2 API policy check points in the v2.1 API. The legacy v2 API is removed and all the old policy check points removed also. This flag is useless anymore, this patch cleanup them. Partially implements blueprint remove-legacy-v2-api-code Change-Id: Ia4a8d9954bf456253101b936f8b4ff513aaa73b2
This commit is contained in:
@@ -36,7 +36,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class AdminActionsController(wsgi.Controller):
|
class AdminActionsController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AdminActionsController, self).__init__(*args, **kwargs)
|
super(AdminActionsController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors((404, 409))
|
@extensions.expected_errors((404, 409))
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class AdminPasswordController(wsgi.Controller):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AdminPasswordController, self).__init__(*args, **kwargs)
|
super(AdminPasswordController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
# TODO(eliqiao): Here should be 204(No content) instead of 202 by v2.1
|
# TODO(eliqiao): Here should be 204(No content) instead of 202 by v2.1
|
||||||
# +micorversions because the password has been changed when returning
|
# +micorversions because the password has been changed when returning
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
|||||||
"""The Assisted volume snapshots API controller for the OpenStack API."""
|
"""The Assisted volume snapshots API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
super(AssistedVolumeSnapshotsController, self).__init__()
|
super(AssistedVolumeSnapshotsController, self).__init__()
|
||||||
|
|
||||||
@extensions.expected_errors(400)
|
@extensions.expected_errors(400)
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class InterfaceAttachmentController(wsgi.Controller):
|
|||||||
"""The interface attachment API controller for the OpenStack API."""
|
"""The interface attachment API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
super(InterfaceAttachmentController, self).__init__()
|
super(InterfaceAttachmentController, self).__init__()
|
||||||
|
|
||||||
@extensions.expected_errors((404, 501))
|
@extensions.expected_errors((404, 501))
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ class CloudpipeController(wsgi.Controller):
|
|||||||
"""Handle creating and listing cloudpipe instances."""
|
"""Handle creating and listing cloudpipe instances."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
self.cloudpipe = pipelib.CloudPipe(skip_policy_check=True)
|
self.cloudpipe = pipelib.CloudPipe()
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class ConsoleOutputController(wsgi.Controller):
|
class ConsoleOutputController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ConsoleOutputController, self).__init__(*args, **kwargs)
|
super(ConsoleOutputController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@extensions.expected_errors((404, 409, 501))
|
@extensions.expected_errors((404, 409, 501))
|
||||||
@wsgi.action('os-getConsoleOutput')
|
@wsgi.action('os-getConsoleOutput')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class CreateBackupController(wsgi.Controller):
|
class CreateBackupController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(CreateBackupController, self).__init__(*args, **kwargs)
|
super(CreateBackupController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@extensions.expected_errors((400, 403, 404, 409))
|
@extensions.expected_errors((400, 403, 404, 409))
|
||||||
@wsgi.action('createBackup')
|
@wsgi.action('createBackup')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class DeferredDeleteController(wsgi.Controller):
|
class DeferredDeleteController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DeferredDeleteController, self).__init__(*args, **kwargs)
|
super(DeferredDeleteController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors((403, 404, 409))
|
@extensions.expected_errors((403, 404, 409))
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class EvacuateController(wsgi.Controller):
|
class EvacuateController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EvacuateController, self).__init__(*args, **kwargs)
|
super(EvacuateController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.host_api = compute.HostAPI()
|
self.host_api = compute.HostAPI()
|
||||||
|
|
||||||
def _get_on_shared_storage(self, req, evacuate_body):
|
def _get_on_shared_storage(self, req, evacuate_body):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ExtendedServerAttributesController(wsgi.Controller):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ExtendedServerAttributesController, self).__init__(*args,
|
super(ExtendedServerAttributesController, self).__init__(*args,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
def _extend_server(self, context, server, instance, req):
|
def _extend_server(self, context, server, instance, req):
|
||||||
key = "OS-EXT-SRV-ATTR:hypervisor_hostname"
|
key = "OS-EXT-SRV-ATTR:hypervisor_hostname"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class FloatingIPDNSDomainController(wsgi.Controller):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FloatingIPDNSDomainController, self).__init__()
|
super(FloatingIPDNSDomainController, self).__init__()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
|
|
||||||
@extensions.expected_errors(501)
|
@extensions.expected_errors(501)
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
@@ -162,7 +162,7 @@ class FloatingIPDNSEntryController(wsgi.Controller):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FloatingIPDNSEntryController, self).__init__()
|
super(FloatingIPDNSEntryController, self).__init__()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
|
|
||||||
@extensions.expected_errors((404, 501))
|
@extensions.expected_errors((404, 501))
|
||||||
def show(self, req, domain_id, id):
|
def show(self, req, domain_id, id):
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class FloatingIPPoolsController(wsgi.Controller):
|
|||||||
"""The Floating IP Pool API controller for the OpenStack API."""
|
"""The Floating IP Pool API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
super(FloatingIPPoolsController, self).__init__()
|
super(FloatingIPPoolsController, self).__init__()
|
||||||
|
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ class FloatingIPController(object):
|
|||||||
"""The Floating IPs API controller for the OpenStack API."""
|
"""The Floating IPs API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
super(FloatingIPController, self).__init__()
|
super(FloatingIPController, self).__init__()
|
||||||
|
|
||||||
@extensions.expected_errors((400, 404))
|
@extensions.expected_errors((400, 404))
|
||||||
@@ -200,8 +200,8 @@ class FloatingIPController(object):
|
|||||||
class FloatingIPActionController(wsgi.Controller):
|
class FloatingIPActionController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FloatingIPActionController, self).__init__(*args, **kwargs)
|
super(FloatingIPActionController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
|
|
||||||
@extensions.expected_errors((400, 403, 404))
|
@extensions.expected_errors((400, 403, 404))
|
||||||
@wsgi.action('addFloatingIp')
|
@wsgi.action('addFloatingIp')
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ CONF = nova.conf.CONF
|
|||||||
class FpingController(wsgi.Controller):
|
class FpingController(wsgi.Controller):
|
||||||
|
|
||||||
def __init__(self, network_api=None):
|
def __init__(self, network_api=None):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.last_call = {}
|
self.last_call = {}
|
||||||
|
|
||||||
def check_fping(self):
|
def check_fping(self):
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class IPsController(wsgi.Controller):
|
|||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(IPsController, self).__init__(**kwargs)
|
super(IPsController, self).__init__(**kwargs)
|
||||||
self._compute_api = nova.compute.API(skip_policy_check=True)
|
self._compute_api = nova.compute.API()
|
||||||
|
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
def index(self, req, server_id):
|
def index(self, req, server_id):
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class LockServerController(wsgi.Controller):
|
class LockServerController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LockServerController, self).__init__(*args, **kwargs)
|
super(LockServerController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class MigrateServerController(wsgi.Controller):
|
class MigrateServerController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MigrateServerController, self).__init__(*args, **kwargs)
|
super(MigrateServerController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors((400, 403, 404, 409))
|
@extensions.expected_errors((400, 403, 404, 409))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class MultinicController(wsgi.Controller):
|
class MultinicController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MultinicController, self).__init__(*args, **kwargs)
|
super(MultinicController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@wsgi.action('addFixedIp')
|
@wsgi.action('addFixedIp')
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ def network_dict(context, network):
|
|||||||
class NetworkController(wsgi.Controller):
|
class NetworkController(wsgi.Controller):
|
||||||
|
|
||||||
def __init__(self, network_api=None):
|
def __init__(self, network_api=None):
|
||||||
self.network_api = network_api or network.API(skip_policy_check=True)
|
self.network_api = network_api or network.API()
|
||||||
|
|
||||||
@extensions.expected_errors(())
|
@extensions.expected_errors(())
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class NetworkAssociateActionController(wsgi.Controller):
|
|||||||
"""Network Association API Controller."""
|
"""Network Association API Controller."""
|
||||||
|
|
||||||
def __init__(self, network_api=None):
|
def __init__(self, network_api=None):
|
||||||
self.network_api = network_api or network.API(skip_policy_check=True)
|
self.network_api = network_api or network.API()
|
||||||
|
|
||||||
@wsgi.action("disassociate_host")
|
@wsgi.action("disassociate_host")
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class PauseServerController(wsgi.Controller):
|
class PauseServerController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PauseServerController, self).__init__(*args, **kwargs)
|
super(PauseServerController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors((404, 409, 501))
|
@extensions.expected_errors((404, 409, 501))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
|
|
||||||
class RemoteConsolesController(wsgi.Controller):
|
class RemoteConsolesController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.handlers = {'vnc': self.compute_api.get_vnc_console,
|
self.handlers = {'vnc': self.compute_api.get_vnc_console,
|
||||||
'spice': self.compute_api.get_spice_console,
|
'spice': self.compute_api.get_spice_console,
|
||||||
'rdp': self.compute_api.get_rdp_console,
|
'rdp': self.compute_api.get_rdp_console,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class RescueController(wsgi.Controller):
|
class RescueController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RescueController, self).__init__(*args, **kwargs)
|
super(RescueController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
# TODO(cyeoh): Should be responding here with 202 Accept
|
# TODO(cyeoh): Should be responding here with 202 Accept
|
||||||
# because rescue is an async call, but keep to 200
|
# because rescue is an async call, but keep to 200
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.security_group_api = (
|
self.security_group_api = (
|
||||||
openstack_driver.get_openstack_security_group_driver(
|
openstack_driver.get_openstack_security_group_driver())
|
||||||
skip_policy_check=True))
|
|
||||||
|
|
||||||
@extensions.expected_errors((400, 409, 501))
|
@extensions.expected_errors((400, 409, 501))
|
||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
|
|||||||
@@ -49,10 +49,9 @@ class SecurityGroupControllerBase(wsgi.Controller):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.security_group_api = (
|
self.security_group_api = (
|
||||||
openstack_driver.get_openstack_security_group_driver(
|
openstack_driver.get_openstack_security_group_driver())
|
||||||
skip_policy_check=True))
|
|
||||||
self.compute_api = compute.API(
|
self.compute_api = compute.API(
|
||||||
security_group_api=self.security_group_api, skip_policy_check=True)
|
security_group_api=self.security_group_api)
|
||||||
|
|
||||||
def _format_security_group_rule(self, context, rule, group_rule_data=None):
|
def _format_security_group_rule(self, context, rule, group_rule_data=None):
|
||||||
"""Return a security group rule in desired API response format.
|
"""Return a security group rule in desired API response format.
|
||||||
@@ -357,10 +356,9 @@ class SecurityGroupActionController(wsgi.Controller):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(SecurityGroupActionController, self).__init__(*args, **kwargs)
|
super(SecurityGroupActionController, self).__init__(*args, **kwargs)
|
||||||
self.security_group_api = (
|
self.security_group_api = (
|
||||||
openstack_driver.get_openstack_security_group_driver(
|
openstack_driver.get_openstack_security_group_driver())
|
||||||
skip_policy_check=True))
|
|
||||||
self.compute_api = compute.API(
|
self.compute_api = compute.API(
|
||||||
security_group_api=self.security_group_api, skip_policy_check=True)
|
security_group_api=self.security_group_api)
|
||||||
|
|
||||||
def _parse(self, body, action):
|
def _parse(self, body, action):
|
||||||
try:
|
try:
|
||||||
@@ -427,10 +425,9 @@ class SecurityGroupActionController(wsgi.Controller):
|
|||||||
class SecurityGroupsOutputController(wsgi.Controller):
|
class SecurityGroupsOutputController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(SecurityGroupsOutputController, self).__init__(*args, **kwargs)
|
super(SecurityGroupsOutputController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.security_group_api = (
|
self.security_group_api = (
|
||||||
openstack_driver.get_openstack_security_group_driver(
|
openstack_driver.get_openstack_security_group_driver())
|
||||||
skip_policy_check=True))
|
|
||||||
|
|
||||||
def _extend_servers(self, req, servers):
|
def _extend_servers(self, req, servers):
|
||||||
# TODO(arosen) this function should be refactored to reduce duplicate
|
# TODO(arosen) this function should be refactored to reduce duplicate
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
|
|
||||||
class ServerDiagnosticsController(wsgi.Controller):
|
class ServerDiagnosticsController(wsgi.Controller):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@extensions.expected_errors((404, 409, 501))
|
@extensions.expected_errors((404, 409, 501))
|
||||||
def index(self, req, server_id):
|
def index(self, req, server_id):
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||||||
"""The server metadata API controller for the OpenStack API."""
|
"""The server metadata API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
super(ServerMetadataController, self).__init__()
|
super(ServerMetadataController, self).__init__()
|
||||||
|
|
||||||
def _get_metadata(self, context, server_id):
|
def _get_metadata(self, context, server_id):
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class ServerMigrationsController(wsgi.Controller):
|
|||||||
"""The server migrations API controller for the OpenStack API."""
|
"""The server migrations API controller for the OpenStack API."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
super(ServerMigrationsController, self).__init__()
|
super(ServerMigrationsController, self).__init__()
|
||||||
|
|
||||||
@wsgi.Controller.api_version("2.22")
|
@wsgi.Controller.api_version("2.22")
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class ServerPasswordController(wsgi.Controller):
|
class ServerPasswordController(wsgi.Controller):
|
||||||
"""The Server Password API controller for the OpenStack API."""
|
"""The Server Password API controller for the OpenStack API."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
def index(self, req, server_id):
|
def index(self, req, server_id):
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class ServersController(wsgi.Controller):
|
|||||||
|
|
||||||
self.extension_info = kwargs.pop('extension_info')
|
self.extension_info = kwargs.pop('extension_info')
|
||||||
super(ServersController, self).__init__(**kwargs)
|
super(ServersController, self).__init__(**kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
# Look for implementation of extension point of server creation
|
# Look for implementation of extension point of server creation
|
||||||
self.create_extension_manager = \
|
self.create_extension_manager = \
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ authorize = exts.os_compute_authorizer(ALIAS)
|
|||||||
class ShelveController(wsgi.Controller):
|
class ShelveController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ShelveController, self).__init__(*args, **kwargs)
|
super(ShelveController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@exts.expected_errors((404, 409))
|
@exts.expected_errors((404, 409))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||||||
class SuspendServerController(wsgi.Controller):
|
class SuspendServerController(wsgi.Controller):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(SuspendServerController, self).__init__(*args, **kwargs)
|
super(SuspendServerController, self).__init__(*args, **kwargs)
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
@wsgi.response(202)
|
@wsgi.response(202)
|
||||||
@extensions.expected_errors((404, 409))
|
@extensions.expected_errors((404, 409))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ def network_dict(network):
|
|||||||
|
|
||||||
class TenantNetworkController(wsgi.Controller):
|
class TenantNetworkController(wsgi.Controller):
|
||||||
def __init__(self, network_api=None):
|
def __init__(self, network_api=None):
|
||||||
self.network_api = nova.network.API(skip_policy_check=True)
|
self.network_api = nova.network.API()
|
||||||
self._default_networks = []
|
self._default_networks = []
|
||||||
|
|
||||||
def _refresh_default_networks(self):
|
def _refresh_default_networks(self):
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ class ServerVirtualInterfaceController(wsgi.Controller):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.network_api = network.API(skip_policy_check=True)
|
self.network_api = network.API()
|
||||||
super(ServerVirtualInterfaceController, self).__init__()
|
super(ServerVirtualInterfaceController, self).__init__()
|
||||||
|
|
||||||
def _items(self, req, server_id, entity_maker):
|
def _items(self, req, server_id, entity_maker):
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=True)
|
self.compute_api = compute.API()
|
||||||
self.volume_api = volume.API()
|
self.volume_api = volume.API()
|
||||||
super(VolumeAttachmentController, self).__init__()
|
super(VolumeAttachmentController, self).__init__()
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ def _load_boot_script():
|
|||||||
|
|
||||||
|
|
||||||
class CloudPipe(object):
|
class CloudPipe(object):
|
||||||
def __init__(self, skip_policy_check=False):
|
def __init__(self):
|
||||||
self.compute_api = compute.API(skip_policy_check=skip_policy_check)
|
self.compute_api = compute.API()
|
||||||
|
|
||||||
def get_encoded_zip(self, project_id):
|
def get_encoded_zip(self, project_id):
|
||||||
# Make a payload.zip
|
# Make a payload.zip
|
||||||
|
|||||||
@@ -188,15 +188,12 @@ class API(base.Base):
|
|||||||
"""API for interacting with the compute manager."""
|
"""API for interacting with the compute manager."""
|
||||||
|
|
||||||
def __init__(self, image_api=None, network_api=None, volume_api=None,
|
def __init__(self, image_api=None, network_api=None, volume_api=None,
|
||||||
security_group_api=None, skip_policy_check=False, **kwargs):
|
security_group_api=None, **kwargs):
|
||||||
self.skip_policy_check = skip_policy_check
|
|
||||||
self.image_api = image_api or image.API()
|
self.image_api = image_api or image.API()
|
||||||
self.network_api = network_api or network.API(
|
self.network_api = network_api or network.API()
|
||||||
skip_policy_check=skip_policy_check)
|
|
||||||
self.volume_api = volume_api or volume.API()
|
self.volume_api = volume_api or volume.API()
|
||||||
self.security_group_api = (security_group_api or
|
self.security_group_api = (security_group_api or
|
||||||
openstack_driver.get_openstack_security_group_driver(
|
openstack_driver.get_openstack_security_group_driver())
|
||||||
skip_policy_check=skip_policy_check))
|
|
||||||
self.consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
|
self.consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
|
||||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||||
self.compute_task_api = conductor.ComputeTaskAPI()
|
self.compute_task_api = conductor.ComputeTaskAPI()
|
||||||
@@ -3983,9 +3980,8 @@ class SecurityGroupAPI(base.Base, security_group_base.SecurityGroupBase):
|
|||||||
# The nova security group api does not use a uuid for the id.
|
# The nova security group api does not use a uuid for the id.
|
||||||
id_is_uuid = False
|
id_is_uuid = False
|
||||||
|
|
||||||
def __init__(self, skip_policy_check=False, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(SecurityGroupAPI, self).__init__(**kwargs)
|
super(SecurityGroupAPI, self).__init__(**kwargs)
|
||||||
self.skip_policy_check = skip_policy_check
|
|
||||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||||
|
|
||||||
def validate_property(self, value, property, allowed):
|
def validate_property(self, value, property, allowed):
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def is_neutron():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def API(skip_policy_check=False):
|
def API():
|
||||||
if is_neutron() is None:
|
if is_neutron() is None:
|
||||||
network_api_class = CONF.network_api_class
|
network_api_class = CONF.network_api_class
|
||||||
elif is_neutron():
|
elif is_neutron():
|
||||||
@@ -64,4 +64,4 @@ def API(skip_policy_check=False):
|
|||||||
network_api_class = NOVA_NET_API
|
network_api_class = NOVA_NET_API
|
||||||
|
|
||||||
cls = importutils.import_class(network_api_class)
|
cls = importutils.import_class(network_api_class)
|
||||||
return cls(skip_policy_check=skip_policy_check)
|
return cls()
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ class NetworkAPI(base.Base):
|
|||||||
"""Base Network API for doing networking operations.
|
"""Base Network API for doing networking operations.
|
||||||
New operations available on specific clients must be added here as well.
|
New operations available on specific clients must be added here as well.
|
||||||
"""
|
"""
|
||||||
def __init__(self, skip_policy_check=False, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.skip_policy_check = skip_policy_check
|
|
||||||
super(NetworkAPI, self).__init__(**kwargs)
|
super(NetworkAPI, self).__init__(**kwargs)
|
||||||
|
|
||||||
def get_all(self, context):
|
def get_all(self, context):
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ def _is_not_duplicate(item, items, items_list_name, instance):
|
|||||||
class API(base_api.NetworkAPI):
|
class API(base_api.NetworkAPI):
|
||||||
"""API for interacting with the neutron 2.x API."""
|
"""API for interacting with the neutron 2.x API."""
|
||||||
|
|
||||||
def __init__(self, skip_policy_check=False):
|
def __init__(self):
|
||||||
super(API, self).__init__(skip_policy_check=skip_policy_check)
|
super(API, self).__init__()
|
||||||
self.last_neutron_extension_sync = None
|
self.last_neutron_extension_sync = None
|
||||||
self.extensions = {}
|
self.extensions = {}
|
||||||
|
|
||||||
|
|||||||
@@ -24,26 +24,15 @@ CONF = nova.conf.CONF
|
|||||||
NOVA_DRIVER = ('nova.compute.api.SecurityGroupAPI')
|
NOVA_DRIVER = ('nova.compute.api.SecurityGroupAPI')
|
||||||
NEUTRON_DRIVER = ('nova.network.security_group.neutron_driver.'
|
NEUTRON_DRIVER = ('nova.network.security_group.neutron_driver.'
|
||||||
'SecurityGroupAPI')
|
'SecurityGroupAPI')
|
||||||
DRIVER_CACHE = {}
|
|
||||||
|
|
||||||
|
|
||||||
def _get_openstack_security_group_driver(skip_policy_check=False):
|
def get_openstack_security_group_driver():
|
||||||
if is_neutron_security_groups():
|
if is_neutron_security_groups():
|
||||||
return importutils.import_object(NEUTRON_DRIVER,
|
return importutils.import_object(NEUTRON_DRIVER)
|
||||||
skip_policy_check=skip_policy_check)
|
|
||||||
elif CONF.security_group_api.lower() == 'nova':
|
elif CONF.security_group_api.lower() == 'nova':
|
||||||
return importutils.import_object(NOVA_DRIVER,
|
return importutils.import_object(NOVA_DRIVER)
|
||||||
skip_policy_check=skip_policy_check)
|
|
||||||
else:
|
else:
|
||||||
return importutils.import_object(CONF.security_group_api,
|
return importutils.import_object(CONF.security_group_api)
|
||||||
skip_policy_check=skip_policy_check)
|
|
||||||
|
|
||||||
|
|
||||||
def get_openstack_security_group_driver(skip_policy_check=False):
|
|
||||||
if skip_policy_check not in DRIVER_CACHE:
|
|
||||||
DRIVER_CACHE[skip_policy_check] = _get_openstack_security_group_driver(
|
|
||||||
skip_policy_check)
|
|
||||||
return DRIVER_CACHE[skip_policy_check]
|
|
||||||
|
|
||||||
|
|
||||||
def is_neutron_security_groups():
|
def is_neutron_security_groups():
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ from nova import utils
|
|||||||
|
|
||||||
class SecurityGroupBase(object):
|
class SecurityGroupBase(object):
|
||||||
|
|
||||||
def __init__(self, skip_policy_check=False):
|
|
||||||
self.skip_policy_check = skip_policy_check
|
|
||||||
|
|
||||||
def parse_cidr(self, cidr):
|
def parse_cidr(self, cidr):
|
||||||
if cidr:
|
if cidr:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class FakeNetworkAPI(object):
|
|||||||
_sentinel = object()
|
_sentinel = object()
|
||||||
_vlan_is_disabled = False
|
_vlan_is_disabled = False
|
||||||
|
|
||||||
def __init__(self, skip_policy_check=False):
|
def __init__(self):
|
||||||
self.networks = copy.deepcopy(FAKE_NETWORKS)
|
self.networks = copy.deepcopy(FAKE_NETWORKS)
|
||||||
|
|
||||||
def delete(self, context, network_id):
|
def delete(self, context, network_id):
|
||||||
@@ -325,7 +325,7 @@ class NetworksTestV21(test.NoDBTestCase):
|
|||||||
self.controller = networks_v21.NetworkController(
|
self.controller = networks_v21.NetworkController(
|
||||||
self.fake_network_api)
|
self.fake_network_api)
|
||||||
self.neutron_ctrl = networks_v21.NetworkController(
|
self.neutron_ctrl = networks_v21.NetworkController(
|
||||||
neutron.API(skip_policy_check=True))
|
neutron.API())
|
||||||
self.req = fakes.HTTPRequest.blank('',
|
self.req = fakes.HTTPRequest.blank('',
|
||||||
project_id=fakes.FAKE_PROJECT_ID)
|
project_id=fakes.FAKE_PROJECT_ID)
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
|
|||||||
.NetworkAssociateActionController(self.fake_network_api)
|
.NetworkAssociateActionController(self.fake_network_api)
|
||||||
self.neutron_assoc_ctrl = (
|
self.neutron_assoc_ctrl = (
|
||||||
networks_associate_v21.NetworkAssociateActionController(
|
networks_associate_v21.NetworkAssociateActionController(
|
||||||
neutron.API(skip_policy_check=True)))
|
neutron.API()))
|
||||||
self.req = fakes.HTTPRequest.blank('')
|
self.req = fakes.HTTPRequest.blank('')
|
||||||
|
|
||||||
def _check_status(self, res, method, code):
|
def _check_status(self, res, method, code):
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ def stub_out_nw_api(test, cls=None, private=None, publics=None):
|
|||||||
publics = ['1.2.3.4']
|
publics = ['1.2.3.4']
|
||||||
|
|
||||||
class Fake(object):
|
class Fake(object):
|
||||||
def __init__(self, skip_policy_check=False):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_instance_nw_info(*args, **kwargs):
|
def get_instance_nw_info(*args, **kwargs):
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from six.moves import range
|
|||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.network.security_group import neutron_driver
|
from nova.network.security_group import neutron_driver
|
||||||
from nova.network.security_group import openstack_driver
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests import uuidsentinel as uuids
|
from nova.tests import uuidsentinel as uuids
|
||||||
@@ -434,19 +433,3 @@ class TestNeutronDriverWithoutMock(test.NoDBTestCase):
|
|||||||
r = sg_api.populate_security_groups('ignore')
|
r = sg_api.populate_security_groups('ignore')
|
||||||
self.assertIsInstance(r, objects.SecurityGroupList)
|
self.assertIsInstance(r, objects.SecurityGroupList)
|
||||||
self.assertEqual(0, len(r))
|
self.assertEqual(0, len(r))
|
||||||
|
|
||||||
|
|
||||||
class TestGetter(test.NoDBTestCase):
|
|
||||||
@mock.patch('nova.network.security_group.openstack_driver.'
|
|
||||||
'_get_openstack_security_group_driver')
|
|
||||||
def test_caches(self, mock_get):
|
|
||||||
getter = openstack_driver.get_openstack_security_group_driver
|
|
||||||
openstack_driver.DRIVER_CACHE = {}
|
|
||||||
getter(False)
|
|
||||||
getter(False)
|
|
||||||
getter(True)
|
|
||||||
getter(False)
|
|
||||||
self.assertEqual(2, len(mock_get.call_args_list))
|
|
||||||
self.assertEqual({True: mock_get.return_value,
|
|
||||||
False: mock_get.return_value},
|
|
||||||
openstack_driver.DRIVER_CACHE)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user