def _do_save_domain(self, src, uri, uuid):
        conn = self._lookup_conn(uri)
        vm = conn.get_vm(uuid)
        managed = bool(vm.managedsave_supported)

        if not managed and conn.is_remote():
            src.err.val_err(
                _(
                    "Saving virtual machines over remote "
                    "connections is not supported with this "
                    "libvirt version or hypervisor."
                )
            )
            return

        if not util.chkbox_helper(
            src,
            self.config.get_confirm_poweroff,
            self.config.set_confirm_poweroff,
            text1=_("Are you sure you want to save '%s'?" % vm.get_name()),
        ):
            return

        path = None
        if not managed:
            path = util.browse_local(
                src.topwin,
                _("Save Virtual Machine"),
                conn,
                dialog_type=gtk.FILE_CHOOSER_ACTION_SAVE,
                browse_reason=self.config.CONFIG_DIR_SAVE,
            )
            if not path:
                return

        _cancel_back = None
        _cancel_args = []
        if vm.getjobinfo_supported:
            _cancel_back = self._save_cancel
            _cancel_args = [vm]

        progWin = vmmAsyncJob(
            self._save_callback,
            [vm, path],
            _("Saving Virtual Machine"),
            _("Saving virtual machine memory to disk "),
            src.topwin,
            cancel_back=_cancel_back,
            cancel_args=_cancel_args,
        )
        error, details = progWin.run()

        if error is not None:
            error = _("Error saving domain: %s") % error
            src.err.show_err(error, details=details)
示例#2
0
    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"))
示例#3
0
    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"))
示例#4
0
    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"))
示例#5
0
    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"))
示例#6
0
    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())
示例#7
0
    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())
示例#8
0
    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"))
示例#9
0
    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"))
示例#10
0
    def _do_save_domain(self, src, uri, uuid):
        conn = self._lookup_conn(uri)
        vm = conn.get_vm(uuid)
        managed = bool(vm.managedsave_supported)

        if not managed and conn.is_remote():
            src.err.val_err(
                _("Saving virtual machines over remote "
                  "connections is not supported with this "
                  "libvirt version or hypervisor."))
            return

        if not util.chkbox_helper(
                src,
                self.config.get_confirm_poweroff,
                self.config.set_confirm_poweroff,
                text1=_(
                    "Are you sure you want to save '%s'?" % vm.get_name())):
            return

        path = None
        if not managed:
            path = util.browse_local(src.topwin,
                                     _("Save Virtual Machine"),
                                     conn,
                                     dialog_type=gtk.FILE_CHOOSER_ACTION_SAVE,
                                     browse_reason=self.config.CONFIG_DIR_SAVE)
            if not path:
                return

        _cancel_back = None
        _cancel_args = []
        if vm.getjobinfo_supported:
            _cancel_back = self._save_cancel
            _cancel_args = [vm]

        progWin = vmmAsyncJob(self._save_callback, [vm, path],
                              _("Saving Virtual Machine"),
                              _("Saving virtual machine memory to disk "),
                              src.topwin,
                              cancel_back=_cancel_back,
                              cancel_args=_cancel_args)
        error, details = progWin.run()

        if error is not None:
            error = _("Error saving domain: %s") % error
            src.err.show_err(error, details=details)
示例#11
0
    def _do_reboot_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 reboot '%s'?" % vm.get_name())):
            return

        logging.debug("Rebooting vm '%s'", vm.get_name())

        def reboot_cb():
            no_support = False
            reboot_err = None
            try:
                vm.reboot()
            except Exception, reboot_err:
                no_support = virtinst.support.is_error_nosupport(reboot_err)
                if not no_support:
                    raise RuntimeError(
                        _("Error rebooting domain: %s" % str(reboot_err)))

            if not no_support:
                return

            # Reboot isn't supported. Let's try to emulate it
            logging.debug("Hypervisor doesn't support reboot, let's fake it")
            try:
                vm.manual_reboot()
            except:
                logging.exception("Could not fake a reboot")

                # Raise the original error message
                raise RuntimeError(
                    _("Error rebooting domain: %s" % str(reboot_err)))
示例#12
0
    def _do_reboot_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 reboot '%s'?" %
                    vm.get_name())):
            return

        logging.debug("Rebooting vm '%s'", vm.get_name())

        def reboot_cb():
            no_support = False
            reboot_err = None
            try:
                vm.reboot()
            except Exception, reboot_err:
                no_support = virtinst.support.is_error_nosupport(reboot_err)
                if not no_support:
                    raise RuntimeError(_("Error rebooting domain: %s" %
                                       str(reboot_err)))

            if not no_support:
                return

            # Reboot isn't supported. Let's try to emulate it
            logging.debug("Hypervisor doesn't support reboot, let's fake it")
            try:
                vm.manual_reboot()
            except:
                logging.exception("Could not fake a reboot")

                # Raise the original error message
                raise RuntimeError(_("Error rebooting domain: %s" %
                                   str(reboot_err)))
示例#13
0
    def finish(self, src_ignore):
        devs = self.get_paths_to_delete()

        if devs:
            ret = util.chkbox_helper(self,
                                     self.config.get_confirm_delstorage,
                                     self.config.set_confirm_delstorage,
                                     text1=_("Are you sure you want to delete "
                                             "the storage?"),
                                     text2=_("All selected storage will "
                                             "be deleted."))
            if not ret:
                return

        self.topwin.set_sensitive(False)
        self.topwin.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))

        title = _("Deleting virtual machine '%s'") % self.vm.get_name()
        text = title
        if devs:
            text = title + _(" and selected storage (this may take a while)")

        progWin = vmmAsyncJob(self._async_delete, [devs],
                              title, text, self.topwin)
        error, details = progWin.run()

        self.topwin.set_sensitive(True)
        self.topwin.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
        conn = self.conn

        if error is not None:
            self.err.show_err(error, details=details)

        conn.tick(noStatsUpdate=True)

        self.close()
示例#14
0
    def finish(self, src_ignore):
        devs = self.get_paths_to_delete()

        if devs:
            ret = util.chkbox_helper(self,
                                     self.config.get_confirm_delstorage,
                                     self.config.set_confirm_delstorage,
                                     text1=_("Are you sure you want to delete "
                                             "all the storage?"),
                                     text2=_("This will delete all selected "
                                             "storage data."))
            if not ret:
                return

        self.topwin.set_sensitive(False)
        self.topwin.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))

        title = _("Deleting virtual machine '%s'") % self.vm.get_name()
        text = title
        if devs:
            text = title + _(" and selected storage (this may take a while)")

        progWin = vmmAsyncJob(self._async_delete, [devs],
                              title, text, self.topwin)
        error, details = progWin.run()

        self.topwin.set_sensitive(True)
        self.topwin.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
        conn = self.conn

        if error is not None:
            self.err.show_err(error, details=details)

        conn.tick(noStatsUpdate=True)

        self.close()