def _do_resume_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) logging.debug("Unpausing vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.resume, [], src, _("Error unpausing domain"))
def _do_resume_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) logging.debug("Unpausing vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.resume, [], src, _("Error unpausing domain"))
def start_pool(self, src_ignore): pool = self.current_pool() if pool is None: return logging.debug("Starting pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(pool.start, [], self, _("Error starting pool '%s'") % pool.get_name())
def start_pool(self, src_ignore): pool = self.current_pool() if pool is None: return logging.debug("Starting pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(pool.start, [], self, _("Error starting pool '%s'") % pool.get_name())
def stop_network(self, src_ignore): net = self.current_network() if net is None: return logging.debug("Stopping network '%s'", net.get_name()) vmmAsyncJob.simple_async_noshow(net.stop, [], self, _("Error stopping network '%s'") % net.get_name())
def stop_network(self, src_ignore): net = self.current_network() if net is None: return logging.debug("Stopping network '%s'", net.get_name()) vmmAsyncJob.simple_async_noshow(net.stop, [], self, _("Error stopping network '%s'") % net.get_name())
def delete_network(self, src_ignore): net = self.current_network() if net is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the network %s?") % net.get_name()) if not result: return logging.debug("Deleting network '%s'", net.get_name()) vmmAsyncJob.simple_async_noshow(net.delete, [], self, _("Error deleting network '%s'") % net.get_name())
def delete_network(self, src_ignore): net = self.current_network() if net is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the network %s?") % net.get_name()) if not result: return logging.debug("Deleting network '%s'", net.get_name()) vmmAsyncJob.simple_async_noshow(net.delete, [], self, _("Error deleting network '%s'") % net.get_name())
def _do_shutdown_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, self.config.set_confirm_poweroff, text1=_("Are you sure you want to poweroff '%s'?" % vm.get_name())): return logging.debug("Shutting down vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.shutdown, [], src, _("Error shutting down domain"))
def _do_suspend_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_pause, self.config.set_confirm_pause, text1=_("Are you sure you want to pause '%s'?" % vm.get_name())): return logging.debug("Pausing vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.suspend, [], src, _("Error pausing domain"))
def _do_suspend_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_pause, self.config.set_confirm_pause, text1=_("Are you sure you want to pause '%s'?" % vm.get_name())): return logging.debug("Pausing vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.suspend, [], src, _("Error pausing domain"))
def _do_shutdown_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, self.config.set_confirm_poweroff, text1=_("Are you sure you want to poweroff '%s'?" % vm.get_name())): return logging.debug("Shutting down vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.shutdown, [], src, _("Error shutting down domain"))
def delete_pool(self, src_ignore): pool = self.current_pool() if pool is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the pool %s?") % pool.get_name()) if not result: return logging.debug("Deleting pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(pool.delete, [], self, _("Error deleting pool '%s'") % pool.get_name())
def delete_pool(self, src_ignore): pool = self.current_pool() if pool is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the pool %s?") % pool.get_name()) if not result: return logging.debug("Deleting pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(pool.delete, [], self, _("Error deleting pool '%s'") % pool.get_name())
def start_interface(self, src_ignore): interface = self.current_interface() if interface is None: return if not util.chkbox_helper(self, self.config.get_confirm_interface, self.config.set_confirm_interface, text1=_("Are you sure you want to start the interface " "'%s'?" % interface.get_name())): return logging.debug("Starting interface '%s'", interface.get_name()) vmmAsyncJob.simple_async_noshow(interface.start, [], self, _("Error starting interface '%s'") % interface.get_name())
def stop_interface(self, src_ignore): interface = self.current_interface() if interface is None: return if not util.chkbox_helper(self, self.config.get_confirm_interface, self.config.set_confirm_interface, text1=_("Are you sure you want to stop the interface " "'%s'?" % interface.get_name())): return logging.debug("Stopping interface '%s'", interface.get_name()) vmmAsyncJob.simple_async_noshow(interface.stop, [], self, _("Error stopping interface '%s'") % interface.get_name())
def delete_interface(self, src_ignore): interface = self.current_interface() if interface is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the interface %s?") % interface.get_name()) if not result: return logging.debug("Deleting interface '%s'", interface.get_name()) vmmAsyncJob.simple_async_noshow(interface.delete, [], self, _("Error deleting interface '%s'") % interface.get_name())
def delete_interface(self, src_ignore): interface = self.current_interface() if interface is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the interface %s?") % interface.get_name()) if not result: return logging.debug("Deleting interface '%s'", interface.get_name()) vmmAsyncJob.simple_async_noshow(interface.delete, [], self, _("Error deleting interface '%s'") % interface.get_name())
def _do_reset_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_forcepoweroff, self.config.set_confirm_forcepoweroff, text1=_("Are you sure you want to force reset '%s'?" % vm.get_name()), text2=_("This will immediately reset the VM without " "shutting down the OS and may cause data loss.")): return logging.debug("Resetting vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.reset, [], src, _("Error resetting domain"))
def _do_reset_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_forcepoweroff, self.config.set_confirm_forcepoweroff, text1=_("Are you sure you want to force reset '%s'?" % vm.get_name()), text2=_("This will immediately reset the VM without " "shutting down the OS and may cause data loss.")): return logging.debug("Resetting vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.reset, [], src, _("Error resetting domain"))
def _do_restore_domain(self, src, uri): conn = self._lookup_conn(uri) if conn.is_remote(): src.err.val_err(_("Restoring virtual machines over remote " "connections is not yet supported")) return path = src.err.browse_local( conn, _("Restore Virtual Machine"), browse_reason=self.config.CONFIG_DIR_RESTORE) if not path: return vmmAsyncJob.simple_async_noshow(conn.restore, [path], src, _("Error restoring domain"))
def _on_delete_clicked(self, ignore): snap = self._get_current_snapshot() if not snap: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the snapshot '%s'?") % snap.get_name()) if not result: return # XXX: how does the work for 'current' snapshot? # XXX: all sorts of flags here like 'delete children', do we care? logging.debug("Deleting snapshot '%s'", snap.get_name()) vmmAsyncJob.simple_async_noshow(snap.delete, [], self, _("Error deleting snapshot '%s'") % snap.get_name(), finish_cb=self._refresh_snapshots)
def delete_vol(self, src_ignore): vol = self.current_vol() if vol is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the volume %s?") % vol.get_name()) if not result: return def cb(): vol.delete() def idlecb(): self.refresh_current_pool() self.populate_storage_volumes() self.idle_add(idlecb) logging.debug("Deleting volume '%s'", vol.get_name()) vmmAsyncJob.simple_async_noshow(cb, [], self, _("Error refreshing volume '%s'") % vol.get_name())
def delete_vol(self, src_ignore): vol = self.current_vol() if vol is None: return result = self.err.yes_no(_("Are you sure you want to permanently " "delete the volume %s?") % vol.get_name()) if not result: return def cb(): vol.delete() def idlecb(): self.refresh_current_pool() self.populate_storage_volumes() self.idle_add(idlecb) logging.debug("Deleting volume '%s'", vol.get_name()) vmmAsyncJob.simple_async_noshow(cb, [], self, _("Error refreshing volume '%s'") % vol.get_name())
def pool_refresh(self, src_ignore): if self._in_refresh: logging.debug("Already refreshing the pool, skipping") return pool = self.current_pool() if pool is None: return self._in_refresh = True def cb(): try: pool.refresh() self.idle_add(self.refresh_current_pool) finally: self._in_refresh = False logging.debug("Refresh pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(cb, [], self, _("Error refreshing pool '%s'") % pool.get_name())
def _do_restore_domain(self, src, uri): conn = self._lookup_conn(uri) if conn.is_remote(): src.err.val_err(_("Restoring virtual machines over remote " "connections is not yet supported")) return path = util.browse_local(src.topwin, _("Restore Virtual Machine"), conn, browse_reason=self.config.CONFIG_DIR_RESTORE) if not path: return def cb(): newconn = util.dup_conn(conn) newconn.restore(path) vmmAsyncJob.simple_async_noshow(cb, [], src, _("Error restoring domain"))
def pool_refresh(self, src_ignore): if self._in_refresh: logging.debug("Already refreshing the pool, skipping") return pool = self.current_pool() if pool is None: return self._in_refresh = True def cb(): try: pool.refresh() self.idle_add(self.refresh_current_pool) finally: self._in_refresh = False logging.debug("Refresh pool '%s'", pool.get_name()) vmmAsyncJob.simple_async_noshow(cb, [], self, _("Error refreshing pool '%s'") % pool.get_name())
def _on_start_clicked(self, ignore): snap = self._get_current_snapshot() if not snap: return # XXX: Not true with external disk snapshots, disk changes are # encoded in the latest snapshot # XXX: Don't run current? # XXX: Warn about state change? result = self.err.yes_no(_("Are you sure you want to revert to " "snapshot '%s'? All disk changes since " "the last snapshot will be discarded.") % snap.get_name()) if not result: return logging.debug("Revertin to snapshot '%s'", snap.get_name()) vmmAsyncJob.simple_async_noshow(self.vm.revert_to_snapshot, [snap], self, _("Error reverting to snapshot '%s'") % snap.get_name(), finish_cb=self._refresh_snapshots)
vm.removeSavedImage() self._do_run_domain(src, uri, uuid) except Exception, e: src.err.show_err(_("Error removing domain state: %s") % str(e)) # VM will be restored, which can take some time, so show progress title = _("Restoring Virtual Machine") text = _("Restoring virtual machine memory from disk") vmmAsyncJob.simple_async(vm.startup, [], title, text, src, "", errorcb=errorcb) else: # Regular startup errorintro = _("Error starting domain") vmmAsyncJob.simple_async_noshow(vm.startup, [], src, errorintro) def _do_shutdown_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, self.config.set_confirm_poweroff, text1=_("Are you sure you want to poweroff '%s'?" % vm.get_name())): return logging.debug("Shutting down vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.shutdown, [], src, _("Error shutting down domain"))
vm.removeSavedImage() self._do_run_domain(src, uri, uuid) except Exception, e: src.err.show_err(_("Error removing domain state: %s") % str(e)) # VM will be restored, which can take some time, so show progress title = _("Restoring Virtual Machine") text = _("Restoring virtual machine memory from disk") vmmAsyncJob.simple_async(vm.startup, [], title, text, src, "", errorcb=errorcb) else: # Regular startup errorintro = _("Error starting domain") vmmAsyncJob.simple_async_noshow(vm.startup, [], src, errorintro) def _do_shutdown_domain(self, src, uri, uuid): conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, self.config.set_confirm_poweroff, text1=_("Are you sure you want to poweroff '%s'?" % vm.get_name())): return logging.debug("Shutting down vm '%s'", vm.get_name()) vmmAsyncJob.simple_async_noshow(vm.shutdown, [], src, _("Error shutting down domain"))