Consolidate sriov agent and driver code
In preparation for decomposing the built-in reference implementation, this commits consolidates the sriov agent and driver code into a coherent place for it's life in the new repository. I've also given the unit tests a new home. DocImpact UpgradeImpact Partially-Implements: blueprint reference-implementation-split Partial-Bug: #1468433 Closes-Bug: #1427317 Change-Id: Ic8b5215de76e191030228bc28773cd6535e889d8 Signed-off-by: Kyle Mestery <mestery@mestery.com>
This commit is contained in:
parent
ab971d78cc
commit
f242b171e9
@ -21,8 +21,9 @@ from oslo_log import log as logging
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from neutron.i18n import _LE, _LW
|
from neutron.i18n import _LE, _LW
|
||||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||||
from neutron.plugins.sriovnicagent import pci_lib
|
import exceptions as exc
|
||||||
|
from neutron.plugins.ml2.drivers.mech_sriov.agent import pci_lib
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -19,7 +19,8 @@ from oslo_log import log as logging
|
|||||||
|
|
||||||
from neutron.agent.linux import ip_lib
|
from neutron.agent.linux import ip_lib
|
||||||
from neutron.i18n import _LE, _LW
|
from neutron.i18n import _LE, _LW
|
||||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||||
|
import exceptions as exc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -34,9 +34,10 @@ from neutron.common import utils as q_utils
|
|||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.i18n import _LE, _LI
|
from neutron.i18n import _LE, _LI
|
||||||
from neutron.openstack.common import loopingcall
|
from neutron.openstack.common import loopingcall
|
||||||
from neutron.plugins.sriovnicagent.common import config # noqa
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config # noqa
|
||||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||||
from neutron.plugins.sriovnicagent import eswitch_manager as esm
|
import exceptions as exc
|
||||||
|
from neutron.plugins.ml2.drivers.mech_sriov.agent import eswitch_manager as esm
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
@ -22,7 +22,8 @@ from neutron.extensions import portbindings
|
|||||||
from neutron.i18n import _LE, _LW
|
from neutron.i18n import _LE, _LW
|
||||||
from neutron.plugins.common import constants as p_const
|
from neutron.plugins.common import constants as p_const
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
from neutron.plugins.ml2 import driver_api as api
|
||||||
from neutron.plugins.ml2.drivers.mech_sriov import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \
|
||||||
|
import exceptions as exc
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
@ -17,8 +17,9 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from neutron.common import utils as q_utils
|
from neutron.common import utils as q_utils
|
||||||
from neutron.plugins.sriovnicagent.common import config
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config
|
||||||
from neutron.plugins.sriovnicagent import sriov_nic_agent as agent
|
from neutron.plugins.ml2.drivers.mech_sriov.agent \
|
||||||
|
import sriov_nic_agent as agent
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
@ -20,8 +20,9 @@ import mock
|
|||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||||
from neutron.plugins.sriovnicagent import eswitch_manager as esm
|
import exceptions as exc
|
||||||
|
from neutron.plugins.ml2.drivers.mech_sriov.agent import eswitch_manager as esm
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
||||||
@ -32,23 +33,25 @@ class TestCreateESwitchManager(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_create_eswitch_mgr_fail(self):
|
def test_create_eswitch_mgr_fail(self):
|
||||||
device_mappings = {'physnet1': 'p6p1'}
|
device_mappings = {'physnet1': 'p6p1'}
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.scan_vf_devices",
|
"eswitch_manager.PciOsWrapper.scan_vf_devices",
|
||||||
side_effect=exc.InvalidDeviceError(
|
side_effect=exc.InvalidDeviceError(
|
||||||
dev_name="p6p1", reason="device" " not found")),\
|
dev_name="p6p1", reason="device" " not found")),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
|
|
||||||
with testtools.ExpectedException(exc.InvalidDeviceError):
|
with testtools.ExpectedException(exc.InvalidDeviceError):
|
||||||
esm.ESwitchManager(device_mappings, None)
|
esm.ESwitchManager(device_mappings, None)
|
||||||
|
|
||||||
def test_create_eswitch_mgr_ok(self):
|
def test_create_eswitch_mgr_ok(self):
|
||||||
device_mappings = {'physnet1': 'p6p1'}
|
device_mappings = {'physnet1': 'p6p1'}
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.scan_vf_devices",
|
"eswitch_manager.PciOsWrapper.scan_vf_devices",
|
||||||
return_value=self.SCANNED_DEVICES),\
|
return_value=self.SCANNED_DEVICES),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
|
|
||||||
esm.ESwitchManager(device_mappings, None)
|
esm.ESwitchManager(device_mappings, None)
|
||||||
|
|
||||||
@ -66,49 +69,52 @@ class TestESwitchManagerApi(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestESwitchManagerApi, self).setUp()
|
super(TestESwitchManagerApi, self).setUp()
|
||||||
device_mappings = {'physnet1': 'p6p1'}
|
device_mappings = {'physnet1': 'p6p1'}
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.scan_vf_devices",
|
"eswitch_manager.PciOsWrapper.scan_vf_devices",
|
||||||
return_value=self.SCANNED_DEVICES),\
|
return_value=self.SCANNED_DEVICES),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
self.eswitch_mgr = esm.ESwitchManager(device_mappings, None)
|
self.eswitch_mgr = esm.ESwitchManager(device_mappings, None)
|
||||||
|
|
||||||
def test_get_assigned_devices(self):
|
def test_get_assigned_devices(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_assigned_devices",
|
"eswitch_manager.EmbSwitch.get_assigned_devices",
|
||||||
return_value=[self.ASSIGNED_MAC]):
|
return_value=[self.ASSIGNED_MAC]):
|
||||||
result = self.eswitch_mgr.get_assigned_devices()
|
result = self.eswitch_mgr.get_assigned_devices()
|
||||||
self.assertEqual(set([self.ASSIGNED_MAC]), result)
|
self.assertEqual(set([self.ASSIGNED_MAC]), result)
|
||||||
|
|
||||||
def test_get_device_status_true(self):
|
def test_get_device_status_true(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC),\
|
return_value=self.ASSIGNED_MAC),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_device_state", return_value=True):
|
"eswitch_manager.EmbSwitch.get_device_state",
|
||||||
|
return_value=True):
|
||||||
result = self.eswitch_mgr.get_device_state(self.ASSIGNED_MAC,
|
result = self.eswitch_mgr.get_device_state(self.ASSIGNED_MAC,
|
||||||
self.PCI_SLOT)
|
self.PCI_SLOT)
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
|
|
||||||
def test_get_device_status_false(self):
|
def test_get_device_status_false(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC),\
|
return_value=self.ASSIGNED_MAC),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_device_state",
|
"eswitch_manager.EmbSwitch.get_device_state",
|
||||||
return_value=False):
|
return_value=False):
|
||||||
result = self.eswitch_mgr.get_device_state(self.ASSIGNED_MAC,
|
result = self.eswitch_mgr.get_device_state(self.ASSIGNED_MAC,
|
||||||
self.PCI_SLOT)
|
self.PCI_SLOT)
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
def test_get_device_status_mismatch(self):
|
def test_get_device_status_mismatch(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC),\
|
return_value=self.ASSIGNED_MAC),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_device_state", return_value=True):
|
"eswitch_manager.EmbSwitch.get_device_state",
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
return_value=True):
|
||||||
"LOG.warning") as log_mock:
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
|
"eswitch_manager.LOG.warning") as log_mock:
|
||||||
result = self.eswitch_mgr.get_device_state(self.WRONG_MAC,
|
result = self.eswitch_mgr.get_device_state(self.WRONG_MAC,
|
||||||
self.PCI_SLOT)
|
self.PCI_SLOT)
|
||||||
log_mock.assert_called_with('device pci mismatch: '
|
log_mock.assert_called_with('device pci mismatch: '
|
||||||
@ -118,22 +124,22 @@ class TestESwitchManagerApi(base.BaseTestCase):
|
|||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
def test_set_device_status(self):
|
def test_set_device_status(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC),\
|
return_value=self.ASSIGNED_MAC),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.set_device_state"):
|
"eswitch_manager.EmbSwitch.set_device_state"):
|
||||||
self.eswitch_mgr.set_device_state(self.ASSIGNED_MAC,
|
self.eswitch_mgr.set_device_state(self.ASSIGNED_MAC,
|
||||||
self.PCI_SLOT, True)
|
self.PCI_SLOT, True)
|
||||||
|
|
||||||
def test_set_device_status_mismatch(self):
|
def test_set_device_status_mismatch(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC),\
|
return_value=self.ASSIGNED_MAC),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.set_device_state"):
|
"eswitch_manager.EmbSwitch.set_device_state"):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"LOG.warning") as log_mock:
|
"eswitch_manager.LOG.warning") as log_mock:
|
||||||
self.eswitch_mgr.set_device_state(self.WRONG_MAC,
|
self.eswitch_mgr.set_device_state(self.WRONG_MAC,
|
||||||
self.PCI_SLOT, True)
|
self.PCI_SLOT, True)
|
||||||
log_mock.assert_called_with('device pci mismatch: '
|
log_mock.assert_called_with('device pci mismatch: '
|
||||||
@ -142,8 +148,8 @@ class TestESwitchManagerApi(base.BaseTestCase):
|
|||||||
'device_mac': self.WRONG_MAC})
|
'device_mac': self.WRONG_MAC})
|
||||||
|
|
||||||
def _mock_device_exists(self, pci_slot, mac_address, expected_result):
|
def _mock_device_exists(self, pci_slot, mac_address, expected_result):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC):
|
return_value=self.ASSIGNED_MAC):
|
||||||
result = self.eswitch_mgr.device_exists(mac_address,
|
result = self.eswitch_mgr.device_exists(mac_address,
|
||||||
pci_slot)
|
pci_slot)
|
||||||
@ -160,11 +166,11 @@ class TestESwitchManagerApi(base.BaseTestCase):
|
|||||||
False)
|
False)
|
||||||
|
|
||||||
def test_device_exists_mismatch(self):
|
def test_device_exists_mismatch(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"EmbSwitch.get_pci_device",
|
"eswitch_manager.EmbSwitch.get_pci_device",
|
||||||
return_value=self.ASSIGNED_MAC):
|
return_value=self.ASSIGNED_MAC):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"LOG.warning") as log_mock:
|
"eswitch_manager.LOG.warning") as log_mock:
|
||||||
result = self.eswitch_mgr.device_exists(self.WRONG_MAC,
|
result = self.eswitch_mgr.device_exists(self.WRONG_MAC,
|
||||||
self.PCI_SLOT)
|
self.PCI_SLOT)
|
||||||
log_mock.assert_called_with('device pci mismatch: '
|
log_mock.assert_called_with('device pci mismatch: '
|
||||||
@ -187,37 +193,38 @@ class TestEmbSwitch(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestEmbSwitch, self).setUp()
|
super(TestEmbSwitch, self).setUp()
|
||||||
exclude_devices = set()
|
exclude_devices = set()
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.scan_vf_devices",
|
"eswitch_manager.PciOsWrapper.scan_vf_devices",
|
||||||
return_value=self.SCANNED_DEVICES):
|
return_value=self.SCANNED_DEVICES):
|
||||||
self.emb_switch = esm.EmbSwitch(self.PHYS_NET, self.DEV_NAME,
|
self.emb_switch = esm.EmbSwitch(self.PHYS_NET, self.DEV_NAME,
|
||||||
exclude_devices)
|
exclude_devices)
|
||||||
|
|
||||||
def test_get_assigned_devices(self):
|
def test_get_assigned_devices(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.get_assigned_macs",
|
"PciDeviceIPWrapper.get_assigned_macs",
|
||||||
return_value=[self.ASSIGNED_MAC]),\
|
return_value=[self.ASSIGNED_MAC]),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
result = self.emb_switch.get_assigned_devices()
|
result = self.emb_switch.get_assigned_devices()
|
||||||
self.assertEqual([self.ASSIGNED_MAC], result)
|
self.assertEqual([self.ASSIGNED_MAC], result)
|
||||||
|
|
||||||
def test_get_assigned_devices_empty(self):
|
def test_get_assigned_devices_empty(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf",
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
return_value=False):
|
return_value=False):
|
||||||
result = self.emb_switch.get_assigned_devices()
|
result = self.emb_switch.get_assigned_devices()
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
def test_get_device_state_ok(self):
|
def test_get_device_state_ok(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.get_vf_state",
|
"PciDeviceIPWrapper.get_vf_state",
|
||||||
return_value=False):
|
return_value=False):
|
||||||
result = self.emb_switch.get_device_state(self.PCI_SLOT)
|
result = self.emb_switch.get_device_state(self.PCI_SLOT)
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
def test_get_device_state_fail(self):
|
def test_get_device_state_fail(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.get_vf_state",
|
"PciDeviceIPWrapper.get_vf_state",
|
||||||
return_value=False):
|
return_value=False):
|
||||||
self.assertRaises(exc.InvalidPciSlotError,
|
self.assertRaises(exc.InvalidPciSlotError,
|
||||||
@ -225,35 +232,37 @@ class TestEmbSwitch(base.BaseTestCase):
|
|||||||
self.WRONG_PCI_SLOT)
|
self.WRONG_PCI_SLOT)
|
||||||
|
|
||||||
def test_set_device_state_ok(self):
|
def test_set_device_state_ok(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.set_vf_state"):
|
"PciDeviceIPWrapper.set_vf_state"):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib.LOG."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"warning") as log_mock:
|
"pci_lib.LOG.warning") as log_mock:
|
||||||
self.emb_switch.set_device_state(self.PCI_SLOT, True)
|
self.emb_switch.set_device_state(self.PCI_SLOT, True)
|
||||||
self.assertEqual(0, log_mock.call_count)
|
self.assertEqual(0, log_mock.call_count)
|
||||||
|
|
||||||
def test_set_device_state_fail(self):
|
def test_set_device_state_fail(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.set_vf_state"):
|
"PciDeviceIPWrapper.set_vf_state"):
|
||||||
self.assertRaises(exc.InvalidPciSlotError,
|
self.assertRaises(exc.InvalidPciSlotError,
|
||||||
self.emb_switch.set_device_state,
|
self.emb_switch.set_device_state,
|
||||||
self.WRONG_PCI_SLOT, True)
|
self.WRONG_PCI_SLOT, True)
|
||||||
|
|
||||||
def test_get_pci_device(self):
|
def test_get_pci_device(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.get_assigned_macs",
|
"PciDeviceIPWrapper.get_assigned_macs",
|
||||||
return_value=[self.ASSIGNED_MAC]),\
|
return_value=[self.ASSIGNED_MAC]),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
result = self.emb_switch.get_pci_device(self.PCI_SLOT)
|
result = self.emb_switch.get_pci_device(self.PCI_SLOT)
|
||||||
self.assertEqual(self.ASSIGNED_MAC, result)
|
self.assertEqual(self.ASSIGNED_MAC, result)
|
||||||
|
|
||||||
def test_get_pci_device_fail(self):
|
def test_get_pci_device_fail(self):
|
||||||
with mock.patch("neutron.plugins.sriovnicagent.pci_lib."
|
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib."
|
||||||
"PciDeviceIPWrapper.get_assigned_macs",
|
"PciDeviceIPWrapper.get_assigned_macs",
|
||||||
return_value=[self.ASSIGNED_MAC]),\
|
return_value=[self.ASSIGNED_MAC]),\
|
||||||
mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
|
mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
|
||||||
"PciOsWrapper.is_assigned_vf", return_value=True):
|
"eswitch_manager.PciOsWrapper.is_assigned_vf",
|
||||||
|
return_value=True):
|
||||||
result = self.emb_switch.get_pci_device(self.WRONG_PCI_SLOT)
|
result = self.emb_switch.get_pci_device(self.WRONG_PCI_SLOT)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||||
from neutron.plugins.sriovnicagent import pci_lib
|
import exceptions as exc
|
||||||
|
from neutron.plugins.ml2.drivers.mech_sriov.agent import pci_lib
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
|||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from neutron.plugins.sriovnicagent.common import config # noqa
|
from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config # noqa
|
||||||
from neutron.plugins.sriovnicagent import sriov_nic_agent
|
from neutron.plugins.ml2.drivers.mech_sriov.agent import sriov_nic_agent
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
DEVICE_MAC = '11:22:33:44:55:66'
|
DEVICE_MAC = '11:22:33:44:55:66'
|
@ -22,8 +22,9 @@ from neutron.extensions import portbindings
|
|||||||
from neutron.plugins.common import constants as p_const
|
from neutron.plugins.common import constants as p_const
|
||||||
from neutron.plugins.ml2 import config # noqa
|
from neutron.plugins.ml2 import config # noqa
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
from neutron.plugins.ml2 import driver_api as api
|
||||||
from neutron.plugins.ml2.drivers.mech_sriov import exceptions as exc
|
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \
|
||||||
from neutron.plugins.ml2.drivers.mech_sriov import mech_driver
|
import exceptions as exc
|
||||||
|
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver import mech_driver
|
||||||
from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
|
from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
|
||||||
|
|
||||||
MELLANOX_CONNECTX3_PCI_INFO = '15b3:1004'
|
MELLANOX_CONNECTX3_PCI_INFO = '15b3:1004'
|
||||||
@ -165,7 +166,7 @@ class SriovSwitchMechProfileTestCase(SriovNicSwitchMechanismBaseTestCase):
|
|||||||
|
|
||||||
def test_profile_unsupported_pci_info(self):
|
def test_profile_unsupported_pci_info(self):
|
||||||
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
||||||
'mech_driver.LOG') as log_mock:
|
'mech_driver.mech_driver.LOG') as log_mock:
|
||||||
self._check_vif_for_pci_info('xxxx:yyyy', None)
|
self._check_vif_for_pci_info('xxxx:yyyy', None)
|
||||||
log_mock.debug.assert_called_with('Refusing to bind due to '
|
log_mock.debug.assert_called_with('Refusing to bind due to '
|
||||||
'unsupported pci_vendor device')
|
'unsupported pci_vendor device')
|
||||||
@ -182,14 +183,14 @@ class SriovSwitchMechProfileFailTestCase(SriovNicSwitchMechanismBaseTestCase):
|
|||||||
|
|
||||||
def test_profile_missing_profile(self):
|
def test_profile_missing_profile(self):
|
||||||
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
||||||
'mech_driver.LOG') as log_mock:
|
'mech_driver.mech_driver.LOG') as log_mock:
|
||||||
self._check_for_pci_vendor_info({})
|
self._check_for_pci_vendor_info({})
|
||||||
log_mock.debug.assert_called_with("Missing profile in port"
|
log_mock.debug.assert_called_with("Missing profile in port"
|
||||||
" binding")
|
" binding")
|
||||||
|
|
||||||
def test_profile_missing_pci_vendor_info(self):
|
def test_profile_missing_pci_vendor_info(self):
|
||||||
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
|
||||||
'mech_driver.LOG') as log_mock:
|
'mech_driver.mech_driver.LOG') as log_mock:
|
||||||
self._check_for_pci_vendor_info({'aa': 'bb'})
|
self._check_for_pci_vendor_info({'aa': 'bb'})
|
||||||
log_mock.debug.assert_called_with("Missing pci vendor"
|
log_mock.debug.assert_called_with("Missing pci vendor"
|
||||||
" info in profile")
|
" info in profile")
|
@ -110,7 +110,7 @@ console_scripts =
|
|||||||
neutron-rootwrap-daemon = oslo_rootwrap.cmd:daemon
|
neutron-rootwrap-daemon = oslo_rootwrap.cmd:daemon
|
||||||
neutron-usage-audit = neutron.cmd.usage_audit:main
|
neutron-usage-audit = neutron.cmd.usage_audit:main
|
||||||
neutron-metering-agent = neutron.cmd.eventlet.services.metering_agent:main
|
neutron-metering-agent = neutron.cmd.eventlet.services.metering_agent:main
|
||||||
neutron-sriov-nic-agent = neutron.plugins.sriovnicagent.sriov_nic_agent:main
|
neutron-sriov-nic-agent = neutron.plugins.ml2.drivers.mech_sriov.agent.sriovnicagent.sriov_nic_agent:main
|
||||||
neutron-sanity-check = neutron.cmd.sanity_check:main
|
neutron-sanity-check = neutron.cmd.sanity_check:main
|
||||||
neutron-cisco-apic-service-agent = neutron.plugins.ml2.drivers.cisco.apic.apic_topology:service_main
|
neutron-cisco-apic-service-agent = neutron.plugins.ml2.drivers.cisco.apic.apic_topology:service_main
|
||||||
neutron-cisco-apic-host-agent = neutron.plugins.ml2.drivers.cisco.apic.apic_topology:agent_main
|
neutron-cisco-apic-host-agent = neutron.plugins.ml2.drivers.cisco.apic.apic_topology:agent_main
|
||||||
@ -187,7 +187,7 @@ neutron.ml2.mechanism_drivers =
|
|||||||
brocade = networking_brocade.vdx.ml2driver.mechanism_brocade:BrocadeMechanism
|
brocade = networking_brocade.vdx.ml2driver.mechanism_brocade:BrocadeMechanism
|
||||||
brocade_fi_ni = neutron.plugins.ml2.drivers.brocade.fi_ni.mechanism_brocade_fi_ni:BrocadeFiNiMechanism
|
brocade_fi_ni = neutron.plugins.ml2.drivers.brocade.fi_ni.mechanism_brocade_fi_ni:BrocadeFiNiMechanism
|
||||||
fslsdn = neutron.plugins.ml2.drivers.freescale.mechanism_fslsdn:FslsdnMechanismDriver
|
fslsdn = neutron.plugins.ml2.drivers.freescale.mechanism_fslsdn:FslsdnMechanismDriver
|
||||||
sriovnicswitch = neutron.plugins.ml2.drivers.mech_sriov.mech_driver:SriovNicSwitchMechanismDriver
|
sriovnicswitch = neutron.plugins.ml2.drivers.mech_sriov.mech_driver.mech_driver:SriovNicSwitchMechanismDriver
|
||||||
nuage = neutron.plugins.ml2.drivers.mech_nuage.driver:NuageMechanismDriver
|
nuage = neutron.plugins.ml2.drivers.mech_nuage.driver:NuageMechanismDriver
|
||||||
fake_agent = neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent:FakeAgentMechanismDriver
|
fake_agent = neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent:FakeAgentMechanismDriver
|
||||||
sdnve = neutron.plugins.ml2.drivers.ibm.mechanism_sdnve:SdnveMechanismDriver
|
sdnve = neutron.plugins.ml2.drivers.ibm.mechanism_sdnve:SdnveMechanismDriver
|
||||||
|
@ -21,7 +21,7 @@ ignore_regexes=(
|
|||||||
# The following open source plugin tests are not actually unit
|
# The following open source plugin tests are not actually unit
|
||||||
# tests and are ignored pending their relocation to the functional
|
# tests and are ignored pending their relocation to the functional
|
||||||
# test tree.
|
# test tree.
|
||||||
"^plugins/ml2/drivers/mech_sriov/test_mech_sriov_nic_switch.py$"
|
"^plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py$"
|
||||||
"^plugins/ml2/test_security_group.py$"
|
"^plugins/ml2/test_security_group.py$"
|
||||||
"^plugins/ml2/test_port_binding.py$"
|
"^plugins/ml2/test_port_binding.py$"
|
||||||
"^plugins/ml2/test_extension_driver_api.py$"
|
"^plugins/ml2/test_extension_driver_api.py$"
|
||||||
|
8
tox.ini
8
tox.ini
@ -106,10 +106,8 @@ commands = sphinx-build -W -b html doc/source doc/build/html
|
|||||||
commands = python -m testtools.run \
|
commands = python -m testtools.run \
|
||||||
neutron.tests.unit.services.metering.drivers.test_iptables \
|
neutron.tests.unit.services.metering.drivers.test_iptables \
|
||||||
neutron.tests.unit.services.l3_router.test_l3_apic \
|
neutron.tests.unit.services.l3_router.test_l3_apic \
|
||||||
neutron.tests.unit.plugins.sriovnicagent.test_sriov_nic_agent \
|
neutron.tests.unit.plugins.ml2.drivers.mech_sriov.agent.test_sriov_nic_agent \
|
||||||
neutron.tests.unit.plugins.sriovnicagent.test_eswitch_manager \
|
neutron.tests.unit.plugins.ml2.drivers.mech_sriov.agent.test_pci_lib \
|
||||||
neutron.tests.unit.plugins.sriovnicagent.common.test_config \
|
|
||||||
neutron.tests.unit.plugins.sriovnicagent.test_pci_lib \
|
|
||||||
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.ovs_test_base \
|
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.ovs_test_base \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_phys \
|
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_phys \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_int \
|
neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_int \
|
||||||
@ -129,7 +127,7 @@ commands = python -m testtools.run \
|
|||||||
neutron.tests.unit.plugins.ml2.drivers.base_type_tunnel \
|
neutron.tests.unit.plugins.ml2.drivers.base_type_tunnel \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.opendaylight.test_driver \
|
neutron.tests.unit.plugins.ml2.drivers.opendaylight.test_driver \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.ext_test \
|
neutron.tests.unit.plugins.ml2.drivers.ext_test \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.mech_sriov.test_mech_sriov_nic_switch \
|
neutron.tests.unit.plugins.ml2.drivers.mech_sriov.mech_driver.test_mech_sriov_nic_switch \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent \
|
neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.test_type_vxlan \
|
neutron.tests.unit.plugins.ml2.drivers.test_type_vxlan \
|
||||||
neutron.tests.unit.plugins.ml2.drivers.test_type_gre \
|
neutron.tests.unit.plugins.ml2.drivers.test_type_gre \
|
||||||
|
Loading…
Reference in New Issue
Block a user