Merge "Remove the skip_policy_check flags"
This commit is contained in:
commit
e3bdce2ddb
@ -36,7 +36,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class AdminActionsController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors((404, 409))
|
||||
|
@ -32,7 +32,7 @@ class AdminPasswordController(wsgi.Controller):
|
||||
|
||||
def __init__(self, *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
|
||||
# +micorversions because the password has been changed when returning
|
||||
|
@ -36,7 +36,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
||||
"""The Assisted volume snapshots API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
super(AssistedVolumeSnapshotsController, self).__init__()
|
||||
|
||||
@extensions.expected_errors(400)
|
||||
|
@ -48,8 +48,8 @@ class InterfaceAttachmentController(wsgi.Controller):
|
||||
"""The interface attachment API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(InterfaceAttachmentController, self).__init__()
|
||||
|
||||
@extensions.expected_errors((404, 501))
|
||||
|
@ -42,9 +42,9 @@ class CloudpipeController(wsgi.Controller):
|
||||
"""Handle creating and listing cloudpipe instances."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.cloudpipe = pipelib.CloudPipe(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
self.cloudpipe = pipelib.CloudPipe()
|
||||
self.setup()
|
||||
|
||||
def setup(self):
|
||||
|
@ -33,7 +33,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class ConsoleOutputController(wsgi.Controller):
|
||||
def __init__(self, *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))
|
||||
@wsgi.action('os-getConsoleOutput')
|
||||
|
@ -30,7 +30,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class CreateBackupController(wsgi.Controller):
|
||||
def __init__(self, *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))
|
||||
@wsgi.action('createBackup')
|
||||
|
@ -30,7 +30,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class DeferredDeleteController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors((403, 404, 409))
|
||||
|
@ -37,7 +37,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class EvacuateController(wsgi.Controller):
|
||||
def __init__(self, *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()
|
||||
|
||||
def _get_on_shared_storage(self, req, evacuate_body):
|
||||
|
@ -28,7 +28,7 @@ class ExtendedServerAttributesController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExtendedServerAttributesController, self).__init__(*args,
|
||||
**kwargs)
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
def _extend_server(self, context, server, instance, req):
|
||||
key = "OS-EXT-SRV-ATTR:hypervisor_hostname"
|
||||
|
@ -84,7 +84,7 @@ class FloatingIPDNSDomainController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(FloatingIPDNSDomainController, self).__init__()
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.network_api = network.API()
|
||||
|
||||
@extensions.expected_errors(501)
|
||||
def index(self, req):
|
||||
@ -162,7 +162,7 @@ class FloatingIPDNSEntryController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(FloatingIPDNSEntryController, self).__init__()
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.network_api = network.API()
|
||||
|
||||
@extensions.expected_errors((404, 501))
|
||||
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."""
|
||||
|
||||
def __init__(self):
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPPoolsController, self).__init__()
|
||||
|
||||
@extensions.expected_errors(())
|
||||
|
@ -108,8 +108,8 @@ class FloatingIPController(object):
|
||||
"""The Floating IPs API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPController, self).__init__()
|
||||
|
||||
@extensions.expected_errors((400, 404))
|
||||
@ -200,8 +200,8 @@ class FloatingIPController(object):
|
||||
class FloatingIPActionController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FloatingIPActionController, self).__init__(*args, **kwargs)
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
|
||||
@extensions.expected_errors((400, 403, 404))
|
||||
@wsgi.action('addFloatingIp')
|
||||
|
@ -38,7 +38,7 @@ CONF = nova.conf.CONF
|
||||
class FpingController(wsgi.Controller):
|
||||
|
||||
def __init__(self, network_api=None):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.last_call = {}
|
||||
|
||||
def check_fping(self):
|
||||
|
@ -36,7 +36,7 @@ class IPsController(wsgi.Controller):
|
||||
|
||||
def __init__(self, **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)
|
||||
def index(self, req, server_id):
|
||||
|
@ -26,7 +26,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class LockServerController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors(404)
|
||||
|
@ -35,7 +35,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class MigrateServerController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors((400, 403, 404, 409))
|
||||
|
@ -33,7 +33,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class MultinicController(wsgi.Controller):
|
||||
def __init__(self, *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.action('addFixedIp')
|
||||
|
@ -80,7 +80,7 @@ def network_dict(context, network):
|
||||
class NetworkController(wsgi.Controller):
|
||||
|
||||
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(())
|
||||
def index(self, req):
|
||||
|
@ -30,7 +30,7 @@ class NetworkAssociateActionController(wsgi.Controller):
|
||||
"""Network Association API Controller."""
|
||||
|
||||
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.response(202)
|
||||
|
@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class PauseServerController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
|
@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
|
||||
class RemoteConsolesController(wsgi.Controller):
|
||||
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,
|
||||
'spice': self.compute_api.get_spice_console,
|
||||
'rdp': self.compute_api.get_rdp_console,
|
||||
|
@ -36,7 +36,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class RescueController(wsgi.Controller):
|
||||
def __init__(self, *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
|
||||
# because rescue is an async call, but keep to 200
|
||||
|
@ -30,8 +30,7 @@ class SecurityGroupDefaultRulesController(sg.SecurityGroupControllerBase):
|
||||
|
||||
def __init__(self):
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver(
|
||||
skip_policy_check=True))
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
|
||||
@extensions.expected_errors((400, 409, 501))
|
||||
def create(self, req, body):
|
||||
|
@ -49,10 +49,9 @@ class SecurityGroupControllerBase(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver(
|
||||
skip_policy_check=True))
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
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):
|
||||
"""Return a security group rule in desired API response format.
|
||||
@ -357,10 +356,9 @@ class SecurityGroupActionController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SecurityGroupActionController, self).__init__(*args, **kwargs)
|
||||
self.security_group_api = (
|
||||
openstack_driver.get_openstack_security_group_driver(
|
||||
skip_policy_check=True))
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
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):
|
||||
try:
|
||||
@ -427,10 +425,9 @@ class SecurityGroupActionController(wsgi.Controller):
|
||||
class SecurityGroupsOutputController(wsgi.Controller):
|
||||
def __init__(self, *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 = (
|
||||
openstack_driver.get_openstack_security_group_driver(
|
||||
skip_policy_check=True))
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
|
||||
def _extend_servers(self, req, servers):
|
||||
# TODO(arosen) this function should be refactored to reduce duplicate
|
||||
|
@ -26,7 +26,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
|
||||
class ServerDiagnosticsController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors((404, 409, 501))
|
||||
def index(self, req, server_id):
|
||||
|
@ -33,7 +33,7 @@ class ServerMetadataController(wsgi.Controller):
|
||||
"""The server metadata API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
super(ServerMetadataController, self).__init__()
|
||||
|
||||
def _get_metadata(self, context, server_id):
|
||||
|
@ -59,7 +59,7 @@ class ServerMigrationsController(wsgi.Controller):
|
||||
"""The server migrations API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
super(ServerMigrationsController, self).__init__()
|
||||
|
||||
@wsgi.Controller.api_version("2.22")
|
||||
|
@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class ServerPasswordController(wsgi.Controller):
|
||||
"""The Server Password API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
def index(self, req, server_id):
|
||||
|
@ -149,7 +149,7 @@ class ServersController(wsgi.Controller):
|
||||
|
||||
self.extension_info = kwargs.pop('extension_info')
|
||||
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
|
||||
self.create_extension_manager = \
|
||||
|
@ -30,7 +30,7 @@ authorize = exts.os_compute_authorizer(ALIAS)
|
||||
class ShelveController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@exts.expected_errors((404, 409))
|
||||
|
@ -29,7 +29,7 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
class SuspendServerController(wsgi.Controller):
|
||||
def __init__(self, *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)
|
||||
@extensions.expected_errors((404, 409))
|
||||
|
@ -53,7 +53,7 @@ def network_dict(network):
|
||||
|
||||
class TenantNetworkController(wsgi.Controller):
|
||||
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 = []
|
||||
|
||||
def _refresh_default_networks(self):
|
||||
|
@ -49,8 +49,8 @@ class ServerVirtualInterfaceController(wsgi.Controller):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.network_api = network.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(ServerVirtualInterfaceController, self).__init__()
|
||||
|
||||
def _items(self, req, server_id, entity_maker):
|
||||
|
@ -248,7 +248,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API(skip_policy_check=True)
|
||||
self.compute_api = compute.API()
|
||||
self.volume_api = volume.API()
|
||||
super(VolumeAttachmentController, self).__init__()
|
||||
|
||||
|
@ -54,8 +54,8 @@ def _load_boot_script():
|
||||
|
||||
|
||||
class CloudPipe(object):
|
||||
def __init__(self, skip_policy_check=False):
|
||||
self.compute_api = compute.API(skip_policy_check=skip_policy_check)
|
||||
def __init__(self):
|
||||
self.compute_api = compute.API()
|
||||
|
||||
def get_encoded_zip(self, project_id):
|
||||
# Make a payload.zip
|
||||
|
@ -188,15 +188,12 @@ class API(base.Base):
|
||||
"""API for interacting with the compute manager."""
|
||||
|
||||
def __init__(self, image_api=None, network_api=None, volume_api=None,
|
||||
security_group_api=None, skip_policy_check=False, **kwargs):
|
||||
self.skip_policy_check = skip_policy_check
|
||||
security_group_api=None, **kwargs):
|
||||
self.image_api = image_api or image.API()
|
||||
self.network_api = network_api or network.API(
|
||||
skip_policy_check=skip_policy_check)
|
||||
self.network_api = network_api or network.API()
|
||||
self.volume_api = volume_api or volume.API()
|
||||
self.security_group_api = (security_group_api or
|
||||
openstack_driver.get_openstack_security_group_driver(
|
||||
skip_policy_check=skip_policy_check))
|
||||
openstack_driver.get_openstack_security_group_driver())
|
||||
self.consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.compute_task_api = conductor.ComputeTaskAPI()
|
||||
@ -4007,9 +4004,8 @@ class SecurityGroupAPI(base.Base, security_group_base.SecurityGroupBase):
|
||||
# The nova security group api does not use a uuid for the id.
|
||||
id_is_uuid = False
|
||||
|
||||
def __init__(self, skip_policy_check=False, **kwargs):
|
||||
def __init__(self, **kwargs):
|
||||
super(SecurityGroupAPI, self).__init__(**kwargs)
|
||||
self.skip_policy_check = skip_policy_check
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
|
||||
def validate_property(self, value, property, allowed):
|
||||
|
@ -55,7 +55,7 @@ def is_neutron():
|
||||
return False
|
||||
|
||||
|
||||
def API(skip_policy_check=False):
|
||||
def API():
|
||||
if is_neutron() is None:
|
||||
network_api_class = CONF.network_api_class
|
||||
elif is_neutron():
|
||||
@ -64,4 +64,4 @@ def API(skip_policy_check=False):
|
||||
network_api_class = NOVA_NET_API
|
||||
|
||||
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.
|
||||
New operations available on specific clients must be added here as well.
|
||||
"""
|
||||
def __init__(self, skip_policy_check=False, **kwargs):
|
||||
self.skip_policy_check = skip_policy_check
|
||||
def __init__(self, **kwargs):
|
||||
super(NetworkAPI, self).__init__(**kwargs)
|
||||
|
||||
def get_all(self, context):
|
||||
|
@ -126,8 +126,8 @@ def _is_not_duplicate(item, items, items_list_name, instance):
|
||||
class API(base_api.NetworkAPI):
|
||||
"""API for interacting with the neutron 2.x API."""
|
||||
|
||||
def __init__(self, skip_policy_check=False):
|
||||
super(API, self).__init__(skip_policy_check=skip_policy_check)
|
||||
def __init__(self):
|
||||
super(API, self).__init__()
|
||||
self.last_neutron_extension_sync = None
|
||||
self.extensions = {}
|
||||
|
||||
|
@ -24,26 +24,15 @@ CONF = nova.conf.CONF
|
||||
NOVA_DRIVER = ('nova.compute.api.SecurityGroupAPI')
|
||||
NEUTRON_DRIVER = ('nova.network.security_group.neutron_driver.'
|
||||
'SecurityGroupAPI')
|
||||
DRIVER_CACHE = {}
|
||||
|
||||
|
||||
def _get_openstack_security_group_driver(skip_policy_check=False):
|
||||
def get_openstack_security_group_driver():
|
||||
if is_neutron_security_groups():
|
||||
return importutils.import_object(NEUTRON_DRIVER,
|
||||
skip_policy_check=skip_policy_check)
|
||||
return importutils.import_object(NEUTRON_DRIVER)
|
||||
elif CONF.security_group_api.lower() == 'nova':
|
||||
return importutils.import_object(NOVA_DRIVER,
|
||||
skip_policy_check=skip_policy_check)
|
||||
return importutils.import_object(NOVA_DRIVER)
|
||||
else:
|
||||
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]
|
||||
return importutils.import_object(CONF.security_group_api)
|
||||
|
||||
|
||||
def is_neutron_security_groups():
|
||||
|
@ -26,9 +26,6 @@ from nova import utils
|
||||
|
||||
class SecurityGroupBase(object):
|
||||
|
||||
def __init__(self, skip_policy_check=False):
|
||||
self.skip_policy_check = skip_policy_check
|
||||
|
||||
def parse_cidr(self, cidr):
|
||||
if cidr:
|
||||
try:
|
||||
|
@ -119,7 +119,7 @@ class FakeNetworkAPI(object):
|
||||
_sentinel = object()
|
||||
_vlan_is_disabled = False
|
||||
|
||||
def __init__(self, skip_policy_check=False):
|
||||
def __init__(self):
|
||||
self.networks = copy.deepcopy(FAKE_NETWORKS)
|
||||
|
||||
def delete(self, context, network_id):
|
||||
@ -325,7 +325,7 @@ class NetworksTestV21(test.NoDBTestCase):
|
||||
self.controller = networks_v21.NetworkController(
|
||||
self.fake_network_api)
|
||||
self.neutron_ctrl = networks_v21.NetworkController(
|
||||
neutron.API(skip_policy_check=True))
|
||||
neutron.API())
|
||||
self.req = fakes.HTTPRequest.blank('',
|
||||
project_id=fakes.FAKE_PROJECT_ID)
|
||||
|
||||
@ -488,7 +488,7 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
|
||||
.NetworkAssociateActionController(self.fake_network_api)
|
||||
self.neutron_assoc_ctrl = (
|
||||
networks_associate_v21.NetworkAssociateActionController(
|
||||
neutron.API(skip_policy_check=True)))
|
||||
neutron.API()))
|
||||
self.req = fakes.HTTPRequest.blank('')
|
||||
|
||||
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']
|
||||
|
||||
class Fake(object):
|
||||
def __init__(self, skip_policy_check=False):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_instance_nw_info(*args, **kwargs):
|
||||
|
@ -22,7 +22,6 @@ from six.moves import range
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
@ -434,19 +433,3 @@ class TestNeutronDriverWithoutMock(test.NoDBTestCase):
|
||||
r = sg_api.populate_security_groups('ignore')
|
||||
self.assertIsInstance(r, objects.SecurityGroupList)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user