def get_screenshot(self): """ Do virsh screenshot of the vm and fetch the image if the VM in remote host. """ sshot_file = os.path.join(data_dir.get_tmp_dir(), "vm_screenshot.ppm") if self.target == "ovirt": vm_sshot = "/tmp/vm_screenshot.ppm" else: vm_sshot = sshot_file virsh.screenshot(self.name, vm_sshot, session_id=self.virsh_session_id) if self.target == "ovirt": remote_ip = self.params.get("remote_ip") remote_user = self.params.get("remote_user") remote_pwd = self.params.get("remote_pwd") remote.scp_from_remote(remote_ip, "22", remote_user, remote_pwd, vm_sshot, sshot_file) r_runner = remote.RemoteRunner(host=remote_ip, username=remote_user, password=remote_pwd) r_runner.run("rm -f %s" % vm_sshot) return sshot_file
def screendump(self, filename, debug=False): if debug: logging.debug("Requesting screenshot %s" % filename) return virsh.screenshot(self.name, filename, uri=self.connect_uri)