Ejemplo n.º 1
0
    def input(self, args, key):
        """Grab the disk choice and update things"""
        self.errors = []
        if self._container.process_user_input(key):
            return InputState.PROCESSED_AND_REDRAW
        else:
            if key.lower() == Prompt.CONTINUE:
                if self._selected_disks:
                    # Is DASD formatting supported?
                    if DasdFormatting.is_supported():
                        # Wait for storage.
                        threadMgr.wait(THREAD_STORAGE)

                        # Allow to format DASDs.
                        self._disk_init_module.SetFormatUnrecognizedEnabled(
                            True)
                        self._disk_init_module.SetFormatLDLEnabled(True)

                        # Get selected disks.
                        disks = filter_disks_by_names(self._available_disks,
                                                      self._selected_disks)

                        # Check if some of the disks should be formatted.
                        dasd_formatting = DasdFormatting()
                        dasd_formatting.search_disks(disks)

                        if dasd_formatting.should_run():
                            # We want to apply current selection before running dasdfmt to
                            # prevent this information from being lost afterward
                            apply_disk_selection(self._selected_disks)

                            # Run the dialog.
                            self.run_dasdfmt_dialog(dasd_formatting)
                            return InputState.PROCESSED_AND_REDRAW

                    # make sure no containers were split up by the user's disk
                    # selection
                    report = ValidationReport.from_structure(
                        self._disk_select_module.ValidateSelectedDisks(
                            self._selected_disks))
                    self.errors.extend(report.get_messages())

                    if self.errors:
                        # The disk selection has to make sense before we can
                        # proceed.
                        return InputState.PROCESSED_AND_REDRAW

                    self.apply()
                    new_spoke = PartTypeSpoke(self.data, self.storage,
                                              self.payload,
                                              self._storage_module,
                                              self._partitioning)
                    ScreenHandler.push_screen_modal(new_spoke)
                    self._partitioning = new_spoke.partitioning
                    self.apply()
                    self.execute()

                return InputState.PROCESSED_AND_CLOSE
            else:
                return super().input(args, key)
Ejemplo n.º 2
0
    def input(self, args, key):
        """ Grab the choice and update things. """
        if not self._container.process_user_input(key):
            # TRANSLATORS: 's' to rescan devices
            if key.lower() == C_('TUI|Spoke Navigation|Partitioning', 's'):
                text = _("Warning: This will revert all changes done so far.\n"
                         "Do you want to proceed?\n")
                question_window = YesNoDialog(text)
                ScreenHandler.push_screen_modal(question_window)
                if question_window.answer:
                    # unset selected disks temporarily so that
                    # storage_initialize() processes all devices
                    disk_select_proxy = STORAGE.get_proxy(DISK_SELECTION)
                    selected_disks = disk_select_proxy.SelectedDisks
                    disk_select_proxy.SetSelectedDisks([])

                    print(_("Scanning disks. This may take a moment..."))
                    storage_initialize(self.storage, self.data, self.storage.protected_dev_names)

                    disk_select_proxy.SetSelectedDisks(selected_disks)
                    self.data.mount.clear_mount_data()
                    self._gather_mount_data_info()
                return InputState.PROCESSED_AND_REDRAW
            # TRANSLATORS: 'c' to continue
            elif key.lower() == C_('TUI|Spoke Navigation', 'c'):
                self.apply()

            return super().input(args, key)

        return InputState.PROCESSED
Ejemplo n.º 3
0
    def input(self, args, key):
        """ Handle the input; this chooses the desktop environment. """
        if self._container is not None and self._container.process_user_input(
                key):
            self.redraw()
        else:
            if key.lower() == Prompt.CONTINUE:

                # No environment was selected, close
                if not self._selection.environment:
                    self.close()

                # The environment was selected, switch screen
                elif args is None:
                    # Get addons for the selected environment
                    environment = self._selection.environment
                    environment_id = self._translate_env_name_to_id(
                        environment)
                    addons = self._get_available_addons(environment_id)

                    # Switch the screen
                    ScreenHandler.replace_screen(self, addons)

                # The addons were selected, apply and close
                else:
                    self.apply()
                    self.execute()
                    self.close()
            else:
                return super().input(args, key)

        return InputState.PROCESSED
Ejemplo n.º 4
0
 def _quit_callback(self, data):
     d = YesNoDialog(_(u"Do you really want to quit?"))
     ScreenHandler.push_screen_modal(d)
     self.redraw()
     if d.answer:
         self._rescue.reboot = True
         self._rescue.finish()
Ejemplo n.º 5
0
    def _unlock_devices(self):
        """Attempt to unlock all locked LUKS devices.

        Returns true if all devices were unlocked.
        """
        try_passphrase = None
        passphrase = None
        for device_name in self._rescue.get_locked_device_names():
            skip = False
            unlocked = False
            while not (skip or unlocked):
                if try_passphrase is None:
                    p = PasswordDialog(device_name)
                    ScreenHandler.push_screen_modal(p)
                    if p.answer:
                        passphrase = p.answer.strip()
                else:
                    passphrase = try_passphrase

                if passphrase is None:
                    # cancelled
                    skip = True
                else:
                    unlocked = self._rescue.unlock_device(device_name, passphrase)
                    try_passphrase = passphrase if unlocked else None

        return not self._rescue.get_locked_device_names()
Ejemplo n.º 6
0
    def _configure_network_interface(self, data):
        devname = data
        ndata = network.ksdata_from_ifcfg(devname)
        if not ndata:
            # There is no ifcfg file for the device.
            # Make sure there is just one connection for the device.
            try:
                nm.nm_device_setting_value(devname, "connection", "uuid")
            except nm.SettingsNotFoundError:
                log.debug("can't find any connection for %s", devname)
                return
            except nm.MultipleSettingsFoundError:
                log.debug("multiple non-ifcfg connections found for %s",
                          devname)
                return

            log.debug("dumping ifcfg file for in-memory connection %s",
                      devname)
            nm.nm_update_settings_of_device(
                devname, [['connection', 'id', devname, None]])
            ndata = network.ksdata_from_ifcfg(devname)

        new_spoke = ConfigureNetworkSpoke(self.data, self.storage,
                                          self.payload, self.instclass, ndata)
        ScreenHandler.push_screen_modal(new_spoke)
        self.redraw()

        if ndata.ip == "dhcp":
            ndata.bootProto = "dhcp"
            ndata.ip = ""
        else:
            ndata.bootProto = "static"
            if not ndata.netmask:
                self.errors.append(
                    _("Configuration not saved: netmask missing in static configuration"
                      ))
                return

        if ndata.ipv6 == "ignore":
            ndata.noipv6 = True
            ndata.ipv6 = ""
        else:
            ndata.noipv6 = False

        uuid = network.update_settings_with_ksdata(devname, ndata)
        network.update_onboot_value(devname,
                                    ndata.onboot,
                                    ksdata=None,
                                    root_path="")
        network.logIfcfgFiles("settings of %s updated in tui" % devname)

        if new_spoke.apply_configuration:
            self._apply = True
            try:
                nm.nm_activate_device_connection(devname, uuid)
            except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                self.errors.append(
                    _("Can't apply configuration, device activation failed."))

        self.apply()
Ejemplo n.º 7
0
    def input(self, args, key):
        try:
            idx = int(key) - 1
            if idx >= 0 and idx < len(self.visible_fields):
                if self.visible_fields[idx].aux == self.CHECK:
                    setdeepattr(
                        self.args,
                        self.visible_fields[idx].attribute, not getdeepattr(
                            self.args, self.visible_fields[idx][1]))
                    self.redraw()
                    self.apply()
                else:
                    ScreenHandler.push_screen_modal(self.dialog,
                                                    self.visible_fields[idx])
                    self.redraw()
                    if self.dialog.value is not None:
                        setdeepattr(self.args,
                                    self.visible_fields[idx].attribute,
                                    self.dialog.value)
                        self.apply()
                return InputState.PROCESSED
        except ValueError:
            pass

        return NormalTUISpoke.input(self, args, key)
Ejemplo n.º 8
0
 def _select_mountable_device(self, data):
     self._device = data
     new_spoke = SelectISOSpoke(self.data,
                                self.storage, self.payload,
                                self.instclass, self._device)
     ScreenHandler.push_screen_modal(new_spoke)
     self.close()
Ejemplo n.º 9
0
    def input(self, args, key):
        """ Handle the input; this chooses the desktop environment. """
        if self._container is not None and self._container.process_user_input(
                key):
            self.redraw()
        else:
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):

                # No environment was selected, close
                if self._selected_environment is None:
                    self.close()

                # The environment was selected, switch screen
                elif args is None:
                    # Get addons for the selected environment
                    environment = self._selected_environment
                    environment_id = self._translate_env_name_to_id(
                        environment)
                    addons = self._get_available_addons(environment_id)

                    # Switch the screen
                    ScreenHandler.replace_screen(self, addons)

                # The addons were selected, apply and close
                else:
                    self.apply()
                    self.close()

                return InputState.PROCESSED
            else:
                return super().input(args, key)

        return InputState.PROCESSED
Ejemplo n.º 10
0
 def _set_iso_install_source(self, data):
     new_spoke = SelectDeviceSpoke(self.data,
                                   self.storage, self.payload,
                                   self.instclass)
     ScreenHandler.push_screen_modal(new_spoke)
     self.apply()
     self.close()
Ejemplo n.º 11
0
 def _set_network_nfs(self, data):
     self.set_source_nfs()
     new_spoke = SpecifyNFSRepoSpoke(self.data, self.storage,
                                     self.payload, self.instclass, self._error)
     ScreenHandler.push_screen_modal(new_spoke)
     self.apply()
     self.close()
Ejemplo n.º 12
0
 def _set_network_nfs(self, data):
     self.set_source_nfs()
     new_spoke = SpecifyNFSRepoSpoke(self.data, self.storage,
                                     self.payload, self.instclass, self._error)
     ScreenHandler.push_screen_modal(new_spoke)
     self.apply()
     self.close()
Ejemplo n.º 13
0
 def refresh(self, args=None):
     super().refresh(args)
     if self._modal_screen_refresh is not None:
         # Start a new modal screen
         ModalTestScreen.modal_counter = self.BEFORE_MODAL_REFRESH
         ScreenHandler.push_screen_modal(self._modal_screen_refresh)
         ModalTestScreen.modal_counter = self.AFTER_MODAL_REFRESH
Ejemplo n.º 14
0
 def _select_mountable_device(self, data):
     self._device = data
     new_spoke = SelectISOSpoke(self.data,
                                self.storage, self.payload,
                                self.instclass, self._device)
     ScreenHandler.push_screen_modal(new_spoke)
     self.close()
Ejemplo n.º 15
0
    def input(self, args, key):
        """Handle user input. Numbers are used to show a spoke, the rest is passed
        to the higher level for processing."""

        if self._container.process_user_input(key):
            return InputState.PROCESSED
        else:
            # If we get a continue, check for unfinished spokes.  If unfinished
            # don't continue
            # TRANSLATORS: 'c' to continue
            if key == Prompt.CONTINUE:
                for spoke in self._spokes.values():
                    if not spoke.completed and spoke.mandatory:
                        print(
                            _("Please complete all spokes before continuing"))
                        return InputState.DISCARDED
            # TRANSLATORS: 'h' to help
            elif key == Prompt.HELP:
                if self.has_help:
                    help_path = ihelp.get_help_path(self.helpFile,
                                                    self.instclass, True)
                    ScreenHandler.push_screen_modal(HelpScreen(help_path))
                    self.redraw()
                    return InputState.PROCESSED
            return key
Ejemplo n.º 16
0
 def input(self, args, key):
     if self._container.process_user_input(key):
         return InputState.PROCESSED
     else:
         if key.lower().replace("_", " ") in self._lower_zones:
             index = self._lower_zones.index(key.lower().replace("_", " "))
             self._selection = self._zones[index]
             self.apply()
             self.close()
             return InputState.PROCESSED
         elif key.lower() in self._lower_regions:
             index = self._lower_regions.index(key.lower())
             if len(self._timezones[self._regions[index]]) == 1:
                 self._selection = "%s/%s" % (
                     self._regions[index],
                     self._timezones[self._regions[index]][0])
                 self.apply()
                 self.close()
             else:
                 ScreenHandler.replace_screen(self, self._regions[index])
             return InputState.PROCESSED
         # TRANSLATORS: 'b' to go back
         elif key.lower() == C_('TUI|Spoke Navigation|Time Settings', 'b'):
             ScreenHandler.replace_screen(self)
             return InputState.PROCESSED
         else:
             return key
Ejemplo n.º 17
0
    def run_dasdfmt_dialog(self, dasd_formatting):
        """Do DASD formatting if user agrees."""
        # Prepare text of the dialog.
        text = ""
        text += _("The following unformatted or LDL DASDs have been "
                  "detected on your system. You can choose to format them "
                  "now with dasdfmt or cancel to leave them unformatted. "
                  "Unformatted DASDs cannot be used during installation.\n\n")

        text += dasd_formatting.dasds_summary + "\n\n"

        text += _("Warning: All storage changes made using the installer will "
                  "be lost when you choose to format.\n\nProceed to run dasdfmt?\n")

        # Run the dialog.
        question_window = YesNoDialog(text)
        ScreenHandler.push_screen_modal(question_window)
        if not question_window.answer:
            return None

        print(_("This may take a moment."), flush=True)

        # Do the DASD formatting.
        dasd_formatting.report.connect(self._show_dasdfmt_report)
        dasd_formatting.run(self.storage, self.data)
        dasd_formatting.report.disconnect(self._show_dasdfmt_report)

        self.update_disks()
Ejemplo n.º 18
0
 def _set_iso_install_source(self, data):
     new_spoke = SelectDeviceSpoke(self.data,
                                   self.storage, self.payload,
                                   self.instclass)
     ScreenHandler.push_screen_modal(new_spoke)
     self.apply()
     self.close()
Ejemplo n.º 19
0
 def _configure_ntp_server_callback(self, data):
     new_spoke = NTPServersSpoke(self.data, self.storage, self.payload,
                                 self._ntp_servers,
                                 self._ntp_servers_states)
     ScreenHandler.push_screen_modal(new_spoke)
     self.apply()
     self.close()
Ejemplo n.º 20
0
 def input(self, args, key):
     if self._container.process_user_input(key):
         return InputState.PROCESSED
     else:
         if key.lower().replace("_", " ") in self._lower_zones:
             index = self._lower_zones.index(key.lower().replace("_", " "))
             self._selection = self._zones[index]
             self.apply()
             return InputState.PROCESSED_AND_CLOSE
         elif key.lower() in self._lower_regions:
             index = self._lower_regions.index(key.lower())
             if len(self._timezones[self._regions[index]]) == 1:
                 self._selection = "%s/%s" % (
                     self._regions[index],
                     self._timezones[self._regions[index]][0])
                 self.apply()
                 self.close()
             else:
                 ScreenHandler.replace_screen(self, self._regions[index])
             return InputState.PROCESSED
         elif key.lower() == PROMPT_BACK_KEY:
             ScreenHandler.replace_screen(self)
             return InputState.PROCESSED
         else:
             return key
Ejemplo n.º 21
0
    def _configure_connection(self, iface, connection_uuid):
        connection = self.nm_client.get_connection_by_uuid(connection_uuid)

        new_spoke = ConfigureDeviceSpoke(self.data, self.storage, self.payload,
                                         self._network_module, iface, connection)
        ScreenHandler.push_screen_modal(new_spoke)

        if new_spoke.errors:
            self.errors.extend(new_spoke.errors)
            self.redraw()
            return

        if new_spoke.apply_configuration:
            self._apply = True
            device = self.nm_client.get_device_by_iface(iface)
            log.debug("activating connection %s with device %s",
                      connection_uuid, iface)
            self.nm_client.activate_connection_async(connection, device, None, None)

        self._network_module.proxy.LogConfigurationState(
            "Settings of {} updated in TUI.".format(iface)
        )

        self.redraw()
        self.apply()
Ejemplo n.º 22
0
 def _quit_callback(self, data):
     d = YesNoDialog(_(QUIT_MESSAGE))
     ScreenHandler.push_screen_modal(d)
     self.redraw()
     if d.answer:
         self._rescue.reboot = True
         self._rescue.finish()
Ejemplo n.º 23
0
    def run_dasdfmt_dialog(self, dasd_formatting):
        """Do DASD formatting if user agrees."""
        # Prepare text of the dialog.
        text = ""
        text += _("The following unformatted or LDL DASDs have been "
                  "detected on your system. You can choose to format them "
                  "now with dasdfmt or cancel to leave them unformatted. "
                  "Unformatted DASDs cannot be used during installation.\n\n")

        text += dasd_formatting.dasds_summary + "\n\n"

        text += _("Warning: All storage changes made using the installer will "
                  "be lost when you choose to format.\n\nProceed to run dasdfmt?\n")

        # Run the dialog.
        question_window = YesNoDialog(text)
        ScreenHandler.push_screen_modal(question_window)
        if not question_window.answer:
            return None

        print(_("This may take a moment."), flush=True)

        # Do the DASD formatting.
        dasd_formatting.report.connect(self._show_dasdfmt_report)
        dasd_formatting.run(self.storage, self.data)
        dasd_formatting.report.disconnect(self._show_dasdfmt_report)

        self.update_disks()
Ejemplo n.º 24
0
    def input(self, args, key):
        """ Handle the input; this chooses the desktop environment. """
        if self._container is not None and self._container.process_user_input(key):
            self.redraw()
        else:
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):

                # No environment was selected, close
                if self._selected_environment is None:
                    self.close()

                # The environment was selected, switch screen
                elif args is None:
                    # Get addons for the selected environment
                    environment = self._translate_env_selection_to_name(self._selected_environment)
                    environment_id = self._translate_env_name_to_id(environment)
                    addons = self._get_available_addons(environment_id)

                    # Switch the screen
                    ScreenHandler.replace_screen(self, addons)

                # The addons were selected, apply and close
                else:
                    self.apply()
                    self.close()

                return InputState.PROCESSED
            else:
                return super(SoftwareSpoke, self).input(args, key)

        return InputState.PROCESSED
Ejemplo n.º 25
0
def start_rescue_mode_ui(anaconda):
    """Start the rescue mode UI."""

    ksdata_rescue = None
    if anaconda.ksdata.rescue.seen:
        ksdata_rescue = anaconda.ksdata.rescue
    scripts = anaconda.ksdata.scripts
    storage = anaconda.storage
    reboot = True
    if conf.target.is_image:
        reboot = False
    if flags.automatedInstall and anaconda.ksdata.reboot.action not in [KS_REBOOT, KS_SHUTDOWN]:
        reboot = False

    rescue = Rescue(storage, ksdata_rescue, reboot, scripts)
    rescue.initialize()

    # We still want to choose from multiple roots, or unlock encrypted devices
    # if needed, so we run UI even for kickstarts (automated install).
    App.initialize()
    loop = App.get_event_loop()
    loop.set_quit_callback(tui_quit_callback)
    spoke = RescueModeSpoke(rescue)
    ScreenHandler.schedule_screen(spoke)
    App.run()
Ejemplo n.º 26
0
 def input(self, args, key):
     if self._container.process_user_input(key):
         return InputState.PROCESSED
     else:
         if key.lower().replace("_", " ") in self._lower_zones:
             index = self._lower_zones.index(key.lower().replace("_", " "))
             self._selection = self._zones[index]
             self.apply()
             return InputState.PROCESSED_AND_CLOSE
         elif key.lower() in self._lower_regions:
             index = self._lower_regions.index(key.lower())
             if len(self._timezones[self._regions[index]]) == 1:
                 self._selection = "%s/%s" % (self._regions[index],
                                              self._timezones[self._regions[index]][0])
                 self.apply()
                 self.close()
             else:
                 ScreenHandler.replace_screen(self, self._regions[index])
             return InputState.PROCESSED
         # TRANSLATORS: 'b' to go back
         elif key.lower() == C_('TUI|Spoke Navigation|Time Settings', 'b'):
             ScreenHandler.replace_screen(self)
             return InputState.PROCESSED
         else:
             return key
Ejemplo n.º 27
0
 def refresh(self, args=None):
     super().refresh(args)
     if self._refresh_screen:
         self.redraw()
         ScreenHandler.push_screen_modal(self._refresh_screen)
         self._refresh_screen = None
     else:
         self.close()
Ejemplo n.º 28
0
 def _select_region_callback(self, data):
     region = data
     selected_timezones = self._timezones[region]
     if len(selected_timezones) == 1:
         self._selection = "%s/%s" % (region, selected_timezones[0])
         self.apply()
         self.close()
     else:
         ScreenHandler.replace_screen(self, region)
Ejemplo n.º 29
0
 def _select_region_callback(self, data):
     region = data
     selected_timezones = self._timezones[region]
     if len(selected_timezones) == 1:
         self._selection = "%s/%s" % (region, selected_timezones[0])
         self.apply()
         self.close()
     else:
         ScreenHandler.replace_screen(self, region)
Ejemplo n.º 30
0
    def show_all(self):
        super().show_all()
        if self._modal_screen_render is not None:
            # Start new modal screen
            ModalTestScreen.modal_counter = self.BEFORE_MODAL_RENDER
            ScreenHandler.push_screen_modal(self._modal_screen_render)
            ModalTestScreen.modal_counter = self.AFTER_MODAL_RENDER

        self.copied_modal_counter = ModalTestScreen.modal_counter
        self.close()
Ejemplo n.º 31
0
    def _showError(self, message):
        """Internal helper function that MUST BE CALLED FROM THE MAIN THREAD."""

        if flags.automatedInstall and not flags.ksprompt:
            log.error(message)
            # If we're in cmdline mode, just exit.
            return

        error_window = IpmiErrorDialog(message)
        ScreenHandler.push_screen_modal(error_window)
Ejemplo n.º 32
0
    def _showError(self, message):
        """Internal helper function that MUST BE CALLED FROM THE MAIN THREAD."""

        if flags.automatedInstall and not flags.ksprompt:
            log.error(message)
            # If we're in cmdline mode, just exit.
            return

        error_window = IpmiErrorDialog(message)
        ScreenHandler.push_screen_modal(error_window)
Ejemplo n.º 33
0
    def input(self, args, key):
        """Handle the input."""
        # TRANSLATORS: 'h' to help
        if key.lower() == Prompt.HELP:
            if self.has_help:
                help_path = ihelp.get_help_path(self.helpFile, True)
                ScreenHandler.push_screen_modal(HelpScreen(help_path))
                return InputState.PROCESSED_AND_REDRAW

        return super().input(args, key)
Ejemplo n.º 34
0
    def input(self, args, key):
        """Handle the input."""
        if key.lower() == Prompt.HELP:
            help_path = self._get_help()

            if help_path:
                ScreenHandler.push_screen_modal(HelpScreen(help_path))
                return InputState.PROCESSED_AND_REDRAW

        return super().input(args, key)
Ejemplo n.º 35
0
    def input(self, args, key):
        """Handle the input."""
        # TRANSLATORS: 'h' to help
        if key.lower() == Prompt.HELP:
            if self.has_help:
                help_path = get_help_path(self.helpFile, True)
                ScreenHandler.push_screen_modal(HelpScreen(help_path))
                return InputState.PROCESSED_AND_REDRAW

        return super().input(args, key)
Ejemplo n.º 36
0
    def _validate_password(self, password, confirm):
        """Validate and process user password."""
        if password != confirm:
            self._report(
                _(constants.SECRET_CONFIRM_ERROR_TUI[self._secret_type]))
            return None

        # If an empty password was provided, unset the value
        if not password:
            return ""

        # prepare a password validation request
        password_check_request = input_checking.PasswordCheckRequest()
        password_check_request.password = password
        password_check_request.password_confirmation = ""
        password_check_request.policy = self._policy

        # validate the password
        password_check = input_checking.PasswordValidityCheck()
        password_check.run(password_check_request)

        # if the score is equal to 0 and we have an error message set
        if not password_check.result.password_score and password_check.result.error_message:
            self._report(password_check.result.error_message)
            return None

        if password_check.result.password_quality < self._policy.min_quality:
            if self._policy.is_strict:
                done_msg = ""
            else:
                done_msg = _("\nWould you like to use it anyway?")

            if password_check.result.error_message:
                weak_prefix = _(
                    constants.SECRET_WEAK_WITH_ERROR[self._secret_type])
                error = "{} {} {}".format(weak_prefix,
                                          password_check.result.error_message,
                                          done_msg)
            else:
                weak_prefix = _(constants.SECRET_WEAK[self._secret_type])
                error = "{} {}".format(weak_prefix, done_msg)

            if not self._policy.is_strict:
                question_window = YesNoDialog(error)
                ScreenHandler.push_screen_modal(question_window)
                if not question_window.answer:
                    return None
            else:
                self._report(error)
                return None

        if any(char not in constants.PW_ASCII_CHARS for char in password):
            self._report(_(constants.SECRET_ASCII[self._secret_type]))

        return self._process_password(password)
Ejemplo n.º 37
0
    def input(self, args, key):
        """Grab the disk choice and update things"""
        self.errors = []
        if self._container.process_user_input(key):
            self.redraw()
            return InputState.PROCESSED
        else:
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):
                if self.selected_disks:
                    # Is DASD formatting supported?
                    if DasdFormatting.is_supported():
                        # Wait for storage.
                        threadMgr.wait(THREAD_STORAGE)

                        # Get selected disks.
                        disks = getDisksByNames(self.disks,
                                                self.selected_disks)

                        # Check if some of the disks should be formatted.
                        dasd_formatting = DasdFormatting()
                        dasd_formatting.search_disks(disks)

                        if dasd_formatting.should_run():
                            # We want to apply current selection before running dasdfmt to
                            # prevent this information from being lost afterward
                            applyDiskSelection(self.storage, self.data,
                                               self.selected_disks)

                            # Run the dialog.
                            self.run_dasdfmt_dialog(dasd_formatting)
                            self.redraw()
                            return InputState.PROCESSED

                    # make sure no containers were split up by the user's disk
                    # selection
                    self.errors.extend(
                        checkDiskSelection(self.storage, self.selected_disks))
                    if self.errors:
                        # The disk selection has to make sense before we can
                        # proceed.
                        self.redraw()
                        return InputState.PROCESSED

                    self.apply()
                    new_spoke = PartTypeSpoke(self.data, self.storage,
                                              self.payload, self.instclass)
                    ScreenHandler.push_screen_modal(new_spoke)
                    self.apply()
                    self.execute()
                    self.close()

                return InputState.PROCESSED
            else:
                return super().input(args, key)
    def input(self, args, key):
        """Run spokes based on the user choice."""
        if key == "1":
            ScreenHandler.push_screen(self._counter_spoke)
            # this input was processed
            return InputState.PROCESSED

        # return for outer processing
        # the basic processing is 'c' for continue, 'r' for refresh, 'q' to quit
        # otherwise the input is discarded and waiting for a new input
        return key
Ejemplo n.º 39
0
 def _mount_root(self):
     # decrypt all luks devices
     self._unlock_devices()
     found_roots = self._rescue.get_found_root_infos()
     if len(found_roots) > 1:
         # have to prompt user for which root to mount
         root_spoke = RootSelectionSpoke(found_roots)
         ScreenHandler.push_screen_modal(root_spoke)
         self.redraw()
         self._rescue.select_root(root_spoke.selection)
     self._rescue.mount_root()
Ejemplo n.º 40
0
    def input(self, args, key):
        """Handle the input."""
        # TRANSLATORS: 'h' to help
        if key.lower() == Prompt.HELP:
            if self.has_help:
                help_path = ihelp.get_help_path(self.helpFile, self.instclass, True)
                ScreenHandler.push_screen_modal(HelpScreen(help_path))
                self.redraw()
                return InputState.PROCESSED

        return super(NormalTUISpoke, self).input(args, key)
Ejemplo n.º 41
0
 def input(self, args, key):
     """ Handle user input. """
     if self._container.process_user_input(key):
         return InputState.PROCESSED
     else:
         # TRANSLATORS: 'b' to go back
         if key.lower() == C_("TUI|Spoke Navigation|Language Support", "b"):
             ScreenHandler.replace_screen(self)
             return InputState.PROCESSED
         else:
             return super().input(args, key)
Ejemplo n.º 42
0
 def _mount_root(self):
     # decrypt all luks devices
     self._unlock_devices()
     found_roots = self._rescue.get_found_root_infos()
     if len(found_roots) > 1:
         # have to prompt user for which root to mount
         root_spoke = RootSelectionSpoke(found_roots)
         ScreenHandler.push_screen_modal(root_spoke)
         self.redraw()
         self._rescue.select_root(root_spoke.selection)
     self._rescue.mount_root()
Ejemplo n.º 43
0
    def input(self, args, key):
        """ Handle user input. """
        if self._container.process_user_input(key):
            return InputState.PROCESSED
        else:

            if key.lower() == PROMPT_BACK_KEY:
                ScreenHandler.replace_screen(self)
                return InputState.PROCESSED
            else:
                return super().input(args, key)
Ejemplo n.º 44
0
 def input(self, args, key):
     """ Handle user input. """
     if self._container.process_user_input(key):
         return InputState.PROCESSED
     else:
         # TRANSLATORS: 'b' to go back
         if key.lower() == C_("TUI|Spoke Navigation|Language Support", "b"):
             ScreenHandler.replace_screen(self)
             return InputState.PROCESSED
         else:
             return super().input(args, key)
Ejemplo n.º 45
0
 def show_all(self):
     super().show_all()
     self.counter += 1
     if self._switch_to_screen is not None:
         ScreenHandler.push_screen(self._switch_to_screen)
         self._switch_to_screen = None
     elif self._replace_screen is not None:
         ScreenHandler.replace_screen(self._replace_screen)
         self._replace_screen = None
     else:
         self.close()
Ejemplo n.º 46
0
    def _showYesNoQuestion(self, message):
        """Internal helper function that MUST BE CALLED FROM THE MAIN THREAD."""

        if flags.automatedInstall and not flags.ksprompt:
            log.error(message)
            # If we're in cmdline mode, just say no.
            return False

        question_window = YesNoDialog(message)
        ScreenHandler.push_screen_modal(question_window)

        return question_window.answer
Ejemplo n.º 47
0
    def input(self, args, key):
        """Handle the input."""
        # TRANSLATORS: 'h' to help
        if key.lower() == Prompt.HELP:
            if self.has_help:
                help_path = ihelp.get_help_path(self.helpFile, self.instclass,
                                                True)
                ScreenHandler.push_screen_modal(HelpScreen(help_path))
                self.redraw()
                return InputState.PROCESSED

        return super(NormalTUISpoke, self).input(args, key)
Ejemplo n.º 48
0
    def _showYesNoQuestion(self, message):
        """Internal helper function that MUST BE CALLED FROM THE MAIN THREAD."""

        if flags.automatedInstall and not flags.ksprompt:
            log.error(message)
            # If we're in cmdline mode, just say no.
            return False

        question_window = YesNoDialog(message)
        ScreenHandler.push_screen_modal(question_window)

        return question_window.answer
Ejemplo n.º 49
0
    def _validate_password(self, password, confirm):
        """Validate and process user password."""
        if password != confirm:
            self._report(_(constants.SECRET_CONFIRM_ERROR_TUI[self._secret_type]))
            return None

        # If an empty password was provided, unset the value
        if not password:
            return ""

        # prepare a password validation request
        password_check_request = input_checking.PasswordCheckRequest()
        password_check_request.password = password
        password_check_request.password_confirmation = ""
        password_check_request.policy = self._policy

        # validate the password
        password_check = input_checking.PasswordValidityCheck()
        password_check.run(password_check_request)

        # if the score is equal to 0 and we have an error message set
        if not password_check.result.password_score and password_check.result.error_message:
            self._report(password_check.result.error_message)
            return None

        if password_check.result.password_quality < self._policy.minquality:
            if self._policy.strict:
                done_msg = ""
            else:
                done_msg = _("\nWould you like to use it anyway?")

            if password_check.result.error_message:
                weak_prefix = _(constants.SECRET_WEAK_WITH_ERROR[self._secret_type])
                error = "{} {} {}".format(weak_prefix, password_check.result.error_message, done_msg)
            else:
                weak_prefix = _(constants.SECRET_WEAK[self._secret_type])
                error = "{} {}".format(weak_prefix, done_msg)

            if not self._policy.strict:
                question_window = YesNoDialog(error)
                ScreenHandler.push_screen_modal(question_window)
                if not question_window.answer:
                    return None
            else:
                self._report(error)
                return None

        if any(char not in constants.PW_ASCII_CHARS for char in password):
            self._report(_(constants.SECRET_ASCII[self._secret_type]))

        return self._process_password(password)
Ejemplo n.º 50
0
    def _configure_network_interface(self, data):
        devname = data
        ndata = network.ksdata_from_ifcfg(devname)
        if not ndata:
            # There is no ifcfg file for the device.
            # Make sure there is just one connection for the device.
            try:
                nm.nm_device_setting_value(devname, "connection", "uuid")
            except nm.SettingsNotFoundError:
                log.debug("can't find any connection for %s", devname)
                return
            except nm.MultipleSettingsFoundError:
                log.debug("multiple non-ifcfg connections found for %s", devname)
                return

            log.debug("dumping ifcfg file for in-memory connection %s", devname)
            nm.nm_update_settings_of_device(devname, [['connection', 'id', devname, None]])
            ndata = network.ksdata_from_ifcfg(devname)

        new_spoke = ConfigureNetworkSpoke(self.data, self.storage,
                                          self.payload, self.instclass, ndata)
        ScreenHandler.push_screen_modal(new_spoke)
        self.redraw()

        if ndata.ip == "dhcp":
            ndata.bootProto = "dhcp"
            ndata.ip = ""
        else:
            ndata.bootProto = "static"
            if not ndata.netmask:
                self.errors.append(_("Configuration not saved: netmask missing in static configuration"))
                return

        if ndata.ipv6 == "ignore":
            ndata.noipv6 = True
            ndata.ipv6 = ""
        else:
            ndata.noipv6 = False

        uuid = network.update_settings_with_ksdata(devname, ndata)
        network.update_onboot_value(devname, ndata.onboot, ksdata=None, root_path="")
        network.logIfcfgFiles("settings of %s updated in tui" % devname)

        if ndata._apply:
            self._apply = True
            try:
                nm.nm_activate_device_connection(devname, uuid)
            except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                self.errors.append(_("Can't apply configuration, device activation failed."))

        self.apply()
Ejemplo n.º 51
0
    def run(self):
        """Get input from user, run the condition functions and call setter callback at the end.

        Repeat asking user for input to the time when all the acceptance conditions will be satisfied.
        """
        screen = GetInputScreen(self._user_prompt)
        if self._conditions:
            for c in self._conditions:
                screen.add_acceptance_condition(c, self._report_func)

        screen.no_separator = self._no_separator

        ScreenHandler.push_screen_modal(screen)
        return screen.value
Ejemplo n.º 52
0
    def _rescan_devices(self):
        """Rescan devices."""
        text = _("Warning: This will revert all changes done so far.\n"
                 "Do you want to proceed?\n")

        question_window = YesNoDialog(text)
        ScreenHandler.push_screen_modal(question_window)

        if not question_window.answer:
            return

        print(_("Scanning disks. This may take a moment..."))
        reset_storage(self.storage, scan_all=True)
        self._manual_part_proxy.SetMountPoints([])
        self._mount_info = self._gather_mount_info()
Ejemplo n.º 53
0
    def input(self, args, key):
        """Grab the disk choice and update things"""
        self.errors = []
        if self._container.process_user_input(key):
            return InputState.PROCESSED_AND_REDRAW
        else:
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):
                if self._selected_disks:
                    # Is DASD formatting supported?
                    if DasdFormatting.is_supported():
                        # Wait for storage.
                        threadMgr.wait(THREAD_STORAGE)

                        # Get selected disks.
                        disks = filter_disks_by_names(self._available_disks, self._selected_disks)

                        # Check if some of the disks should be formatted.
                        dasd_formatting = DasdFormatting()
                        dasd_formatting.search_disks(disks)

                        if dasd_formatting.should_run():
                            # We want to apply current selection before running dasdfmt to
                            # prevent this information from being lost afterward
                            apply_disk_selection(self.storage, self._selected_disks)

                            # Run the dialog.
                            self.run_dasdfmt_dialog(dasd_formatting)
                            return InputState.PROCESSED_AND_REDRAW

                    # make sure no containers were split up by the user's disk
                    # selection
                    self.errors.extend(check_disk_selection(self.storage,
                                                            self._selected_disks))
                    if self.errors:
                        # The disk selection has to make sense before we can
                        # proceed.
                        return InputState.PROCESSED_AND_REDRAW

                    self.apply()
                    new_spoke = PartTypeSpoke(self.data, self.storage, self.payload)
                    ScreenHandler.push_screen_modal(new_spoke)
                    self.apply()
                    self.execute()

                return InputState.PROCESSED_AND_CLOSE
            else:
                return super().input(args, key)
Ejemplo n.º 54
0
    def input(self, args, key):
        """Grab the choice and update things"""
        if not self._container.process_user_input(key):
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):
                new_spoke = PartitionSchemeSpoke(self.data, self.storage,
                                                 self.payload, self.instclass)
                ScreenHandler.push_screen_modal(new_spoke)
                self.apply()
                self.close()
                return InputState.PROCESSED
            else:
                return super(AutoPartSpoke, self).input(args, key)

        self.redraw()
        return InputState.PROCESSED
Ejemplo n.º 55
0
    def changeVNCPasswdWindow(self):
        """ Change the password to a sane parameter.

        We ask user to input a password that (len(password) > 6
        and len(password) <= 8) or password == ''.
        """

        message = _("VNC password must be six to eight characters long.\n"
                    "Please enter a new one, or leave blank for no password.")
        App.initialize()
        loop = App.get_event_loop()
        loop.set_quit_callback(tui_quit_callback)
        spoke = VNCPassSpoke(self.anaconda.ksdata, None, None, None, message)
        ScreenHandler.schedule_screen(spoke)
        App.run()

        self.password = self.anaconda.ksdata.vnc.password
Ejemplo n.º 56
0
    def input(self, args, key):
        """Grab the choice and update things"""
        if not self._container.process_user_input(key):
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):
                self.apply()
                self._ensure_init_storage()
                if self._do_mount_assign:
                    new_spoke = MountPointAssignSpoke(self.data, self.storage, self.payload)
                else:
                    new_spoke = PartitionSchemeSpoke(self.data, self.storage, self.payload)
                ScreenHandler.push_screen_modal(new_spoke)
                return InputState.PROCESSED_AND_CLOSE
            else:
                return super().input(args, key)

        return InputState.PROCESSED_AND_REDRAW
Ejemplo n.º 57
0
 def input(self, args, key):
     """Override input so that we can launch the VNC password spoke"""
     if self._container.process_user_input(key):
         self.apply()
         return InputState.PROCESSED_AND_CLOSE
     else:
         # TRANSLATORS: 'q' to quit
         if key.lower() == C_('TUI|Spoke Navigation', 'q'):
             d = YesNoDialog(_(u"Do you really want to quit?"))
             ScreenHandler.push_screen_modal(d)
             if d.answer:
                 ipmi_abort(scripts=self.data.scripts)
                 if conf.system.can_reboot:
                     execWithRedirect("systemctl", ["--no-wall", "reboot"])
                 else:
                     sys.exit(1)
         else:
             return super().input(args, key)
Ejemplo n.º 58
0
    def _mount_root(self):
        # decrypt all luks devices
        self._unlock_devices()
        roots = self._rescue.find_roots()

        if not roots:
            return

        if len(roots) == 1:
            root = roots[0]
        else:
            # have to prompt user for which root to mount
            root_spoke = RootSelectionSpoke(roots)
            ScreenHandler.push_screen_modal(root_spoke)
            self.redraw()

            root = root_spoke.selection

        self._rescue.mount_root(root)
Ejemplo n.º 59
0
    def input(self, args, key):
        """Grab the disk choice and update things"""
        self.errors = []
        if self._container.process_user_input(key):
            self.redraw()
            return InputState.PROCESSED
        else:
            # TRANSLATORS: 'c' to continue
            if key.lower() == C_('TUI|Spoke Navigation', 'c'):
                if self.selected_disks:
                    # check selected disks to see if we have any unformatted DASDs
                    # if we're on s390x, since they need to be formatted before we
                    # can use them.
                    if arch.is_s390():
                        _disks = [d for d in self.disks if d.name in self.selected_disks]
                        to_format = [d for d in _disks if d.type == "dasd" and
                                     blockdev.s390.dasd_needs_format(d.busid)]
                        if to_format:
                            self.run_dasdfmt(to_format)
                            self.redraw()
                            return InputState.PROCESSED

                    # make sure no containers were split up by the user's disk
                    # selection
                    self.errors.extend(checkDiskSelection(self.storage,
                                                          self.selected_disks))
                    if self.errors:
                        # The disk selection has to make sense before we can
                        # proceed.
                        self.redraw()
                        return InputState.PROCESSED

                    new_spoke = AutoPartSpoke(self.data, self.storage,
                                              self.payload, self.instclass)
                    ScreenHandler.push_screen_modal(new_spoke)
                    self.apply()
                    self.execute()
                    self.close()

                return InputState.PROCESSED
            else:
                return super(StorageSpoke, self).input(args, key)
Ejemplo n.º 60
0
def ask_vnc_question(anaconda, vnc_server, message):
    """ Ask the user if TUI or GUI-over-VNC should be started.

    :param anaconda: instance of the Anaconda class
    :param vnc_server: instance of the VNC server object
    :param str message: a message to show to the user together
                        with the question
    """
    App.initialize()
    loop = App.get_event_loop()
    loop.set_quit_callback(tui_quit_callback)
    spoke = AskVNCSpoke(anaconda.ksdata, message)
    ScreenHandler.schedule_screen(spoke)
    App.run()

    if anaconda.ksdata.vnc.enabled:
        if not anaconda.gui_mode:
            log.info("VNC requested via VNC question, switching Anaconda to GUI mode.")
        anaconda.display_mode = constants.DisplayModes.GUI
        flags.usevnc = True
        vnc_server.password = anaconda.ksdata.vnc.password