Esempio n. 1
0
    def __init__(self, title, description, plugin):
        self.keys = [
            "rhn.proxyhost", "rhn.proxyport", "rhn.proxyuser",
            "rhn.proxypassword"
        ]

        def clear_invalid(dialog, changes):
            [plugin.stash_change(prefix) for prefix in self.keys]

        title = _("RHSM Proxy Information")

        entries = [
            ui.Entry("rhn.proxyhost", "Server:"),
            ui.Entry("rhn.proxyport", "Port:"),
            ui.Entry("rhn.proxyuser", "Username:"******"rhn.proxypassword", "Password:"******"label[0]", description),
            ui.Divider("divider[0]")
        ]
        children.extend(entries)
        super(ProxyDialog, self).__init__("proxy.dialog", title, children)
        self.buttons = [
            ui.CloseButton("proxy.save", _("Save"), enabled=True),
            ui.CloseButton("proxy.close", _("Cancel"))
        ]

        b = plugins.UIElements(self.buttons)
        b["proxy.close"].on_activate.clear()
        b["proxy.close"].on_activate.connect(ui.CloseAction())
        b["proxy.close"].on_activate.connect(clear_invalid)
def quit(instance):
    def ui_quit(dialog, changes):
        instance.ui.quit()

    txt = "Are you sure you want to quit?"
    dialog = ui.ConfirmationDialog("dialog.exit", "Exit", txt, [
        ui.Button("dialog.exit.yes", "Yes"),
        ui.CloseButton("dialog.exit.close", "No")
    ])

    dialog.buttons[0].on_activate.clear()
    dialog.buttons[0].on_activate.connect(ui.CloseAction())
    dialog.buttons[0].on_activate.connect(ui_quit)
    instance.show(dialog)
Esempio n. 3
0
def quit(instance):
    def ui_quit(dialog, changes):
        utils.system.reboot()
        instance.ui.quit()

    txt = "Are you sure you want to quit? The system will be rebooted."
    dialog = ui.ConfirmationDialog("dialog.exit", "Exit", txt, [
        ui.Button("dialog.exit.yes", "Reboot"),
        ui.CloseButton("dialog.exit.close", "Cancel")
    ])

    dialog.buttons[0].on_activate.clear()
    dialog.buttons[0].on_activate.connect(ui.CloseAction())
    dialog.buttons[0].on_activate.connect(ui_quit)
    instance.show(dialog)
Esempio n. 4
0
    def __init__(self, path_prefix, title, description, plugin):
        def clear_invalid(dialog, changes):
            plugin.stash_change(path_prefix)

        title = _("Custom Block Device")

        device_entry = ui.Entry(path_prefix, _("Device path:"))
        children = [ui.Label("label[0]", description),
                    ui.Divider("divider[0]"),
                    device_entry]
        super(CustomDeviceDialog, self).__init__("%s.dialog" % path_prefix,
                                                 title, children)
        self.buttons = [ui.SaveButton("dialog.device.custom.save", _("Save"),
                                      enabled=False),
                        ui.CloseButton("dialog.device.custom.close",
                                       _("Cancel"))]

        b = plugins.UIElements(self.buttons)
        b["dialog.device.custom.close"].on_activate.clear()
        b["dialog.device.custom.close"].on_activate.connect(ui.CloseAction())
        b["dialog.device.custom.close"].on_activate.connect(clear_invalid)
Esempio n. 5
0
    def __drop_to_shell(self):
        def open_console():
            utils.process.call("bash", shell=True)

        def return_ok(dialog, changes):
            with self.ui.suspended():
                utils.console.reset()
                utils.console.writeln("Dropping to rescue shell...")
                open_console()

        try:
            txt = "Making changes in the rescue shell is unsupported. Do not "
            txt += "use this without guidance from support representatives"
            dialog = ui.ConfirmationDialog("dialog.shell", "Rescue Shell", txt)

            dialog.buttons[0].on_activate.clear()
            dialog.buttons[0].on_activate.connect(ui.CloseAction())
            dialog.buttons[0].on_activate.connect(return_ok)
            self.show(dialog)

        except:
            # Error when the UI is not running
            open_console()
    def __init__(self, title, plugin):
        self.keys = ["maintenance.level"]
        self.plugin = plugin

        def clear_invalid(dialog, changes):
            [plugin.stash_change(prefix) for prefix in self.keys]

        entries = [ui.Options("maintenance.level", "Maintenance Level",
                              self.states, selected=self.__vm_status())]
        children = [ui.Divider("divider.options"),
                    ui.Label("label[0]", "Please select the maintenance "
                             "level"),
                    ui.Divider("divider[0]")]
        children.extend(entries)
        super(MaintenanceDialog, self).__init__(
            "maintenance.dialog", title, children)
        self.buttons = [ui.SaveButton("maintenance.confirm", "Set"),
                        ui.CloseButton("maintenance.close", "Cancel")]

        b = plugins.UIElements(self.buttons)
        b["maintenance.close"].on_activate.clear()
        b["maintenance.close"].on_activate.connect(ui.CloseAction())
        b["maintenance.close"].on_activate.connect(clear_invalid)
    def __init__(self, title, plugin):
        self.keys = ["hosted_engine.diskpath", "hosted_engine.pxe"]

        def clear_invalid(dialog, changes):
            [plugin.stash_change(prefix) for prefix in self.keys]

        entries = [ui.Entry("hosted_engine.diskpath",
                            "Engine ISO/OVA URL for download:"),
                   ui.Checkbox("hosted_engine.pxe", "PXE Boot Engine VM"),
                   ui.Divider("divider[1]"),
                   ui.SaveButton("deploy.additional",
                                 "Add this host to an existing group")]
        children = [ui.Label("label[0]", "Please provide details for "
                             "deployment of hosted engine"),
                    ui.Divider("divider[0]")]
        children.extend(entries)
        super(DeployDialog, self).__init__("deploy.dialog", title, children)
        self.buttons = [ui.SaveButton("deploy.confirm", "Deploy"),
                        ui.CloseButton("deploy.close", "Cancel")]

        b = plugins.UIElements(self.buttons)
        b["deploy.close"].on_activate.clear()
        b["deploy.close"].on_activate.connect(ui.CloseAction())
        b["deploy.close"].on_activate.connect(clear_invalid)
    def show_dialog(self):
        def open_console():
            if self.temp_cfg_file and os.path.isfile(self.temp_cfg_file):
                try:
                    utils.process.call("reset; screen " +
                                       "ovirt-node-hosted-engine-setup" +
                                       " --config-append=%s" %
                                       self.temp_cfg_file, shell=True)
                    self.__persist_configs()
                except:
                    self.logger.exception("hosted-engine failed to deploy!",
                                          exc_info=True)

            else:
                self.logger.error("Cannot trigger ovirt-hosted-engine-setup" +
                                  " because the configuration file was not " +
                                  "generated, please check the location " +
                                  "referenced in /var/log/ovirt-node.log")
            self.application.show(self.ui_content())

        def return_ok(dialog, changes):
            self.application.ui.close_dialog("Begin Hosted Engine Setup")
            with self.application.ui.suspended():
                open_console()

        if self.application.current_plugin() is self:
            try:
                # if show_progressbar is not set, the download process has
                # never started (PXE) or it finished
                if self._show_progressbar:
                    # Clear out the counters once we're done, and hide the
                    # progress bar
                    self.widgets["download.progress"].current(0)
                    self.widgets["download.status"].text("")
                    self._show_progressbar = False

                    self._model["download.progress"] = 0
                    self._model["download.status"] = ""

                # if the temp config file is empty, we removed it in the model
                # because there was an exception, so don't do anything
                if self.temp_cfg_file and not os.path.isfile(
                        self.temp_cfg_file):
                    self.logger.debug("The temporary config file %s does not"
                                      "exist. Not running screen")
                    return

                if self._install_ready:
                    utils.console.writeln("Beginning Hosted Engine Setup ...")
                    txt = "Setup will be ran with screen enabled that can be "
                    txt += "reconnected in the event of a timeout or "
                    txt += "connection failure.\n"
                    txt += "\nIt can be reconnected by running 'screen -d -r'"

                    dialog = ui.ConfirmationDialog("dialog.shell",
                                                   "Begin Hosted Engine Setup",
                                                   txt
                                                   )
                    dialog.buttons[0].on_activate.clear()
                    dialog.buttons[0].on_activate.connect(ui.CloseAction())
                    dialog.buttons[0].on_activate.connect(return_ok)
                    self.application.show(dialog)
                else:
                    if self._model['display_message']:
                        msg = self._model['display_message']
                        self._model['display_message'] = ''
                    else:
                        msg = "\n\nError Downloading ISO/OVA Image!"

                    dialog = ui.InfoDialog("dialog.notice",
                                           "Hosted Engine Setup",
                                           msg)

                self.application.show(dialog)

            except:
                # Error when the UI is not running
                self.logger.info("Exception on TUI!", exc_info=True)
                open_console()

        self.application.show(self.ui_content())