summaryrefslogtreecommitdiff
path: root/nova/tests/unit/network
diff options
context:
space:
mode:
authorDmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>2022-03-16 03:09:24 +0300
committerDmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>2022-04-14 15:44:40 +0300
commit2234b179b5202d4d609c1df2c9c999656ca12378 (patch)
treef12ec217d8d7e968a44cdd08a70ce275ae994e71 /nova/tests/unit/network
parenta1f006d799d2294234d381395a9ae9c22a2d80b9 (diff)
downloadnova-2234b179b5202d4d609c1df2c9c999656ca12378.tar.gz
Store pf_mac_address and vf_num in extra_info
Remote-managed port support relies on placing additional data into the "binding:profile" attribute of a port: a mac address of a PF associated with a VF and the VF number. This data is currently retrieved via sysfs at the time when it needs to be placed into binding:profile initially or when it needs to be updated during migration processes. To avoid having extra sysfs dependencies in the manager and neutron modules, those attributes are now stored in the extra-info of a given VF's PciDevice and persisted in the DB. The PF mac is stored for each VF since PFs are not guaranteed to be present in the whitelist and so may not be present in the database in the first place. A by-product of that is that it is easier to access this data by just looking at a given VF's extra-info dict. Change-Id: I2ed738f87fed952f60849cc22bde7291ec52d286
Diffstat (limited to 'nova/tests/unit/network')
-rw-r--r--nova/tests/unit/network/test_neutron.py68
1 files changed, 6 insertions, 62 deletions
diff --git a/nova/tests/unit/network/test_neutron.py b/nova/tests/unit/network/test_neutron.py
index dbcfa80c27..2cbe569b11 100644
--- a/nova/tests/unit/network/test_neutron.py
+++ b/nova/tests/unit/network/test_neutron.py
@@ -7697,12 +7697,16 @@ class TestAPIPortbinding(TestAPIBase):
'address': '0000:0a:00.1',
'parent_addr': '0000:0a:00.0',
'card_serial_number': 'MT2113X00000',
+ 'sriov_cap': {
+ 'pf_mac_address': '52:54:00:1e:59:c6',
+ 'vf_num': 1,
+ },
'dev_type': obj_fields.PciDeviceType.SRIOV_VF,
}
PciDevice = collections.namedtuple('PciDevice',
['vendor_id', 'product_id', 'address',
- 'card_serial_number', 'dev_type',
- 'parent_addr'])
+ 'card_serial_number', 'sriov_cap',
+ 'dev_type', 'parent_addr'])
mydev = PciDevice(**pci_dev)
self.assertEqual(self.api._get_vf_pci_device_profile(mydev),
{'pf_mac_address': '52:54:00:1e:59:c6',
@@ -7710,66 +7714,6 @@ class TestAPIPortbinding(TestAPIBase):
'card_serial_number': 'MT2113X00000'})
@mock.patch.object(
- pci_utils, 'get_mac_by_pci_address',
- new=mock.MagicMock(
- side_effect=exception.PciDeviceNotFoundById(id='0000:0a:00.1'))
- )
- def test__get_vf_pci_device_profile_invalid_pf_address(self):
- pci_dev = {'vendor_id': 'a2d6',
- 'product_id': '15b3',
- 'address': '0000:0a:00.1',
- 'parent_addr': '0000:0a:00.0',
- 'card_serial_number': 'MT2113X00000',
- 'dev_type': obj_fields.PciDeviceType.SRIOV_VF,
- }
- PciDevice = collections.namedtuple('PciDevice',
- ['vendor_id', 'product_id', 'address',
- 'card_serial_number', 'dev_type',
- 'parent_addr'])
- mydev = PciDevice(**pci_dev)
- self.assertEqual(self.api._get_vf_pci_device_profile(mydev), {})
-
- @mock.patch.object(
- pci_utils, 'get_vf_num_by_pci_address',
- new=mock.MagicMock(
- side_effect=exception.PciDeviceNotFoundById(id='0000:0a:00.0'))
- )
- @mock.patch.object(
- pci_utils, 'get_mac_by_pci_address',
- new=mock.MagicMock(side_effect=(lambda vf_a: {
- '0000:0a:00.0': '52:54:00:1e:59:c6'}.get(vf_a))))
- def test__get_vf_pci_device_profile_invalid_vf_address(self):
- pci_dev = {'vendor_id': 'a2d6',
- 'product_id': '15b3',
- 'address': '0000:0a:00.1',
- 'parent_addr': '0000:0a:00.0',
- 'card_serial_number': 'MT2113X00000',
- 'dev_type': obj_fields.PciDeviceType.SRIOV_VF,
- }
- PciDevice = collections.namedtuple('PciDevice',
- ['vendor_id', 'product_id', 'address',
- 'card_serial_number', 'dev_type',
- 'parent_addr'])
- mydev = PciDevice(**pci_dev)
- vf_profile = self.api._get_vf_pci_device_profile(mydev)
- self.assertEqual(vf_profile, {})
-
- def test__get_vf_pci_device_profile_not_vf_address(self):
- pci_dev = {'vendor_id': 'a2d6',
- 'product_id': '15b3',
- 'address': '0000:0a:00.1',
- 'parent_addr': None,
- 'card_serial_number': 'MT2113X00000',
- 'dev_type': obj_fields.PciDeviceType.SRIOV_VF,
- }
- PciDevice = collections.namedtuple('PciDevice',
- ['vendor_id', 'product_id', 'address',
- 'card_serial_number', 'dev_type',
- 'parent_addr'])
- mydev = PciDevice(**pci_dev)
- self.assertEqual(self.api._get_vf_pci_device_profile(mydev), {})
-
- @mock.patch.object(
neutronapi.API, '_get_vf_pci_device_profile',
new=mock.MagicMock(side_effect=(
lambda dev: {'0000:0a:00.1': {