Remove nova net support from service_instance

Nova network was deprecated in Newton and is no longer supported for
regular deployments in Ocata [1].

As a first step towards removal and cleanup of nova network plugin
from manila, remove support for it from the service instance module.

[1] http://docs.openstack.org/releasenotes/nova/unreleased.html

Partially-implements: bp remove-nova-net-plugin

Change-Id: I846b760fa7c01f7f86768399a2bfad9ced7e57cd
This commit is contained in:
Tom Barron 2016-12-13 07:24:35 -05:00
parent cbda16bc57
commit 0f33dcf62b
3 changed files with 52 additions and 256 deletions

View File

@ -39,7 +39,6 @@ from manila import utils
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
NEUTRON_NAME = "neutron" NEUTRON_NAME = "neutron"
NOVA_NAME = "nova"
share_servers_handling_mode_opts = [ share_servers_handling_mode_opts = [
cfg.StrOpt( cfg.StrOpt(
@ -102,11 +101,6 @@ share_servers_handling_mode_opts = [
help="Attach share server directly to share network. " help="Attach share server directly to share network. "
"Used only with Neutron and " "Used only with Neutron and "
"if driver_handles_share_servers=True."), "if driver_handles_share_servers=True."),
cfg.StrOpt(
"service_instance_network_helper_type",
default=NEUTRON_NAME,
help="Allowed values are %s. " % [NOVA_NAME, NEUTRON_NAME] +
"Only used if driver_handles_share_servers=True."),
cfg.StrOpt( cfg.StrOpt(
"admin_network_id", "admin_network_id",
help="ID of neutron network used to communicate with admin network," help="ID of neutron network used to communicate with admin network,"
@ -183,22 +177,12 @@ class ServiceInstanceManager(object):
return CONF.get(key) return CONF.get(key)
def _get_network_helper(self): def _get_network_helper(self):
network_helper_type = ( # Historically, there were multiple types of network helper,
self.get_config_option( # but currently the only network helper type is Neutron.
"service_instance_network_helper_type").lower()) return NeutronNetworkHelper(self)
if network_helper_type == NEUTRON_NAME:
return NeutronNetworkHelper(self)
elif network_helper_type == NOVA_NAME:
return NovaNetworkHelper(self)
else:
raise exception.ManilaException(
_("Wrong value '%(provided)s' for config opt "
"'service_instance_network_helper_type'. "
"Allowed values are %(allowed)s.") % dict(
provided=network_helper_type,
allowed=[NOVA_NAME, NEUTRON_NAME]))
def __init__(self, driver_config=None): def __init__(self, driver_config=None):
super(ServiceInstanceManager, self).__init__() super(ServiceInstanceManager, self).__init__()
self.driver_config = driver_config self.driver_config = driver_config
@ -558,32 +542,20 @@ class ServiceInstanceManager(object):
security_group = self._get_or_create_security_group(context) security_group = self._get_or_create_security_group(context)
if security_group: if security_group:
if self.network_helper.NAME == NOVA_NAME: sg_id = security_group.id
# NOTE(vponomaryov): Nova-network allows to assign
# secgroups only by names.
sg_id = security_group.name
else:
sg_id = security_group.id
LOG.debug( LOG.debug(
"Adding security group '%(sg)s' to server '%(si)s'.", "Adding security group '%(sg)s' to server '%(si)s'.",
dict(sg=sg_id, si=service_instance["id"])) dict(sg=sg_id, si=service_instance["id"]))
self.compute_api.add_security_group_to_server( self.compute_api.add_security_group_to_server(
context, service_instance["id"], sg_id) context, service_instance["id"], sg_id)
if self.network_helper.NAME == NEUTRON_NAME: ip = (network_data.get('service_port',
ip = (network_data.get('service_port', network_data.get(
network_data.get( 'admin_port'))['fixed_ips'])
'admin_port'))['fixed_ips']) service_instance['ip'] = ip[0]['ip_address']
service_instance['ip'] = ip[0]['ip_address'] public_ip = (network_data.get('public_port', network_data.get(
public_ip = (network_data.get( 'service_port'))['fixed_ips'])
'public_port', network_data.get( service_instance['public_address'] = public_ip[0]['ip_address']
'service_port'))['fixed_ips'])
service_instance['public_address'] = public_ip[0]['ip_address']
else:
net_name = self.network_helper.get_network_name(network_info)
service_instance['ip'] = self._get_server_ip(
service_instance, net_name)
service_instance['public_address'] = service_instance['ip']
except Exception as e: except Exception as e:
e.detail_data = {'server_details': fail_safe_data} e.detail_data = {'server_details': fail_safe_data}
@ -1087,50 +1059,3 @@ class NeutronNetworkHelper(BaseNetworkhelper):
for subnet_id in service_network['subnets']: for subnet_id in service_network['subnets']:
subnets.append(self.neutron_api.get_subnet(subnet_id)) subnets.append(self.neutron_api.get_subnet(subnet_id))
return subnets return subnets
class NovaNetworkHelper(BaseNetworkhelper):
"""Nova network helper for Manila service instances.
All security-group rules are applied to all interfaces of Nova VM
using Nova-network. In that case there is no need to create additional
service network. Only one thing should be satisfied - Manila host
should have access to all tenant networks.
This network helper does not create resources.
"""
def __init__(self, service_instance_manager):
self.compute_api = service_instance_manager.compute_api
self.admin_context = service_instance_manager.admin_context
@property
def NAME(self):
return NOVA_NAME
def setup_network(self, network_info):
net = self._get_nova_network(network_info['nova_net_id'])
network_info['nics'] = [{'net-id': net['id']}]
return network_info
def get_network_name(self, network_info):
"""Returns name of network for service instance."""
return self._get_nova_network(network_info['nova_net_id'])['label']
def teardown_network(self, server_details):
"""Nothing to do. Placeholder."""
def setup_connectivity_with_service_instances(self):
"""Nothing to do. Placeholder."""
def _get_nova_network(self, nova_network_id):
"""Returns network to be used for service instance.
:param nova_network_id: string with id of network.
:returns: dict -- network data as dict
:raises: exception.ManilaException
"""
if not nova_network_id:
raise exception.ManilaException(
_('Nova network for service instance is not provided.'))
net = self.compute_api.network_get(self.admin_context, nova_network_id)
return net

View File

@ -67,8 +67,6 @@ def fake_get_config_option(key):
return '99.254.0.0/24' return '99.254.0.0/24'
elif key == 'service_network_division_mask': elif key == 'service_network_division_mask':
return 27 return 27
elif key == 'service_instance_network_helper_type':
return service_instance.NEUTRON_NAME
elif key == 'service_network_name': elif key == 'service_network_name':
return 'fake_service_network_name' return 'fake_service_network_name'
elif key == 'interface_driver': elif key == 'interface_driver':
@ -97,7 +95,7 @@ class FakeNetworkHelper(service_instance.BaseNetworkhelper):
@property @property
def NAME(self): def NAME(self):
return self.get_config_option("service_instance_network_helper_type") return service_instance.NEUTRON_NAME
def __init__(self, service_instance_manager): def __init__(self, service_instance_manager):
self.get_config_option = service_instance_manager.get_config_option self.get_config_option = service_instance_manager.get_config_option
@ -131,8 +129,6 @@ class ServiceInstanceManagerTestCase(test.TestCase):
service_instance.os.path, 'exists', mock.Mock(return_value=True)) service_instance.os.path, 'exists', mock.Mock(return_value=True))
self.mock_object(service_instance, 'NeutronNetworkHelper', self.mock_object(service_instance, 'NeutronNetworkHelper',
mock.Mock(side_effect=FakeNetworkHelper)) mock.Mock(side_effect=FakeNetworkHelper))
self.mock_object(service_instance, 'NovaNetworkHelper',
mock.Mock(side_effect=FakeNetworkHelper))
self._manager = service_instance.ServiceInstanceManager(self.config) self._manager = service_instance.ServiceInstanceManager(self.config)
self._manager._execute = mock.Mock(return_value=('', '')) self._manager._execute = mock.Mock(return_value=('', ''))
self.mock_object(time, 'sleep') self.mock_object(time, 'sleep')
@ -159,64 +155,23 @@ class ServiceInstanceManagerTestCase(test.TestCase):
result = self._manager.get_config_option('service_instance_user') result = self._manager.get_config_option('service_instance_user')
self.assertEqual(username, result) self.assertEqual(username, result)
def test_get_nova_network_helper(self):
# Mock it again, because one of these was called in setUp method.
self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(DEFAULT=dict(
service_instance_user='fake_username',
driver_handles_share_servers=True,
service_instance_network_helper_type=service_instance.NOVA_NAME))
with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager()
self._manager.network_helper
service_instance.NovaNetworkHelper.assert_called_once_with(
self._manager)
self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_get_neutron_network_helper(self): def test_get_neutron_network_helper(self):
# Mock it again, because one of these was called in setUp method. # Mock it again, because it was called in setUp method.
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper') config_data = dict(DEFAULT=dict(service_instance_user='fake_username',
config_data = dict(DEFAULT=dict( driver_handles_share_servers=True))
service_instance_user='fake_username',
driver_handles_share_servers=True,
service_instance_network_helper_type=service_instance.NEUTRON_NAME)
)
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager() self._manager = service_instance.ServiceInstanceManager()
self._manager.network_helper self._manager.network_helper
service_instance.NeutronNetworkHelper.assert_called_once_with( service_instance.NeutronNetworkHelper.assert_called_once_with(
self._manager) self._manager)
self.assertFalse(service_instance.NovaNetworkHelper.called)
@ddt.data(
None, '', 'fake', service_instance.NOVA_NAME + '_as_prefix',
service_instance.NEUTRON_NAME + '_as_prefix',
'as_suffix_' + service_instance.NOVA_NAME,
'as_suffix_' + service_instance.NEUTRON_NAME)
def test_get_fake_network_helper(self, value):
# Mock it again, because one of these was called in setUp method.
self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(DEFAULT=dict(
service_instance_user='fake_username',
driver_handles_share_servers=True,
service_instance_network_helper_type=value))
with test_utils.create_temp_config_with_opts(config_data):
manager = service_instance.ServiceInstanceManager()
self.assertRaises(exception.ManilaException,
lambda: manager.network_helper)
self.assertFalse(service_instance.NeutronNetworkHelper.called)
self.assertFalse(service_instance.NovaNetworkHelper.called)
def test_init_with_driver_config_and_handling_of_share_servers(self): def test_init_with_driver_config_and_handling_of_share_servers(self):
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(CUSTOM=dict( config_data = dict(CUSTOM=dict(
driver_handles_share_servers=True, driver_handles_share_servers=True,
service_instance_user='fake_user', service_instance_user='fake_user'))
service_instance_network_helper_type=service_instance.NOVA_NAME))
opts = service_instance.common_opts + driver.share_opts opts = service_instance.common_opts + driver.share_opts
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self.config = configuration.Configuration(opts, 'CUSTOM') self.config = configuration.Configuration(opts, 'CUSTOM')
@ -226,12 +181,10 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self._manager.get_config_option("driver_handles_share_servers")) self._manager.get_config_option("driver_handles_share_servers"))
self.assertIsNotNone(self._manager.driver_config) self.assertIsNotNone(self._manager.driver_config)
self.assertTrue(hasattr(self._manager, 'network_helper')) self.assertTrue(hasattr(self._manager, 'network_helper'))
self.assertTrue(service_instance.NovaNetworkHelper.called) self.assertTrue(service_instance.NeutronNetworkHelper.called)
self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_init_with_driver_config_and_wo_handling_of_share_servers(self): def test_init_with_driver_config_and_wo_handling_of_share_servers(self):
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(CUSTOM=dict( config_data = dict(CUSTOM=dict(
driver_handles_share_servers=False, driver_handles_share_servers=False,
service_instance_user='fake_user')) service_instance_user='fake_user'))
@ -242,28 +195,23 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self.config) self.config)
self.assertIsNotNone(self._manager.driver_config) self.assertIsNotNone(self._manager.driver_config)
self.assertFalse(hasattr(self._manager, 'network_helper')) self.assertFalse(hasattr(self._manager, 'network_helper'))
self.assertFalse(service_instance.NovaNetworkHelper.called)
self.assertFalse(service_instance.NeutronNetworkHelper.called) self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_init_with_common_config_and_handling_of_share_servers(self): def test_init_with_common_config_and_handling_of_share_servers(self):
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(DEFAULT=dict( config_data = dict(DEFAULT=dict(
service_instance_user='fake_username', service_instance_user='fake_username',
driver_handles_share_servers=True, driver_handles_share_servers=True))
service_instance_network_helper_type=service_instance.NOVA_NAME))
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager() self._manager = service_instance.ServiceInstanceManager()
self.assertTrue( self.assertTrue(
self._manager.get_config_option("driver_handles_share_servers")) self._manager.get_config_option("driver_handles_share_servers"))
self.assertIsNone(self._manager.driver_config) self.assertIsNone(self._manager.driver_config)
self.assertTrue(hasattr(self._manager, 'network_helper')) self.assertTrue(hasattr(self._manager, 'network_helper'))
self.assertTrue(service_instance.NovaNetworkHelper.called) self.assertTrue(service_instance.NeutronNetworkHelper.called)
self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_init_with_common_config_and_wo_handling_of_share_servers(self): def test_init_with_common_config_and_wo_handling_of_share_servers(self):
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(DEFAULT=dict( config_data = dict(DEFAULT=dict(
service_instance_user='fake_username', service_instance_user='fake_username',
driver_handles_share_servers=False)) driver_handles_share_servers=False))
@ -274,7 +222,6 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self._manager.get_config_option("driver_handles_share_servers")) self._manager.get_config_option("driver_handles_share_servers"))
self.assertIsNone(self._manager.driver_config) self.assertIsNone(self._manager.driver_config)
self.assertFalse(hasattr(self._manager, 'network_helper')) self.assertFalse(hasattr(self._manager, 'network_helper'))
self.assertFalse(service_instance.NovaNetworkHelper.called)
self.assertFalse(service_instance.NeutronNetworkHelper.called) self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_no_service_user_defined(self): def test_no_service_user_defined(self):
@ -290,11 +237,9 @@ class ServiceInstanceManagerTestCase(test.TestCase):
def test_get_service_instance_name_using_driver_config(self): def test_get_service_instance_name_using_driver_config(self):
fake_server_id = 'fake_share_server_id_%s' % self.id() fake_server_id = 'fake_share_server_id_%s' % self.id()
self.mock_object(service_instance, 'NeutronNetworkHelper') self.mock_object(service_instance, 'NeutronNetworkHelper')
self.mock_object(service_instance, 'NovaNetworkHelper')
config_data = dict(CUSTOM=dict( config_data = dict(CUSTOM=dict(
driver_handles_share_servers=True, driver_handles_share_servers=True,
service_instance_user='fake_user', service_instance_user='fake_user'))
service_instance_network_helper_type=service_instance.NOVA_NAME))
opts = service_instance.common_opts + driver.share_opts opts = service_instance.common_opts + driver.share_opts
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self.config = configuration.Configuration(opts, 'CUSTOM') self.config = configuration.Configuration(opts, 'CUSTOM')
@ -310,14 +255,12 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self.assertTrue( self.assertTrue(
self._manager.get_config_option("driver_handles_share_servers")) self._manager.get_config_option("driver_handles_share_servers"))
self.assertTrue(hasattr(self._manager, 'network_helper')) self.assertTrue(hasattr(self._manager, 'network_helper'))
self.assertTrue(service_instance.NovaNetworkHelper.called) self.assertTrue(service_instance.NeutronNetworkHelper.called)
self.assertFalse(service_instance.NeutronNetworkHelper.called)
def test_get_service_instance_name_using_default_config(self): def test_get_service_instance_name_using_default_config(self):
fake_server_id = 'fake_share_server_id_%s' % self.id() fake_server_id = 'fake_share_server_id_%s' % self.id()
config_data = dict(CUSTOM=dict( config_data = dict(CUSTOM=dict(
service_instance_user='fake_user', service_instance_user='fake_user'))
service_instance_network_helper_type=service_instance.NOVA_NAME))
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager() self._manager = service_instance.ServiceInstanceManager()
result = self._manager._get_service_instance_name(fake_server_id) result = self._manager._get_service_instance_name(fake_server_id)
@ -943,16 +886,12 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self.assertTrue( self.assertTrue(
self._manager.compute_api.server_get_by_name_or_id.called) self._manager.compute_api.server_get_by_name_or_id.called)
@ddt.data(service_instance.NOVA_NAME, service_instance.NEUTRON_NAME) def test___create_service_instance_with_sg_success(self):
def test___create_service_instance_with_sg_success(self, helper_type):
self.mock_object(service_instance, 'NeutronNetworkHelper', self.mock_object(service_instance, 'NeutronNetworkHelper',
mock.Mock(side_effect=FakeNetworkHelper)) mock.Mock(side_effect=FakeNetworkHelper))
self.mock_object(service_instance, 'NovaNetworkHelper',
mock.Mock(side_effect=FakeNetworkHelper))
config_data = dict(DEFAULT=dict( config_data = dict(DEFAULT=dict(
driver_handles_share_servers=True, driver_handles_share_servers=True,
service_instance_user='fake_user', service_instance_user='fake_user'))
service_instance_network_helper_type=helper_type))
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager() self._manager = service_instance.ServiceInstanceManager()
@ -965,19 +904,17 @@ class ServiceInstanceManagerTestCase(test.TestCase):
instance_name = 'fake_instance_name' instance_name = 'fake_instance_name'
network_info = dict() network_info = dict()
network_data = {'nics': ['fake_nic1', 'fake_nic2']} network_data = {'nics': ['fake_nic1', 'fake_nic2']}
if helper_type == service_instance.NEUTRON_NAME: network_data['router'] = dict(id='fake_router_id')
network_data['router'] = dict(id='fake_router_id')
server_get = dict( server_get = dict(
id='fakeid', status='ACTIVE', networks={net_name: [ip_address]}) id='fakeid', status='ACTIVE', networks={net_name: [ip_address]})
if helper_type == service_instance.NEUTRON_NAME: network_data.update(dict(
network_data.update(dict( router_id='fake_router_id', subnet_id='fake_subnet_id',
router_id='fake_router_id', subnet_id='fake_subnet_id', public_port=dict(id='fake_public_port',
public_port=dict(id='fake_public_port', fixed_ips=[dict(ip_address=ip_address)]),
fixed_ips=[dict(ip_address=ip_address)]), service_port=dict(id='fake_service_port',
service_port=dict(id='fake_service_port', fixed_ips=[{'ip_address': ip_address}]),
fixed_ips=[{'ip_address': ip_address}]), admin_port={'id': 'fake_admin_port',
admin_port={'id': 'fake_admin_port', 'fixed_ips': [{'ip_address': ip_address}]}))
'fixed_ips': [{'ip_address': ip_address}]}))
self.mock_object(service_instance.time, 'time', self.mock_object(service_instance.time, 'time',
mock.Mock(return_value=5)) mock.Mock(return_value=5))
self.mock_object(self._manager.network_helper, 'setup_network', self.mock_object(self._manager.network_helper, 'setup_network',
@ -1005,13 +942,13 @@ class ServiceInstanceManagerTestCase(test.TestCase):
'subnet_id': network_data.get('subnet_id'), 'subnet_id': network_data.get('subnet_id'),
'instance_id': server_get['id'], 'instance_id': server_get['id'],
'ip': ip_address, 'ip': ip_address,
'networks': server_get['networks']} 'networks': server_get['networks'],
if helper_type == service_instance.NEUTRON_NAME: 'router_id': network_data['router']['id'],
expected['router_id'] = network_data['router']['id'] 'public_port_id': 'fake_public_port',
expected['public_port_id'] = 'fake_public_port' 'service_port_id': 'fake_service_port',
expected['service_port_id'] = 'fake_service_port' 'admin_port_id': 'fake_admin_port',
expected['admin_port_id'] = 'fake_admin_port' 'admin_ip': 'fake_ip_address',
expected['admin_ip'] = 'fake_ip_address' }
result = self._manager._create_service_instance( result = self._manager._create_service_instance(
self._manager.admin_context, instance_name, network_info) self._manager.admin_context, instance_name, network_info)
@ -1033,26 +970,17 @@ class ServiceInstanceManagerTestCase(test.TestCase):
availability_zone=service_instance.CONF.storage_availability_zone) availability_zone=service_instance.CONF.storage_availability_zone)
self._manager.compute_api.server_get.assert_called_once_with( self._manager.compute_api.server_get.assert_called_once_with(
self._manager.admin_context, server_create['id']) self._manager.admin_context, server_create['id'])
if helper_type == service_instance.NEUTRON_NAME: self._manager.compute_api.add_security_group_to_server.\
self._manager.compute_api.add_security_group_to_server.\ assert_called_once_with(
assert_called_once_with( self._manager.admin_context, server_get['id'], sg.id)
self._manager.admin_context, server_get['id'], sg.id) self._manager.network_helper.get_network_name.assert_has_calls([])
self._manager.network_helper.get_network_name.assert_has_calls([])
else:
self._manager.compute_api.add_security_group_to_server.\
assert_called_once_with(
self._manager.admin_context, server_get['id'], sg.name)
self._manager.network_helper.get_network_name.\
assert_called_once_with(network_info)
def test___create_service_instance_neutron_no_admin_ip(self): def test___create_service_instance_neutron_no_admin_ip(self):
self.mock_object(service_instance, 'NeutronNetworkHelper', self.mock_object(service_instance, 'NeutronNetworkHelper',
mock.Mock(side_effect=FakeNetworkHelper)) mock.Mock(side_effect=FakeNetworkHelper))
config_data = {'DEFAULT': { config_data = {'DEFAULT': {
'driver_handles_share_servers': True, 'driver_handles_share_servers': True,
'service_instance_user': 'fake_user', 'service_instance_user': 'fake_user'}}
'service_instance_network_helper_type': (
service_instance.NEUTRON_NAME)}}
with test_utils.create_temp_config_with_opts(config_data): with test_utils.create_temp_config_with_opts(config_data):
self._manager = service_instance.ServiceInstanceManager() self._manager = service_instance.ServiceInstanceManager()
@ -2333,65 +2261,3 @@ class NeutronNetworkHelperTestCase(test.TestCase):
instance.service_network_id) instance.service_network_id)
instance.neutron_api.get_subnet.assert_has_calls([ instance.neutron_api.get_subnet.assert_has_calls([
mock.call(subnet_id1), mock.call(subnet_id2)]) mock.call(subnet_id1), mock.call(subnet_id2)])
@ddt.ddt
class NovaNetworkHelperTestCase(test.TestCase):
"""Tests Nova network helper for service instance."""
def setUp(self):
super(NovaNetworkHelperTestCase, self).setUp()
self.fake_manager = FakeServiceInstance()
def test_init(self):
instance = service_instance.NovaNetworkHelper(self.fake_manager)
self.assertEqual(service_instance.NOVA_NAME, instance.NAME)
self.assertIsNone(instance.teardown_network('fake'))
self.assertIsNone(
instance.setup_connectivity_with_service_instances())
def test_get_network_name(self):
network_info = dict(nova_net_id='fake_nova_net_id')
network = dict(label='fake_network')
instance = service_instance.NovaNetworkHelper(self.fake_manager)
self.mock_object(instance.compute_api, 'network_get',
mock.Mock(return_value=network))
result = instance.get_network_name(network_info)
self.assertEqual(network['label'], result)
instance.compute_api.network_get.assert_called_once_with(
instance.admin_context, network_info['nova_net_id'])
@ddt.data(None, [], {}, '')
def test_get_network_name_invalid(self, net_name):
network_info = dict(nova_net_id=net_name)
instance = service_instance.NovaNetworkHelper(self.fake_manager)
self.assertRaises(
exception.ManilaException, instance.get_network_name, network_info)
def test_setup_network(self):
network_info = dict(nova_net_id='fake_nova_net_id')
network = dict(label='fake_network', id='fake_network_id',
gateway='fake_gateway_ip')
instance = service_instance.NovaNetworkHelper(self.fake_manager)
self.mock_object(instance.compute_api, 'network_get',
mock.Mock(return_value=network))
expected = {
'nova_net_id': network_info['nova_net_id'],
'nics': [{'net-id': network['id']}]}
result = instance.setup_network(network_info)
self.assertEqual(expected, result)
instance.compute_api.network_get.assert_called_once_with(
instance.admin_context, network_info['nova_net_id'])
@ddt.data(None, [], {}, '')
def test_setup_network_invalid(self, net_name):
network_info = dict(nova_net_id=net_name)
instance = service_instance.NovaNetworkHelper(self.fake_manager)
self.assertRaises(
exception.ManilaException, instance.get_network_name, network_info)

View File

@ -0,0 +1,5 @@
---
upgrade:
- Removed nova net support from the service instance module since
legacy nova networking was deprecated in Newton and is no longer
supported in regular deployments in Ocata.