Exemplo n.º 1
0
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        saved_model = self.model()
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.ssh_key",
                      "kdump.nfs_location"]

        txs = utils.Transaction(_("Updating kdump related configuration"))

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                kdump_keys)
            if ktype == "nfs":
                model.configure_nfs(nfsloc)
            elif ktype == "ssh":
                if "kdump.ssh_key" in changes:
                    model.configure_ssh(sshloc, sshkey)
                else:
                    model.configure_ssh(sshloc)
            elif ktype == "local":
                model.configure_local()
            else:
                model.configure_disable()
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except KeyboardInterrupt:
            def _handler(signum, frame):
                console.writeln("\nWait for configuration to be restored\n")
            with self.application.ui.suspended():
                _original_sigint = signal.getsignal(signal.SIGINT)
                signal.signal(signal.SIGINT, _handler)
                self.restore_config(saved_model)
                signal.signal(signal.SIGINT, _original_sigint)
                return InfoDialog("dialog.restore", "Restored the "
                                  "configuration on keyboard interrupt")
        except Exception as e:
            self.restore_config(saved_model)
            self.logger.exception("Exception while configuring kdump")
            self.application.show(self.ui_content())
            return InfoDialog("dialog.info", "An error occurred", e.message)
        return self.ui_content()
 def run_additional(*args):
     with self.application.ui.suspended():
         try:
             utils.process.call(
                 "reset; screen hosted-engine --deploy",
                 shell=True)
             sys.stdout.write("Press <Return> to return to the TUI")
             console.wait_for_keypress()
             self.__persist_configs()
         except:
             self.logger.exception("hosted-engine failed to "
                                   "deploy!", exc_info=True)
Exemplo n.º 3
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("f12", self.__reload_page)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        self.ui.header = "\n %s\n" % str(self.product)
        self.ui.footer = "Press esc to quit."

        try:
            if system.is_rescue_mode():
                self.logger.error("The TUI cannot be used in rescue mode. "
                                  "Please reboot without rescue to "
                                  "configure/install.")
                sys.exit(0)
            self.ui.run()
        except Exception as e:
            console.reset()
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.debug("Exception:", exc_info=True)
            if self.args.debug:
                raise
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 4
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("f12", self.__reload_page)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        self.ui.header = "\n %s\n" % str(self.product)
        self.ui.footer = "Press esc to quit."

        try:
            if system.is_rescue_mode():
                self.logger.error("The TUI cannot be used in rescue mode. "
                                  "Please reboot without rescue to "
                                  "configure/install.")
                import sys
                sys.exit(0)
            self.ui.run()
        except Exception as e:
            console.reset()
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.info("Exception:", exc_info=True)
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 5
0
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.ssh_key",
                      "kdump.nfs_location"]

        txs = utils.Transaction(_("Updating kdump related configuration"))

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                kdump_keys)
            if ktype == "nfs":
                model.update(nfsloc, None, None, None)
            elif ktype == "ssh":
                if "kdump.ssh_key" in changes:
                    model.update(None, sshloc, sshkey, None)
                else:
                    model.update(None, sshloc, None, None)
            elif ktype == "local":
                model.update(None, None, None, True)
            else:
                model.update(None, None, None, None)
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except Exception as e:
            self.logger.exception("Exception while configuring kdump")
            return InfoDialog("dialog.info", _("An error occurred"), e.message)
Exemplo n.º 6
0
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.nfs_location"]

        txs = utils.Transaction("Updating kdump related configuration")

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, nfsloc = effective_model.values_for(kdump_keys)
            if ktype == "nfs":
                model.update(nfsloc, None, None)
            elif ktype == "ssh":
                model.update(None, sshloc, None)
            elif ktype == "local":
                model.update(None, None, True)
            else:
                model.update(None, None, None)
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except Exception as e:
            self.logger.exception("Exception while configuring kdump")
            return InfoDialog("dialog.info", "An error occurred", e.message)
Exemplo n.º 7
0
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.nfs_location"]

        txs = utils.Transaction("Updating kdump related configuration")

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, nfsloc = effective_model.values_for(kdump_keys)
            if ktype == "nfs":
                model.update(nfsloc, None, None)
            elif ktype == "ssh":
                model.update(None, sshloc, None)
            elif ktype == "local":
                model.update(None, None, True)
            else:
                model.update(None, None, None)
            txs += model.transaction()

        with self.application.ui.suspended():
            utils.process.call("reset")
            progress_dialog = console.TransactionProgress(txs, self)
            progress_dialog.run()
            console.writeln("\nPlease press any key to continue")
            console.wait_for_keypress()
Exemplo n.º 8
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("f12", self.__reload_page)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        if os.path.exists("/etc/ovirt-node/node-comment"):
            with open("/etc/ovirt-node/node-comment") as f:
                self.ui.header = "\n%s %s\n" % (f.read(), str(self.product))
        else:
            self.ui.header = "\n %s\n" % str(self.product)

        self.ui.footer = "Press esc to quit."

        # Catch ctrl+c
        if not self.args.debug:

            def _handler(signum, frame):
                self.logger.debug("CTRL+C pressed")

            sys_signal.signal(sys_signal.SIGINT, _handler)

        if system.is_rescue_mode():
            self.logger.error("The TUI cannot be used in rescue mode. "
                              "Please reboot without rescue to "
                              "configure/install.")
            sys.exit(0)

        try:
            self.ui.run()
        except Exception as e:
            console.reset()
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.info("Exception:", exc_info=True)
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 9
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        self.ui.header = "\n %s\n" % str(self.product)
        self.ui.footer = "Press esc to quit."

        try:
            self.ui.run()
        except Exception as e:
            utils.process.call("reset")
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.debug("Exception:", exc_info=True)
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 10
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        self.ui.header = "\n %s\n" % str(self.product)
        self.ui.footer = "Press esc to quit."

        try:
            self.ui.run()
        except Exception as e:
            utils.process.call("reset")
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.debug("Exception:", exc_info=True)
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 11
0
    def run(self):
        self.__load_plugins()

        if not self.__plugins:
            raise Exception("No plugins found in '%s'" % self.plugin_base)
        self.ui.register_hotkey("f2", self.__drop_to_shell)
        self.ui.register_hotkey("f12", self.__reload_page)
        self.ui.register_hotkey("window resize", self.__check_terminal_size)

        if os.path.exists("/etc/ovirt-node/node-comment"):
            with open("/etc/ovirt-node/node-comment") as f:
                self.ui.header = "\n%s %s\n" % (f.read(), str(self.product))
        else:
            self.ui.header = "\n %s\n" % str(self.product)

        self.ui.footer = "Press esc to quit."

        # Catch ctrl+c
        if not self.args.debug:
            def _handler(signum, frame):
                self.logger.debug("CTRL+C pressed")
            sys_signal.signal(sys_signal.SIGINT, _handler)

        if system.is_rescue_mode():
            self.logger.error("The TUI cannot be used in rescue mode. "
                              "Please reboot without rescue to "
                              "configure/install.")
            sys.exit(0)

        try:
            self.ui.run()
        except Exception as e:
            console.reset()
            self.logger.error("An error appeared in the UI: %s" % repr(e))
            self.logger.info("Exception:", exc_info=True)
            console.writeln("Press ENTER to logout ...")
            console.writeln("or enter 's' to drop to shell")
            if console.wait_for_keypress() == 's':
                self.__drop_to_shell()
Exemplo n.º 12
0
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        saved_model = self.model()
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = [
            "kdump.type", "kdump.ssh_location", "kdump.ssh_key",
            "kdump.nfs_location"
        ]

        txs = utils.Transaction(_("Updating kdump related configuration"))

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                kdump_keys)
            if ktype == "nfs":
                model.configure_nfs(nfsloc)
            elif ktype == "ssh":
                if "kdump.ssh_key" in changes:
                    model.configure_ssh(sshloc, sshkey)
                else:
                    model.configure_ssh(sshloc)
            elif ktype == "local":
                model.configure_local()
            else:
                model.configure_disable()
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except KeyboardInterrupt:

            def _handler(signum, frame):
                console.writeln("\nWait for configuration to be restored\n")

            with self.application.ui.suspended():
                _original_sigint = signal.getsignal(signal.SIGINT)
                signal.signal(signal.SIGINT, _handler)
                self.restore_config(saved_model)
                signal.signal(signal.SIGINT, _original_sigint)
                return InfoDialog(
                    "dialog.restore", "Restored the "
                    "configuration on keyboard interrupt")
        except Exception as e:
            self.restore_config(saved_model)
            self.logger.exception("Exception while configuring kdump")
            self.application.show(self.ui_content())
            return InfoDialog("dialog.info", "An error occurred", e.message)
        return self.ui_content()