def state(self, p_or_s_vm = 'p'): """ Return domain state """ if p_or_s_vm == 'p': return virsh.domstate(self.name, uri=self.connect_uri).stdout.strip() elif p_or_s_vm == 's': return virsh.domstate(self.name, uri=self.sec_vm_con_uri).stdout.strip()
def main(self): #self.file.save() #self.file.search_file() print os.environ['VIRTTEST_PATH'],"\n" print virttest_dir+"\n" print virsh.domstate('test').stdout.strip() #virsh.qemu_monitor_command("test", "sendkey 1") virsh.qemu_monitor_command("test", "mouse_move 10 1000") virsh.qemu_monitor_command("test", "\'mouse_button 1 1000 4000 0\'")
def main(self): #self.file.save() #self.file.search_file() print os.environ['VIRTTEST_PATH'], "\n" print virttest_dir + "\n" print virsh.domstate('test').stdout.strip() #virsh.qemu_monitor_command("test", "sendkey 1") virsh.qemu_monitor_command("test", "mouse_move 10 1000") virsh.qemu_monitor_command("test", "\'mouse_button 1 1000 4000 0\'")
def state(self, p_or_s_vm='p'): """ Return domain state """ if p_or_s_vm == 'p': return virsh.domstate(self.name, uri=self.connect_uri).stdout.strip() elif p_or_s_vm == 's': return virsh.domstate(self.name, uri=self.sec_vm_con_uri).stdout.strip()
def restore_from_file(self, path): """ Override BaseVM restore_from_file method """ state = virsh.domstate(self.name) if state not in ("shut off",): raise virt_vm.VMStatusError("Can not restore VM that is %s" % state) logging.debug("Restoring VM from %s" % path) virsh.restore(path, uri=self.connect_uri) state = virsh.domstate(self.name) if state not in ("paused", "running"): raise virt_vm.VMStatusError("VM not paused after restore, it is %s." % state)
def save_to_file(self, path): """ Override BaseVM save_to_file method """ state = virsh.domstate(self.name) if state not in ("paused",): raise virt_vm.VMStatusError("Cannot save a VM that is %s" % state) logging.debug("Saving VM %s to %s" % (self.name, path)) virsh.save(self.name, path, uri=self.connect_uri) state = virsh.domstate(self.name) if state not in ("shut off",): raise virt_vm.VMStatusError("VM not shut off after save")
def save_to_file(self, path): """ Override BaseVM save_to_file method """ state = virsh.domstate(self.name) if state not in ('paused',): raise virt_vm.VMStatusError("Cannot save a VM that is %s" % state) logging.debug("Saving VM %s to %s" %(self.name, path)) virsh.save(self.name, path, uri=self.connect_uri) state = virsh.domstate(self.name) if state not in ('shut off',): raise virt_vm.VMStatusError("VM not shut off after save")
def restore_from_file(self, path): """ Override BaseVM restore_from_file method """ state = virsh.domstate(self.name) if state not in ('shut off',): raise virt_vm.VMStatusError("Can not restore VM that is %s" % state) logging.debug("Restoring VM from %s" % path) virsh.restore(path, uri=self.connect_uri) state = virsh.domstate(self.name) if state not in ('paused','running'): raise virt_vm.VMStatusError("VM not paused after restore, it is %s." % state)
def verify_alive(self): """ Make sure the VM is alive. @raise VMDeadError: If the VM is dead """ if not self.is_alive(): raise virt_vm.VMDeadError( "Domain %s is inactive" % self.name, virsh.domstate(self.name, uri=self.connect_uri) )
def verify_alive(self): """ Make sure the VM is alive. @raise VMDeadError: If the VM is dead """ if not self.is_alive(): raise virt_vm.VMDeadError("Domain %s is inactive" % self.name, virsh.domstate(self.name, uri=self.connect_uri))
def shutdown(self): """ Shuts down this VM. """ try: if virsh.domstate(self.name) != "shut off": virsh.shutdown(self.name, uri=self.connect_uri) if self.wait_for_shutdown(): logging.debug("VM %s shut down", self.name) return True else: logging.error("VM %s failed to shut down", self.name) return False except error.CmdError: logging.error("VM %s failed to shut down", self.name) return False
def state(self): """ Return domain state. """ return virsh.domstate(self.name, uri=self.connect_uri)