Merge "In AIO-SX, allow SRIOV VF parameters modify without host lock"

This commit is contained in:
Zuul 2021-04-12 17:58:56 +00:00 committed by Gerrit Code Review
commit 3d1a3688d9
4 changed files with 77 additions and 1 deletions

View File

@ -1832,6 +1832,18 @@ def _create(interface, from_profile=False):
pecan.request.dbapi.iinterface_destroy(new_interface['uuid'])
raise e
if (cutils.is_aio_simplex_system(pecan.request.dbapi)
and new_interface['iftype'] == constants.INTERFACE_TYPE_VF):
try:
pecan.request.rpcapi.update_sriov_vf_config(
pecan.request.context,
ihost['uuid'])
except Exception as e:
LOG.exception(e)
msg = _("Interface pci-sriov-vf creation failed: host %s if %s"
% (ihost['hostname'], interface['ifname']))
raise wsme.exc.ClientSideError(msg)
return new_interface

View File

@ -6529,6 +6529,27 @@ class ConductorManager(service.PeriodicService):
self._config_apply_runtime_manifest(
context, config_uuid, config_dict, force=True)
def update_sriov_vf_config(self, context, host_uuid):
"""update sriov vf configuration for a host
:param context: an admin context
:param host_uuid: the host uuid
"""
# update manifest files and notify agent to apply them
personalities = [constants.CONTROLLER,
constants.WORKER]
config_uuid = self._config_update_hosts(context, personalities,
host_uuids=[host_uuid])
config_dict = {
"personalities": personalities,
'host_uuids': [host_uuid],
"classes": ['platform::interfaces::sriov::vf::runtime']
}
self._config_apply_runtime_manifest(
context, config_uuid, config_dict, force=True)
def update_pcidp_config(self, context, host_uuid):
"""update pcidp configuration for a host

View File

@ -566,6 +566,22 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
return self.call(context, self.make_msg('update_sriov_config',
host_uuid=host_uuid))
def update_sriov_vf_config(self, context, host_uuid):
"""Synchronously, have a conductor configure sriov vf config.
Does the following tasks:
- sends a message to conductor
- who sends a message to all inventory agents
- who each apply the network manifest
:param context: request context.
:param host_uuid: the host unique uuid
"""
LOG.debug("ConductorApi.update_sriov_vf_config: sending "
"update_sriov_vf_config to conductor")
return self.call(context, self.make_msg('update_sriov_vf_config',
host_uuid=host_uuid))
def update_pcidp_config(self, context, host_uuid):
"""Synchronously, have a conductor configure pcidp config.

View File

@ -2528,6 +2528,13 @@ class TestAIOPatch(InterfaceTestCase):
response.json['error_message'])
class FakeConductorAPI(object):
def __init__(self):
self.update_sriov_config = mock.MagicMock()
self.update_sriov_vf_config = mock.MagicMock()
class TestAIOUnlockedPost(InterfaceTestCase):
def setUp(self):
super(TestAIOUnlockedPost, self).setUp()
@ -2536,6 +2543,13 @@ class TestAIOUnlockedPost(InterfaceTestCase):
self.mock_utils_is_aio_simplex_system.return_value = True
self.addCleanup(p.stop)
# Mock the conductor API
self.fake_conductor_api = FakeConductorAPI()
p = mock.patch('sysinv.conductor.rpcapi.ConductorAPI')
self.mock_conductor_api = p.start()
self.mock_conductor_api.return_value = self.fake_conductor_api
self.addCleanup(p.stop)
self._create_host(constants.CONTROLLER, constants.WORKER,
admin=constants.ADMIN_UNLOCKED)
self.interfaces = {
@ -2583,9 +2597,11 @@ class TestAIOUnlockedPost(InterfaceTestCase):
forihostid=self.controller.id,
ihost_uuid=self.controller.uuid,
sriov_numvfs=1,
sriov_vf_driver='vfio')
sriov_vf_driver='vfio',
max_tx_rate=200)
# system host-if-add controller-0 sriov_vf vf sriov -c pci-sriov --num-vfs 1
self._post_and_check(interface, expect_errors=False)
self.fake_conductor_api.update_sriov_vf_config.assert_called()
def test_non_aiosx_add_interface_sriov_vf_error(self):
self.mock_utils_is_aio_simplex_system.return_value = False
@ -2639,6 +2655,13 @@ class TestAIOUnlockedPatch(InterfaceTestCase):
self.mock_utils_is_aio_simplex_system.return_value = True
self.addCleanup(p.stop)
# Mock the conductor API
self.fake_conductor_api = FakeConductorAPI()
p = mock.patch('sysinv.conductor.rpcapi.ConductorAPI')
self.mock_conductor_api = p.start()
self.mock_conductor_api.return_value = self.fake_conductor_api
self.addCleanup(p.stop)
self._create_host(constants.CONTROLLER, constants.WORKER,
admin=constants.ADMIN_UNLOCKED)
@ -2697,10 +2720,12 @@ class TestAIOUnlockedPatch(InterfaceTestCase):
'ifname': 'sriov0',
'ifclass': 'pci-sriov',
'sriov_numvfs': 8,
'sriov_vf_driver': 'vfio',
}
# system host-if-modify controller-0 data0 -c pci-sriov -n sriov0 -N 8
self._patch_and_check(data, self._get_path(self.interfaces['data0'].uuid),
expect_errors=False)
self.fake_conductor_api.update_sriov_config.assert_called()
def test_interface_platform_conversion_to_sriov(self):
data = {
@ -2711,6 +2736,7 @@ class TestAIOUnlockedPatch(InterfaceTestCase):
# system host-if-modify controller-0 plat0 -c pci-sriov -n sriov1 -N 8
self._patch_and_check(data, self._get_path(self.interfaces['plat0'].uuid),
expect_errors=False)
self.fake_conductor_api.update_sriov_config.assert_called()
def test_interface_pcipasstrough_conversion_to_sriov(self):
data = {
@ -2721,6 +2747,7 @@ class TestAIOUnlockedPatch(InterfaceTestCase):
# system host-if-modify controller-0 pass0 -c pci-sriov -n sriov2 -N 8
self._patch_and_check(data, self._get_path(self.interfaces['pass0'].uuid),
expect_errors=False)
self.fake_conductor_api.update_sriov_config.assert_called()
def test_non_aiosx_interface_conversion_to_sriov_error(self):
self.mock_utils_is_aio_simplex_system.return_value = False