def test_nodedev_reset(devices, expect_error): """ Test nodedev-reset command on a list of devices :param devices : A list of node devices to be tested. :param expect_error : 'yes' for expect command run successfully and 'no' for fail. """ for device in devices: result = virsh.nodedev_reset(device) logging.debug(result) # Check whether exit code match expectation. libvirt.check_exit_status(result, expect_error)
def nodedev_test(dev_name, status_error=False): """ Execute virsh nodedev-* commands :param dev_name: Name of a device(eg. pci_0000_05_00_1) :param status_error: Whether the command should be failed """ res = virsh.nodedev_reset(dev_name, debug=True) libvirt.check_exit_status(res, status_error) res = virsh.nodedev_detach(dev_name, debug=True) libvirt.check_exit_status(res, status_error) res = virsh.nodedev_reattach(dev_name, debug=True) libvirt.check_exit_status(res, status_error)
def test_nodedev_reset(devices, expect_error, **virsh_dargs): """ Test nodedev-reset command on a list of devices :param devices : A list of node devices to be tested. :param expect_error : 'yes' for expect command run successfully and 'no' for fail. :param virsh_dargs: standardized virsh function API keywords """ readonly = virsh_dargs.get('readonly', 'no') for device in devices: result = virsh.nodedev_reset(device, readonly=readonly, debug=True) # Check whether exit code match expectation. libvirt.check_exit_status(result, expect_error)
def test_nodedev_reset(devices, expect_succeed): """ Test nodedev-reset command on a list of devices :param devices : A list of node devices to be tested. :param expect_succeed : 'yes' for expect command run successfully and 'no' for fail. :raise TestFail : If result doesn't meet expectation. """ for device in devices: result = virsh.nodedev_reset(device) logging.debug(result) # Check whether exit code match expectation. if (result.exit_status == 0) != (expect_succeed == "yes"): raise error.TestFail("Result do not meet expect_succeed (%s). Result:\n %s" % (expect_succeed, result))
def test_nodedev_reset(devices, expect_succeed): """ Test nodedev-reset command on a list of devices :param devices : A list of node devices to be tested. :param expect_succeed : 'yes' for expect command run successfully and 'no' for fail. :raise TestFail : If result doesn't meet expectation. """ for device in devices: result = virsh.nodedev_reset(device) logging.debug(result) # Check whether exit code match expectation. if (result.exit_status == 0) != (expect_succeed == 'yes'): raise error.TestFail( 'Result do not meet expect_succeed (%s). Result:\n %s' % (expect_succeed, result))