diff --git a/nova/conf/network.py b/nova/conf/network.py index 5e651e7e479a..b4149d5056b7 100644 --- a/nova/conf/network.py +++ b/nova/conf/network.py @@ -257,12 +257,6 @@ with the name 'mtu'. None """), - cfg.StrOpt('network_api_class', - default=NOVA_NET_API, - help='DEPRECATED: The full class name of the ' - 'network API class to use. ``use_neutron`` ' - 'should be used instead.', - deprecated_for_removal=True), cfg.BoolOpt('use_neutron', default=False, help="Whether to use Neutron or Nova Network as the back end " diff --git a/nova/network/__init__.py b/nova/network/__init__.py index 18ee8c9ff364..3ce9a4f4993c 100644 --- a/nova/network/__init__.py +++ b/nova/network/__init__.py @@ -18,7 +18,6 @@ from oslo_log import log as logging from oslo_utils import importutils import nova.conf -from nova.i18n import _LW LOG = logging.getLogger(__name__) @@ -34,31 +33,11 @@ def is_neutron(): This logic exists as a separate config option """ - legacy_class = CONF.network_api_class - use_neutron = CONF.use_neutron - - if legacy_class not in (NEUTRON_NET_API, NOVA_NET_API): - # Someone actually used this option, this gets a pass for now, - # but will just go away once deleted. - return None - elif legacy_class == NEUTRON_NET_API and not use_neutron: - # If they specified neutron via class, we should respect that - LOG.warn(_LW("Config mismatch. The network_api_class specifies %s, " - "however use_neutron is not set to True. Using Neutron " - "networking for now, however please set use_neutron to " - "True in your configuration as network_api_class is " - "deprecated and will be removed."), legacy_class) - return True - elif use_neutron: - return True - else: - return False + return CONF.use_neutron def API(): - if is_neutron() is None: - network_api_class = CONF.network_api_class - elif is_neutron(): + if is_neutron(): network_api_class = NEUTRON_NET_API else: network_api_class = NOVA_NET_API diff --git a/nova/tests/unit/network/test_config.py b/nova/tests/unit/network/test_config.py index 0baa4c88c9d8..041bf29022eb 100644 --- a/nova/tests/unit/network/test_config.py +++ b/nova/tests/unit/network/test_config.py @@ -40,20 +40,6 @@ class NetworkAPIConfigTest(nova.test.NoDBTestCase): netapi = nova.network.API() self.assertIsInstance(netapi, nova.network.api.API) - def test_legacy_use_neutron(self): - """use neutron even if config is false because of legacy option.""" - self.flags(use_neutron=False) - self.flags(network_api_class='nova.network.neutronv2.api.API') - netapi = nova.network.API() - self.assertIsInstance(netapi, nova.network.neutronv2.api.API) - - def test_legacy_custom_class(self): - """use neutron even if config is false because of legacy option.""" - self.flags(network_api_class= - 'nova.tests.unit.network.test_config.FileATicket') - netapi = nova.network.API() - self.assertIsInstance(netapi, FileATicket) - class SecurityGroupAPIConfigTest(nova.test.NoDBTestCase): diff --git a/nova/tests/unit/virt/hyperv/test_vmops.py b/nova/tests/unit/virt/hyperv/test_vmops.py index 0df6de62a7fc..9f09d7c1a2a6 100644 --- a/nova/tests/unit/virt/hyperv/test_vmops.py +++ b/nova/tests/unit/virt/hyperv/test_vmops.py @@ -85,18 +85,6 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_import_object.assert_called_once_with( vmops.NOVA_VIF_DRIVER) - @mock.patch('nova.network.is_neutron') - def test_load_vif_driver_unknown(self, is_neutron): - # TODO(sdague): delete once network_api_class is removed from - # config. - is_neutron.return_value = None - self.assertRaises(TypeError, self._vmops._load_vif_driver_class) - - @mock.patch('nova.virt.hyperv.vmops.importutils.import_object') - def test_load_vif_driver_class_error(self, mock_import_object): - mock_import_object.side_effect = KeyError - self.assertRaises(TypeError, self._vmops._load_vif_driver_class) - def test_list_instances(self): mock_instance = mock.MagicMock() self._vmops._vmutils.list_instances.return_value = [mock_instance] diff --git a/nova/utils.py b/nova/utils.py index eeeb8ea1c9d1..46d169a6f626 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -1093,10 +1093,7 @@ def is_neutron(): if _IS_NEUTRON is not None: return _IS_NEUTRON - # TODO(sdague): As long as network_api_class is importable - # is_neutron can return None to mean we have no idea what their - # class is. - _IS_NEUTRON = (nova.network.is_neutron() is True) + _IS_NEUTRON = nova.network.is_neutron() return _IS_NEUTRON diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py index 49031b3b7994..027925c300ca 100644 --- a/nova/virt/hyperv/vmops.py +++ b/nova/virt/hyperv/vmops.py @@ -85,10 +85,7 @@ NOVA_VIF_DRIVER = 'nova.virt.hyperv.vif.HyperVNovaNetworkVIFDriver' def get_network_driver(): """"Return the correct network module""" - if nova.network.is_neutron() is None: - # this is an unknown network type, not neutron or nova - raise KeyError() - elif nova.network.is_neutron(): + if nova.network.is_neutron(): return NEUTRON_VIF_DRIVER else: return NOVA_VIF_DRIVER @@ -115,13 +112,8 @@ class VMOps(object): self._load_vif_driver_class() def _load_vif_driver_class(self): - try: - class_name = get_network_driver() - self._vif_driver = importutils.import_object(class_name) - except KeyError: - raise TypeError(_("VIF driver not found for " - "network_api_class: %s") % - CONF.network_api_class) + class_name = get_network_driver() + self._vif_driver = importutils.import_object(class_name) def list_instance_uuids(self): instance_uuids = [] diff --git a/releasenotes/notes/network-api-class-removed-a4a754ca24c02bde.yaml b/releasenotes/notes/network-api-class-removed-a4a754ca24c02bde.yaml new file mode 100644 index 000000000000..a8b78c388ee1 --- /dev/null +++ b/releasenotes/notes/network-api-class-removed-a4a754ca24c02bde.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - The network_api_class option was deprecated in Mitaka and is removed + in Newton. The use_neutron option replaces this functionality.