From e8fd2505e29eb620e102d73af71a25d2162604ce Mon Sep 17 00:00:00 2001 From: Edan David Date: Mon, 31 Oct 2016 13:58:48 +0000 Subject: [PATCH] SR-IOV: Remove deprecated supported_pci_vendor_devs option The SR-IOV option supported_pci_vendor_devs has been deprecated in Newton and This change removes it from Ocata. Change-Id: I42dadfd0b62730ca2d34d37cb63f19f6fec75567 --- neutron/cmd/sanity_check.py | 3 - neutron/opts.py | 9 -- .../mech_sriov/mech_driver/mech_driver.py | 62 +-------- .../mech_driver/test_mech_sriov_nic_switch.py | 120 ------------------ setup.cfg | 1 - 5 files changed, 1 insertion(+), 194 deletions(-) diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index 8b2bd601766..9e56c75f182 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -36,9 +36,6 @@ def setup_conf(): cfg.CONF.import_group('VXLAN', 'neutron.plugins.ml2.drivers.linuxbridge.' 'agent.common.config') cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config') - cfg.CONF.import_group('ml2_sriov', - 'neutron.plugins.ml2.drivers.mech_sriov.mech_driver.' - 'mech_driver') cfg.CONF.import_group('SECURITYGROUP', 'neutron.agent.securitygroups_rpc') dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS) diff --git a/neutron/opts.py b/neutron/opts.py index 639e25453e1..08a9e06e013 100644 --- a/neutron/opts.py +++ b/neutron/opts.py @@ -54,7 +54,6 @@ import neutron.extensions.securitygroup import neutron.plugins.ml2.config import neutron.plugins.ml2.drivers.macvtap.agent.config import neutron.plugins.ml2.drivers.mech_sriov.agent.common.config -import neutron.plugins.ml2.drivers.mech_sriov.mech_driver.mech_driver import neutron.plugins.ml2.drivers.openvswitch.agent.common.config import neutron.wsgi @@ -257,14 +256,6 @@ def list_ml2_conf_opts(): ] -def list_ml2_conf_sriov_opts(): - return [ - ('ml2_sriov', - neutron.plugins.ml2.drivers.mech_sriov.mech_driver.mech_driver. - sriov_opts) - ] - - def list_ovs_opts(): return [ ('ovs', diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index 93107a14c0e..fe09950b784 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -14,10 +14,9 @@ # limitations under the License. from neutron_lib import constants -from oslo_config import cfg from oslo_log import log -from neutron._i18n import _, _LE, _LW +from neutron._i18n import _LW from neutron.extensions import portbindings from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import driver_api as api @@ -32,22 +31,6 @@ VIF_TYPE_HW_VEB = 'hw_veb' VIF_TYPE_HOSTDEV_PHY = 'hostdev_physical' FLAT_VLAN = 0 -sriov_opts = [ - cfg.ListOpt('supported_pci_vendor_devs', - help=_("Comma-separated list of supported PCI vendor devices, " - "as defined by vendor_id:product_id according to the " - "PCI ID Repository. Default None accept all PCI vendor " - "devices" - "DEPRECATED: This option is deprecated in the Newton " - "release and will be removed in the Ocata release. " - "Starting from Ocata the mechanism driver will accept " - "all PCI vendor devices."), - deprecated_for_removal=True), - -] - -cfg.CONF.register_opts(sriov_opts, "ml2_sriov") - class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): """Mechanism Driver for SR-IOV capable NIC based switching. @@ -95,15 +78,6 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): def get_mappings(self, agent): return agent['configurations'].get('device_mappings', {}) - def initialize(self): - try: - self.pci_vendor_info = cfg.CONF.ml2_sriov.supported_pci_vendor_devs - if self.pci_vendor_info is not None: - self._check_pci_vendor_config(self.pci_vendor_info) - except ValueError: - LOG.exception(_LE("Failed to parse supported PCI vendor devices")) - raise cfg.Error(_("Parsing supported pci_vendor_devs failed")) - def bind_port(self, context): LOG.debug("Attempting to bind port %(port)s on " "network %(network)s", @@ -116,10 +90,6 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): vnic_type) return - if not self._check_supported_pci_vendor_device(context): - LOG.debug("Refusing to bind due to unsupported pci_vendor device") - return - if vnic_type == portbindings.VNIC_DIRECT_PHYSICAL: # Physical functions don't support things like QoS properties, # spoof checking, etc. so we might as well side-step the agent @@ -183,24 +153,6 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): """SR-IOV driver vlan transparency support.""" return True - def _check_supported_pci_vendor_device(self, context): - if self.pci_vendor_info is None: - return True - if self.pci_vendor_info: - profile = context.current.get(portbindings.PROFILE, {}) - if not profile: - LOG.debug("Missing profile in port binding") - return False - pci_vendor_info = profile.get('pci_vendor_info') - if not pci_vendor_info: - LOG.debug("Missing pci vendor info in profile") - return False - if pci_vendor_info not in self.pci_vendor_info: - LOG.debug("Unsupported pci_vendor %s", pci_vendor_info) - return False - return True - return False - def _get_vif_details(self, segment): network_type = segment[api.NETWORK_TYPE] if network_type == p_const.TYPE_FLAT: @@ -212,15 +164,3 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): vif_details = self.vif_details.copy() vif_details[portbindings.VIF_DETAILS_VLAN] = str(vlan_id) return vif_details - - @staticmethod - def _check_pci_vendor_config(pci_vendor_list): - for pci_vendor_info in pci_vendor_list: - try: - vendor_id, product_id = [ - item.strip() for item in pci_vendor_info.split(':') - if item.strip()] - except ValueError: - raise ValueError(_('Incorrect pci_vendor_info: "%s", should be' - ' pair vendor_id:product_id') % - pci_vendor_info) diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py index 3460a1945b6..aba559d4ced 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py @@ -13,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock from neutron_lib import constants -from oslo_config import cfg import testtools from neutron.extensions import portbindings from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import config # noqa from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \ import exceptions as exc @@ -149,79 +146,6 @@ class SriovSwitchMechVnicTypeTestCase(SriovNicSwitchMechanismBaseTestCase): mech_driver.VIF_TYPE_HOSTDEV_PHY) -class SriovSwitchMechProfileTestCase(SriovNicSwitchMechanismBaseTestCase): - def _check_vif_for_pci_info(self, pci_vendor_info, expected_vif_type): - context = TestFakePortContext(self.AGENT_TYPE, - self.AGENTS, - self.VLAN_SEGMENTS, - portbindings.VNIC_DIRECT, - {'pci_vendor_info': pci_vendor_info}) - self.driver.bind_port(context) - self.assertEqual(expected_vif_type, context._bound_vif_type) - - def test_profile_supported_pci_info(self): - self._check_vif_for_pci_info(MELLANOX_CONNECTX3_PCI_INFO, - mech_driver.VIF_TYPE_HW_VEB) - - def test_profile_unsupported_pci_info(self): - cfg.CONF.set_override('supported_pci_vendor_devs', ['aa:bb'], - 'ml2_sriov') - self.driver.initialize() - with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.' - 'mech_driver.mech_driver.LOG') as log_mock: - self._check_vif_for_pci_info('xxxx:yyyy', None) - log_mock.debug.assert_called_with('Refusing to bind due to ' - 'unsupported pci_vendor device') - - -class SriovSwitchMechProfileFailTestCase(SriovNicSwitchMechanismBaseTestCase): - def _check_for_pci_vendor_info( - self, pci_vendor_info, expected_result=False): - context = TestFakePortContext(self.AGENT_TYPE, - self.AGENTS, - self.VLAN_SEGMENTS, - portbindings.VNIC_DIRECT, - pci_vendor_info) - self.assertEqual( - expected_result, - self.driver._check_supported_pci_vendor_device(context)) - - def test_profile_missing_profile(self): - cfg.CONF.set_override('supported_pci_vendor_devs', ['aa:bb'], - 'ml2_sriov') - self.driver.initialize() - with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.' - 'mech_driver.mech_driver.LOG') as log_mock: - self._check_for_pci_vendor_info({}) - log_mock.debug.assert_called_with("Missing profile in port" - " binding") - - def test_profile_missing_pci_vendor_info(self): - cfg.CONF.set_override('supported_pci_vendor_devs', ['aa:bb'], - 'ml2_sriov') - self.driver.initialize() - with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.' - 'mech_driver.mech_driver.LOG') as log_mock: - self._check_for_pci_vendor_info({'aa': 'bb'}) - log_mock.debug.assert_called_with("Missing pci vendor" - " info in profile") - - def test_pci_vendor_info_with_none(self): - self.driver.initialize() - self._check_for_pci_vendor_info( - {'aa': 'bb'}, expected_result=True) - - def test_pci_vendor_info(self): - cfg.CONF.set_override( - 'supported_pci_vendor_devs', - [MELLANOX_CONNECTX3_PCI_INFO], - 'ml2_sriov') - self.driver.initialize() - self._check_for_pci_vendor_info( - {'pci_vendor_info': MELLANOX_CONNECTX3_PCI_INFO}, - expected_result=True) - - class SriovSwitchMechVifDetailsTestCase(SriovNicSwitchMechanismBaseTestCase): VLAN_SEGMENTS = [{api.ID: 'vlan_segment_id', api.NETWORK_TYPE: 'vlan', @@ -268,47 +192,3 @@ class SriovSwitchMechVifDetailsTestCase(SriovNicSwitchMechanismBaseTestCase): self.driver.bind_port(context) self.assertEqual(constants.PORT_STATUS_ACTIVE, context._bound_state) - - -class SriovSwitchMechConfigTestCase(SriovNicSwitchMechanismBaseTestCase): - def _set_config(self, pci_devs=['aa:bb']): - cfg.CONF.set_override('mechanism_drivers', - ['logger', 'sriovnicswitch'], 'ml2') - if pci_devs: - cfg.CONF.set_override('supported_pci_vendor_devs', pci_devs, - 'ml2_sriov') - - def test_pci_vendor_config_single_entry(self): - self._set_config() - self.driver.initialize() - self.assertEqual(['aa:bb'], self.driver.pci_vendor_info) - - def test_pci_vendor_config_multiple_entry(self): - self._set_config(['x:y', 'a:b']) - self.driver.initialize() - self.assertEqual(['x:y', 'a:b'], self.driver.pci_vendor_info) - - def test_pci_vendor_config_wrong_entry(self): - self._set_config(['wrong_entry']) - self.assertRaises(cfg.Error, self.driver.initialize) - - def test_initialize_missing_product_id(self): - self._set_config(['vendor_id:']) - self.assertRaises(cfg.Error, self.driver.initialize) - - def test_initialize_missing_vendor_id(self): - self._set_config([':product_id']) - self.assertRaises(cfg.Error, self.driver.initialize) - - def test_initialize_multiple_colons(self): - self._set_config(['foo:bar:baz']) - self.assertRaises(cfg.Error, self.driver.initialize) - - def test_initialize_empty_string(self): - self._set_config(['']) - self.assertRaises(cfg.Error, self.driver.initialize) - - def test_initialize_pci_devs_none(self): - self._set_config(pci_devs=None) - self.driver.initialize() - self.assertIsNone(self.driver.pci_vendor_info) diff --git a/setup.cfg b/setup.cfg index 96e5ebe9d12..706fba2958c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -140,7 +140,6 @@ oslo.config.opts = neutron.ml2.linuxbridge.agent = neutron.opts:list_linux_bridge_opts neutron.ml2.macvtap.agent = neutron.opts:list_macvtap_opts neutron.ml2.ovs.agent = neutron.opts:list_ovs_opts - neutron.ml2.sriov = neutron.opts:list_ml2_conf_sriov_opts neutron.ml2.sriov.agent = neutron.opts:list_sriov_agent_opts neutron.qos = neutron.opts:list_qos_opts nova.auth = neutron.opts:list_auth_opts