diff --git a/os_net_config/sriov_config.py b/os_net_config/sriov_config.py index 27460e31..b3a25e5e 100644 --- a/os_net_config/sriov_config.py +++ b/os_net_config/sriov_config.py @@ -313,6 +313,9 @@ def configure_sriov_pf(execution_from_cli=False, restart_openvswitch=False): for item in sriov_map: if item['device_type'] == 'pf': + if pf_configure_status(item): + logger.debug(f"PF {item['name']} is already configured") + continue _pf_interface_up(item) if item.get('link_mode') == "legacy": # Add a udev rule to configure the VF's when PF's are @@ -626,6 +629,10 @@ def _pf_interface_up(pf_device): run_ip_config_cmd('ip', 'link', 'set', 'dev', pf_device['name'], 'up') +def pf_configure_status(pf_device): + return pf_device['numvfs'] == get_numvfs(pf_device['name']) + + def run_ip_config_cmd_safe(raise_error, *cmd, **kwargs): try: run_ip_config_cmd(*cmd) diff --git a/os_net_config/tests/test_sriov_config.py b/os_net_config/tests/test_sriov_config.py index fd9b45dd..988fc4a4 100644 --- a/os_net_config/tests/test_sriov_config.py +++ b/os_net_config/tests/test_sriov_config.py @@ -330,11 +330,13 @@ class TestSriovConfig(base.TestCase): exp_actions = [ 'udev_monitor_setup', 'udev_monitor_start', + 'get_numvfs', 'reload_udev_rules', 'set_numvfs', 'get_numvfs', '_wait_for_vf_creation', 'get_numvfs', + 'get_numvfs', 'reload_udev_rules', 'set_numvfs', 'get_numvfs', @@ -373,10 +375,12 @@ class TestSriovConfig(base.TestCase): exp_actions = [ 'udev_monitor_setup', 'udev_monitor_start', + 'get_numvfs', 'set_numvfs', 'get_numvfs', '_wait_for_vf_creation', 'get_numvfs', + 'get_numvfs', 'reload_udev_rules', 'set_numvfs', 'get_numvfs', @@ -419,11 +423,13 @@ class TestSriovConfig(base.TestCase): exp_actions = [ 'udev_monitor_setup', 'udev_monitor_start', + 'get_numvfs', 'reload_udev_rules', 'set_numvfs', 'get_numvfs', '_wait_for_vf_creation', 'get_numvfs', + 'get_numvfs', 'reload_udev_rules', 'set_numvfs', 'get_numvfs', @@ -464,6 +470,7 @@ class TestSriovConfig(base.TestCase): 'udev_monitor_setup', 'udev_monitor_start', 'get_vdpa_vhost_devices', + 'get_numvfs', 'configure_switchdev', 'set_numvfs', 'get_numvfs', @@ -473,6 +480,7 @@ class TestSriovConfig(base.TestCase): 'reload_udev_rules', 'reload_udev_rules', 'reload_udev_rules', + 'get_numvfs', 'configure_switchdev', 'set_numvfs', 'get_numvfs',