Merge "supported_vnic_type configurable for sriov"

changes/36/601336/11
Zuul 4 years ago committed by Gerrit Code Review
commit c4f081d024
  1. 2
      doc/source/admin/config-ml2.rst
  2. 35
      neutron/conf/plugins/ml2/drivers/mech_sriov/mech_sriov_conf.py
  3. 6
      neutron/opts.py
  4. 16
      neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py
  5. 75
      neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py
  6. 9
      releasenotes/notes/make-supported-vnic-types-configurable-for-sriov-094f7663e8975e9b.yaml

@ -283,7 +283,7 @@ The ``vnic_type_blacklist`` option is used to remove values from the mechanism d
- yes (ovs_driver vnic_type_blacklist, see: `Configuration Reference <../configuration/ml2-conf.html#ovs_driver>`__)
* - SRIOV
- direct, macvtap, direct_physical
- no
- yes (sriov_driver vnic_type_blacklist, see: `Configuration Reference <../configuration/ml2-conf.html#sriov_driver>`__)
Extension Drivers

@ -0,0 +1,35 @@
# Copyright (c) 2018 Ericsson
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from neutron._i18n import _
sriov_driver_opts = [
cfg.ListOpt('vnic_type_blacklist',
default=[],
help=_("Comma-separated list of VNIC types for which support "
"is administratively prohibited by the mechanism "
"driver. Please note that the supported vnic_types "
"depend on your network interface card, on the kernel "
"version of your operating system, and on other "
"factors. "
"In case of sriov mechanism driver the valid "
"VNIC types are direct, macvtap and direct-physical.")),
]
def register_sriov_mech_driver_opts(cfg=cfg.CONF):
cfg.register_opts(sriov_driver_opts, "SRIOV_DRIVER")

@ -47,6 +47,7 @@ import neutron.conf.plugins.ml2.drivers.l2pop
import neutron.conf.plugins.ml2.drivers.linuxbridge
import neutron.conf.plugins.ml2.drivers.macvtap
import neutron.conf.plugins.ml2.drivers.mech_sriov.agent_common
import neutron.conf.plugins.ml2.drivers.mech_sriov.mech_sriov_conf
import neutron.conf.plugins.ml2.drivers.openvswitch.mech_ovs_conf
import neutron.conf.plugins.ml2.drivers.ovs_conf
import neutron.conf.quota
@ -259,7 +260,10 @@ def list_ml2_conf_opts():
neutron.conf.plugins.ml2.drivers.l2pop.l2_population_options),
('ovs_driver',
neutron.conf.plugins.ml2.drivers.openvswitch.mech_ovs_conf.
ovs_driver_opts)
ovs_driver_opts),
('sriov_driver',
neutron.conf.plugins.ml2.drivers.mech_sriov.mech_sriov_conf.
sriov_driver_opts)
]

@ -16,8 +16,11 @@
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
from oslo_log import log
from neutron.conf.plugins.ml2.drivers.mech_sriov import mech_sriov_conf
from neutron.plugins.ml2.drivers import mech_agent
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \
import exceptions as exc
@ -28,6 +31,9 @@ LOG = log.getLogger(__name__)
FLAT_VLAN = 0
mech_sriov_conf.register_sriov_mech_driver_opts()
class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
"""Mechanism Driver for SR-IOV capable NIC based switching.
@ -54,7 +60,15 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
:param supported_vnic_types: The binding:vnic_type values we can bind
"""
self.agent_type = agent_type
self.supported_vnic_types = supported_vnic_types
# TODO(lajoskatona): move this blacklisting to
# SimpleAgentMechanismDriverBase. By that e blacklisting and validation
# of the vnic_types would be available for all mechanism drivers.
self.supported_vnic_types = self.blacklist_supported_vnic_types(
vnic_types=supported_vnic_types,
blacklist=cfg.CONF.SRIOV_DRIVER.vnic_type_blacklist
)
# NOTE(ndipanov): PF passthrough requires a different vif type
self.vnic_type_for_vif_type = (
{vtype: portbindings.VIF_TYPE_HOSTDEV_PHY

@ -17,8 +17,10 @@ import mock
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
import testtools
from neutron.conf.plugins.ml2.drivers.mech_sriov import mech_sriov_conf
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \
import exceptions as exc
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver import mech_driver
@ -195,3 +197,76 @@ class SriovSwitchMechVifDetailsTestCase(SriovNicSwitchMechanismBaseTestCase):
self.driver.bind_port(context)
self.assertEqual(constants.PORT_STATUS_ACTIVE, context._bound_state)
class SriovSwitchMechVnicTypesTestCase(SriovNicSwitchMechanismBaseTestCase):
def setUp(self):
self.override_vnic_types = [portbindings.VNIC_DIRECT,
portbindings.VNIC_MACVTAP]
self.driver_with_vnic_types = \
mech_driver.SriovNicSwitchMechanismDriver(
supported_vnic_types=self.override_vnic_types)
self.default_supported_vnics = [
portbindings.VNIC_DIRECT,
portbindings.VNIC_MACVTAP,
portbindings.VNIC_DIRECT_PHYSICAL]
self.blacklist_cfg = {
'SRIOV_DRIVER': {
'vnic_type_blacklist': []
}
}
super(SriovSwitchMechVnicTypesTestCase, self).setUp()
def test_default_vnic_types(self):
self.assertEqual(self.default_supported_vnics,
self.driver.supported_vnic_types)
def test_override_default_vnic_types(self):
self.assertEqual(
self.override_vnic_types,
self.driver_with_vnic_types.supported_vnic_types)
def test_vnic_type_blacklist_valid_item(self):
self.blacklist_cfg['SRIOV_DRIVER']['vnic_type_blacklist'] = \
[portbindings.VNIC_MACVTAP]
fake_conf = cfg.CONF
fake_conf_fixture = base.MechDriverConfFixture(
fake_conf, self.blacklist_cfg,
mech_sriov_conf.register_sriov_mech_driver_opts)
self.useFixture(fake_conf_fixture)
test_driver = mech_driver.SriovNicSwitchMechanismDriver(
supported_vnic_types=self.default_supported_vnics)
supported_vnic_types = test_driver.supported_vnic_types
self.assertNotIn(portbindings.VNIC_MACVTAP, supported_vnic_types)
self.assertEqual(len(self.default_supported_vnics) - 1,
len(supported_vnic_types))
def test_vnic_type_blacklist_not_valid_item(self):
self.blacklist_cfg['SRIOV_DRIVER']['vnic_type_blacklist'] = ['foo']
fake_conf = cfg.CONF
fake_conf_fixture = base.MechDriverConfFixture(
fake_conf, self.blacklist_cfg,
mech_sriov_conf.register_sriov_mech_driver_opts)
self.useFixture(fake_conf_fixture)
self.assertRaises(ValueError,
mech_driver.SriovNicSwitchMechanismDriver)
def test_vnic_type_blacklist_all_items(self):
self.blacklist_cfg['SRIOV_DRIVER']['vnic_type_blacklist'] = \
[portbindings.VNIC_DIRECT,
portbindings.VNIC_MACVTAP,
portbindings.VNIC_DIRECT_PHYSICAL]
fake_conf = cfg.CONF
fake_conf_fixture = base.MechDriverConfFixture(
fake_conf, self.blacklist_cfg,
mech_sriov_conf.register_sriov_mech_driver_opts)
self.useFixture(fake_conf_fixture)
self.assertRaises(ValueError,
mech_driver.SriovNicSwitchMechanismDriver)

@ -0,0 +1,9 @@
---
other:
- |
Add new configuration group ``sriov_driver`` and new configuration option
under it ``vnic_type_blacklist``, to make the previously hardcoded
``supported_vnic_types`` parameter of the SriovNicSwitchMechanismDriver
configurable.
The ``vnic_types`` listed in the blacklist will be removed from the
supported_vnic_types list.
Loading…
Cancel
Save