def _postprocess_images(): # remove and check the images _disks = [] for disk in params['images'].split(' '): if disk.startswith("stg"): env_process.postprocess_image(test, params.object_params(disk), disk) else: _disks.append(disk) params['images'] = " ".join(_disks)
def unplug_serial(new_devices, qdev, monitor): """ Do the actual unplug of new_devices using monitor monitor :param new_devices: List of devices which should be hotplugged :type new_devices: List of virttest.qemu_devices.qdevice.QBaseDevice :param qdev: qemu devices container :type qdev: virttest.qemu_devices.qcontainer.DevContainer :param monitor: Monitor which should be used for hotplug :type monitor: virttest.qemu_monitor.Monitor """ error.context("Unplug and remove the devices", logging.debug) failed = 0 passed = 0 unverif = 0 for device in new_devices[::-1]: if device in qdev: time.sleep(float(params.get('wait_between_unplugs', 0))) _out = device.unplug(monitor) for _ in xrange(50): # unplug waits for VM response out = device.verify_unplug(_out, monitor) if out is True: break time.sleep(0.1) # Remove from qdev even when unplug failed because further in # this test we compare VM with qdev, which should be without # these devices. We can do this because we already set the VM # as dirty. qdev.remove(device) else: continue if out is True: passed += 1 elif out is False: failed += 1 else: unverif += 1 # remove the images _disks = [] for disk in params['images'].split(' '): if disk.startswith("stg"): env_process.postprocess_image(test, params.object_params(disk), disk) else: _disks.append(disk) params['images'] = " ".join(_disks) if failed == 0 and unverif == 0: logging.debug("Unplug status: verified %d", passed) elif failed == 0: logging.warn("Unplug status: verified %d, unverified %d", passed, unverif) else: logging.error("Unplug status: verified %d, unverified %d, failed " "%d", passed, unverif, failed) raise error.TestFail("Unplug of some devices failed.")
def unplug_serial(new_devices, qdev, monitor): """ Do the actual unplug of new_devices using monitor monitor :param new_devices: List of devices which should be hotplugged :type new_devices: List of virttest.qemu_devices.QBaseDevice :param qdev: qemu devices container :type qdev: virttest.qemu_devices.DevContainer :param monitor: Monitor which should be used for hotplug :type monitor: virttest.qemu_monitor.Monitor """ failed = 0 passed = 0 unverif = 0 for device in new_devices[::-1]: if device in qdev: time.sleep(float(params.get('wait_between_unplugs', 0))) out = qdev.unplug(device, monitor, True) else: continue if out is True: passed += 1 elif out is False: failed += 1 else: unverif += 1 # remove the images _disks = [] for disk in params['images'].split(' '): if disk.startswith("stg"): env_process.postprocess_image(test, params.object_params(disk), disk) else: _disks.append(disk) params['images'] = " ".join(_disks) if failed == 0 and unverif == 0: logging.debug("Unplug status: verified %d", passed) elif failed == 0: logging.warn("Unplug status: verified %d, unverified %d", passed, unverif) else: logging.error( "Unplug status: verified %d, unverified %d, failed " "%d", passed, unverif, failed) raise error.TestFail("Unplug of some devices failed.")
def unplug_serial(new_devices, qdev, monitor): """ Do the actual unplug of new_devices using monitor monitor :param new_devices: List of devices which should be hotplugged :type new_devices: List of virttest.qemu_devices.QBaseDevice :param qdev: qemu devices container :type qdev: virttest.qemu_devices.DevContainer :param monitor: Monitor which should be used for hotplug :type monitor: virttest.qemu_monitor.Monitor """ failed = 0 passed = 0 unverif = 0 for device in new_devices[::-1]: if device in qdev: time.sleep(float(params.get('wait_between_unplugs', 0))) out = qdev.unplug(device, monitor, True) else: continue if out is True: passed += 1 elif out is False: failed += 1 else: unverif += 1 # remove the images _disks = [] for disk in params['images'].split(' '): if disk.startswith("stg"): env_process.postprocess_image(test, params.object_params(disk), disk) else: _disks.append(disk) params['images'] = " ".join(_disks) if failed == 0 and unverif == 0: logging.debug("Unplug status: verified %d", passed) elif failed == 0: logging.warn("Unplug status: verified %d, unverified %d", passed, unverif) else: logging.error("Unplug status: verified %d, unverified %d, failed " "%d", passed, unverif, failed) raise error.TestFail("Unplug of some devices failed.")
def unset_root(params, object=None): """ Unset a root state to prevent object existence. :param params: configuration parameters :type params: {str, str} :param object: object whose states are manipulated :type object: VM object or None """ vm_name = params["vms"] for image in params.objects("images"): image_params = params.object_params(image) image_name = image_params["image_name"] if not os.path.isabs(image_name): image_name = os.path.join(image_params["images_base_dir"], image_name) logging.info("Removing image %s for %s", image_name, vm_name) image_params.update({"remove_image": "yes"}) env_process.postprocess_image(None, image_params, image_name)
def unset_root(cls, params, object=None): """ Unset a root state to prevent object existence. :param params: configuration parameters :type params: {str, str} :param object: object whose states are manipulated :type object: VM object or None """ vm_name = params["vms"] if object is not None and object.is_alive(): object.destroy(gracefully=params.get_boolean("soft_boot", True)) image_name = params["image_name"] if not os.path.isabs(image_name): image_name = os.path.join(params["images_base_dir"], image_name) logging.info("Removing image %s for %s", image_name, vm_name) params.update({"remove_image": "yes"}) env_process.postprocess_image(None, params, image_name) try: os.rmdir(os.path.dirname(image_name)) except OSError as error: logging.debug("Image directory not yet empty: %s", error)