update Quantum usage to Neutron
This change updates to use the neutron client library and provides backwards compatiblity with the network_api_class. implements bug: 1197208 Change-Id: Ia6c74e40eff516a0fcbe53fdc48e16fb0f98e864
This commit is contained in:
parent
d9a11fb927
commit
566a44fbdf
|
@ -395,13 +395,13 @@
|
|||
# Options defined in nova.api.metadata.handler
|
||||
#
|
||||
|
||||
# Set flag to indicate Quantum will proxy metadata requests
|
||||
# Set flag to indicate Neutron will proxy metadata requests
|
||||
# and resolve instance ids. (boolean value)
|
||||
#service_quantum_metadata_proxy=false
|
||||
#service_neutron_metadata_proxy=false
|
||||
|
||||
# Shared secret to validate proxies Quantum metadata requests
|
||||
# Shared secret to validate proxies Neutron metadata requests
|
||||
# (string value)
|
||||
#quantum_metadata_proxy_shared_secret=
|
||||
#neutron_metadata_proxy_shared_secret=
|
||||
|
||||
|
||||
#
|
||||
|
@ -466,11 +466,11 @@
|
|||
#enable_network_quota=false
|
||||
|
||||
# Control for checking for default networks (string value)
|
||||
#use_quantum_default_nets=False
|
||||
#use_neutron_default_nets=False
|
||||
|
||||
# Default tenant id when creating quantum networks (string
|
||||
# Default tenant id when creating neutron networks (string
|
||||
# value)
|
||||
#quantum_default_tenant_id=default
|
||||
#neutron_default_tenant_id=default
|
||||
|
||||
|
||||
#
|
||||
|
@ -1204,50 +1204,50 @@
|
|||
|
||||
|
||||
#
|
||||
# Options defined in nova.network.quantumv2.api
|
||||
# Options defined in nova.network.neutronv2.api
|
||||
#
|
||||
|
||||
# URL for connecting to quantum (string value)
|
||||
#quantum_url=http://127.0.0.1:9696
|
||||
# URL for connecting to neutron (string value)
|
||||
#neutron_url=http://127.0.0.1:9696
|
||||
|
||||
# timeout value for connecting to quantum in seconds (integer
|
||||
# timeout value for connecting to neutron in seconds (integer
|
||||
# value)
|
||||
#quantum_url_timeout=30
|
||||
#neutron_url_timeout=30
|
||||
|
||||
# username for connecting to quantum in admin context (string
|
||||
# username for connecting to neutron in admin context (string
|
||||
# value)
|
||||
#quantum_admin_username=<None>
|
||||
#neutron_admin_username=<None>
|
||||
|
||||
# password for connecting to quantum in admin context (string
|
||||
# password for connecting to neutron in admin context (string
|
||||
# value)
|
||||
#quantum_admin_password=<None>
|
||||
#neutron_admin_password=<None>
|
||||
|
||||
# tenant name for connecting to quantum in admin context
|
||||
# tenant name for connecting to neutron in admin context
|
||||
# (string value)
|
||||
#quantum_admin_tenant_name=<None>
|
||||
#neutron_admin_tenant_name=<None>
|
||||
|
||||
# region name for connecting to quantum in admin context
|
||||
# region name for connecting to neutron in admin context
|
||||
# (string value)
|
||||
#quantum_region_name=<None>
|
||||
#neutron_region_name=<None>
|
||||
|
||||
# auth url for connecting to quantum in admin context (string
|
||||
# auth url for connecting to neutron in admin context (string
|
||||
# value)
|
||||
#quantum_admin_auth_url=http://localhost:5000/v2.0
|
||||
#neutron_admin_auth_url=http://localhost:5000/v2.0
|
||||
|
||||
# if set, ignore any SSL validation issues (boolean value)
|
||||
#quantum_api_insecure=false
|
||||
#neutron_api_insecure=false
|
||||
|
||||
# auth strategy for connecting to quantum in admin context
|
||||
# auth strategy for connecting to neutron in admin context
|
||||
# (string value)
|
||||
#quantum_auth_strategy=keystone
|
||||
#neutron_auth_strategy=keystone
|
||||
|
||||
# Name of Integration Bridge used by Open vSwitch (string
|
||||
# value)
|
||||
#quantum_ovs_bridge=br-int
|
||||
#neutron_ovs_bridge=br-int
|
||||
|
||||
# Number of seconds before querying quantum for extensions
|
||||
# Number of seconds before querying neutron for extensions
|
||||
# (integer value)
|
||||
#quantum_extension_sync_interval=600
|
||||
#neutron_extension_sync_interval=600
|
||||
|
||||
|
||||
#
|
||||
|
|
|
@ -42,7 +42,7 @@ from nova import db
|
|||
from nova import exception
|
||||
from nova.image import s3
|
||||
from nova import network
|
||||
from nova.network.security_group import quantum_driver
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
|
@ -518,7 +518,7 @@ class CloudController(object):
|
|||
'userId': source_group['project_id']}]
|
||||
else:
|
||||
# rule is not always joined with grantee_group
|
||||
# for example when using quantum driver.
|
||||
# for example when using neutron driver.
|
||||
source_group = self.security_group_api.get(
|
||||
context, id=rule['group_id'])
|
||||
r['groups'] += [{'groupName': source_group.get('name'),
|
||||
|
@ -1866,15 +1866,15 @@ class CloudSecurityGroupNovaAPI(EC2SecurityGroupExceptions,
|
|||
pass
|
||||
|
||||
|
||||
class CloudSecurityGroupQuantumAPI(EC2SecurityGroupExceptions,
|
||||
quantum_driver.SecurityGroupAPI):
|
||||
class CloudSecurityGroupNeutronAPI(EC2SecurityGroupExceptions,
|
||||
neutron_driver.SecurityGroupAPI):
|
||||
pass
|
||||
|
||||
|
||||
def get_cloud_security_group_api():
|
||||
if cfg.CONF.security_group_api.lower() == 'nova':
|
||||
return CloudSecurityGroupNovaAPI()
|
||||
elif cfg.CONF.security_group_api.lower() == 'quantum':
|
||||
return CloudSecurityGroupQuantumAPI()
|
||||
elif cfg.CONF.security_group_api.lower() in ('neutron', 'quantum'):
|
||||
return CloudSecurityGroupNeutronAPI()
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -39,14 +39,16 @@ CONF.import_opt('use_forwarded_for', 'nova.api.auth')
|
|||
|
||||
metadata_proxy_opts = [
|
||||
cfg.BoolOpt(
|
||||
'service_quantum_metadata_proxy',
|
||||
'service_neutron_metadata_proxy',
|
||||
default=False,
|
||||
help='Set flag to indicate Quantum will proxy metadata requests and '
|
||||
deprecated_name='service_quantum_metadata_proxy',
|
||||
help='Set flag to indicate Neutron will proxy metadata requests and '
|
||||
'resolve instance ids.'),
|
||||
cfg.StrOpt(
|
||||
'quantum_metadata_proxy_shared_secret',
|
||||
'neutron_metadata_proxy_shared_secret',
|
||||
default='',
|
||||
help='Shared secret to validate proxies Quantum metadata requests')
|
||||
deprecated_name='quantum_metadata_proxy_shared_secret',
|
||||
help='Shared secret to validate proxies Neutron metadata requests')
|
||||
]
|
||||
|
||||
CONF.register_opts(metadata_proxy_opts)
|
||||
|
@ -100,13 +102,13 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
if os.path.normpath("/" + req.path_info) == "/":
|
||||
return(base.ec2_md_print(base.VERSIONS + ["latest"]))
|
||||
|
||||
if CONF.service_quantum_metadata_proxy:
|
||||
if CONF.service_neutron_metadata_proxy:
|
||||
meta_data = self._handle_instance_id_request(req)
|
||||
else:
|
||||
if req.headers.get('X-Instance-ID'):
|
||||
LOG.warn(
|
||||
_("X-Instance-ID present in request headers. The "
|
||||
"'service_quantum_metadata_proxy' option must be enabled"
|
||||
"'service_neutron_metadata_proxy' option must be enabled"
|
||||
" to process this header."))
|
||||
meta_data = self._handle_remote_ip_request(req)
|
||||
|
||||
|
@ -160,7 +162,7 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
expected_signature = hmac.new(
|
||||
CONF.quantum_metadata_proxy_shared_secret,
|
||||
CONF.neutron_metadata_proxy_shared_secret,
|
||||
instance_id,
|
||||
hashlib.sha256).hexdigest()
|
||||
|
||||
|
|
|
@ -36,12 +36,14 @@ try:
|
|||
cfg.BoolOpt("enable_network_quota",
|
||||
default=False,
|
||||
help="Enables or disables quotaing of tenant networks"),
|
||||
cfg.StrOpt('use_quantum_default_nets',
|
||||
cfg.StrOpt('use_neutron_default_nets',
|
||||
default="False",
|
||||
deprecated_name='use_quantum_default_nets',
|
||||
help=('Control for checking for default networks')),
|
||||
cfg.StrOpt('quantum_default_tenant_id',
|
||||
cfg.StrOpt('neutron_default_tenant_id',
|
||||
default="default",
|
||||
help=('Default tenant id when creating quantum '
|
||||
deprecated_name='quantum_default_tenant_id',
|
||||
help=('Default tenant id when creating neutron '
|
||||
'networks'))
|
||||
]
|
||||
CONF.register_opts(os_network_opts)
|
||||
|
@ -76,14 +78,14 @@ class NetworkController(object):
|
|||
|
||||
def _refresh_default_networks(self):
|
||||
self._default_networks = []
|
||||
if CONF.use_quantum_default_nets == "True":
|
||||
if CONF.use_neutron_default_nets == "True":
|
||||
try:
|
||||
self._default_networks = self._get_default_networks()
|
||||
except Exception:
|
||||
LOG.exception("Failed to get default networks")
|
||||
|
||||
def _get_default_networks(self):
|
||||
project_id = CONF.quantum_default_tenant_id
|
||||
project_id = CONF.neutron_default_tenant_id
|
||||
ctx = nova_context.RequestContext(user_id=None,
|
||||
project_id=project_id)
|
||||
networks = {}
|
||||
|
|
|
@ -29,8 +29,8 @@ from nova.api.openstack import xmlutil
|
|||
from nova import compute
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova.network.security_group import quantum_driver
|
||||
from nova.virt import netutils
|
||||
|
||||
|
||||
|
@ -508,7 +508,7 @@ class SecurityGroupsOutputController(wsgi.Controller):
|
|||
return
|
||||
key = "security_groups"
|
||||
context = _authorize_context(req)
|
||||
if not openstack_driver.is_quantum_security_groups():
|
||||
if not openstack_driver.is_neutron_security_groups():
|
||||
for server in servers:
|
||||
instance = req.get_db_instance(server['id'])
|
||||
groups = instance.get(key)
|
||||
|
@ -517,8 +517,8 @@ class SecurityGroupsOutputController(wsgi.Controller):
|
|||
else:
|
||||
# If method is a POST we get the security groups intended for an
|
||||
# instance from the request. The reason for this is if using
|
||||
# quantum security groups the requested security groups for the
|
||||
# instance are not in the db and have not been sent to quantum yet.
|
||||
# neutron security groups the requested security groups for the
|
||||
# instance are not in the db and have not been sent to neutron yet.
|
||||
if req.method != 'POST':
|
||||
if len(servers) == 1:
|
||||
group = (self.security_group_api
|
||||
|
@ -676,6 +676,6 @@ class NativeNovaSecurityGroupAPI(NativeSecurityGroupExceptions,
|
|||
pass
|
||||
|
||||
|
||||
class NativeQuantumSecurityGroupAPI(NativeSecurityGroupExceptions,
|
||||
quantum_driver.SecurityGroupAPI):
|
||||
class NativeNeutronSecurityGroupAPI(NativeSecurityGroupExceptions,
|
||||
neutron_driver.SecurityGroupAPI):
|
||||
pass
|
||||
|
|
|
@ -28,8 +28,8 @@ from nova.api.openstack import xmlutil
|
|||
from nova import compute
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova.network.security_group import quantum_driver
|
||||
|
||||
|
||||
ALIAS = 'os-security-groups'
|
||||
|
@ -129,7 +129,7 @@ class SecurityGroupsOutputController(wsgi.Controller):
|
|||
return
|
||||
key = "security_groups"
|
||||
context = _authorize_context(req)
|
||||
if not openstack_driver.is_quantum_security_groups():
|
||||
if not openstack_driver.is_neutron_security_groups():
|
||||
for server in servers:
|
||||
instance = req.get_db_instance(server['id'])
|
||||
groups = instance.get(key)
|
||||
|
@ -138,8 +138,8 @@ class SecurityGroupsOutputController(wsgi.Controller):
|
|||
else:
|
||||
# If method is a POST we get the security groups intended for an
|
||||
# instance from the request. The reason for this is if using
|
||||
# quantum security groups the requested security groups for the
|
||||
# instance are not in the db and have not been sent to quantum yet.
|
||||
# neutron security groups the requested security groups for the
|
||||
# instance are not in the db and have not been sent to neutron yet.
|
||||
if req.method != 'POST':
|
||||
if len(servers) == 1:
|
||||
group = (self.security_group_api
|
||||
|
@ -280,6 +280,6 @@ class NativeNovaSecurityGroupAPI(NativeSecurityGroupExceptions,
|
|||
pass
|
||||
|
||||
|
||||
class NativeQuantumSecurityGroupAPI(NativeSecurityGroupExceptions,
|
||||
quantum_driver.SecurityGroupAPI):
|
||||
class NativeNeutronSecurityGroupAPI(NativeSecurityGroupExceptions,
|
||||
neutron_driver.SecurityGroupAPI):
|
||||
pass
|
||||
|
|
|
@ -504,7 +504,7 @@ class ServersController(wsgi.Controller):
|
|||
self.extension_info = kwargs.pop('extension_info')
|
||||
super(ServersController, self).__init__(**kwargs)
|
||||
self.compute_api = compute.API()
|
||||
self.quantum_attempted = False
|
||||
self.neutron_attempted = False
|
||||
|
||||
# Look for implmentation of extension point of server creation
|
||||
self.create_extension_manager = \
|
||||
|
@ -674,21 +674,26 @@ class ServersController(wsgi.Controller):
|
|||
injected_files.append((path, contents))
|
||||
return injected_files
|
||||
|
||||
def _is_quantum_v2(self):
|
||||
# NOTE(dprince): quantumclient is not a requirement
|
||||
if self.quantum_attempted:
|
||||
return self.have_quantum
|
||||
def _is_neutron_v2(self):
|
||||
# NOTE(dprince): neutron is not a requirement
|
||||
if self.neutron_attempted:
|
||||
return self.have_neutron
|
||||
|
||||
try:
|
||||
self.quantum_attempted = True
|
||||
from nova.network.quantumv2 import api as quantum_api
|
||||
self.have_quantum = issubclass(
|
||||
importutils.import_class(CONF.network_api_class),
|
||||
quantum_api.API)
|
||||
except ImportError:
|
||||
self.have_quantum = False
|
||||
# compatibility with Folsom/Grizzly configs
|
||||
cls_name = CONF.network_api_class
|
||||
if cls_name == 'nova.network.quantumv2.api.API':
|
||||
cls_name = 'nova.network.neutronv2.api.API'
|
||||
|
||||
return self.have_quantum
|
||||
self.neutron_attempted = True
|
||||
from nova.network.neutronv2 import api as neutron_api
|
||||
self.have_neutron = issubclass(
|
||||
importutils.import_class(cls_name),
|
||||
neutron_api.API)
|
||||
except ImportError:
|
||||
self.have_neutron = False
|
||||
|
||||
return self.have_neutron
|
||||
|
||||
def _get_requested_networks(self, requested_networks):
|
||||
"""Create a list of requested networks from the networks attribute."""
|
||||
|
@ -698,8 +703,8 @@ class ServersController(wsgi.Controller):
|
|||
port_id = network.get('port', None)
|
||||
if port_id:
|
||||
network_uuid = None
|
||||
if not self._is_quantum_v2():
|
||||
# port parameter is only for quantum v2.0
|
||||
if not self._is_neutron_v2():
|
||||
# port parameter is only for neutron v2.0
|
||||
msg = _("Unknown argment : port")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
if not uuidutils.is_uuid_like(port_id):
|
||||
|
@ -726,9 +731,9 @@ class ServersController(wsgi.Controller):
|
|||
msg = _("Invalid fixed IP address (%s)") % address
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
# For quantumv2, requestd_networks
|
||||
# For neutronv2, requestd_networks
|
||||
# should be tuple of (network_uuid, fixed_ip, port_id)
|
||||
if self._is_quantum_v2():
|
||||
if self._is_neutron_v2():
|
||||
networks.append((network_uuid, address, port_id))
|
||||
else:
|
||||
# check if the network id is already present in the list,
|
||||
|
@ -856,12 +861,12 @@ class ServersController(wsgi.Controller):
|
|||
# TODO(cyeoh): bp v3-api-core-as-extensions
|
||||
# Replace with an extension point when the os-networks
|
||||
# extension is ported. Currently reworked
|
||||
# to take into account _is_quantum_v2
|
||||
# to take into account _is_neutron_v2
|
||||
#if (self.ext_mgr.is_loaded('os-networks')
|
||||
# or self._is_quantum_v2()):
|
||||
# or self._is_neutron_v2()):
|
||||
# requested_networks = server_dict.get('networks')
|
||||
|
||||
if self._is_quantum_v2():
|
||||
if self._is_neutron_v2():
|
||||
requested_networks = server_dict.get('networks')
|
||||
if requested_networks is not None:
|
||||
requested_networks = self._get_requested_networks(
|
||||
|
|
|
@ -463,7 +463,7 @@ class Controller(wsgi.Controller):
|
|||
super(Controller, self).__init__(**kwargs)
|
||||
self.compute_api = compute.API()
|
||||
self.ext_mgr = ext_mgr
|
||||
self.quantum_attempted = False
|
||||
self.neutron_attempted = False
|
||||
|
||||
@wsgi.serializers(xml=MinimalServersTemplate)
|
||||
def index(self, req):
|
||||
|
@ -612,21 +612,26 @@ class Controller(wsgi.Controller):
|
|||
injected_files.append((path, contents))
|
||||
return injected_files
|
||||
|
||||
def _is_quantum_v2(self):
|
||||
# NOTE(dprince): quantumclient is not a requirement
|
||||
if self.quantum_attempted:
|
||||
return self.have_quantum
|
||||
def _is_neutron_v2(self):
|
||||
# NOTE(dprince): neutronclient is not a requirement
|
||||
if self.neutron_attempted:
|
||||
return self.have_neutron
|
||||
|
||||
try:
|
||||
self.quantum_attempted = True
|
||||
from nova.network.quantumv2 import api as quantum_api
|
||||
self.have_quantum = issubclass(
|
||||
importutils.import_class(CONF.network_api_class),
|
||||
quantum_api.API)
|
||||
except ImportError:
|
||||
self.have_quantum = False
|
||||
# compatibility with Folsom/Grizzly configs
|
||||
cls_name = CONF.network_api_class
|
||||
if cls_name == 'nova.network.quantumv2.api.API':
|
||||
cls_name = 'nova.network.neutronv2.api.API'
|
||||
self.neutron_attempted = True
|
||||
|
||||
return self.have_quantum
|
||||
from nova.network.neutronv2 import api as neutron_api
|
||||
self.have_neutron = issubclass(
|
||||
importutils.import_class(cls_name),
|
||||
neutron_api.API)
|
||||
except ImportError:
|
||||
self.have_neutron = False
|
||||
|
||||
return self.have_neutron
|
||||
|
||||
def _get_requested_networks(self, requested_networks):
|
||||
"""Create a list of requested networks from the networks attribute."""
|
||||
|
@ -636,8 +641,8 @@ class Controller(wsgi.Controller):
|
|||
port_id = network.get('port', None)
|
||||
if port_id:
|
||||
network_uuid = None
|
||||
if not self._is_quantum_v2():
|
||||
# port parameter is only for quantum v2.0
|
||||
if not self._is_neutron_v2():
|
||||
# port parameter is only for neutron v2.0
|
||||
msg = _("Unknown argment : port")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
if not uuidutils.is_uuid_like(port_id):
|
||||
|
@ -664,9 +669,9 @@ class Controller(wsgi.Controller):
|
|||
msg = _("Invalid fixed IP address (%s)") % address
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
# For quantumv2, requestd_networks
|
||||
# For neutronv2, requestd_networks
|
||||
# should be tuple of (network_uuid, fixed_ip, port_id)
|
||||
if self._is_quantum_v2():
|
||||
if self._is_neutron_v2():
|
||||
networks.append((network_uuid, address, port_id))
|
||||
else:
|
||||
# check if the network id is already present in the list,
|
||||
|
@ -779,7 +784,7 @@ class Controller(wsgi.Controller):
|
|||
|
||||
requested_networks = None
|
||||
if (self.ext_mgr.is_loaded('os-networks')
|
||||
or self._is_quantum_v2()):
|
||||
or self._is_neutron_v2()):
|
||||
requested_networks = server_dict.get('networks')
|
||||
|
||||
if requested_networks is not None:
|
||||
|
|
|
@ -539,13 +539,13 @@ class NetworkCommands(object):
|
|||
raise Exception(_("Please specify either fixed_range or uuid"))
|
||||
|
||||
net_manager = importutils.import_object(CONF.network_manager)
|
||||
if "QuantumManager" in CONF.network_manager:
|
||||
if "NeutronManager" in CONF.network_manager:
|
||||
if uuid is None:
|
||||
raise Exception(_("UUID is required to delete "
|
||||
"Quantum Networks"))
|
||||
"Neutron Networks"))
|
||||
if fixed_range:
|
||||
raise Exception(_("Deleting by fixed_range is not supported "
|
||||
"with the QuantumManager"))
|
||||
"with the NeutronManager"))
|
||||
# delete the network
|
||||
net_manager.delete_network(context.get_admin_context(),
|
||||
fixed_range, uuid)
|
||||
|
|
|
@ -362,8 +362,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||
self.compute_api = compute.API()
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.conductor_api = conductor.API()
|
||||
self.is_quantum_security_groups = (
|
||||
openstack_driver.is_quantum_security_groups())
|
||||
self.is_neutron_security_groups = (
|
||||
openstack_driver.is_neutron_security_groups())
|
||||
self.consoleauth_rpcapi = consoleauth.rpcapi.ConsoleAuthAPI()
|
||||
self.cells_rpcapi = cells_rpcapi.CellsAPI()
|
||||
self._resource_tracker_dict = {}
|
||||
|
@ -959,9 +959,9 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||
node, instance, image_meta):
|
||||
context = context.elevated()
|
||||
|
||||
# If quantum security groups pass requested security
|
||||
# If neutron security groups pass requested security
|
||||
# groups to allocate_for_instance()
|
||||
if request_spec and self.is_quantum_security_groups:
|
||||
if request_spec and self.is_neutron_security_groups:
|
||||
security_groups = request_spec.get('security_group')
|
||||
else:
|
||||
security_groups = []
|
||||
|
|
|
@ -35,5 +35,7 @@ oslo.config.cfg.CONF.register_opts(_network_opts)
|
|||
def API():
|
||||
importutils = nova.openstack.common.importutils
|
||||
network_api_class = oslo.config.cfg.CONF.network_api_class
|
||||
if 'quantumv2' in network_api_class:
|
||||
network_api_class = network_api_class.replace('quantumv2', 'neutronv2')
|
||||
cls = importutils.import_class(network_api_class)
|
||||
return cls()
|
||||
|
|
|
@ -118,7 +118,7 @@ class API(base.Base):
|
|||
"""API for doing networking via the nova-network network manager.
|
||||
|
||||
This is a pluggable module - other implementations do networking via
|
||||
other services (such as Quantum).
|
||||
other services (such as Neutron).
|
||||
"""
|
||||
_sentinel = object()
|
||||
|
||||
|
@ -305,22 +305,22 @@ class API(base.Base):
|
|||
args['host'] = instance['host']
|
||||
self.network_rpcapi.deallocate_for_instance(context, **args)
|
||||
|
||||
# NOTE(danms): Here for quantum compatibility
|
||||
# NOTE(danms): Here for neutron compatibility
|
||||
def allocate_port_for_instance(self, context, instance, port_id,
|
||||
network_id=None, requested_ip=None,
|
||||
conductor_api=None):
|
||||
raise NotImplementedError()
|
||||
|
||||
# NOTE(danms): Here for quantum compatibility
|
||||
# NOTE(danms): Here for neutron compatibility
|
||||
def deallocate_port_for_instance(self, context, instance, port_id,
|
||||
conductor_api=None):
|
||||
raise NotImplementedError()
|
||||
|
||||
# NOTE(danms): Here for quantum compatibility
|
||||
# NOTE(danms): Here for neutron compatibility
|
||||
def list_ports(self, *args, **kwargs):
|
||||
raise NotImplementedError()
|
||||
|
||||
# NOTE(danms): Here for quantum compatibility
|
||||
# NOTE(danms): Here for neutron compatibility
|
||||
def show_port(self, *args, **kwargs):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
@ -1719,8 +1719,8 @@ class LinuxOVSInterfaceDriver(LinuxNetInterfaceDriver):
|
|||
return dev
|
||||
|
||||
|
||||
# plugs interfaces using Linux Bridge when using QuantumManager
|
||||
class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
|
||||
# plugs interfaces using Linux Bridge when using NeutronManager
|
||||
class NeutronLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
|
||||
|
||||
BRIDGE_NAME_PREFIX = 'brq'
|
||||
GATEWAY_INTERFACE_PREFIX = 'gw-'
|
||||
|
@ -1779,4 +1779,7 @@ class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
|
|||
bridge = self.BRIDGE_NAME_PREFIX + str(network['uuid'][0:11])
|
||||
return bridge
|
||||
|
||||
# provide compatibility with existing configs
|
||||
QuantumLinuxBridgeInterfaceDriver = NeutronLinuxBridgeInterfaceDriver
|
||||
|
||||
iptables_manager = IptablesManager()
|
||||
|
|
|
@ -453,7 +453,7 @@ class NetworkInfoAsyncWrapper(NetworkInfo):
|
|||
As an example:
|
||||
|
||||
def allocate_net_info(arg1, arg2)
|
||||
return call_quantum_to_allocate(arg1, arg2)
|
||||
return call_neutron_to_allocate(arg1, arg2)
|
||||
|
||||
network_info = NetworkInfoAsyncWrapper(allocate_net_info, arg1, arg2)
|
||||
[do a long running operation -- real network_info will be retrieved
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutronclient import client
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.v2_0 import client as clientv20
|
||||
from oslo.config import cfg
|
||||
from quantumclient import client
|
||||
from quantumclient.common import exceptions
|
||||
from quantumclient.v2_0 import client as clientv20
|
||||
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -30,28 +30,28 @@ LOG = logging.getLogger(__name__)
|
|||
def _get_auth_token():
|
||||
try:
|
||||
httpclient = client.HTTPClient(
|
||||
username=CONF.quantum_admin_username,
|
||||
tenant_name=CONF.quantum_admin_tenant_name,
|
||||
region_name=CONF.quantum_region_name,
|
||||
password=CONF.quantum_admin_password,
|
||||
auth_url=CONF.quantum_admin_auth_url,
|
||||
timeout=CONF.quantum_url_timeout,
|
||||
auth_strategy=CONF.quantum_auth_strategy,
|
||||
insecure=CONF.quantum_api_insecure)
|
||||
username=CONF.neutron_admin_username,
|
||||
tenant_name=CONF.neutron_admin_tenant_name,
|
||||
region_name=CONF.neutron_region_name,
|
||||
password=CONF.neutron_admin_password,
|
||||
auth_url=CONF.neutron_admin_auth_url,
|
||||
timeout=CONF.neutron_url_timeout,
|
||||
auth_strategy=CONF.neutron_auth_strategy,
|
||||
insecure=CONF.neutron_api_insecure)
|
||||
httpclient.authenticate()
|
||||
return httpclient.auth_token
|
||||
except exceptions.QuantumClientException as e:
|
||||
except exceptions.NeutronClientException as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_('Quantum client authentication failed: %s'), e)
|
||||
LOG.error(_('Neutron client authentication failed: %s'), e)
|
||||
|
||||
|
||||
def _get_client(token=None):
|
||||
if not token and CONF.quantum_auth_strategy:
|
||||
if not token and CONF.neutron_auth_strategy:
|
||||
token = _get_auth_token()
|
||||
params = {
|
||||
'endpoint_url': CONF.quantum_url,
|
||||
'timeout': CONF.quantum_url_timeout,
|
||||
'insecure': CONF.quantum_api_insecure,
|
||||
'endpoint_url': CONF.neutron_url,
|
||||
'timeout': CONF.neutron_url_timeout,
|
||||
'insecure': CONF.neutron_api_insecure,
|
||||
}
|
||||
if token:
|
||||
params['token'] = token
|
|
@ -27,52 +27,63 @@ from nova.db import base
|
|||
from nova import exception
|
||||
from nova.network import api as network_api
|
||||
from nova.network import model as network_model
|
||||
from nova.network import quantumv2
|
||||
from nova.network.quantumv2 import constants
|
||||
from nova.network import neutronv2
|
||||
from nova.network.neutronv2 import constants
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import uuidutils
|
||||
|
||||
quantum_opts = [
|
||||
cfg.StrOpt('quantum_url',
|
||||
neutron_opts = [
|
||||
cfg.StrOpt('neutron_url',
|
||||
default='http://127.0.0.1:9696',
|
||||
help='URL for connecting to quantum'),
|
||||
cfg.IntOpt('quantum_url_timeout',
|
||||
deprecated_name='quantum_url',
|
||||
help='URL for connecting to neutron'),
|
||||
cfg.IntOpt('neutron_url_timeout',
|
||||
default=30,
|
||||
help='timeout value for connecting to quantum in seconds'),
|
||||
cfg.StrOpt('quantum_admin_username',
|
||||
help='username for connecting to quantum in admin context'),
|
||||
cfg.StrOpt('quantum_admin_password',
|
||||
help='password for connecting to quantum in admin context',
|
||||
deprecated_name='quantum_url_timeout',
|
||||
help='timeout value for connecting to neutron in seconds'),
|
||||
cfg.StrOpt('neutron_admin_username',
|
||||
deprecated_name='quantum_admin_username',
|
||||
help='username for connecting to neutron in admin context'),
|
||||
cfg.StrOpt('neutron_admin_password',
|
||||
deprecated_name='quantum_admin_password',
|
||||
help='password for connecting to neutron in admin context',
|
||||
secret=True),
|
||||
cfg.StrOpt('quantum_admin_tenant_name',
|
||||
help='tenant name for connecting to quantum in admin context'),
|
||||
cfg.StrOpt('quantum_region_name',
|
||||
help='region name for connecting to quantum in admin context'),
|
||||
cfg.StrOpt('quantum_admin_auth_url',
|
||||
cfg.StrOpt('neutron_admin_tenant_name',
|
||||
deprecated_name='quantum_admin_tenant_name',
|
||||
help='tenant name for connecting to neutron in admin context'),
|
||||
cfg.StrOpt('neutron_region_name',
|
||||
deprecated_name='quantum_region_name',
|
||||
help='region name for connecting to neutron in admin context'),
|
||||
cfg.StrOpt('neutron_admin_auth_url',
|
||||
deprecated_name='quantum_admin_auth_url',
|
||||
default='http://localhost:5000/v2.0',
|
||||
help='auth url for connecting to quantum in admin context'),
|
||||
cfg.BoolOpt('quantum_api_insecure',
|
||||
help='auth url for connecting to neutron in admin context'),
|
||||
cfg.BoolOpt('neutron_api_insecure',
|
||||
default=False,
|
||||
deprecated_name='quantum_api_insecure',
|
||||
help='if set, ignore any SSL validation issues'),
|
||||
cfg.StrOpt('quantum_auth_strategy',
|
||||
cfg.StrOpt('neutron_auth_strategy',
|
||||
default='keystone',
|
||||
deprecated_name='quantum_auth_strategy',
|
||||
help='auth strategy for connecting to '
|
||||
'quantum in admin context'),
|
||||
# TODO(berrange) temporary hack until Quantum can pass over the
|
||||
'neutron in admin context'),
|
||||
# TODO(berrange) temporary hack until Neutron can pass over the
|
||||
# name of the OVS bridge it is configured with
|
||||
cfg.StrOpt('quantum_ovs_bridge',
|
||||
cfg.StrOpt('neutron_ovs_bridge',
|
||||
default='br-int',
|
||||
deprecated_name='quantum_ovs_bridge',
|
||||
help='Name of Integration Bridge used by Open vSwitch'),
|
||||
cfg.IntOpt('quantum_extension_sync_interval',
|
||||
cfg.IntOpt('neutron_extension_sync_interval',
|
||||
default=600,
|
||||
help='Number of seconds before querying quantum for'
|
||||
deprecated_name='quantum_extension_sync_interval',
|
||||
help='Number of seconds before querying neutron for'
|
||||
' extensions'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(quantum_opts)
|
||||
CONF.register_opts(neutron_opts)
|
||||
CONF.import_opt('default_floating_pool', 'nova.network.floating_ips')
|
||||
CONF.import_opt('flat_injected', 'nova.network.manager')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -82,14 +93,14 @@ update_instance_info_cache = network_api.update_instance_cache_with_nw_info
|
|||
|
||||
|
||||
class API(base.Base):
|
||||
"""API for interacting with the quantum 2.x API."""
|
||||
"""API for interacting with the neutron 2.x API."""
|
||||
|
||||
conductor_api = conductor.API()
|
||||
security_group_api = openstack_driver.get_openstack_security_group_driver()
|
||||
|
||||
def __init__(self):
|
||||
super(API, self).__init__()
|
||||
self.last_quantum_extension_sync = None
|
||||
self.last_neutron_extension_sync = None
|
||||
self.extensions = {}
|
||||
|
||||
def setup_networks_on_host(self, context, instance, host=None,
|
||||
|
@ -102,7 +113,7 @@ class API(base.Base):
|
|||
The list contains networks owned by the tenant and public networks.
|
||||
If net_ids specified, it searches networks with requested IDs only.
|
||||
"""
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
|
||||
# If user has specified to attach instance only to specific
|
||||
# networks, add them to **search_opts
|
||||
|
@ -110,12 +121,12 @@ class API(base.Base):
|
|||
search_opts = {"tenant_id": project_id, 'shared': False}
|
||||
if net_ids:
|
||||
search_opts['id'] = net_ids
|
||||
nets = quantum.list_networks(**search_opts).get('networks', [])
|
||||
nets = neutron.list_networks(**search_opts).get('networks', [])
|
||||
# (2) Retrieve public network list.
|
||||
search_opts = {'shared': True}
|
||||
if net_ids:
|
||||
search_opts['id'] = net_ids
|
||||
nets += quantum.list_networks(**search_opts).get('networks', [])
|
||||
nets += neutron.list_networks(**search_opts).get('networks', [])
|
||||
|
||||
_ensure_requested_network_ordering(
|
||||
lambda x: x['id'],
|
||||
|
@ -134,7 +145,7 @@ class API(base.Base):
|
|||
:param macs: None or a set of MAC addresses that the instance
|
||||
should use. macs is supplied by the hypervisor driver (contrast
|
||||
with requested_networks which is user supplied).
|
||||
NB: QuantumV2 currently assigns hypervisor supplied MAC addresses
|
||||
NB: NeutronV2 currently assigns hypervisor supplied MAC addresses
|
||||
to arbitrary networks, which requires openflow switches to
|
||||
function correctly if more than one network is being used with
|
||||
the bare metal hypervisor (which is the only one known to limit
|
||||
|
@ -147,7 +158,7 @@ class API(base.Base):
|
|||
# to create a port on a network. If we find a mac with a
|
||||
# pre-allocated port we also remove it from this set.
|
||||
available_macs = set(hypervisor_macs)
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
LOG.debug(_('allocate_for_instance() for %s'),
|
||||
instance['display_name'])
|
||||
if not instance['project_id']:
|
||||
|
@ -161,7 +172,7 @@ class API(base.Base):
|
|||
if requested_networks:
|
||||
for network_id, fixed_ip, port_id in requested_networks:
|
||||
if port_id:
|
||||
port = quantum.show_port(port_id)['port']
|
||||
port = neutron.show_port(port_id)['port']
|
||||
if hypervisor_macs is not None:
|
||||
if port['mac_address'] not in hypervisor_macs:
|
||||
raise exception.PortNotUsable(port_id=port_id,
|
||||
|
@ -193,7 +204,7 @@ class API(base.Base):
|
|||
# group if len(security_groups) == 1
|
||||
if len(security_groups):
|
||||
search_opts = {'tenant_id': instance['project_id']}
|
||||
user_security_groups = quantum.list_security_groups(
|
||||
user_security_groups = neutron.list_security_groups(
|
||||
**search_opts).get('security_groups')
|
||||
|
||||
for security_group in security_groups:
|
||||
|
@ -241,12 +252,12 @@ class API(base.Base):
|
|||
'device_owner': zone}}
|
||||
try:
|
||||
port = ports.get(network_id)
|
||||
self._populate_quantum_extension_values(instance,
|
||||
self._populate_neutron_extension_values(instance,
|
||||
port_req_body)
|
||||
# Requires admin creds to set port bindings
|
||||
port_client = (quantum if not
|
||||
port_client = (neutron if not
|
||||
self._has_port_binding_extension() else
|
||||
quantumv2.get_client(context, admin=True))
|
||||
neutronv2.get_client(context, admin=True))
|
||||
if port:
|
||||
port_client.update_port(port['id'], port_req_body)
|
||||
touched_port_ids.append(port['id'])
|
||||
|
@ -277,10 +288,10 @@ class API(base.Base):
|
|||
# Requires admin creds to set port bindings
|
||||
if self._has_port_binding_extension():
|
||||
port_req_body['port']['binding:host_id'] = None
|
||||
port_client = quantumv2.get_client(
|
||||
port_client = neutronv2.get_client(
|
||||
context, admin=True)
|
||||
else:
|
||||
port_client = quantum
|
||||
port_client = neutron
|
||||
port_client.update_port(port_id, port_req_body)
|
||||
except Exception:
|
||||
msg = _("Failed to update port %s")
|
||||
|
@ -288,7 +299,7 @@ class API(base.Base):
|
|||
|
||||
for port_id in created_port_ids:
|
||||
try:
|
||||
quantum.delete_port(port_id)
|
||||
neutron.delete_port(port_id)
|
||||
except Exception:
|
||||
msg = _("Failed to delete port %s")
|
||||
LOG.exception(msg, port_id)
|
||||
|
@ -303,29 +314,29 @@ class API(base.Base):
|
|||
if port['id'] in created_port_ids +
|
||||
touched_port_ids])
|
||||
|
||||
def _refresh_quantum_extensions_cache(self):
|
||||
"""Refresh the quantum extensions cache when necessary."""
|
||||
if (not self.last_quantum_extension_sync or
|
||||
((time.time() - self.last_quantum_extension_sync)
|
||||
>= CONF.quantum_extension_sync_interval)):
|
||||
quantum = quantumv2.get_client(context.get_admin_context())
|
||||
extensions_list = quantum.list_extensions()['extensions']
|
||||
self.last_quantum_extension_sync = time.time()
|
||||
def _refresh_neutron_extensions_cache(self):
|
||||
"""Refresh the neutron extensions cache when necessary."""
|
||||
if (not self.last_neutron_extension_sync or
|
||||
((time.time() - self.last_neutron_extension_sync)
|
||||
>= CONF.neutron_extension_sync_interval)):
|
||||
neutron = neutronv2.get_client(context.get_admin_context())
|
||||
extensions_list = neutron.list_extensions()['extensions']
|
||||
self.last_neutron_extension_sync = time.time()
|
||||
self.extensions.clear()
|
||||
self.extensions = dict((ext['name'], ext)
|
||||
for ext in extensions_list)
|
||||
|
||||
def _has_port_binding_extension(self, refresh_cache=False):
|
||||
if refresh_cache:
|
||||
self._refresh_quantum_extensions_cache()
|
||||
self._refresh_neutron_extensions_cache()
|
||||
return constants.PORTBINDING_EXT in self.extensions
|
||||
|
||||
def _populate_quantum_extension_values(self, instance, port_req_body):
|
||||
"""Populate quantum extension values for the instance.
|
||||
def _populate_neutron_extension_values(self, instance, port_req_body):
|
||||
"""Populate neutron extension values for the instance.
|
||||
|
||||
If the extension contains nvp-qos then get the rxtx_factor.
|
||||
"""
|
||||
self._refresh_quantum_extensions_cache()
|
||||
self._refresh_neutron_extensions_cache()
|
||||
if 'nvp-qos' in self.extensions:
|
||||
instance_type = flavors.extract_flavor(instance)
|
||||
rxtx_factor = instance_type.get('rxtx_factor')
|
||||
|
@ -338,13 +349,13 @@ class API(base.Base):
|
|||
LOG.debug(_('deallocate_for_instance() for %s'),
|
||||
instance['display_name'])
|
||||
search_opts = {'device_id': instance['uuid']}
|
||||
data = quantumv2.get_client(context).list_ports(**search_opts)
|
||||
data = neutronv2.get_client(context).list_ports(**search_opts)
|
||||
ports = data.get('ports', [])
|
||||
for port in ports:
|
||||
try:
|
||||
quantumv2.get_client(context).delete_port(port['id'])
|
||||
neutronv2.get_client(context).delete_port(port['id'])
|
||||
except Exception:
|
||||
LOG.exception(_("Failed to delete quantum port %(portid)s")
|
||||
LOG.exception(_("Failed to delete neutron port %(portid)s")
|
||||
% {'portid': port['id']})
|
||||
|
||||
@refresh_cache
|
||||
|
@ -364,20 +375,20 @@ class API(base.Base):
|
|||
Return network information for the instance
|
||||
"""
|
||||
try:
|
||||
quantumv2.get_client(context).delete_port(port_id)
|
||||
neutronv2.get_client(context).delete_port(port_id)
|
||||
except Exception as ex:
|
||||
LOG.exception(_("Failed to delete quantum port %(port_id)s ") %
|
||||
LOG.exception(_("Failed to delete neutron port %(port_id)s ") %
|
||||
locals())
|
||||
|
||||
return self._get_instance_nw_info(context, instance)
|
||||
|
||||
def list_ports(self, context, **search_opts):
|
||||
"""List ports for the client based on search options."""
|
||||
return quantumv2.get_client(context).list_ports(**search_opts)
|
||||
return neutronv2.get_client(context).list_ports(**search_opts)
|
||||
|
||||
def show_port(self, context, port_id):
|
||||
"""Return the port for the client given the port id."""
|
||||
return quantumv2.get_client(context).show_port(port_id)
|
||||
return neutronv2.get_client(context).show_port(port_id)
|
||||
|
||||
def get_instance_nw_info(self, context, instance, conductor_api=None,
|
||||
networks=None):
|
||||
|
@ -400,7 +411,7 @@ class API(base.Base):
|
|||
conductor_api=None):
|
||||
"""Add a fixed ip to the instance from specified network."""
|
||||
search_opts = {'network_id': network_id}
|
||||
data = quantumv2.get_client(context).list_subnets(**search_opts)
|
||||
data = neutronv2.get_client(context).list_subnets(**search_opts)
|
||||
ipam_subnets = data.get('subnets', [])
|
||||
if not ipam_subnets:
|
||||
raise exception.NetworkNotFoundForInstance(
|
||||
|
@ -410,7 +421,7 @@ class API(base.Base):
|
|||
search_opts = {'device_id': instance['uuid'],
|
||||
'device_owner': zone,
|
||||
'network_id': network_id}
|
||||
data = quantumv2.get_client(context).list_ports(**search_opts)
|
||||
data = neutronv2.get_client(context).list_ports(**search_opts)
|
||||
ports = data['ports']
|
||||
for p in ports:
|
||||
for subnet in ipam_subnets:
|
||||
|
@ -418,7 +429,7 @@ class API(base.Base):
|
|||
fixed_ips.append({'subnet_id': subnet['id']})
|
||||
port_req_body = {'port': {'fixed_ips': fixed_ips}}
|
||||
try:
|
||||
quantumv2.get_client(context).update_port(p['id'],
|
||||
neutronv2.get_client(context).update_port(p['id'],
|
||||
port_req_body)
|
||||
return
|
||||
except Exception as ex:
|
||||
|
@ -439,7 +450,7 @@ class API(base.Base):
|
|||
search_opts = {'device_id': instance['uuid'],
|
||||
'device_owner': zone,
|
||||
'fixed_ips': 'ip_address=%s' % address}
|
||||
data = quantumv2.get_client(context).list_ports(**search_opts)
|
||||
data = neutronv2.get_client(context).list_ports(**search_opts)
|
||||
ports = data['ports']
|
||||
for p in ports:
|
||||
fixed_ips = p['fixed_ips']
|
||||
|
@ -449,7 +460,7 @@ class API(base.Base):
|
|||
new_fixed_ips.append(fixed_ip)
|
||||
port_req_body = {'port': {'fixed_ips': new_fixed_ips}}
|
||||
try:
|
||||
quantumv2.get_client(context).update_port(p['id'],
|
||||
neutronv2.get_client(context).update_port(p['id'],
|
||||
port_req_body)
|
||||
except Exception as ex:
|
||||
msg = _("Unable to update port %(portid)s with"
|
||||
|
@ -470,7 +481,7 @@ class API(base.Base):
|
|||
|
||||
for (net_id, _i, port_id) in requested_networks:
|
||||
if port_id:
|
||||
port = (quantumv2.get_client(context)
|
||||
port = (neutronv2.get_client(context)
|
||||
.show_port(port_id)
|
||||
.get('port'))
|
||||
if not port:
|
||||
|
@ -500,7 +511,7 @@ class API(base.Base):
|
|||
e.g. [{'instance_uuid': uuid}, ...]
|
||||
"""
|
||||
search_opts = {"fixed_ips": 'ip_address=%s' % address}
|
||||
data = quantumv2.get_client(context).list_ports(**search_opts)
|
||||
data = neutronv2.get_client(context).list_ports(**search_opts)
|
||||
ports = data.get('ports', [])
|
||||
return [{'instance_uuid': port['device_id']} for port in ports
|
||||
if port['device_id']]
|
||||
|
@ -547,7 +558,7 @@ class API(base.Base):
|
|||
# since it is not used anywhere in nova code and I could
|
||||
# find why this parameter exists.
|
||||
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
port_id = self._get_port_id_by_fixed_address(client, instance,
|
||||
fixed_address)
|
||||
fip = self._get_floating_ip_by_address(client, floating_address)
|
||||
|
@ -557,7 +568,7 @@ class API(base.Base):
|
|||
|
||||
def get_all(self, context):
|
||||
"""Get all networks for client."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
networks = client.list_networks().get('networks')
|
||||
for network in networks:
|
||||
network['label'] = network['name']
|
||||
|
@ -565,7 +576,7 @@ class API(base.Base):
|
|||
|
||||
def get(self, context, network_uuid):
|
||||
"""Get specific network for client."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
network = client.show_network(network_uuid).get('network') or {}
|
||||
network['label'] = network['name']
|
||||
return network
|
||||
|
@ -616,7 +627,7 @@ class API(base.Base):
|
|||
|
||||
def get_floating_ip(self, context, id):
|
||||
"""Return floating ip object given the floating ip id."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
fip = client.show_floatingip(id)['floatingip']
|
||||
pool_dict = self._setup_net_dict(client,
|
||||
fip['floating_network_id'])
|
||||
|
@ -632,7 +643,7 @@ class API(base.Base):
|
|||
|
||||
def get_floating_ip_pools(self, context):
|
||||
"""Return floating ip pools."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
pools = self._get_floating_ip_pools(client)
|
||||
return [{'name': n['name'] or n['id']} for n in pools]
|
||||
|
||||
|
@ -642,10 +653,10 @@ class API(base.Base):
|
|||
'address': fip['floating_ip_address'],
|
||||
'pool': pool['name'] or pool['id'],
|
||||
'project_id': fip['tenant_id'],
|
||||
# In Quantum v2, an exact fixed_ip_id does not exist.
|
||||
# In Neutron v2, an exact fixed_ip_id does not exist.
|
||||
'fixed_ip_id': fip['port_id'],
|
||||
}
|
||||
# In Quantum v2 API fixed_ip_address and instance uuid
|
||||
# In Neutron v2 API fixed_ip_address and instance uuid
|
||||
# (= device_id) are known here, so pass it as a result.
|
||||
result['fixed_ip'] = {'address': fip['fixed_ip_address']}
|
||||
if fip['port_id']:
|
||||
|
@ -657,7 +668,7 @@ class API(base.Base):
|
|||
|
||||
def get_floating_ip_by_address(self, context, address):
|
||||
"""Return a floating ip given an address."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
fip = self._get_floating_ip_by_address(client, address)
|
||||
pool_dict = self._setup_net_dict(client,
|
||||
fip['floating_network_id'])
|
||||
|
@ -665,7 +676,7 @@ class API(base.Base):
|
|||
return self._format_floating_ip_model(fip, pool_dict, port_dict)
|
||||
|
||||
def get_floating_ips_by_project(self, context):
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
project_id = context.project_id
|
||||
fips = client.list_floatingips(tenant_id=project_id)['floatingips']
|
||||
pool_dict = self._setup_pools_dict(client)
|
||||
|
@ -678,7 +689,7 @@ class API(base.Base):
|
|||
|
||||
def get_instance_id_by_floating_address(self, context, address):
|
||||
"""Return the instance id a floating ip's fixed ip is allocated to."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
fip = self._get_floating_ip_by_address(client, address)
|
||||
if not fip['port_id']:
|
||||
return None
|
||||
|
@ -711,7 +722,7 @@ class API(base.Base):
|
|||
|
||||
def allocate_floating_ip(self, context, pool=None):
|
||||
"""Add a floating ip to a project from a pool."""
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
pool = pool or CONF.default_floating_pool
|
||||
pool_id = self._get_floating_ip_pool_id_by_name_or_id(client, pool)
|
||||
|
||||
|
@ -739,9 +750,9 @@ class API(base.Base):
|
|||
try:
|
||||
data = client.list_floatingips(fixed_ip_address=fixed_ip,
|
||||
port_id=port)
|
||||
# If a quantum plugin does not implement the L3 API a 404 from
|
||||
# If a neutron plugin does not implement the L3 API a 404 from
|
||||
# list_floatingips will be raised.
|
||||
except quantumv2.exceptions.QuantumClientException as e:
|
||||
except neutronv2.exceptions.NeutronClientException as e:
|
||||
if e.status_code == 404:
|
||||
return []
|
||||
raise
|
||||
|
@ -760,7 +771,7 @@ class API(base.Base):
|
|||
# since it is not used anywhere in nova code and I could
|
||||
# find why this parameter exists.
|
||||
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
fip = self._get_floating_ip_by_address(client, address)
|
||||
if fip['port_id']:
|
||||
raise exception.FloatingIpAssociated(address=address)
|
||||
|
@ -775,7 +786,7 @@ class API(base.Base):
|
|||
# since it is not used anywhere in nova code and I could
|
||||
# find why this parameter exists.
|
||||
|
||||
client = quantumv2.get_client(context)
|
||||
client = neutronv2.get_client(context)
|
||||
fip = self._get_floating_ip_by_address(client, address)
|
||||
client.update_floatingip(fip['id'], {'floatingip': {'port_id': None}})
|
||||
|
||||
|
@ -789,15 +800,15 @@ class API(base.Base):
|
|||
"""Finish migrating the network of an instance."""
|
||||
if not self._has_port_binding_extension(refresh_cache=True):
|
||||
return
|
||||
quantum = quantumv2.get_client(context, admin=True)
|
||||
neutron = neutronv2.get_client(context, admin=True)
|
||||
search_opts = {'device_id': instance['uuid'],
|
||||
'tenant_id': instance['project_id']}
|
||||
data = quantum.list_ports(**search_opts)
|
||||
data = neutron.list_ports(**search_opts)
|
||||
ports = data['ports']
|
||||
for p in ports:
|
||||
port_req_body = {'port': {'binding:host_id': instance.get('host')}}
|
||||
try:
|
||||
quantum.update_port(p['id'], port_req_body)
|
||||
neutron.update_port(p['id'], port_req_body)
|
||||
except Exception as ex:
|
||||
with excutils.save_and_reraise_exception():
|
||||
msg = _("Unable to update host of port %s")
|
||||
|
@ -840,10 +851,10 @@ class API(base.Base):
|
|||
# Network model metadata
|
||||
should_create_bridge = None
|
||||
vif_type = port.get('binding:vif_type')
|
||||
# TODO(berrange) Quantum should pass the bridge name
|
||||
# TODO(berrange) Neutron should pass the bridge name
|
||||
# in another binding metadata field
|
||||
if vif_type == network_model.VIF_TYPE_OVS:
|
||||
bridge = CONF.quantum_ovs_bridge
|
||||
bridge = CONF.neutron_ovs_bridge
|
||||
ovs_interfaceid = port['id']
|
||||
elif vif_type == network_model.VIF_TYPE_BRIDGE:
|
||||
bridge = "brq" + port['network_id']
|
||||
|
@ -867,7 +878,7 @@ class API(base.Base):
|
|||
def _build_network_info_model(self, context, instance, networks=None):
|
||||
search_opts = {'tenant_id': instance['project_id'],
|
||||
'device_id': instance['uuid'], }
|
||||
client = quantumv2.get_client(context, admin=True)
|
||||
client = neutronv2.get_client(context, admin=True)
|
||||
data = client.list_ports(**search_opts)
|
||||
ports = data.get('ports', [])
|
||||
if networks is None:
|
||||
|
@ -914,7 +925,7 @@ class API(base.Base):
|
|||
if not fixed_ips:
|
||||
return []
|
||||
search_opts = {'id': [ip['subnet_id'] for ip in fixed_ips]}
|
||||
data = quantumv2.get_client(context).list_subnets(**search_opts)
|
||||
data = neutronv2.get_client(context).list_subnets(**search_opts)
|
||||
ipam_subnets = data.get('subnets', [])
|
||||
subnets = []
|
||||
|
||||
|
@ -928,7 +939,7 @@ class API(base.Base):
|
|||
# attempt to populate DHCP server field
|
||||
search_opts = {'network_id': subnet['network_id'],
|
||||
'device_owner': 'network:dhcp'}
|
||||
data = quantumv2.get_client(context).list_ports(**search_opts)
|
||||
data = neutronv2.get_client(context).list_ports(**search_opts)
|
||||
dhcp_ports = data.get('ports', [])
|
||||
for p in dhcp_ports:
|
||||
for ip_pair in p['fixed_ips']:
|
|
@ -20,11 +20,11 @@ from nova import ipv6
|
|||
|
||||
|
||||
def get_ipam_lib(net_man):
|
||||
return QuantumNovaIPAMLib(net_man)
|
||||
return NeutronNovaIPAMLib(net_man)
|
||||
|
||||
|
||||
class QuantumNovaIPAMLib(object):
|
||||
"""Implements Quantum IP Address Management (IPAM) interface
|
||||
class NeutronNovaIPAMLib(object):
|
||||
"""Implements Neutron IP Address Management (IPAM) interface
|
||||
using the local Nova database. This implementation is inline
|
||||
with how IPAM is used by other NetworkManagers.
|
||||
"""
|
||||
|
@ -38,7 +38,7 @@ class QuantumNovaIPAMLib(object):
|
|||
|
||||
def get_subnets_by_net_id(self, context, tenant_id, net_id, _vif_id=None):
|
||||
"""Returns information about the IPv4 and IPv6 subnets
|
||||
associated with a Quantum Network UUID.
|
||||
associated with a Neutron Network UUID.
|
||||
"""
|
||||
n = db.network_get_by_uuid(context.elevated(), net_id)
|
||||
subnet_v4 = {
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
import sys
|
||||
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from oslo.config import cfg
|
||||
from quantumclient.common import exceptions as q_exc
|
||||
from quantumclient.quantum import v2_0 as quantumv20
|
||||
from webob import exc
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova.network import quantumv2
|
||||
from nova.network import neutronv2
|
||||
from nova.network.security_group import security_group_base
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -46,17 +46,17 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
id_is_uuid = True
|
||||
|
||||
def create_security_group(self, context, name, description):
|
||||
quantum = quantumv2.get_client(context)
|
||||
body = self._make_quantum_security_group_dict(name, description)
|
||||
neutron = neutronv2.get_client(context)
|
||||
body = self._make_neutron_security_group_dict(name, description)
|
||||
try:
|
||||
security_group = quantum.create_security_group(
|
||||
security_group = neutron.create_security_group(
|
||||
body).get('security_group')
|
||||
except q_exc.QuantumClientException as e:
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
LOG.exception(_("Quantum Error creating security group %s"),
|
||||
LOG.exception(_("Neutron Error creating security group %s"),
|
||||
name)
|
||||
if e.status_code == 401:
|
||||
# TODO(arosen) Cannot raise generic response from quantum here
|
||||
# TODO(arosen) Cannot raise generic response from neutron here
|
||||
# as this error code could be related to bad input or over
|
||||
# quota
|
||||
raise exc.HTTPBadRequest()
|
||||
|
@ -65,17 +65,17 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
|
||||
def update_security_group(self, context, security_group,
|
||||
name, description):
|
||||
quantum = quantumv2.get_client(context)
|
||||
body = self._make_quantum_security_group_dict(name, description)
|
||||
neutron = neutronv2.get_client(context)
|
||||
body = self._make_neutron_security_group_dict(name, description)
|
||||
try:
|
||||
security_group = quantum.update_security_group(
|
||||
security_group = neutron.update_security_group(
|
||||
security_group['id'], body).get('security_group')
|
||||
except q_exc.QuantumClientException as e:
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
LOG.exception(_("Quantum Error updating security group %s"),
|
||||
LOG.exception(_("Neutron Error updating security group %s"),
|
||||
name)
|
||||
if e.status_code == 401:
|
||||
# TODO(arosen) Cannot raise generic response from quantum here
|
||||
# TODO(arosen) Cannot raise generic response from neutron here
|
||||
# as this error code could be related to bad input or over
|
||||
# quota
|
||||
raise exc.HTTPBadRequest()
|
||||
|
@ -117,19 +117,19 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
return nova_rule
|
||||
|
||||
def get(self, context, name=None, id=None, map_exception=False):
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
try:
|
||||
if not id and name:
|
||||
id = quantumv20.find_resourceid_by_name_or_id(
|
||||
quantum, 'security_group', name)
|
||||
group = quantum.show_security_group(id).get('security_group')
|
||||
except q_exc.QuantumClientException as e:
|
||||
id = neutronv20.find_resourceid_by_name_or_id(
|
||||
neutron, 'security_group', name)
|
||||
group = neutron.show_security_group(id).get('security_group')
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 404:
|
||||
LOG.debug(_("Quantum security group %s not found"), name)
|
||||
LOG.debug(_("Neutron security group %s not found"), name)
|
||||
self.raise_not_found(e.message)
|
||||
else:
|
||||
LOG.error(_("Quantum Error: %s"), e)
|
||||
LOG.error(_("Neutron Error: %s"), e)
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
|
||||
return self._convert_to_nova_security_group_format(group)
|
||||
|
@ -137,7 +137,7 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
def list(self, context, names=None, ids=None, project=None,
|
||||
search_opts=None):
|
||||
"""Returns list of security group rules owned by tenant."""
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
search_opts = {}
|
||||
if names:
|
||||
search_opts['name'] = names
|
||||
|
@ -146,11 +146,11 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
if project:
|
||||
search_opts['tenant_id'] = project
|
||||
try:
|
||||
security_groups = quantum.list_security_groups(**search_opts).get(
|
||||
security_groups = neutron.list_security_groups(**search_opts).get(
|
||||
'security_groups')
|
||||
except q_exc.QuantumClientException:
|
||||
except n_exc.NeutronClientException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error getting security groups"))
|
||||
LOG.exception(_("Neutron Error getting security groups"))
|
||||
converted_rules = []
|
||||
for security_group in security_groups:
|
||||
converted_rules.append(
|
||||
|
@ -166,17 +166,17 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
def destroy(self, context, security_group):
|
||||
"""This function deletes a security group."""
|
||||
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
try:
|
||||
quantum.delete_security_group(security_group['id'])
|
||||
except q_exc.QuantumClientException as e:
|
||||
neutron.delete_security_group(security_group['id'])
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 404:
|
||||
self.raise_not_found(e.message)
|
||||
elif e.status_code == 409:
|
||||
self.raise_invalid_property(e.message)
|
||||
else:
|
||||
LOG.error(_("Quantum Error: %s"), e)
|
||||
LOG.error(_("Neutron Error: %s"), e)
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
|
||||
def add_rules(self, context, id, name, vals):
|
||||
|
@ -185,22 +185,22 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
Note: the Nova security group API doesn't support adding muliple
|
||||
security group rules at once but the EC2 one does. Therefore,
|
||||
this function is writen to support both. Multiple rules are
|
||||
installed to a security group in quantum using bulk support.
|
||||
installed to a security group in neutron using bulk support.
|
||||
"""
|
||||
|
||||
quantum = quantumv2.get_client(context)
|
||||
body = self._make_quantum_security_group_rules_list(vals)
|
||||
neutron = neutronv2.get_client(context)
|
||||
body = self._make_neutron_security_group_rules_list(vals)
|
||||
try:
|
||||
rules = quantum.create_security_group_rule(
|
||||
rules = neutron.create_security_group_rule(
|
||||
body).get('security_group_rules')
|
||||
except q_exc.QuantumClientException as e:
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 409:
|
||||
LOG.exception(_("Quantum Error getting security group %s"),
|
||||
LOG.exception(_("Neutron Error getting security group %s"),
|
||||
name)
|
||||
self.raise_not_found(e.message)
|
||||
else:
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
converted_rules = []
|
||||
for rule in rules:
|
||||
|
@ -208,11 +208,11 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
self._convert_to_nova_security_group_rule_format(rule))
|
||||
return converted_rules
|
||||
|
||||
def _make_quantum_security_group_dict(self, name, description):
|
||||
def _make_neutron_security_group_dict(self, name, description):
|
||||
return {'security_group': {'name': name,
|
||||
'description': description}}
|
||||
|
||||
def _make_quantum_security_group_rules_list(self, rules):
|
||||
def _make_neutron_security_group_rules_list(self, rules):
|
||||
new_rules = []
|
||||
for rule in rules:
|
||||
new_rule = {}
|
||||
|
@ -223,10 +223,10 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
# FIXME(arosen) Nova does not expose ethertype on security group
|
||||
# rules. Therefore, in the case of self referential rules we
|
||||
# should probably assume they want to allow both IPv4 and IPv6.
|
||||
# Unfortunately, this would require adding two rules in quantum.
|
||||
# Unfortunately, this would require adding two rules in neutron.
|
||||
# The reason we do not do this is because when the user using the
|
||||
# nova api wants to remove the rule we'd have to have some way to
|
||||
# know that we should delete both of these rules in quantum.
|
||||
# know that we should delete both of these rules in neutron.
|
||||
# For now, self referential rules only support IPv4.
|
||||
if not rule.get('cidr'):
|
||||
new_rule['ethertype'] = 'IPv4'
|
||||
|
@ -243,31 +243,31 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
return {'security_group_rules': new_rules}
|
||||
|
||||
def remove_rules(self, context, security_group, rule_ids):
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
rule_ids = set(rule_ids)
|
||||
try:
|
||||
# The ec2 api allows one to delete multiple security group rules
|
||||
# at once. Since there is no bulk delete for quantum the best
|
||||
# at once. Since there is no bulk delete for neutron the best
|
||||
# thing we can do is delete the rules one by one and hope this
|
||||
# works.... :/
|
||||
for rule_id in range(0, len(rule_ids)):
|
||||
quantum.delete_security_group_rule(rule_ids.pop())
|
||||
except q_exc.QuantumClientException as e:
|
||||
neutron.delete_security_group_rule(rule_ids.pop())
|
||||
except n_exc.NeutronClientException as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error unable to delete %s"), rule_ids)
|
||||
LOG.exception(_("Neutron Error unable to delete %s"), rule_ids)
|
||||
|
||||
def get_rule(self, context, id):
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
try:
|
||||
rule = quantum.show_security_group_rule(
|
||||
rule = neutron.show_security_group_rule(
|
||||
id).get('security_group_rule')
|
||||
except q_exc.QuantumClientException as e:
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 404:
|
||||
LOG.debug(_("Quantum security group rule %s not found"), id)
|
||||
LOG.debug(_("Neutron security group rule %s not found"), id)
|
||||
self.raise_not_found(e.message)
|
||||
else:
|
||||
LOG.error(_("Quantum Error: %s"), e)
|
||||
LOG.error(_("Neutron Error: %s"), e)
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
return self._convert_to_nova_security_group_rule_format(rule)
|
||||
|
||||
|
@ -275,9 +275,9 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
"""Returns a dict(instance_id, [security_groups]) to allow obtaining
|
||||
all of the instances and their security groups in one shot.
|
||||
"""
|
||||
quantum = quantumv2.get_client(context)
|
||||
ports = quantum.list_ports().get('ports')
|
||||
security_groups = quantum.list_security_groups().get('security_groups')
|
||||
neutron = neutronv2.get_client(context)
|
||||
ports = neutron.list_ports().get('ports')
|
||||
security_groups = neutron.list_security_groups().get('security_groups')
|
||||
security_group_lookup = {}
|
||||
instances_security_group_bindings = {}
|
||||
for security_group in security_groups:
|
||||
|
@ -287,7 +287,7 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
for port_security_group in port.get('security_groups', []):
|
||||
try:
|
||||
sg = security_group_lookup[port_security_group]
|
||||
# name is optional in quantum so if not specified return id
|
||||
# name is optional in neutron so if not specified return id
|
||||
if sg.get('name'):
|
||||
sg_entry = {'name': sg['name']}
|
||||
else:
|
||||
|
@ -308,10 +308,10 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
If detailed is True then it also returns the full details of the
|
||||
security groups associated with an instance.
|
||||
"""
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
params = {'device_id': instance_uuid}
|
||||
ports = quantum.list_ports(**params)
|
||||
security_groups = quantum.list_security_groups().get('security_groups')
|
||||
ports = neutron.list_ports(**params)
|
||||
security_groups = neutron.list_security_groups().get('security_groups')
|
||||
|
||||
security_group_lookup = {}
|
||||
for security_group in security_groups:
|
||||
|
@ -328,7 +328,7 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
name = security_group_lookup[security_group].get(
|
||||
'name')
|
||||
# Since the name is optional for
|
||||
# quantum security groups
|
||||
# neutron security groups
|
||||
if not name:
|
||||
name = security_group
|
||||
ret.append({'name': name})
|
||||
|
@ -352,25 +352,25 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
def add_to_instance(self, context, instance, security_group_name):
|
||||
"""Add security group to the instance."""
|
||||
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
try:
|
||||
security_group_id = quantumv20.find_resourceid_by_name_or_id(
|
||||
quantum, 'security_group', security_group_name)
|
||||
except q_exc.QuantumClientException as e:
|
||||
security_group_id = neutronv20.find_resourceid_by_name_or_id(
|
||||
neutron, 'security_group', security_group_name)
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 404:
|
||||
msg = ("Security group %s is not found for project %s" %
|
||||
(security_group_name, context.project_id))
|
||||
self.raise_not_found(msg)
|
||||
else:
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
params = {'device_id': instance['uuid']}
|
||||
try:
|
||||
ports = quantum.list_ports(**params).get('ports')
|
||||
except q_exc.QuantumClientException:
|
||||
ports = neutron.list_ports(**params).get('ports')
|
||||
except n_exc.NeutronClientException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
|
||||
if not ports:
|
||||
msg = ("instance_id %s could not be found as device id on"
|
||||
|
@ -393,33 +393,33 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
"port %(port_id)s"),
|
||||
{'security_group_id': security_group_id,
|
||||
'port_id': port['id']})
|
||||
quantum.update_port(port['id'], {'port': updated_port})
|
||||
neutron.update_port(port['id'], {'port': updated_port})
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
|
||||
@wrap_check_security_groups_policy
|
||||
def remove_from_instance(self, context, instance, security_group_name):
|
||||
"""Remove the security group associated with the instance."""
|
||||
quantum = quantumv2.get_client(context)
|
||||
neutron = neutronv2.get_client(context)
|
||||
try:
|
||||
security_group_id = quantumv20.find_resourceid_by_name_or_id(
|
||||
quantum, 'security_group', security_group_name)
|
||||
except q_exc.QuantumClientException as e:
|
||||
security_group_id = neutronv20.find_resourceid_by_name_or_id(
|
||||
neutron, 'security_group', security_group_name)
|
||||
except n_exc.NeutronClientException as e:
|
||||
exc_info = sys.exc_info()
|
||||
if e.status_code == 404:
|
||||
msg = ("Security group %s is not found for project %s" %
|
||||
(security_group_name, context.project_id))
|
||||
self.raise_not_found(msg)
|
||||
else:
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
params = {'device_id': instance['uuid']}
|
||||
try:
|
||||
ports = quantum.list_ports(**params).get('ports')
|
||||
except q_exc.QuantumClientException:
|
||||
ports = neutron.list_ports(**params).get('ports')
|
||||
except n_exc.NeutronClientException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
|
||||
if not ports:
|
||||
msg = ("instance_id %s could not be found as device id on"
|
||||
|
@ -444,11 +444,11 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
"port %(port_id)s"),
|
||||
{'security_group_id': security_group_id,
|
||||
'port_id': port['id']})
|
||||
quantum.update_port(port['id'], {'port': updated_port})
|
||||
neutron.update_port(port['id'], {'port': updated_port})
|
||||
found_security_group = True
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Quantum Error:"))
|
||||
LOG.exception(_("Neutron Error:"))
|
||||
if not found_security_group:
|
||||
msg = (_("Security group %(security_group_name)s not assocaited "
|
||||
"with the instance %(instance)s"),
|
||||
|
@ -458,5 +458,5 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
|
|||
|
||||
def populate_security_groups(self, instance, security_groups):
|
||||
# Setting to emply list since we do not want to populate this field
|
||||
# in the nova database if using the quantum driver
|
||||
# in the nova database if using the neutron driver
|
||||
instance['security_groups'] = []
|
|
@ -32,21 +32,18 @@ CONF.register_opts(security_group_opts)
|
|||
|
||||
NOVA_DRIVER = ('nova.api.openstack.compute.contrib.security_groups.'
|
||||
'NativeNovaSecurityGroupAPI')
|
||||
QUANTUM_DRIVER = ('nova.api.openstack.compute.contrib.security_groups.'
|
||||
'NativeQuantumSecurityGroupAPI')
|
||||
NEUTRON_DRIVER = ('nova.api.openstack.compute.contrib.security_groups.'
|
||||
'NativeNeutronSecurityGroupAPI')
|
||||
|
||||
|
||||
def get_openstack_security_group_driver():
|
||||
if CONF.security_group_api.lower() == 'nova':
|
||||
return importutils.import_object(NOVA_DRIVER)
|
||||
elif CONF.security_group_api.lower() == 'quantum':
|
||||
return importutils.import_object(QUANTUM_DRIVER)
|
||||
elif CONF.security_group_api.lower() in ('neutron', 'quantum'):
|
||||
return importutils.import_object(NEUTRON_DRIVER)
|
||||
else:
|
||||
return importutils.import_object(CONF.security_group_api)
|
||||
|
||||
|
||||
def is_quantum_security_groups():
|
||||
if CONF.security_group_api.lower() == "quantum":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def is_neutron_security_groups():
|
||||
return CONF.security_group_api.lower() in ('neutron', 'quantum')
|
||||
|
|
|
@ -44,13 +44,13 @@ from nova import db
|
|||
from nova import exception
|
||||
from nova.image import s3
|
||||
from nova.network import api as network_api
|
||||
from nova.network import quantumv2
|
||||
from nova.network import neutronv2
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import rpc
|
||||
from nova.openstack.common import timeutils
|
||||
from nova import test
|
||||
from nova.tests.api.openstack.compute.contrib import (
|
||||
test_quantum_security_groups as test_quantum)
|
||||
test_neutron_security_groups as test_neutron)
|
||||
from nova.tests import fake_network
|
||||
from nova.tests import fake_utils
|
||||
from nova.tests.image import fake
|
||||
|
@ -2688,23 +2688,23 @@ class CloudTestCase(test.TestCase):
|
|||
None)
|
||||
|
||||
|
||||
class CloudTestCaseQuantumProxy(test.TestCase):
|
||||
class CloudTestCaseNeutronProxy(test.TestCase):
|
||||
def setUp(self):
|
||||
cfg.CONF.set_override('security_group_api', 'quantum')
|
||||
cfg.CONF.set_override('security_group_api', 'neutron')
|
||||
self.cloud = cloud.CloudController()
|
||||
self.original_client = quantumv2.get_client
|
||||
quantumv2.get_client = test_quantum.get_client
|
||||
self.original_client = neutronv2.get_client
|
||||
neutronv2.get_client = test_neutron.get_client
|
||||
self.user_id = 'fake'
|
||||
self.project_id = 'fake'
|
||||
self.context = context.RequestContext(self.user_id,
|
||||
self.project_id,
|
||||
is_admin=True)
|
||||
super(CloudTestCaseQuantumProxy, self).setUp()
|
||||
super(CloudTestCaseNeutronProxy, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
quantumv2.get_client = self.original_client
|
||||
test_quantum.get_client()._reset()
|
||||
super(CloudTestCaseQuantumProxy, self).tearDown()
|
||||
neutronv2.get_client = self.original_client
|
||||
test_neutron.get_client()._reset()
|
||||
super(CloudTestCaseNeutronProxy, self).tearDown()
|
||||
|
||||
def test_describe_security_groups(self):
|
||||
# Makes sure describe_security_groups works and filters results.
|
||||
|
@ -2727,11 +2727,11 @@ class CloudTestCaseQuantumProxy(test.TestCase):
|
|||
description = 'test'
|
||||
self.cloud.create_security_group(self.context, group_name,
|
||||
description)
|
||||
quantum = test_quantum.get_client()
|
||||
# Get id from quantum since cloud.create_security_group
|
||||
neutron = test_neutron.get_client()
|
||||
# Get id from neutron since cloud.create_security_group
|
||||
# does not expose it.
|
||||
search_opts = {'name': group_name}
|
||||
groups = quantum.list_security_groups(
|
||||
groups = neutron.list_security_groups(
|
||||
**search_opts)['security_groups']
|
||||
result = self.cloud.describe_security_groups(self.context,
|
||||
group_id=[groups[0]['id']])
|
||||
|
|
|
@ -135,9 +135,9 @@ def fake_get_instance(self, context, intance_id):
|
|||
class InterfaceAttachTests(test.TestCase):
|
||||
def setUp(self):
|
||||
super(InterfaceAttachTests, self).setUp()
|
||||
self.flags(quantum_auth_strategy=None)
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(quantum_url_timeout=30)
|
||||
self.flags(neutron_auth_strategy=None)
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
self.flags(neutron_url_timeout=30)
|
||||
self.stubs.Set(network_api.API, 'show_port', fake_show_port)
|
||||
self.stubs.Set(network_api.API, 'list_ports', fake_list_ports)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get_instance)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import uuid
|
||||
|
||||
from lxml import etree
|
||||
from neutronclient.common import exceptions as q_exc
|
||||
from oslo.config import cfg
|
||||
import webob
|
||||
|
||||
|
@ -29,32 +30,31 @@ from nova import compute
|
|||
from nova import context
|
||||
import nova.db
|
||||
from nova import exception
|
||||
from nova.network import quantumv2
|
||||
from nova.network.quantumv2 import api as quantum_api
|
||||
from nova.network.security_group import quantum_driver
|
||||
from nova.network import neutronv2
|
||||
from nova.network.neutronv2 import api as neutron_api
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova import test
|
||||
from nova.tests.api.openstack.compute.contrib import test_security_groups
|
||||
from nova.tests.api.openstack import fakes
|
||||
from quantumclient.common import exceptions as q_exc
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupsTestCase(test.TestCase):
|
||||
class TestNeutronSecurityGroupsTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(TestQuantumSecurityGroupsTestCase, self).setUp()
|
||||
cfg.CONF.set_override('security_group_api', 'quantum')
|
||||
self.original_client = quantumv2.get_client
|
||||
quantumv2.get_client = get_client
|
||||
super(TestNeutronSecurityGroupsTestCase, self).setUp()
|
||||
cfg.CONF.set_override('security_group_api', 'neutron')
|
||||
self.original_client = neutronv2.get_client
|
||||
neutronv2.get_client = get_client
|
||||
|
||||
def tearDown(self):
|
||||
quantumv2.get_client = self.original_client
|
||||
neutronv2.get_client = self.original_client
|
||||
get_client()._reset()
|
||||
super(TestQuantumSecurityGroupsTestCase, self).tearDown()
|
||||
super(TestNeutronSecurityGroupsTestCase, self).tearDown()
|
||||
|
||||
|
||||
class TestQuantumSecurityGroups(
|
||||
class TestNeutronSecurityGroups(
|
||||
test_security_groups.TestSecurityGroups,
|
||||
TestQuantumSecurityGroupsTestCase):
|
||||
TestNeutronSecurityGroupsTestCase):
|
||||
|
||||
def _create_sg_template(self, **kwargs):
|
||||
sg = test_security_groups.security_group_template(**kwargs)
|
||||
|
@ -63,11 +63,11 @@ class TestQuantumSecurityGroups(
|
|||
|
||||
def _create_network(self):
|
||||
body = {'network': {'name': 'net1'}}
|
||||
quantum = get_client()
|
||||
net = quantum.create_network(body)
|
||||
neutron = get_client()
|
||||
net = neutron.create_network(body)
|
||||
body = {'subnet': {'network_id': net['network']['id'],
|
||||
'cidr': '10.0.0.0/24'}}
|
||||
quantum.create_subnet(body)
|
||||
neutron.create_subnet(body)
|
||||
return net
|
||||
|
||||
def _create_port(self, **kwargs):
|
||||
|
@ -77,47 +77,47 @@ class TestQuantumSecurityGroups(
|
|||
for field in fields:
|
||||
if field in kwargs:
|
||||
body['port'][field] = kwargs[field]
|
||||
quantum = get_client()
|
||||
return quantum.create_port(body)
|
||||
neutron = get_client()
|
||||
return neutron.create_port(body)
|
||||
|
||||
def test_create_security_group_with_no_description(self):
|
||||
# Quantum's security group descirption field is optional.
|
||||
# Neutron's security group descirption field is optional.
|
||||
pass
|
||||
|
||||
def test_create_security_group_with_blank_name(self):
|
||||
# Quantum's security group name field is optional.
|
||||
# Neutron's security group name field is optional.
|
||||
pass
|
||||
|
||||
def test_create_security_group_with_whitespace_name(self):
|
||||
# Quantum allows security group name to be whitespace.
|
||||
# Neutron allows security group name to be whitespace.
|
||||
pass
|
||||
|
||||
def test_create_security_group_with_blank_description(self):
|
||||
# Quantum's security group descirption field is optional.
|
||||
# Neutron's security group descirption field is optional.
|
||||
pass
|
||||
|
||||
def test_create_security_group_with_whitespace_description(self):
|
||||
# Quantum allows description to be whitespace.
|
||||
# Neutron allows description to be whitespace.
|
||||
pass
|
||||
|
||||
def test_create_security_group_with_duplicate_name(self):
|
||||
# Quantum allows duplicate names for security groups.
|
||||
# Neutron allows duplicate names for security groups.
|
||||
pass
|
||||
|
||||
def test_create_security_group_non_string_name(self):
|
||||
# Quantum allows security group name to be non string.
|
||||
# Neutron allows security group name to be non string.
|
||||
pass
|
||||
|
||||
def test_create_security_group_non_string_description(self):
|
||||
# Quantum allows non string description.
|
||||
# Neutron allows non string description.
|
||||
pass
|
||||
|
||||
def test_create_security_group_quota_limit(self):
|
||||
# Enforced by Quantum server.
|
||||
# Enforced by Neutron server.
|
||||
pass
|
||||
|
||||
def test_update_security_group(self):
|
||||
# Enforced by Quantum server.
|
||||
# Enforced by Neutron server.
|
||||
pass
|
||||
|
||||
def test_get_security_group_list(self):
|
||||
|
@ -167,8 +167,8 @@ class TestQuantumSecurityGroups(
|
|||
'security_groups': [],
|
||||
'uuid': str(uuid.uuid4()),
|
||||
'display_name': 'test_instance'}
|
||||
quantum = quantum_api.API()
|
||||
quantum.allocate_for_instance(context.get_admin_context(),
|
||||
neutron = neutron_api.API()
|
||||
neutron.allocate_for_instance(context.get_admin_context(),
|
||||
fake_instance,
|
||||
security_groups=[sg['id']])
|
||||
|
||||
|
@ -178,13 +178,13 @@ class TestQuantumSecurityGroups(
|
|||
req, sg['id'])
|
||||
|
||||
def test_associate_non_running_instance(self):
|
||||
# Quantum does not care if the instance is running or not. When the
|
||||
# instances is detected by quantum it will push down the security
|
||||
# Neutron does not care if the instance is running or not. When the
|
||||
# instances is detected by nuetron it will push down the security
|
||||
# group policy to it.
|
||||
pass
|
||||
|
||||
def test_associate_already_associated_security_group_to_instance(self):
|
||||
# Quantum security groups does not raise an error if you update a
|
||||
# Neutron security groups does not raise an error if you update a
|
||||
# port adding a security group to it that was already associated
|
||||
# to the port. This is because PUT semantics are used.
|
||||
pass
|
||||
|
@ -244,13 +244,13 @@ class TestQuantumSecurityGroups(
|
|||
self.manager._removeSecurityGroup, req, '1', body)
|
||||
|
||||
def test_disassociate_non_running_instance(self):
|
||||
# Quantum does not care if the instance is running or not. When the
|
||||
# instances is detected by quantum it will push down the security
|
||||
# Neutron does not care if the instance is running or not. When the
|
||||
# instances is detected by neutron it will push down the security
|
||||
# group policy to it.
|
||||
pass
|
||||
|
||||
def test_disassociate_already_associated_security_group_to_instance(self):
|
||||
# Quantum security groups does not raise an error if you update a
|
||||
# Neutron security groups does not raise an error if you update a
|
||||
# port adding a security group to it that was already associated
|
||||
# to the port. This is because PUT semantics are used.
|
||||
pass
|
||||
|
@ -335,9 +335,9 @@ class TestQuantumSecurityGroups(
|
|||
device_id=test_security_groups.FAKE_UUID1)
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupRulesTestCase(TestQuantumSecurityGroupsTestCase):
|
||||
class TestNeutronSecurityGroupRulesTestCase(TestNeutronSecurityGroupsTestCase):
|
||||
def setUp(self):
|
||||
super(TestQuantumSecurityGroupRulesTestCase, self).setUp()
|
||||
super(TestNeutronSecurityGroupRulesTestCase, self).setUp()
|
||||
id1 = '11111111-1111-1111-1111-111111111111'
|
||||
sg_template1 = test_security_groups.security_group_template(
|
||||
security_group_rules=[], id=id1)
|
||||
|
@ -345,19 +345,19 @@ class TestQuantumSecurityGroupRulesTestCase(TestQuantumSecurityGroupsTestCase):
|
|||
sg_template2 = test_security_groups.security_group_template(
|
||||
security_group_rules=[], id=id2)
|
||||
self.controller_sg = security_groups.SecurityGroupController()
|
||||
quantum = get_client()
|
||||
quantum._fake_security_groups[id1] = sg_template1
|
||||
quantum._fake_security_groups[id2] = sg_template2
|
||||
neutron = get_client()
|
||||
neutron._fake_security_groups[id1] = sg_template1
|
||||
neutron._fake_security_groups[id2] = sg_template2
|
||||
|
||||
def tearDown(self):
|
||||
quantumv2.get_client = self.original_client
|
||||
neutronv2.get_client = self.original_client
|
||||
get_client()._reset()
|
||||
super(TestQuantumSecurityGroupsTestCase, self).tearDown()
|
||||
super(TestNeutronSecurityGroupsTestCase, self).tearDown()
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupRules(
|
||||
class TestNeutronSecurityGroupRules(
|
||||
test_security_groups.TestSecurityGroupRules,
|
||||
TestQuantumSecurityGroupRulesTestCase):
|
||||
TestNeutronSecurityGroupRulesTestCase):
|
||||
|
||||
def test_create_add_existing_rules_by_cidr(self):
|
||||
sg = test_security_groups.security_group_template()
|
||||
|
@ -393,27 +393,27 @@ class TestQuantumSecurityGroupRules(
|
|||
self.controller.delete(req, security_group_rule['id'])
|
||||
|
||||
def test_create_rule_quota_limit(self):
|
||||
# Enforced by quantum
|
||||
# Enforced by neutron
|
||||
pass
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupsXMLDeserializer(
|
||||
class TestNeutronSecurityGroupsXMLDeserializer(
|
||||
test_security_groups.TestSecurityGroupXMLDeserializer,
|
||||
TestQuantumSecurityGroupsTestCase):
|
||||
TestNeutronSecurityGroupsTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupsXMLSerializer(
|
||||
class TestNeutronSecurityGroupsXMLSerializer(
|
||||
test_security_groups.TestSecurityGroupXMLSerializer,
|
||||
TestQuantumSecurityGroupsTestCase):
|
||||
TestNeutronSecurityGroupsTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupsOutputTest(TestQuantumSecurityGroupsTestCase):
|
||||
class TestNeutronSecurityGroupsOutputTest(TestNeutronSecurityGroupsTestCase):
|
||||
content_type = 'application/json'
|
||||
|
||||
def setUp(self):
|
||||
super(TestQuantumSecurityGroupsOutputTest, self).setUp()
|
||||
super(TestNeutronSecurityGroupsOutputTest, self).setUp()
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.controller = security_groups.SecurityGroupController()
|
||||
self.stubs.Set(compute.api.API, 'get',
|
||||
|
@ -422,7 +422,7 @@ class TestQuantumSecurityGroupsOutputTest(TestQuantumSecurityGroupsTestCase):
|
|||
test_security_groups.fake_compute_get_all)
|
||||
self.stubs.Set(compute.api.API, 'create',
|
||||
test_security_groups.fake_compute_create)
|
||||
self.stubs.Set(quantum_driver.SecurityGroupAPI,
|
||||
self.stubs.Set(neutron_driver.SecurityGroupAPI,
|
||||
'get_instances_security_groups_bindings',
|
||||
(test_security_groups.
|
||||
fake_get_instances_security_groups_bindings))
|
||||
|
@ -486,7 +486,7 @@ class TestQuantumSecurityGroupsOutputTest(TestQuantumSecurityGroupsTestCase):
|
|||
def fake_get_instance_security_groups(inst, context, id):
|
||||
return [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]
|
||||
|
||||
self.stubs.Set(quantum_driver.SecurityGroupAPI,
|
||||
self.stubs.Set(neutron_driver.SecurityGroupAPI,
|
||||
'get_instance_security_groups',
|
||||
fake_get_instance_security_groups)
|
||||
|
||||
|
@ -540,8 +540,8 @@ class TestQuantumSecurityGroupsOutputTest(TestQuantumSecurityGroupsTestCase):
|
|||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
|
||||
class TestQuantumSecurityGroupsOutputXMLTest(
|
||||
TestQuantumSecurityGroupsOutputTest):
|
||||
class TestNeutronSecurityGroupsOutputXMLTest(
|
||||
TestNeutronSecurityGroupsOutputTest):
|
||||
|
||||
content_type = 'application/xml'
|
||||
|
||||
|
@ -610,7 +610,7 @@ class MockClient(object):
|
|||
s = body.get('security_group')
|
||||
if len(s.get('name')) > 255 or len(s.get('description')) > 255:
|
||||
msg = 'Security Group name great than 255'
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=401)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=401)
|
||||
ret = {'name': s.get('name'), 'description': s.get('description'),
|
||||
'tenant_id': 'fake_tenant', 'security_group_rules': [],
|
||||
'id': str(uuid.uuid4())}
|
||||
|
@ -635,7 +635,7 @@ class MockClient(object):
|
|||
net = self._fake_networks[s.get('network_id')]
|
||||
except KeyError:
|
||||
msg = 'Network %s not found' % s.get('network_id')
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
ret = {'name': s.get('name'), 'network_id': s.get('network_id'),
|
||||
'tenant_id': 'fake_tenant', 'cidr': s.get('cidr'),
|
||||
'id': str(uuid.uuid4()), 'gateway_ip': '10.0.0.1'}
|
||||
|
@ -694,7 +694,7 @@ class MockClient(object):
|
|||
sg = self._fake_security_groups[security_group]
|
||||
except KeyError:
|
||||
msg = 'Security Group %s not found' % security_group
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
for security_group_rule in self._fake_security_group_rules.values():
|
||||
if security_group_rule['security_group_id'] == sg['id']:
|
||||
sg['security_group_rules'].append(security_group_rule)
|
||||
|
@ -707,7 +707,7 @@ class MockClient(object):
|
|||
self._fake_security_group_rules[security_group_rule]}
|
||||
except KeyError:
|
||||
msg = 'Security Group rule %s not found' % security_group_rule
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
|
||||
def show_network(self, network, **_params):
|
||||
try:
|
||||
|
@ -715,7 +715,7 @@ class MockClient(object):
|
|||
self._fake_networks[network]}
|
||||
except KeyError:
|
||||
msg = 'Network %s not found' % network
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
|
||||
def show_port(self, port, **_params):
|
||||
try:
|
||||
|
@ -723,7 +723,7 @@ class MockClient(object):
|
|||
self._fake_ports[port]}
|
||||
except KeyError:
|
||||
msg = 'Port %s not found' % port
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
|
||||
def show_subnet(self, subnet, **_params):
|
||||
try:
|
||||
|
@ -731,7 +731,7 @@ class MockClient(object):
|
|||
self._fake_subnets[subnet]}
|
||||
except KeyError:
|
||||
msg = 'Port %s not found' % subnet
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=404)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=404)
|
||||
|
||||
def list_security_groups(self, **_params):
|
||||
ret = []
|
||||
|
@ -784,7 +784,7 @@ class MockClient(object):
|
|||
if sg_port == security_group:
|
||||
msg = ('Unable to delete Security group %s in use'
|
||||
% security_group)
|
||||
raise q_exc.QuantumClientException(message=msg,
|
||||
raise q_exc.NeutronClientException(message=msg,
|
||||
status_code=409)
|
||||
del self._fake_security_groups[security_group]
|
||||
|
||||
|
@ -824,4 +824,4 @@ class MockClient(object):
|
|||
msg = ('Unable to complete operation on network %s. There is '
|
||||
'one or more ports still in use on the network'
|
||||
% network)
|
||||
raise q_exc.QuantumClientException(message=msg, status_code=409)
|
||||
raise q_exc.NeutronClientException(message=msg, status_code=409)
|
|
@ -135,9 +135,9 @@ def fake_get_instance(self, context, intance_id):
|
|||
class InterfaceAttachTests(test.TestCase):
|
||||
def setUp(self):
|
||||
super(InterfaceAttachTests, self).setUp()
|
||||
self.flags(quantum_auth_strategy=None)
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(quantum_url_timeout=30)
|
||||
self.flags(neutron_auth_strategy=None)
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
self.flags(neutron_url_timeout=30)
|
||||
self.stubs.Set(network_api.API, 'show_port', fake_show_port)
|
||||
self.stubs.Set(network_api.API, 'list_ports', fake_list_ports)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get_instance)
|
||||
|
|
|
@ -43,7 +43,7 @@ from nova.db.sqlalchemy import models
|
|||
from nova import exception
|
||||
from nova.image import glance
|
||||
from nova.network import manager
|
||||
from nova.network.quantumv2 import api as quantum_api
|
||||
from nova.network.neutronv2 import api as neutron_api
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import policy as common_policy
|
||||
|
@ -141,7 +141,7 @@ class Base64ValidationTest(test.TestCase):
|
|||
self.assertEqual(result, None)
|
||||
|
||||
|
||||
class QuantumV2Subclass(quantum_api.API):
|
||||
class NeutronV2Subclass(neutron_api.API):
|
||||
"""Used to ensure that API handles subclasses properly."""
|
||||
pass
|
||||
|
||||
|
@ -184,29 +184,29 @@ class ServersControllerTest(test.TestCase):
|
|||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertTrue((uuid, None) in res)
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_port(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_port(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_network(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_network(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
requested_networks = [{'uuid': network}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(network, None, None)])
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_network_and_port(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_network_and_port(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'uuid': network, 'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_disabled_with_port(self):
|
||||
def test_requested_networks_neutronv2_disabled_with_port(self):
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
self.assertRaises(
|
||||
|
@ -215,15 +215,15 @@ class ServersControllerTest(test.TestCase):
|
|||
requested_networks)
|
||||
|
||||
def test_requested_networks_api_enabled_with_v2_subclass(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'uuid': network, 'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_subclass_with_port(self):
|
||||
cls = 'nova.tests.api.openstack.compute.test_servers.QuantumV2Subclass'
|
||||
def test_requested_networks_neutronv2_subclass_with_port(self):
|
||||
cls = 'nova.tests.api.openstack.compute.test_servers.NeutronV2Subclass'
|
||||
self.flags(network_api_class=cls)
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
|
@ -2735,8 +2735,8 @@ class ServersControllerCreateTest(test.TestCase):
|
|||
# self.stubs.Set(compute_api.API, 'create', create)
|
||||
# self._test_create_extra(params)
|
||||
|
||||
def test_create_instance_with_networks_disabled_quantumv2(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_create_instance_with_networks_disabled_neutronv2(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
net_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
requested_networks = [{'uuid': net_uuid}]
|
||||
params = {'networks': requested_networks}
|
||||
|
|
|
@ -44,7 +44,7 @@ from nova.db.sqlalchemy import models
|
|||
from nova import exception
|
||||
from nova.image import glance
|
||||
from nova.network import manager
|
||||
from nova.network.quantumv2 import api as quantum_api
|
||||
from nova.network.neutronv2 import api as neutron_api
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import policy as common_policy
|
||||
|
@ -143,7 +143,7 @@ class Base64ValidationTest(test.TestCase):
|
|||
self.assertEqual(result, None)
|
||||
|
||||
|
||||
class QuantumV2Subclass(quantum_api.API):
|
||||
class NeutronV2Subclass(neutron_api.API):
|
||||
"""Used to ensure that API handles subclasses properly."""
|
||||
pass
|
||||
|
||||
|
@ -187,29 +187,29 @@ class ServersControllerTest(test.TestCase):
|
|||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertTrue((uuid, None) in res)
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_port(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_port(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_network(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_network(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
requested_networks = [{'uuid': network}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(network, None, None)])
|
||||
|
||||
def test_requested_networks_quantumv2_enabled_with_network_and_port(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_requested_networks_neutronv2_enabled_with_network_and_port(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'uuid': network, 'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_disabled_with_port(self):
|
||||
def test_requested_networks_neutronv2_disabled_with_port(self):
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
self.assertRaises(
|
||||
|
@ -218,15 +218,15 @@ class ServersControllerTest(test.TestCase):
|
|||
requested_networks)
|
||||
|
||||
def test_requested_networks_api_enabled_with_v2_subclass(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
network = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'uuid': network, 'port': port}]
|
||||
res = self.controller._get_requested_networks(requested_networks)
|
||||
self.assertEquals(res, [(None, None, port)])
|
||||
|
||||
def test_requested_networks_quantumv2_subclass_with_port(self):
|
||||
cls = 'nova.tests.api.openstack.compute.test_servers.QuantumV2Subclass'
|
||||
def test_requested_networks_neutronv2_subclass_with_port(self):
|
||||
cls = 'nova.tests.api.openstack.compute.test_servers.NeutronV2Subclass'
|
||||
self.flags(network_api_class=cls)
|
||||
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
requested_networks = [{'port': port}]
|
||||
|
@ -2764,8 +2764,8 @@ class ServersControllerCreateTest(test.TestCase):
|
|||
self.stubs.Set(compute_api.API, 'create', create)
|
||||
self._test_create_extra(params)
|
||||
|
||||
def test_create_instance_with_networks_disabled_quantumv2(self):
|
||||
self.flags(network_api_class='nova.network.quantumv2.api.API')
|
||||
def test_create_instance_with_networks_disabled_neutronv2(self):
|
||||
self.flags(network_api_class='nova.network.neutronv2.api.API')
|
||||
net_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
requested_networks = [{'uuid': net_uuid}]
|
||||
params = {'networks': requested_networks}
|
||||
|
|
|
@ -358,11 +358,11 @@ def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
|
|||
stubs.Set(db, 'network_get', network_get_fake)
|
||||
stubs.Set(db, 'instance_info_cache_update', update_cache_fake)
|
||||
|
||||
stubs.Set(nova_ipam_lib.QuantumNovaIPAMLib, 'get_subnets_by_net_id',
|
||||
stubs.Set(nova_ipam_lib.NeutronNovaIPAMLib, 'get_subnets_by_net_id',
|
||||
get_subnets_by_net_id)
|
||||
stubs.Set(nova_ipam_lib.QuantumNovaIPAMLib, 'get_v4_ips_by_interface',
|
||||
stubs.Set(nova_ipam_lib.NeutronNovaIPAMLib, 'get_v4_ips_by_interface',
|
||||
get_v4_fake)
|
||||
stubs.Set(nova_ipam_lib.QuantumNovaIPAMLib, 'get_v6_ips_by_interface',
|
||||
stubs.Set(nova_ipam_lib.NeutronNovaIPAMLib, 'get_v6_ips_by_interface',
|
||||
get_v6_fake)
|
||||
|
||||
class FakeContext(nova.context.RequestContext):
|
||||
|
|
|
@ -3685,9 +3685,9 @@ class AttachInterfacesSampleJsonTest(ServersSampleBase):
|
|||
fake_attach_interface)
|
||||
self.stubs.Set(compute_api.API, 'detach_interface',
|
||||
fake_detach_interface)
|
||||
self.flags(quantum_auth_strategy=None)
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(quantum_url_timeout=30)
|
||||
self.flags(neutron_auth_strategy=None)
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
self.flags(neutron_url_timeout=30)
|
||||
|
||||
def generalize_subs(self, subs, vanilla_regexes):
|
||||
subs['subnet_id'] = vanilla_regexes['uuid']
|
||||
|
|
|
@ -16,20 +16,20 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
import mox
|
||||
from quantumclient.v2_0 import client
|
||||
from neutronclient.v2_0 import client
|
||||
|
||||
from nova import context
|
||||
from nova.network import quantumv2
|
||||
from nova.network.security_group import quantum_driver
|
||||
from nova.network import neutronv2
|
||||
from nova.network.security_group import neutron_driver
|
||||
from nova import test
|
||||
|
||||
|
||||
class TestQuantumDriver(test.TestCase):
|
||||
class TestNeutronDriver(test.TestCase):
|
||||
def setUp(self):
|
||||
super(TestQuantumDriver, self).setUp()
|
||||
self.mox.StubOutWithMock(quantumv2, 'get_client')
|
||||
super(TestNeutronDriver, self).setUp()
|
||||
self.mox.StubOutWithMock(neutronv2, 'get_client')
|
||||
self.moxed_client = self.mox.CreateMock(client.Client)
|
||||
quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self.context = context.RequestContext('userid', 'my_tenantid')
|
||||
setattr(self.context,
|
||||
|
@ -43,5 +43,5 @@ class TestQuantumDriver(test.TestCase):
|
|||
security_groups_list)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
sg_api = quantum_driver.SecurityGroupAPI()
|
||||
sg_api = neutron_driver.SecurityGroupAPI()
|
||||
sg_api.list(self.context, project=project_id)
|
|
@ -18,27 +18,27 @@
|
|||
import uuid
|
||||
|
||||
import mox
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.v2_0 import client
|
||||
from oslo.config import cfg
|
||||
from quantumclient.common import exceptions
|
||||
from quantumclient.v2_0 import client
|
||||
|
||||
from nova.compute import flavors
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.network import model
|
||||
from nova.network import quantumv2
|
||||
from nova.network.quantumv2 import api as quantumapi
|
||||
from nova.network.quantumv2 import constants
|
||||
from nova.network import neutronv2
|
||||
from nova.network.neutronv2 import api as neutronapi
|
||||
from nova.network.neutronv2 import constants
|
||||
from nova import test
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
#NOTE: Quantum client raises Exception which is discouraged by HACKING.
|
||||
#NOTE: Neutron client raises Exception which is discouraged by HACKING.
|
||||
# We set this variable here and use it for assertions below to avoid
|
||||
# the hacking checks until we can make quantum client throw a custom
|
||||
# the hacking checks until we can make neutron client throw a custom
|
||||
# exception class instead.
|
||||
QUANTUM_CLIENT_EXCEPTION = Exception
|
||||
NEUTRON_CLIENT_EXCEPTION = Exception
|
||||
|
||||
|
||||
class MyComparator(mox.Comparator):
|
||||
|
@ -88,49 +88,49 @@ class MyComparator(mox.Comparator):
|
|||
return str(self.lhs)
|
||||
|
||||
|
||||
class TestQuantumClient(test.TestCase):
|
||||
class TestNeutronClient(test.TestCase):
|
||||
def test_withtoken(self):
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(quantum_url_timeout=30)
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
self.flags(neutron_url_timeout=30)
|
||||
my_context = context.RequestContext('userid',
|
||||
'my_tenantid',
|
||||
auth_token='token')
|
||||
self.mox.StubOutWithMock(client.Client, "__init__")
|
||||
client.Client.__init__(
|
||||
endpoint_url=CONF.quantum_url,
|
||||
endpoint_url=CONF.neutron_url,
|
||||
token=my_context.auth_token,
|
||||
timeout=CONF.quantum_url_timeout,
|
||||
timeout=CONF.neutron_url_timeout,
|
||||
insecure=False).AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client(my_context)
|
||||
neutronv2.get_client(my_context)
|
||||
|
||||
def test_withouttoken_keystone_connection_error(self):
|
||||
self.flags(quantum_auth_strategy='keystone')
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(neutron_auth_strategy='keystone')
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
my_context = context.RequestContext('userid', 'my_tenantid')
|
||||
self.assertRaises(QUANTUM_CLIENT_EXCEPTION,
|
||||
quantumv2.get_client,
|
||||
self.assertRaises(NEUTRON_CLIENT_EXCEPTION,
|
||||
neutronv2.get_client,
|
||||
my_context)
|
||||
|
||||
def test_withouttoken_keystone_not_auth(self):
|
||||
self.flags(quantum_auth_strategy=None)
|
||||
self.flags(quantum_url='http://anyhost/')
|
||||
self.flags(quantum_url_timeout=30)
|
||||
self.flags(neutron_auth_strategy=None)
|
||||
self.flags(neutron_url='http://anyhost/')
|
||||
self.flags(neutron_url_timeout=30)
|
||||
my_context = context.RequestContext('userid', 'my_tenantid')
|
||||
self.mox.StubOutWithMock(client.Client, "__init__")
|
||||
client.Client.__init__(
|
||||
endpoint_url=CONF.quantum_url,
|
||||
endpoint_url=CONF.neutron_url,
|
||||
auth_strategy=None,
|
||||
timeout=CONF.quantum_url_timeout,
|
||||
timeout=CONF.neutron_url_timeout,
|
||||
insecure=False).AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client(my_context)
|
||||
neutronv2.get_client(my_context)
|
||||
|
||||
|
||||
class TestQuantumv2Base(test.TestCase):
|
||||
class TestNeutronv2Base(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQuantumv2Base, self).setUp()
|
||||
super(TestNeutronv2Base, self).setUp()
|
||||
self.context = context.RequestContext('userid', 'my_tenantid')
|
||||
setattr(self.context,
|
||||
'auth_token',
|
||||
|
@ -237,7 +237,7 @@ class TestQuantumv2Base(test.TestCase):
|
|||
'fixed_ip_address': fixed_ip_address,
|
||||
'router_id': 'router_id1'}
|
||||
self._returned_nw_info = []
|
||||
self.mox.StubOutWithMock(quantumv2, 'get_client')
|
||||
self.mox.StubOutWithMock(neutronv2, 'get_client')
|
||||
self.moxed_client = self.mox.CreateMock(client.Client)
|
||||
self.addCleanup(CONF.reset)
|
||||
self.addCleanup(self.mox.VerifyAll)
|
||||
|
@ -245,21 +245,21 @@ class TestQuantumv2Base(test.TestCase):
|
|||
self.addCleanup(self.stubs.UnsetAll)
|
||||
|
||||
def _stub_allocate_for_instance(self, net_idx=1, **kwargs):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_get_instance_nw_info')
|
||||
has_portbinding = False
|
||||
if kwargs.get('portbinding'):
|
||||
has_portbinding = True
|
||||
api.extensions[constants.PORTBINDING_EXT] = 1
|
||||
self.mox.StubOutWithMock(api, '_refresh_quantum_extensions_cache')
|
||||
quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
self.mox.StubOutWithMock(api, '_refresh_neutron_extensions_cache')
|
||||
neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
quantumv2.get_client(
|
||||
neutronv2.get_client(
|
||||
mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
api._refresh_quantum_extensions_cache()
|
||||
api._refresh_neutron_extensions_cache()
|
||||
else:
|
||||
self.mox.StubOutWithMock(api, '_populate_quantum_extension_values')
|
||||
self.mox.StubOutWithMock(api, '_populate_neutron_extension_values')
|
||||
self.mox.StubOutWithMock(api, '_has_port_binding_extension')
|
||||
# Net idx is 1-based for compatibility with existing unit tests
|
||||
nets = self.nets[net_idx - 1]
|
||||
|
@ -315,10 +315,10 @@ class TestQuantumv2Base(test.TestCase):
|
|||
self.instance.get('host'))
|
||||
port = ports.get(net_id, None)
|
||||
if not has_portbinding:
|
||||
api._populate_quantum_extension_values(
|
||||
api._populate_neutron_extension_values(
|
||||
self.instance, mox.IgnoreArg()).AndReturn(None)
|
||||
else:
|
||||
# since _populate_quantum_extension_values() will call
|
||||
# since _populate_neutron_extension_values() will call
|
||||
# _has_port_binding_extension()
|
||||
api._has_port_binding_extension().AndReturn(has_portbinding)
|
||||
api._has_port_binding_extension().AndReturn(has_portbinding)
|
||||
|
@ -372,7 +372,7 @@ class TestQuantumv2Base(test.TestCase):
|
|||
nw_inf[index]['network']['subnets'][0]['dns'])
|
||||
|
||||
def _get_instance_nw_info(self, number):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api.db, 'instance_info_cache_update')
|
||||
api.db.instance_info_cache_update(mox.IgnoreArg(),
|
||||
self.instance['uuid'],
|
||||
|
@ -415,30 +415,30 @@ class TestQuantumv2Base(test.TestCase):
|
|||
return api.allocate_for_instance(self.context, self.instance, **kwargs)
|
||||
|
||||
|
||||
class TestQuantumv2(TestQuantumv2Base):
|
||||
class TestNeutronv2(TestNeutronv2Base):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQuantumv2, self).setUp()
|
||||
quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
super(TestNeutronv2, self).setUp()
|
||||
neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
|
||||
def test_get_instance_nw_info_1(self):
|
||||
# Test to get one port in one network and subnet.
|
||||
quantumv2.get_client(mox.IgnoreArg(),
|
||||
neutronv2.get_client(mox.IgnoreArg(),
|
||||
admin=True).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self._get_instance_nw_info(1)
|
||||
|
||||
def test_get_instance_nw_info_2(self):
|
||||
# Test to get one port in each of two networks and subnets.
|
||||
quantumv2.get_client(mox.IgnoreArg(),
|
||||
neutronv2.get_client(mox.IgnoreArg(),
|
||||
admin=True).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self._get_instance_nw_info(2)
|
||||
|
||||
def test_get_instance_nw_info_with_nets(self):
|
||||
# Test get instance_nw_info with networks passed in.
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api.db, 'instance_info_cache_update')
|
||||
api.db.instance_info_cache_update(
|
||||
mox.IgnoreArg(),
|
||||
|
@ -460,7 +460,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
network_id='my_netid1',
|
||||
device_owner='network:dhcp').AndReturn(
|
||||
{'ports': self.dhcp_port_data1})
|
||||
quantumv2.get_client(mox.IgnoreArg(),
|
||||
neutronv2.get_client(mox.IgnoreArg(),
|
||||
admin=True).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self.mox.ReplayAll()
|
||||
|
@ -471,7 +471,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
def test_get_instance_nw_info_without_subnet(self):
|
||||
# Test get instance_nw_info for a port without subnet.
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api.db, 'instance_info_cache_update')
|
||||
api.db.instance_info_cache_update(
|
||||
mox.IgnoreArg(),
|
||||
|
@ -486,7 +486,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
{'networks': self.nets1})
|
||||
self.moxed_client.list_networks(
|
||||
shared=True).AndReturn({'networks': []})
|
||||
quantumv2.get_client(mox.IgnoreArg(),
|
||||
neutronv2.get_client(mox.IgnoreArg(),
|
||||
admin=True).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self.mox.ReplayAll()
|
||||
|
@ -501,16 +501,16 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEquals('my_mac%s' % id_suffix, nw_inf[0]['address'])
|
||||
self.assertEquals(0, len(nw_inf[0]['network']['subnets']))
|
||||
|
||||
def test_refresh_quantum_extensions_cache(self):
|
||||
api = quantumapi.API()
|
||||
def test_refresh_neutron_extensions_cache(self):
|
||||
api = neutronapi.API()
|
||||
self.moxed_client.list_extensions().AndReturn(
|
||||
{'extensions': [{'name': 'nvp-qos'}]})
|
||||
self.mox.ReplayAll()
|
||||
api._refresh_quantum_extensions_cache()
|
||||
api._refresh_neutron_extensions_cache()
|
||||
self.assertEquals({'nvp-qos': {'name': 'nvp-qos'}}, api.extensions)
|
||||
|
||||
def test_populate_quantum_extension_values_rxtx_factor(self):
|
||||
api = quantumapi.API()
|
||||
def test_populate_neutron_extension_values_rxtx_factor(self):
|
||||
api = neutronapi.API()
|
||||
self.moxed_client.list_extensions().AndReturn(
|
||||
{'extensions': [{'name': 'nvp-qos'}]})
|
||||
self.mox.ReplayAll()
|
||||
|
@ -520,7 +520,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
flavors.save_flavor_info({}, instance_type))
|
||||
instance = {'system_metadata': sys_meta}
|
||||
port_req_body = {'port': {}}
|
||||
api._populate_quantum_extension_values(instance, port_req_body)
|
||||
api._populate_neutron_extension_values(instance, port_req_body)
|
||||
self.assertEquals(port_req_body['port']['rxtx_factor'], 1)
|
||||
|
||||
def test_allocate_for_instance_1(self):
|
||||
|
@ -626,7 +626,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
def test_allocate_for_instance_no_networks(self):
|
||||
"""verify the exception thrown when there are no networks defined."""
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.moxed_client.list_networks(
|
||||
tenant_id=self.instance['project_id'],
|
||||
shared=False).AndReturn(
|
||||
|
@ -644,8 +644,8 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
Mox to raise exception when creating a second port.
|
||||
In this case, the code should delete the first created port.
|
||||
"""
|
||||
api = quantumapi.API()
|
||||
self.mox.StubOutWithMock(api, '_populate_quantum_extension_values')
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_populate_neutron_extension_values')
|
||||
self.mox.StubOutWithMock(api, '_has_port_binding_extension')
|
||||
api._has_port_binding_extension().MultipleTimes().AndReturn(False)
|
||||
self.moxed_client.list_networks(
|
||||
|
@ -672,7 +672,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
port_req_body['port'].update(binding_port_req_body['port'])
|
||||
port = {'id': 'portid_' + network['id']}
|
||||
|
||||
api._populate_quantum_extension_values(
|
||||
api._populate_neutron_extension_values(
|
||||
self.instance, binding_port_req_body).AndReturn(None)
|
||||
if index == 0:
|
||||
self.moxed_client.create_port(
|
||||
|
@ -684,7 +684,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
index += 1
|
||||
self.moxed_client.delete_port('portid_' + self.nets2[0]['id'])
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(QUANTUM_CLIENT_EXCEPTION, api.allocate_for_instance,
|
||||
self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.allocate_for_instance,
|
||||
self.context, self.instance)
|
||||
|
||||
def test_allocate_for_instance_ex2(self):
|
||||
|
@ -694,7 +694,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
Mox to raise exception when creating the first port.
|
||||
In this case, the code should not delete any ports.
|
||||
"""
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.moxed_client.list_networks(
|
||||
tenant_id=self.instance['project_id'],
|
||||
shared=False).AndReturn(
|
||||
|
@ -713,13 +713,13 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
MyComparator(port_req_body)).AndRaise(
|
||||
Exception("fail to create port"))
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(QUANTUM_CLIENT_EXCEPTION, api.allocate_for_instance,
|
||||
self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.allocate_for_instance,
|
||||
self.context, self.instance)
|
||||
|
||||
def test_allocate_for_instance_no_port_or_network(self):
|
||||
class BailOutEarly(Exception):
|
||||
pass
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_get_available_networks')
|
||||
# Make sure we get an empty list and then bail out of the rest
|
||||
# of the function
|
||||
|
@ -749,7 +749,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
api.deallocate_for_instance(self.context, self.instance)
|
||||
|
||||
def test_deallocate_for_instance_1(self):
|
||||
|
@ -764,13 +764,13 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
port_data = number == 1 and self.port_data1 or self.port_data2
|
||||
self.moxed_client.delete_port(port_data[0]['id'])
|
||||
|
||||
quantumv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
self.moxed_client)
|
||||
self.moxed_client.list_ports(
|
||||
tenant_id=self.instance['project_id'],
|
||||
device_id=self.instance['uuid']).AndReturn(
|
||||
{'ports': port_data[1:]})
|
||||
quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn(
|
||||
self.moxed_client)
|
||||
self.moxed_client.list_networks(
|
||||
tenant_id=self.instance['project_id'],
|
||||
|
@ -790,7 +790,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
nwinfo = api.deallocate_port_for_instance(self.context, self.instance,
|
||||
port_data[0]['id'])
|
||||
self.assertEqual(len(nwinfo), len(port_data[1:]))
|
||||
|
@ -809,12 +809,12 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
search_opts = {'parm': 'value'}
|
||||
self.moxed_client.list_ports(**search_opts)
|
||||
self.mox.ReplayAll()
|
||||
quantumapi.API().list_ports(self.context, **search_opts)
|
||||
neutronapi.API().list_ports(self.context, **search_opts)
|
||||
|
||||
def test_show_port(self):
|
||||
self.moxed_client.show_port('foo')
|
||||
self.mox.ReplayAll()
|
||||
quantumapi.API().show_port(self.context, 'foo')
|
||||
neutronapi.API().show_port(self.context, 'foo')
|
||||
|
||||
def test_validate_networks(self):
|
||||
requested_networks = [('my_netid1', 'test', None),
|
||||
|
@ -829,7 +829,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
shared=True).AndReturn(
|
||||
{'networks': []})
|
||||
self.mox.ReplayAll()
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
api.validate_networks(self.context, requested_networks)
|
||||
|
||||
def test_validate_networks_ex_1(self):
|
||||
|
@ -845,7 +845,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
shared=True).AndReturn(
|
||||
{'networks': []})
|
||||
self.mox.ReplayAll()
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
try:
|
||||
api.validate_networks(self.context, requested_networks)
|
||||
except exception.NetworkNotFound as ex:
|
||||
|
@ -865,7 +865,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
shared=True).AndReturn(
|
||||
{'networks': []})
|
||||
self.mox.ReplayAll()
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
try:
|
||||
api.validate_networks(self.context, requested_networks)
|
||||
except exception.NetworkNotFound as ex:
|
||||
|
@ -879,8 +879,8 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
('my_netid1', None, None)]
|
||||
self.mox.ReplayAll()
|
||||
# Expected call from setUp.
|
||||
quantumv2.get_client(None)
|
||||
api = quantumapi.API()
|
||||
neutronv2.get_client(None)
|
||||
api = neutronapi.API()
|
||||
self.assertRaises(exception.NetworkDuplicated,
|
||||
api.validate_networks,
|
||||
self.context, requested_networks)
|
||||
|
@ -898,33 +898,33 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
def test_get_instance_uuids_by_ip_filter(self):
|
||||
self._mock_list_ports()
|
||||
filters = {'ip': '^10\\.0\\.1\\.2$'}
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
result = api.get_instance_uuids_by_ip_filter(self.context, filters)
|
||||
self.assertEquals('device_id1', result[0]['instance_uuid'])
|
||||
self.assertEquals('device_id2', result[1]['instance_uuid'])
|
||||
|
||||
def test_get_fixed_ip_by_address_fails_for_no_ports(self):
|
||||
address = self._mock_list_ports(port_data=[])
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.assertRaises(exception.FixedIpNotFoundForAddress,
|
||||
api.get_fixed_ip_by_address,
|
||||
self.context, address)
|
||||
|
||||
def test_get_fixed_ip_by_address_succeeds_for_1_port(self):
|
||||
address = self._mock_list_ports(port_data=self.port_data1)
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
result = api.get_fixed_ip_by_address(self.context, address)
|
||||
self.assertEquals('device_id1', result['instance_uuid'])
|
||||
|
||||
def test_get_fixed_ip_by_address_fails_for_more_than_1_port(self):
|
||||
address = self._mock_list_ports()
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.assertRaises(exception.FixedIpAssociatedWithMultipleInstances,
|
||||
api.get_fixed_ip_by_address,
|
||||
self.context, address)
|
||||
|
||||
def _get_available_networks(self, prv_nets, pub_nets, req_ids=None):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
nets = prv_nets + pub_nets
|
||||
mox_list_network_params = dict(tenant_id=self.instance['project_id'],
|
||||
shared=False)
|
||||
|
@ -961,7 +961,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self._get_available_networks(prv_nets, pub_nets, req_ids)
|
||||
|
||||
def test_get_floating_ip_pools(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
search_opts = {'router:external': True}
|
||||
self.moxed_client.list_networks(**search_opts).\
|
||||
AndReturn({'networks': [self.fip_pool, self.fip_pool_nova]})
|
||||
|
@ -985,7 +985,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
return expected
|
||||
|
||||
def _test_get_floating_ip(self, fip_data, idx=0, by_address=False):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
fip_id = fip_data['id']
|
||||
net_id = fip_data['floating_network_id']
|
||||
address = fip_data['floating_ip_address']
|
||||
|
@ -1025,7 +1025,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
by_address=True)
|
||||
|
||||
def test_get_floating_ip_by_address_not_found(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_unassociated['floating_ip_address']
|
||||
self.moxed_client.list_floatingips(floating_ip_address=address).\
|
||||
AndReturn({'floatingips': []})
|
||||
|
@ -1035,7 +1035,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.context, address)
|
||||
|
||||
def test_get_floating_ip_by_address_multiple_found(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_unassociated['floating_ip_address']
|
||||
self.moxed_client.list_floatingips(floating_ip_address=address).\
|
||||
AndReturn({'floatingips': [self.fip_unassociated] * 2})
|
||||
|
@ -1045,7 +1045,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.context, address)
|
||||
|
||||
def test_get_floating_ips_by_project(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
project_id = self.context.project_id
|
||||
self.moxed_client.list_floatingips(tenant_id=project_id).\
|
||||
AndReturn({'floatingips': [self.fip_unassociated,
|
||||
|
@ -1064,7 +1064,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
def _test_get_instance_id_by_floating_address(self, fip_data,
|
||||
associated=False):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = fip_data['floating_ip_address']
|
||||
self.moxed_client.list_floatingips(floating_ip_address=address).\
|
||||
AndReturn({'floatingips': [fip_data]})
|
||||
|
@ -1088,7 +1088,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
associated=True)
|
||||
|
||||
def test_allocate_floating_ip(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
pool_name = self.fip_pool['name']
|
||||
pool_id = self.fip_pool['id']
|
||||
search_opts = {'router:external': True,
|
||||
|
@ -1104,7 +1104,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEqual(fip, self.fip_unassociated['floating_ip_address'])
|
||||
|
||||
def test_allocate_floating_ip_with_pool_id(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
pool_id = self.fip_pool['id']
|
||||
search_opts = {'router:external': True,
|
||||
'fields': 'id',
|
||||
|
@ -1119,7 +1119,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEqual(fip, self.fip_unassociated['floating_ip_address'])
|
||||
|
||||
def test_allocate_floating_ip_with_default_pool(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
pool_name = self.fip_pool_nova['name']
|
||||
pool_id = self.fip_pool_nova['id']
|
||||
search_opts = {'router:external': True,
|
||||
|
@ -1135,7 +1135,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEqual(fip, self.fip_unassociated['floating_ip_address'])
|
||||
|
||||
def test_release_floating_ip(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_unassociated['floating_ip_address']
|
||||
fip_id = self.fip_unassociated['id']
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
api.release_floating_ip(self.context, address)
|
||||
|
||||
def test_release_floating_ip_associated(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_associated['floating_ip_address']
|
||||
|
||||
self.moxed_client.list_floatingips(floating_ip_address=address).\
|
||||
|
@ -1167,7 +1167,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
mox.IgnoreArg())
|
||||
|
||||
def test_associate_floating_ip(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_associated['floating_ip_address']
|
||||
fixed_address = self.fip_associated['fixed_ip_address']
|
||||
fip_id = self.fip_associated['id']
|
||||
|
@ -1188,7 +1188,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
address, fixed_address)
|
||||
|
||||
def test_associate_floating_ip_not_found_fixed_ip(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_associated['floating_ip_address']
|
||||
fixed_address = self.fip_associated['fixed_ip_address']
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.instance, address, fixed_address)
|
||||
|
||||
def test_disassociate_floating_ip(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
address = self.fip_associated['floating_ip_address']
|
||||
fip_id = self.fip_associated['id']
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
api.disassociate_floating_ip(self.context, self.instance, address)
|
||||
|
||||
def test_add_fixed_ip_to_instance(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self._setup_mock_for_refresh_cache(api)
|
||||
network_id = 'my_netid1'
|
||||
search_opts = {'network_id': network_id}
|
||||
|
@ -1244,7 +1244,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
api.add_fixed_ip_to_instance(self.context, self.instance, network_id)
|
||||
|
||||
def test_remove_fixed_ip_from_instance(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self._setup_mock_for_refresh_cache(api)
|
||||
address = '10.0.0.3'
|
||||
zone = 'compute:%s' % self.instance['availability_zone']
|
||||
|
@ -1267,13 +1267,13 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
api.remove_fixed_ip_from_instance(self.context, self.instance, address)
|
||||
|
||||
def test_list_floating_ips_without_l3_support(self):
|
||||
api = quantumapi.API()
|
||||
QuantumNotFound = exceptions.QuantumClientException(
|
||||
api = neutronapi.API()
|
||||
NeutronNotFound = exceptions.NeutronClientException(
|
||||
status_code=404)
|
||||
self.moxed_client.list_floatingips(
|
||||
fixed_ip_address='1.1.1.1', port_id=1).AndRaise(QuantumNotFound)
|
||||
fixed_ip_address='1.1.1.1', port_id=1).AndRaise(NeutronNotFound)
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client('fake')
|
||||
neutronv2.get_client('fake')
|
||||
floatingips = api._get_floating_ips_by_fixed_and_port(
|
||||
self.moxed_client, '1.1.1.1', 1)
|
||||
self.assertEqual(floatingips, [])
|
||||
|
@ -1284,13 +1284,13 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
{'ip_address': '1.1.1.1'}],
|
||||
'id': 'port-id',
|
||||
}
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_get_floating_ips_by_fixed_and_port')
|
||||
api._get_floating_ips_by_fixed_and_port(
|
||||
self.moxed_client, '1.1.1.1', 'port-id').AndReturn(
|
||||
[{'floating_ip_address': '10.0.0.1'}])
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client('fake')
|
||||
neutronv2.get_client('fake')
|
||||
result = api._nw_info_get_ips(self.moxed_client, fake_port)
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(result[0]['address'], '1.1.1.1')
|
||||
|
@ -1305,12 +1305,12 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
}
|
||||
fake_subnet = model.Subnet(cidr='1.0.0.0/8')
|
||||
fake_ips = [model.IP(x['ip_address']) for x in fake_port['fixed_ips']]
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_get_subnets_from_port')
|
||||
api._get_subnets_from_port(self.context, fake_port).AndReturn(
|
||||
[fake_subnet])
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client('fake')
|
||||
neutronv2.get_client('fake')
|
||||
subnets = api._nw_info_get_subnets(self.context, fake_port, fake_ips)
|
||||
self.assertEqual(len(subnets), 1)
|
||||
self.assertEqual(len(subnets[0]['ips']), 1)
|
||||
|
@ -1325,9 +1325,9 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
}
|
||||
fake_subnets = [model.Subnet(cidr='1.0.0.0/8')]
|
||||
fake_nets = [{'id': 'net-id', 'name': 'foo', 'tenant_id': 'tenant'}]
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client('fake')
|
||||
neutronv2.get_client('fake')
|
||||
net, iid = api._nw_info_build_network(fake_port, fake_nets,
|
||||
fake_subnets)
|
||||
self.assertEqual(net['subnets'], fake_subnets)
|
||||
|
@ -1339,7 +1339,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
|
||||
def test_nw_info_build_network_ovs(self):
|
||||
net, iid = self._test_nw_info_build_network(model.VIF_TYPE_OVS)
|
||||
self.assertEqual(net['bridge'], CONF.quantum_ovs_bridge)
|
||||
self.assertEqual(net['bridge'], CONF.neutron_ovs_bridge)
|
||||
self.assertFalse('should_create_bridge' in net)
|
||||
self.assertEqual(iid, 'port-id')
|
||||
|
||||
|
@ -1356,7 +1356,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEqual(iid, None)
|
||||
|
||||
def test_build_network_info_model(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
fake_inst = {'project_id': 'fake', 'uuid': 'uuid'}
|
||||
fake_ports = [
|
||||
{'id': 'port0',
|
||||
|
@ -1378,7 +1378,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
'tenant_id': 'fake',
|
||||
}
|
||||
]
|
||||
quantumv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes(
|
||||
neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes(
|
||||
).AndReturn(self.moxed_client)
|
||||
self.moxed_client.list_ports(
|
||||
tenant_id='fake', device_id='uuid').AndReturn(
|
||||
|
@ -1391,7 +1391,7 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
api._get_subnets_from_port(self.context, fake_ports[0]).AndReturn(
|
||||
fake_subnets)
|
||||
self.mox.ReplayAll()
|
||||
quantumv2.get_client('fake')
|
||||
neutronv2.get_client('fake')
|
||||
nw_info = api._build_network_info_model(self.context, fake_inst,
|
||||
fake_nets)
|
||||
self.assertEqual(len(nw_info), 1)
|
||||
|
@ -1403,18 +1403,18 @@ class TestQuantumv2(TestQuantumv2Base):
|
|||
self.assertEqual(nw_info[0]['network']['bridge'], 'brqnet-id')
|
||||
|
||||
def test_get_all_empty_list_networks(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.moxed_client.list_networks().AndReturn({'networks': []})
|
||||
self.mox.ReplayAll()
|
||||
networks = api.get_all(self.context)
|
||||
self.assertEqual(networks, [])
|
||||
|
||||
|
||||
class TestQuantumv2ModuleMethods(test.TestCase):
|
||||
class TestNeutronv2ModuleMethods(test.TestCase):
|
||||
def test_ensure_requested_network_ordering_no_preference_ids(self):
|
||||
l = [1, 2, 3]
|
||||
|
||||
quantumapi._ensure_requested_network_ordering(
|
||||
neutronapi._ensure_requested_network_ordering(
|
||||
lambda x: x,
|
||||
l,
|
||||
None)
|
||||
|
@ -1422,7 +1422,7 @@ class TestQuantumv2ModuleMethods(test.TestCase):
|
|||
def test_ensure_requested_network_ordering_no_preference_hashes(self):
|
||||
l = [{'id': 3}, {'id': 1}, {'id': 2}]
|
||||
|
||||
quantumapi._ensure_requested_network_ordering(
|
||||
neutronapi._ensure_requested_network_ordering(
|
||||
lambda x: x['id'],
|
||||
l,
|
||||
None)
|
||||
|
@ -1432,7 +1432,7 @@ class TestQuantumv2ModuleMethods(test.TestCase):
|
|||
def test_ensure_requested_network_ordering_with_preference(self):
|
||||
l = [{'id': 3}, {'id': 1}, {'id': 2}]
|
||||
|
||||
quantumapi._ensure_requested_network_ordering(
|
||||
neutronapi._ensure_requested_network_ordering(
|
||||
lambda x: x['id'],
|
||||
l,
|
||||
[1, 2, 3])
|
||||
|
@ -1440,14 +1440,14 @@ class TestQuantumv2ModuleMethods(test.TestCase):
|
|||
self.assertEqual(l, [{'id': 1}, {'id': 2}, {'id': 3}])
|
||||
|
||||
|
||||
class TestQuantumv2Portbinding(TestQuantumv2Base):
|
||||
class TestNeutronv2Portbinding(TestNeutronv2Base):
|
||||
|
||||
def test_allocate_for_instance_portbinding(self):
|
||||
self._allocate_for_instance(1, portbinding=True)
|
||||
|
||||
def test_populate_quantum_extension_values_binding(self):
|
||||
api = quantumapi.API()
|
||||
quantumv2.get_client(mox.IgnoreArg()).AndReturn(
|
||||
def test_populate_neutron_extension_values_binding(self):
|
||||
api = neutronapi.API()
|
||||
neutronv2.get_client(mox.IgnoreArg()).AndReturn(
|
||||
self.moxed_client)
|
||||
self.moxed_client.list_extensions().AndReturn(
|
||||
{'extensions': [{'name': constants.PORTBINDING_EXT}]})
|
||||
|
@ -1455,21 +1455,21 @@ class TestQuantumv2Portbinding(TestQuantumv2Base):
|
|||
host_id = 'my_host_id'
|
||||
instance = {'host': host_id}
|
||||
port_req_body = {'port': {}}
|
||||
api._populate_quantum_extension_values(instance, port_req_body)
|
||||
api._populate_neutron_extension_values(instance, port_req_body)
|
||||
self.assertEquals(port_req_body['port']['binding:host_id'], host_id)
|
||||
|
||||
def test_migrate_instance_finish_binding_false(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_has_port_binding_extension')
|
||||
api._has_port_binding_extension(refresh_cache=True).AndReturn(False)
|
||||
self.mox.ReplayAll()
|
||||
api.migrate_instance_finish(self.context, None, None)
|
||||
|
||||
def test_migrate_instance_finish_binding_true(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_has_port_binding_extension')
|
||||
api._has_port_binding_extension(refresh_cache=True).AndReturn(True)
|
||||
quantumv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
self.moxed_client)
|
||||
search_opts = {'device_id': self.instance['uuid'],
|
||||
'tenant_id': self.instance['project_id']}
|
||||
|
@ -1483,10 +1483,10 @@ class TestQuantumv2Portbinding(TestQuantumv2Base):
|
|||
api.migrate_instance_finish(self.context, self.instance, None)
|
||||
|
||||
def test_migrate_instance_finish_binding_true_exception(self):
|
||||
api = quantumapi.API()
|
||||
api = neutronapi.API()
|
||||
self.mox.StubOutWithMock(api, '_has_port_binding_extension')
|
||||
api._has_port_binding_extension(refresh_cache=True).AndReturn(True)
|
||||
quantumv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
|
||||
self.moxed_client)
|
||||
search_opts = {'device_id': self.instance['uuid'],
|
||||
'tenant_id': self.instance['project_id']}
|
||||
|
@ -1498,6 +1498,6 @@ class TestQuantumv2Portbinding(TestQuantumv2Base):
|
|||
port_req_body).AndRaise(
|
||||
Exception("fail to update port"))
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(QUANTUM_CLIENT_EXCEPTION,
|
||||
self.assertRaises(NEUTRON_CLIENT_EXCEPTION,
|
||||
api.migrate_instance_finish,
|
||||
self.context, self.instance, None)
|
|
@ -523,7 +523,7 @@ class MetadataHandlerTestCase(test.TestCase):
|
|||
headers=None)
|
||||
self.assertEqual(response.status_int, 500)
|
||||
|
||||
def test_user_data_with_quantum_instance_id(self):
|
||||
def test_user_data_with_neutron_instance_id(self):
|
||||
expected_instance_id = 'a-b-c-d'
|
||||
|
||||
def fake_get_metadata(instance_id, remote_address):
|
||||
|
@ -537,7 +537,7 @@ class MetadataHandlerTestCase(test.TestCase):
|
|||
(expected_instance_id, instance_id))
|
||||
|
||||
signed = hmac.new(
|
||||
CONF.quantum_metadata_proxy_shared_secret,
|
||||
CONF.neutron_metadata_proxy_shared_secret,
|
||||
expected_instance_id,
|
||||
hashlib.sha256).hexdigest()
|
||||
|
||||
|
@ -551,7 +551,7 @@ class MetadataHandlerTestCase(test.TestCase):
|
|||
self.assertEqual(response.status_int, 200)
|
||||
|
||||
# now enable the service
|
||||
self.flags(service_quantum_metadata_proxy=True)
|
||||
self.flags(service_neutron_metadata_proxy=True)
|
||||
response = fake_request(
|
||||
self.stubs, self.mdinst,
|
||||
relpath="/2009-04-04/user-data",
|
||||
|
@ -590,7 +590,7 @@ class MetadataHandlerTestCase(test.TestCase):
|
|||
|
||||
# unexpected Instance-ID
|
||||
signed = hmac.new(
|
||||
CONF.quantum_metadata_proxy_shared_secret,
|
||||
CONF.neutron_metadata_proxy_shared_secret,
|
||||
'z-z-z-z',
|
||||
hashlib.sha256).hexdigest()
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class HyperVAPITestCase(test.TestCase):
|
|||
self._setup_stubs()
|
||||
|
||||
self.flags(instances_path=r'C:\Hyper-V\test\instances',
|
||||
network_api_class='nova.network.quantumv2.api.API')
|
||||
network_api_class='nova.network.neutronv2.api.API')
|
||||
|
||||
self._conn = driver_hyperv.HyperVDriver(None)
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
'id': 'network-id-xxx-yyy-zzz'
|
||||
}
|
||||
|
||||
net_bridge_quantum = {
|
||||
net_bridge_neutron = {
|
||||
'cidr': '101.168.1.0/24',
|
||||
'cidr_v6': '101:1db9::/64',
|
||||
'gateway_v6': '101:1db9::1',
|
||||
|
@ -70,7 +70,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
'vif_type': network_model.VIF_TYPE_BRIDGE,
|
||||
}
|
||||
|
||||
mapping_bridge_quantum = {
|
||||
mapping_bridge_neutron = {
|
||||
'mac': 'ca:fe:de:ad:be:ef',
|
||||
'gateway_v6': net_bridge['gateway_v6'],
|
||||
'ips': [{'ip': '101.168.1.9'}],
|
||||
|
@ -430,16 +430,16 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
self.mapping_bridge,
|
||||
self.net_bridge['bridge'])
|
||||
|
||||
def test_quantum_bridge_driver(self):
|
||||
def test_neutron_bridge_driver(self):
|
||||
def get_connection():
|
||||
return fakelibvirt.Connection("qemu:///session",
|
||||
False)
|
||||
d = vif.QuantumLinuxBridgeVIFDriver(get_connection)
|
||||
br_want = 'brq' + self.net_bridge_quantum['id']
|
||||
d = vif.NeutronLinuxBridgeVIFDriver(get_connection)
|
||||
br_want = 'brq' + self.net_bridge_neutron['id']
|
||||
br_want = br_want[:network_model.NIC_NAME_LEN]
|
||||
self._check_bridge_driver(d,
|
||||
self.net_bridge_quantum,
|
||||
self.mapping_bridge_quantum,
|
||||
self.net_bridge_neutron,
|
||||
self.mapping_bridge_neutron,
|
||||
br_want)
|
||||
|
||||
def _check_ivs_ethernet_driver(self, d, net, mapping, dev_prefix):
|
||||
|
@ -590,7 +590,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
self.mapping_ivs,
|
||||
want_iface_id)
|
||||
|
||||
def _check_quantum_hybrid_driver(self, d, net, mapping, br_want):
|
||||
def _check_neutron_hybrid_driver(self, d, net, mapping, br_want):
|
||||
self.flags(firewall_driver="nova.virt.firewall.IptablesFirewallDriver")
|
||||
xml = self._get_instance_xml(d, net, mapping)
|
||||
|
||||
|
@ -606,14 +606,14 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
mac = node.find("mac").get("address")
|
||||
self.assertEqual(mac, mapping['mac'])
|
||||
|
||||
def test_quantum_hybrid_driver(self):
|
||||
def test_neutron_hybrid_driver(self):
|
||||
def get_connection():
|
||||
return fakelibvirt.Connection("qemu:///session",
|
||||
False)
|
||||
br_want = "qbr" + self.mapping_ovs['vif_uuid']
|
||||
br_want = br_want[:network_model.NIC_NAME_LEN]
|
||||
d = vif.LibvirtHybridOVSBridgeDriver(get_connection)
|
||||
self._check_quantum_hybrid_driver(d,
|
||||
self._check_neutron_hybrid_driver(d,
|
||||
self.net_ovs,
|
||||
self.mapping_ovs_legacy,
|
||||
br_want)
|
||||
|
@ -625,7 +625,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
d = vif.LibvirtGenericVIFDriver(get_connection)
|
||||
br_want = "qbr" + self.mapping_ovs['vif_uuid']
|
||||
br_want = br_want[:network_model.NIC_NAME_LEN]
|
||||
self._check_quantum_hybrid_driver(d,
|
||||
self._check_neutron_hybrid_driver(d,
|
||||
self.net_ovs,
|
||||
self.mapping_ovs,
|
||||
br_want)
|
||||
|
@ -637,7 +637,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||
d = vif.LibvirtGenericVIFDriver(get_connection)
|
||||
br_want = "qbr" + self.mapping_ivs['vif_uuid']
|
||||
br_want = br_want[:network_model.NIC_NAME_LEN]
|
||||
self._check_quantum_hybrid_driver(d,
|
||||
self._check_neutron_hybrid_driver(d,
|
||||
self.net_ovs,
|
||||
self.mapping_ivs,
|
||||
br_want)
|
||||
|
|
|
@ -48,15 +48,15 @@ class HyperVBaseVIFDriver(object):
|
|||
pass
|
||||
|
||||
|
||||
class HyperVQuantumVIFDriver(HyperVBaseVIFDriver):
|
||||
"""Quantum VIF driver."""
|
||||
class HyperVNeutronVIFDriver(HyperVBaseVIFDriver):
|
||||
"""Neutron VIF driver."""
|
||||
|
||||
def plug(self, instance, vif):
|
||||
# Quantum takes care of plugging the port
|
||||
# Neutron takes care of plugging the port
|
||||
pass
|
||||
|
||||
def unplug(self, instance, vif):
|
||||
# Quantum takes care of unplugging the port
|
||||
# Neutron takes care of unplugging the port
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ CONF.import_opt('network_api_class', 'nova.network')
|
|||
|
||||
class VMOps(object):
|
||||
_vif_driver_class_map = {
|
||||
'nova.network.quantumv2.api.API':
|
||||
'nova.virt.hyperv.vif.HyperVQuantumVIFDriver',
|
||||
'nova.network.neutronv2.api.API':
|
||||
'nova.virt.hyperv.vif.HyperVNeutronVIFDriver',
|
||||
'nova.network.api.API':
|
||||
'nova.virt.hyperv.vif.HyperVNovaNetworkVIFDriver',
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ from nova.virt.libvirt import designer
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
libvirt_vif_opts = [
|
||||
# quantum_ovs_bridge is used, if Quantum provides Nova
|
||||
# neutron_ovs_bridge is used, if Neutron provides Nova
|
||||
# the 'vif_type' portbinding field
|
||||
cfg.StrOpt('libvirt_ovs_bridge',
|
||||
default='br-int',
|
||||
|
@ -154,7 +154,7 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver):
|
|||
|
||||
def get_firewall_required(self):
|
||||
# TODO(berrange): Extend this to use information from VIF model
|
||||
# which can indicate whether the network provider (eg Quantum)
|
||||
# which can indicate whether the network provider (eg Neutron)
|
||||
# has already applied firewall filtering itself.
|
||||
if CONF.firewall_driver != "nova.virt.firewall.NoopFirewallDriver":
|
||||
return True
|
||||
|
@ -637,7 +637,7 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver):
|
|||
|
||||
|
||||
class LibvirtBridgeDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
"""Retained in Grizzly for compatibility with Neutron
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
@ -659,7 +659,7 @@ class LibvirtBridgeDriver(LibvirtGenericVIFDriver):
|
|||
|
||||
|
||||
class LibvirtOpenVswitchDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
"""Retained in Grizzly for compatibility with Neutron
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
@ -688,7 +688,7 @@ class LibvirtOpenVswitchDriver(LibvirtGenericVIFDriver):
|
|||
|
||||
|
||||
class LibvirtHybridOVSBridgeDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
"""Retained in Grizzly for compatibility with Neutron
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
@ -718,7 +718,7 @@ class LibvirtHybridOVSBridgeDriver(LibvirtGenericVIFDriver):
|
|||
|
||||
|
||||
class LibvirtOpenVswitchVirtualPortDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
"""Retained in Grizzly for compatibility with Neutron
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
@ -747,8 +747,8 @@ class LibvirtOpenVswitchVirtualPortDriver(LibvirtGenericVIFDriver):
|
|||
return self.unplug_ovs_bridge(instance, vif)
|
||||
|
||||
|
||||
class QuantumLinuxBridgeVIFDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Quantum
|
||||
class NeutronLinuxBridgeVIFDriver(LibvirtGenericVIFDriver):
|
||||
"""Retained in Grizzly for compatibility with Nuetron
|
||||
drivers which do not yet report 'vif_type' port binding.
|
||||
Will be deprecated in Havana, and removed in Ixxxx.
|
||||
"""
|
||||
|
@ -758,7 +758,7 @@ class QuantumLinuxBridgeVIFDriver(LibvirtGenericVIFDriver):
|
|||
return network.get('bridge') or def_bridge
|
||||
|
||||
def get_config(self, instance, network, mapping, image_meta, inst_type):
|
||||
LOG.deprecated(_("The QuantumLinuxBridgeVIFDriver VIF driver is now "
|
||||
LOG.deprecated(_("The NeutronLinuxBridgeVIFDriver VIF driver is now "
|
||||
"deprecated and will be removed in the next release. "
|
||||
"Please use the LibvirtGenericVIFDriver VIF driver, "
|
||||
"together with a network plugin that reports the "
|
||||
|
@ -775,3 +775,6 @@ class QuantumLinuxBridgeVIFDriver(LibvirtGenericVIFDriver):
|
|||
|
||||
def unplug(self, instance, vif):
|
||||
self.unplug_bridge(instance, vif)
|
||||
|
||||
# For compatibility with exsiting Nova deployments
|
||||
QuantumLinuxBridgeVIFDriver = NeutronLinuxBridgeVIFDriver
|
||||
|
|
|
@ -79,7 +79,7 @@ def get_vm_create_spec(client_factory, instance, data_store_name,
|
|||
|
||||
config_spec.deviceChange = device_config_spec
|
||||
|
||||
# add vm-uuid and iface-id.x values for Quantum
|
||||
# add vm-uuid and iface-id.x values for Neutron
|
||||
extra_config = []
|
||||
opt = client_factory.create('ns0:OptionValue')
|
||||
opt.key = "nvp.vm-uuid"
|
||||
|
|
|
@ -23,7 +23,7 @@ Babel>=0.9.6
|
|||
iso8601>=0.1.4
|
||||
requests>=1.1,<1.2.1 # order-dependent python-cinderclient req cap, bug 1182271
|
||||
python-cinderclient>=1.0.1
|
||||
python-quantumclient>=2.2.0,<3.0.0
|
||||
python-neutronclient>=2.2.3,<3.0.0
|
||||
python-glanceclient>=0.5.0,<2
|
||||
python-keystoneclient>=0.2.0
|
||||
six
|
||||
|
|
Loading…
Reference in New Issue