def test_update_numvfs(self, mock_open): fd = six.StringIO() mock_open.return_value.__enter__.return_value = fd sriov.update_numvfs(PCI1, NUMVFS) expected_sysfs_path = '/sys/bus/pci/devices/' + PCI1 + '/sriov_numvfs' mock_open.assert_called_once_with(expected_sysfs_path, 'w', 0) self.assertEqual(fd.getvalue(), '0' + str(NUMVFS))
def change_numvfs(pci_path, numvfs, devname): """Change number of virtual functions of a device. The persistence is stored in the same place as other network persistence is stored. A call to setSafeNetworkConfig() will persist it across reboots. """ logging.info('Changing number of vfs on device %s -> %s.', pci_path, numvfs) sriov.update_numvfs(pci_path, numvfs) sriov.persist_numvfs(devname, numvfs) link_iface.iface(devname).up()
def change_numvfs(pci_path, numvfs, net_name): """Change number of virtual functions of a device. The persistence is stored in the same place as other network persistence is stored. A call to setSafeNetworkConfig() will persist it across reboots. """ # TODO: net_name is here only because it is hard to call pf_to_net_name # TODO: from here. once all our code will be under lib/vdsm this should be # TODO: removed. logging.info('Changing number of vfs on device %s -> %s.', pci_path, numvfs) sriov.update_numvfs(pci_path, numvfs) sriov.persist_numvfs(pci_path, numvfs) link_iface.iface(net_name).up()
def change_numvfs(pci_path, numvfs, net_name): """Change number of virtual functions of a device. The persistence is stored in the same place as other network persistence is stored. A call to setSafeNetworkConfig() will persist it across reboots. """ # TODO: net_name is here only because it is hard to call pf_to_net_name # TODO: from here. once all our code will be under lib/vdsm this should be # TODO: removed. logging.info('Changing number of vfs on device %s -> %s.', pci_path, numvfs) sriov.update_numvfs(pci_path, numvfs) sriov.persist_numvfs(pci_path, numvfs) link_iface.up(net_name)
def test_update_numvfs_1_to_2(self, mock_open): fd = _create_fd(mock_open) sriov.update_numvfs(PCI1, NUMVFS) _assert_open_was_called(mock_open) assert fd.getvalue() == b'0%d' % NUMVFS
def test_update_numvfs_0_to_0(self, mock_open): fd = _create_fd(mock_open) sriov.update_numvfs(PCI1, 0) _assert_open_was_called(mock_open) assert fd.getvalue() == b''
def test_update_numvfs_0_to_2(self, mock_open): fd = _create_fd(mock_open) sriov.update_numvfs(PCI1, NUMVFS) _assert_open_was_called(mock_open) self.assertEqual(fd.getvalue(), str(NUMVFS))
def test_update_numvfs_2_to_0(self, mock_open): fd = _create_fd(mock_open) sriov.update_numvfs(PCI1, 0) _assert_open_was_called(mock_open) self.assertEqual(fd.getvalue(), '0')