diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py index e1d03ae10a5..43edad0f9d4 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py @@ -59,10 +59,6 @@ class PciOsWrapper(object): file_link = os.readlink(file_path) pci_slot = os.path.basename(file_link) vf_list.append((pci_slot, vf_index)) - if not vf_list: - raise exc.InvalidDeviceError( - dev_name=dev_name, - reason=_("Device has no virtual functions")) return vf_list @classmethod diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py index 385a1cd21f5..66499e70f2a 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py @@ -479,17 +479,15 @@ class TestPciOsWrapper(base.BaseTestCase): def test_scan_vf_devices_no_content(self): with mock.patch("os.path.isdir", return_value=True),\ mock.patch("os.listdir", return_value=[]): - self.assertRaises(exc.InvalidDeviceError, - esm.PciOsWrapper.scan_vf_devices, - self.DEV_NAME) + self.assertEqual([], + esm.PciOsWrapper.scan_vf_devices(self.DEV_NAME)) def test_scan_vf_devices_no_match(self): with mock.patch("os.path.isdir", return_value=True),\ mock.patch("os.listdir", return_value=self.DIR_CONTENTS_NO_MATCH): - self.assertRaises(exc.InvalidDeviceError, - esm.PciOsWrapper.scan_vf_devices, - self.DEV_NAME) + self.assertEqual([], + esm.PciOsWrapper.scan_vf_devices(self.DEV_NAME)) @mock.patch("os.listdir", side_effect=OSError()) def test_is_assigned_vf_true(self, *args): diff --git a/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml b/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml new file mode 100644 index 00000000000..b65b657ed66 --- /dev/null +++ b/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Allow SR-IOV agent to run with 0 vfs