def test_upgrade_devices_sriov_config(self): old_cfg = {PCI1: 2, PCI2: 5} new_cfg = sriov.upgrade_devices_sriov_config(old_cfg) expected_new_cfg = {DEV0: {'sriov': {'numvfs': 2}}, DEV1: {'sriov': {'numvfs': 5}}} self.assertEqual(new_cfg, expected_new_cfg)
def _upgrade_sriov_config(devices, old_sriov_confpath): old_config = sriov.get_old_persisted_devices_numvfs(old_sriov_confpath) new_config = sriov.upgrade_devices_sriov_config(old_config) for devname in new_config: devices.setdefault(devname, {}).update(new_config[devname]) shutil.rmtree(old_sriov_confpath)