Merge "SR-IOV: Remove deprecated supported_pci_vendor_devs option"

This commit is contained in:
Jenkins 2016-11-01 15:00:16 +00:00 committed by Gerrit Code Review
commit d42f948a80
5 changed files with 1 additions and 194 deletions

View File

@ -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)

View File

@ -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',

View File

@ -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)

View File

@ -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)

View File

@ -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