Ejemplo n.º 1
0
 def initialize(self):
     # Start a thread to wait for the payload and run the first, automatic
     # dependency check
     self.initialize_start()
     super(SoftwareSpoke, self).initialize()
     threadMgr.add(AnacondaThread(name=THREAD_SOFTWARE_WATCHER,
                                  target=self._initialize))
Ejemplo n.º 2
0
def test_exception_handling():
    """
    Function that can be used for testing exception handling in anaconda. It
    tries to prepare a worst case scenario designed from bugs seen so far.

    """

    # XXX: this is a huge hack, but probably the only way, how we can get
    #      "unique" stack and thus unique hash and new bugreport
    def raise_exception(msg, non_ascii):
        timestamp = str(time.time()).split(".", 1)[0]

        code = """
def f%s(msg, non_ascii):
        raise RuntimeError(msg)

f%s(msg, non_ascii)
""" % (timestamp, timestamp)

        eval(compile(code, "str_eval", "exec"))

    # test non-ascii characters dumping
    non_ascii = u'\u0159'

    msg = "NOTABUG: testing exception handling"

    # raise exception from a separate thread
    from pyanaconda.threading import AnacondaThread
    threadMgr.add(AnacondaThread(name=THREAD_EXCEPTION_HANDLING_TEST,
                                 target=raise_exception,
                                 args=(msg, non_ascii)))
Ejemplo n.º 3
0
    def _apply(self):
        # Environment needs to be set during a GUI installation, but is not required
        # for a kickstart install (even partial)
        if not self.environment:
            log.debug("Environment is not set, skip user packages settings")
            return

        # NOTE: This block is skipped for kickstart where addons and _origAddons will
        # both be [], preventing it from wiping out the kickstart's package selection
        addons = self._get_selected_addons()
        if not self._kickstarted and set(addons) != set(self._origAddons):
            self._selectFlag = False
            self.payload.data.packages.packageList = []
            self.payload.data.packages.groupList = []
            self.payload.selectEnvironment(self.environment)
            log.debug("Environment selected for installation: %s", self.environment)
            log.debug("Groups selected for installation: %s", addons)
            for group in addons:
                self.payload.selectGroup(group)

            # And then save these values so we can check next time.
            self._origAddons = addons
            self._origEnvironment = self.environment

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_not_ready("SourceSpoke")
        threadMgr.add(AnacondaThread(name=constants.THREAD_CHECK_SOFTWARE,
                                     target=self.checkSoftwareSelection))
Ejemplo n.º 4
0
    def initialize(self):
        NormalTUISpoke.initialize(self)
        self.initialize_start()

        threadMgr.add(AnacondaThread(name=THREAD_SOURCE_WATCHER,
                                     target=self._initialize))
        payloadMgr.addListener(payloadMgr.STATE_ERROR, self._payload_error)
Ejemplo n.º 5
0
    def show_all(self):
        super().show_all()
        from pyanaconda.installation import doInstall, doConfiguration
        from pyanaconda.threading import threadMgr, AnacondaThread

        thread_args = (self.storage, self.payload, self.data, self.instclass)

        threadMgr.add(AnacondaThread(name=THREAD_INSTALL, target=doInstall, args=thread_args))

        # This will run until we're all done with the install thread.
        self._update_progress()

        threadMgr.add(AnacondaThread(name=THREAD_CONFIGURATION, target=doConfiguration, args=thread_args))

        # This will run until we're all done with the configuration thread.
        self._update_progress()

        util.ipmi_report(IPMI_FINISHED)

        if self.instclass.eula_path:
            # Notify user about the EULA (if any).
            print(_("Installation complete"))
            print('')
            print(_("Use of this product is subject to the license agreement found at:"))
            print(self.instclass.eula_path)
            print('')

        # kickstart install, continue automatically if reboot or shutdown selected
        if flags.automatedInstall and self.data.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
            # Just pretend like we got input, and our input doesn't care
            # what it gets, it just quits.
            raise ExitMainLoop()
Ejemplo n.º 6
0
    def on_login_clicked(self, *args):
        # Make the buttons UI while we work.
        self._okButton.set_sensitive(False)
        self._cancelButton.set_sensitive(False)
        self._loginButton.set_sensitive(False)

        self._loginConditionNotebook.set_current_page(0)
        self._set_login_sensitive(False)

        spinner = self.builder.get_object("loginSpinner")
        spinner.start()
        spinner.set_visible(True)
        spinner.show()

        # Are we reusing the credentials from the discovery step?  If so, grab them
        # out of the UI again here.  They should still be there.
        page = self._loginAuthNotebook.get_current_page()
        if page == 3:
            credentials = discoverMap[self._authNotebook.get_current_page()](self.builder)
        else:
            credentials = loginMap[page](self.builder)

        threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_LOGIN, target=self._login,
                                     args=(credentials,)))
        Timer().timeout_msec(250, self._check_login)
Ejemplo n.º 7
0
    def _refresh_server_working(self, itr):
        """ Runs a new thread with _set_server_ok_nok(itr) as a taget. """

        self._serversStore.set_value(itr, SERVER_WORKING, constants.NTP_SERVER_QUERY)
        threadMgr.add(AnacondaThread(prefix=constants.THREAD_NTP_SERVER_CHECK,
                                     target=self._set_server_ok_nok,
                                     args=(itr, self._epoch)))
Ejemplo n.º 8
0
    def restart_thread(self, storage, ksdata, payload,
                       fallback=False, checkmount=True, onlyOnChange=False):
        """Start or restart the payload thread.

        This method starts a new thread to restart the payload thread, so
        this method's return is not blocked by waiting on the previous payload
        thread. If there is already a payload thread restart pending, this method
        has no effect.

        :param pyanaconda.storage.InstallerStorage storage: The blivet storage instance
        :param kickstart.AnacondaKSHandler ksdata: The kickstart data instance
        :param payload.Payload payload: The payload instance
        :param bool fallback: Whether to fall back to the default repo in case of error
        :param bool checkmount: Whether to check for valid mounted media
        :param bool onlyOnChange: Restart thread only if existing repositories changed.
                                  This won't restart thread even when a new repository was added!!
        """
        log.debug("Restarting payload thread")

        # If a restart thread is already running, don't start a new one
        if threadMgr.get(THREAD_PAYLOAD_RESTART):
            return

        thread_args = (storage, ksdata, payload, fallback, checkmount, onlyOnChange)
        # Launch a new thread so that this method can return immediately
        threadMgr.add(AnacondaThread(name=THREAD_PAYLOAD_RESTART, target=self._restart_thread,
                                     args=thread_args))
Ejemplo n.º 9
0
    def on_start_clicked(self, *args):
        # First, update some widgets to not be usable while discovery happens.
        self._startButton.hide()
        self._cancelButton.set_sensitive(False)
        self._okButton.set_sensitive(False)

        self._conditionNotebook.set_current_page(1)
        self._set_configure_sensitive(False)
        self._initiatorEntry.set_sensitive(False)

        # Now get the node discovery credentials.
        credentials = discoverMap[self._authNotebook.get_current_page()](self.builder)

        discoveredLabelText = _("The following nodes were discovered using the iSCSI initiator "\
                                "<b>%(initiatorName)s</b> using the target IP address "\
                                "<b>%(targetAddress)s</b>.  Please select which nodes you "\
                                "wish to log into:") % \
                                {"initiatorName": escape_markup(credentials.initiator),
                                 "targetAddress": escape_markup(credentials.targetIP)}

        discoveredLabel = self.builder.get_object("discoveredLabel")
        discoveredLabel.set_markup(discoveredLabelText)

        bind = self._bindCheckbox.get_active()

        spinner = self.builder.get_object("waitSpinner")
        spinner.start()

        threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover,
                                     args=(credentials, bind)))
        Timer().timeout_msec(250, self._check_discover)
Ejemplo n.º 10
0
def wait_and_fetch_net_data(url, out_file, ca_certs=None):
    """
    Function that waits for network connection and starts a thread that fetches
    data over network.

    :see: org_fedora_oscap.data_fetch.fetch_data
    :return: the name of the thread running fetch_data
    :rtype: str

    """

    # get thread that tries to establish a network connection
    nm_conn_thread = threadMgr.get(constants.THREAD_WAIT_FOR_CONNECTING_NM)
    if nm_conn_thread:
        # NM still connecting, wait for it to finish
        nm_conn_thread.join()

    if not nm.nm_is_connected():
        raise OSCAPaddonNetworkError("Network connection needed to fetch data.")

    fetch_data_thread = AnacondaThread(name=THREAD_FETCH_DATA,
                                       target=fetch_data,
                                       args=(url, out_file, ca_certs),
                                       fatal=False)

    # register and run the thread
    threadMgr.add(fetch_data_thread)

    return THREAD_FETCH_DATA
Ejemplo n.º 11
0
    def initialize(self):
        NormalTUISpoke.initialize(self)
        self.initialize_start()

        threadMgr.add(AnacondaThread(name=THREAD_STORAGE_WATCHER,
                                     target=self._initialize))

        self.selected_disks = self.data.ignoredisk.onlyuse[:]
Ejemplo n.º 12
0
    def _restart_thread(self, storage, ksdata, payload, fallback, checkmount, onlyOnChange):
        # Wait for the old thread to finish
        threadMgr.wait(THREAD_PAYLOAD)

        thread_args = (storage, ksdata, payload, fallback, checkmount, onlyOnChange)
        # Start a new payload thread
        threadMgr.add(AnacondaThread(name=THREAD_PAYLOAD, target=self._run_thread,
                                     args=thread_args))
Ejemplo n.º 13
0
    def initialize(self):
        super().initialize()
        self.initialize_start()


        # set X keyboard defaults
        # - this needs to be done early in spoke initialization so that
        #   the spoke status does not show outdated keyboard selection
        keyboard.set_x_keyboard_defaults(self._l12_module.proxy, self._xkl_wrapper)

        # make sure the x_layouts list has at least one keyboard layout
        if not self._l12_module.proxy.XLayouts:
            self._l12_module.proxy.SetXLayouts([DEFAULT_KEYBOARD])

        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if conf.system.can_configure_keyboard:
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        override_cell_property(layoutColumn, layoutRenderer, "text", _show_layout,
                                            self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(self.data, self._l12_module)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not conf.system.can_configure_keyboard:
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [self.builder.get_object("testingLabel"),
                       self.builder.get_object("testingWindow"),
                       self.builder.get_object("layoutSwitchLabel")]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(_("Testing layouts configuration not "
                                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(AnacondaThread(name=THREAD_KEYBOARD_INIT,
                                     target=self._wait_ready))
Ejemplo n.º 14
0
    def _check_ntp_servers_async(self, servers):
        """Asynchronously check if given NTP servers appear to be working.

        :param list servers: list of servers to check
        """
        for server in servers:
            threadMgr.add(AnacondaThread(prefix=constants.THREAD_NTP_SERVER_CHECK,
                                         target=self._check_ntp_server,
                                         args=(server,)))
Ejemplo n.º 15
0
    def refresh(self):
        from pyanaconda.installation import doInstall
        from pyanaconda.threading import threadMgr, AnacondaThread

        super().refresh()

        self._start_ransom_notes()
        self._update_progress_timer.timeout_msec(250, self._update_progress, self._install_done)
        threadMgr.add(AnacondaThread(name=THREAD_INSTALL, target=doInstall,
                                     args=(self.storage, self.payload, self.data)))
Ejemplo n.º 16
0
    def on_format_clicked(self, *args):
        """
        Once the format button is clicked, the option to cancel expires.
        We also need to display the spinner showing activity.
        """
        self._cancel_button.set_sensitive(False)
        self._ok_button.set_sensitive(False)
        self._notebook.set_current_page(1)

        # Format dasds and update the storage.
        threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT, target=self.run_format, args=()))
Ejemplo n.º 17
0
    def on_start_clicked(self, *args):
        self._conditionNotebook.set_current_page(PAGE_ACTION)

        for widget in [self._startButton, self._cancelButton, self._sectorSizeSpinButton,
                       self._okButton]:
            widget.set_sensitive(False)

        self._reconfigureSpinner.start()

        threadMgr.add(AnacondaThread(name=THREAD_NVDIMM_RECONFIGURE, target=self._reconfigure,
                                     args=(self.namespaces, NVDIMM_MODE_SECTOR, self.sector_size)))
Ejemplo n.º 18
0
    def on_start_clicked(self, *args):
        """ Go through the process of validating entry contents and then
            attempt to add the device.
        """
        # First update widgets
        self._startButton.hide()
        self._cancelButton.set_sensitive(False)
        self._okButton.set_sensitive(False)
        self._set_configure_sensitive(False)
        self._conditionNotebook.set_current_page(1)

        # Initialize.
        config_error = None
        device = None
        wwpn = None
        lun = None

        # Get the input.
        device_name = self._deviceEntry.get_text().strip()
        wwpn_name = self._wwpnEntry.get_text().strip()
        lun_name = self._lunEntry.get_text().strip()

        # Check the input.
        if not DASD_DEVICE_NUMBER.match(device_name):
            config_error = "Incorrect format of the given device number."
        elif not ZFCP_WWPN_NUMBER.match(wwpn_name):
            config_error = "Incorrect format of the given WWPN number."
        elif not ZFCP_LUN_NUMBER.match(lun_name):
            config_error = "Incorrect format of the given LUN number."
        else:
            try:
                # Get the full ids.
                device = blockdev.s390.sanitize_dev_input(device_name)
                wwpn = blockdev.s390.zfcp_sanitize_wwpn_input(wwpn_name)
                lun = blockdev.s390.zfcp_sanitize_lun_input(lun_name)
            except (blockdev.S390Error, ValueError) as err:
                config_error = str(err)

        # Process the configuration error.
        if config_error:
            self._errorLabel.set_text(config_error)
            self._conditionNotebook.set_current_page(2)
            self._set_configure_sensitive(True)
            self._cancelButton.set_sensitive(True)
        # Start the discovery.
        else:
            # Discover.
            self._spinner.start()
            threadMgr.add(AnacondaThread(name=constants.THREAD_ZFCP_DISCOVER,
                                         target=self._discover,
                                         args=(device, wwpn, lun)))

            # Periodically call the check till it is done.
            GLib.timeout_add(250, self._check_discover)
Ejemplo n.º 19
0
    def initialize(self):
        NormalTUISpoke.initialize(self)
        self.initialize_start()

        # Ask for a default passphrase.
        if flags.automatedInstall and flags.ksprompt:
            self.run_passphrase_dialog()

        threadMgr.add(AnacondaThread(name=THREAD_STORAGE_WATCHER,
                                     target=self._initialize))

        self._selected_disks = self._disk_select_observer.proxy.SelectedDisks
Ejemplo n.º 20
0
 def start(self):
     """Start the task in a new thread."""
     threadMgr.add(
         AnacondaThread(
             name=self._thread_name,
             target=self._task_run_callback,
             target_started=self._task_started_callback,
             target_stopped=self._task_stopped_callback,
             target_failed=self._task_failed_with_info_callback,
             fatal=False
         )
     )
Ejemplo n.º 21
0
    def on_format_clicked(self, *args):
        """
        Once the format button is clicked, the option to cancel expires.
        We also need to display the spinner showing activity.
        """
        self._cancel_button.set_sensitive(False)
        self._ok_button.set_sensitive(False)
        self._notebook.set_current_page(1)

        # Loop through all of our unformatted DASDs and format them
        threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT,
                                target=self.run_dasdfmt, args=(self._epoch,)))
Ejemplo n.º 22
0
    def on_add_clicked(self, *args):
        # Set some widgets to visible/not while we work.
        self._errorBox.hide()
        self._addSpinner.set_visible(True)
        self._addSpinner.show()

        for widget in [self._addButton, self._cancelButton, self._nicCombo,
                       self._dcbCheckbox, self._autoCheckbox]:
            widget.set_sensitive(False)

        self._addSpinner.start()

        threadMgr.add(AnacondaThread(name=constants.THREAD_FCOE, target=self._add))
Ejemplo n.º 23
0
 def refresh(self):
     """Refresh location info."""
     # check if a refresh is already in progress
     if threadMgr.get(constants.THREAD_GEOLOCATION_REFRESH):
         log.debug("Geoloc: refresh already in progress")
     else:  # wait for Internet connectivity
         if network.wait_for_connectivity():
             threadMgr.add(AnacondaThread(
                 name=constants.THREAD_GEOLOCATION_REFRESH,
                 target=self._provider.refresh))
         else:
             log.error("Geolocation refresh failed"
                       " - no connectivity")
Ejemplo n.º 24
0
    def install(self):
        """ Install the payload if it is a tar.
            Otherwise fall back to rsync of INSTALL_TREE
        """
        # If it doesn't look like a tarfile use the super's install()
        if not self.is_tarfile:
            super().install()
            return

        # Use 2x the archive's size to estimate the size of the install
        # This is used to drive the progress display
        self.source_size = os.stat(self.image_path)[stat.ST_SIZE] * 2

        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
                                     target=self.progress))

        cmd = "tar"
        # preserve: ACL's, xattrs, and SELinux context
        args = ["--selinux", "--acls", "--xattrs", "--xattrs-include", "*",
                "--exclude", "/dev/", "--exclude", "/proc/",
                "--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*",
                "--exclude", "/etc/machine-id", "-xaf", self.image_path, "-C", util.getSysroot()]
        try:
            rc = util.execWithRedirect(cmd, args)
        except (OSError, RuntimeError) as e:
            msg = None
            err = str(e)
            log.error(err)
        else:
            err = None
            msg = "%s exited with code %d" % (cmd, rc)
            log.info(msg)

        if err:
            exn = PayloadInstallError(err or msg)
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)

        # Live needs to create the rescue image before bootloader is written
        for kernel in self.kernel_version_list:
            log.info("Generating rescue image for %s", kernel)
            util.execInSysroot("new-kernel-pkg",
                               ["--rpmposttrans", kernel])
Ejemplo n.º 25
0
    def install(self):
        """ Install the payload. """

        if self.source_size <= 0:
            raise PayloadInstallError("Nothing to install")

        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
                                     target=self.progress))

        cmd = "rsync"
        # preserve: permissions, owners, groups, ACL's, xattrs, times,
        #           symlinks, hardlinks
        # go recursively, include devices and special files, don't cross
        # file system boundaries
        args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
                "--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*",
                "--exclude", "/etc/machine-id", INSTALL_TREE + "/", iutil.getSysroot()]
        try:
            rc = iutil.execWithRedirect(cmd, args)
        except (OSError, RuntimeError) as e:
            msg = None
            err = str(e)
            log.error(err)
        else:
            err = None
            msg = "%s exited with code %d" % (cmd, rc)
            log.info(msg)

        if err or rc == 12:
            exn = PayloadInstallError(err or msg)
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)

        # Live needs to create the rescue image before bootloader is written
        if not os.path.exists(iutil.getSysroot() + "/usr/sbin/new-kernel-pkg"):
            log.error("new-kernel-pkg does not exist - grubby wasn't installed?  skipping")
            return

        for kernel in self.kernelVersionList:
            log.info("Generating rescue image for %s", kernel)
            iutil.execInSysroot("new-kernel-pkg",
                                ["--rpmposttrans", kernel])
Ejemplo n.º 26
0
    def _after_reconfigure(self):
        # When reconfiguration is done, update the UI.  We don't need to worry
        # about the user escaping from the dialog because all the buttons are
        # marked insensitive.
        self._reconfigureSpinner.stop()

        if self._error:
            self.builder.get_object("deviceErrorLabel").set_text(self._error)
            self._error = None
            self._conditionNotebook.set_current_page(PAGE_RESULT_ERROR)
            self._okButton.set_sensitive(True)
        else:
            self._conditionNotebook.set_current_page(PAGE_RESULT_SUCCESS)
            if self._update_devicetree:
                self._repopulateSpinner.start()
                threadMgr.add(AnacondaThread(name=THREAD_NVDIMM_REPOPULATE, target=self._repopulate))
Ejemplo n.º 27
0
    def on_rescan_clicked(self, button):
        # Once the rescan button is clicked, the option to cancel expires.
        # We also need to display the spinner showing activity.
        self._cancel_button.set_sensitive(False)
        self._ok_button.set_sensitive(False)
        self._notebook.set_current_page(1)

        # And now to fire up the storage reinitialization.
        threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE, target=storage_initialize,
                                     args=(self.storage, self.data, self.storage.devicetree.protected_dev_names)))

        self._elapsed = 0

        # This watches for the rescan to be finished and updates the dialog when
        # that happens.
        self._watcher_id = GLib.timeout_add_seconds(1, self._check_rescan)
Ejemplo n.º 28
0
    def on_rescan_clicked(self, button):
        # Once the rescan button is clicked, the option to cancel expires.
        # We also need to display the spinner showing activity.
        self._cancel_button.set_sensitive(False)
        self._ok_button.set_sensitive(False)
        self._notebook.set_current_page(1)

        # And now to fire up the storage reinitialization.
        threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE,
                                     target=reset_storage,
                                     args=(self.storage, ),
                                     kwargs={"scan_all": True}))

        self._elapsed = 0

        # This watches for the rescan to be finished and updates the dialog when
        # that happens.
        self._rescan_timer.timeout_sec(1, self._check_rescan)
Ejemplo n.º 29
0
    def _apply(self):
        """ Private apply. """
        self.environment = self._selected_environment
        self.addons = self._addons_selection if self.environment is not None else set()

        log.debug("Apply called old env %s, new env %s and addons %s",
                  self._orig_env, self.environment, self.addons)

        if self.environment is None:
            return

        changed = False

        # Not a kickstart with packages, setup the selected environment and addons
        if not self._kickstarted:

            # Changed the environment or addons, clear and setup
            if not self._orig_env \
                    or self._orig_env != self.environment \
                    or set(self._orig_addons) != set(self.addons):

                log.debug("Setting new software selection old env %s, new env %s and addons %s",
                          self._orig_env, self.environment, self.addons)

                self.payload.data.packages.packageList = []
                self.data.packages.groupList = []
                self.payload.select_environment(self.environment)

                environment_id = self._translate_env_name_to_id(self.environment)
                available_addons = self._get_available_addons(environment_id)

                for addon_id in available_addons:
                    if addon_id in self.addons:
                        self.payload.select_group(addon_id)

                changed = True

            self._orig_env = self.environment
            self._orig_addons = set(self.addons)

        # Check the software selection
        if changed or self._kickstarted:
            threadMgr.add(AnacondaThread(name=THREAD_CHECK_SOFTWARE,
                                         target=self.check_software_selection))
Ejemplo n.º 30
0
    def _do_configuration(self, widget=None, reenable_ransom=True):
        from pyanaconda.installation import doConfiguration
        from pyanaconda.threading import threadMgr, AnacondaThread

        assert self._configurationDone == False

        self._configurationDone = True

        # Disable all personalization spokes
        self.builder.get_object("progressWindow-scroll").set_sensitive(False)

        if reenable_ransom:
            self._start_ransom_notes()

        self._restart_spinner()

        GLib.timeout_add(250, self._update_progress, self._configuration_done)
        threadMgr.add(AnacondaThread(name=THREAD_CONFIGURATION, target=doConfiguration,
                                     args=(self.storage, self.payload, self.data, self.instclass)))
Ejemplo n.º 31
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self.initialize_start()

        # get object references from the builders
        self._main_notebook = self.builder.get_object("main_notebook")

        # * the registration tab  * #

        # container for the main registration controls
        self._registration_grid = self.builder.get_object("registration_grid")

        # authentication
        self._account_radio_button = self.builder.get_object(
            "account_radio_button")
        self._activation_key_radio_button = self.builder.get_object(
            "activation_key_radio_button")

        # authentication - account
        self._account_revealer = self.builder.get_object("account_revealer")
        self._username_entry = self.builder.get_object("username_entry")
        self._password_entry = self.builder.get_object("password_entry")

        # authentication - activation key
        self._activation_key_revealer = self.builder.get_object(
            "activation_key_revealer")
        self._organization_entry = self.builder.get_object(
            "organization_entry")
        self._activation_key_entry = self.builder.get_object(
            "activation_key_entry")

        # system purpose
        self._system_purpose_checkbox = self.builder.get_object(
            "system_purpose_checkbox")
        self._system_purpose_revealer = self.builder.get_object(
            "system_purpose_revealer")
        self._system_purpose_role_combobox = self.builder.get_object(
            "system_purpose_role_combobox")
        self._system_purpose_sla_combobox = self.builder.get_object(
            "system_purpose_sla_combobox")
        self._system_purpose_usage_combobox = self.builder.get_object(
            "system_purpose_usage_combobox")

        # insights
        self._insights_checkbox = self.builder.get_object("insights_checkbox")

        # options expander
        self._options_expander = self.builder.get_object("options_expander")

        # HTTP proxy
        self._http_proxy_checkbox = self.builder.get_object(
            "http_proxy_checkbox")
        self._http_proxy_revealer = self.builder.get_object(
            "http_proxy_revealer")
        self._http_proxy_location_entry = self.builder.get_object(
            "http_proxy_location_entry")
        self._http_proxy_username_entry = self.builder.get_object(
            "http_proxy_username_entry")
        self._http_proxy_password_entry = self.builder.get_object(
            "http_proxy_password_entry")

        # RHSM baseurl
        self._custom_rhsm_baseurl_checkbox = self.builder.get_object(
            "custom_rhsm_baseurl_checkbox")
        self._custom_rhsm_baseurl_revealer = self.builder.get_object(
            "custom_rhsm_baseurl_revealer")
        self._custom_rhsm_baseurl_entry = self.builder.get_object(
            "custom_rhsm_baseurl_entry")

        # server hostname
        self._custom_server_hostname_checkbox = self.builder.get_object(
            "custom_server_hostname_checkbox")
        self._custom_server_hostname_revealer = self.builder.get_object(
            "custom_server_hostname_revealer")
        self._custom_server_hostname_entry = self.builder.get_object(
            "custom_server_hostname_entry")

        # status label
        self._registration_status_label = self.builder.get_object(
            "registration_status_label")

        # register button
        self._register_button = self.builder.get_object("register_button")

        # * the subscription status tab * #

        # general status
        self._method_status_label = self.builder.get_object(
            "method_status_label")
        self._role_status_label = self.builder.get_object("role_status_label")
        self._sla_status_label = self.builder.get_object("sla_status_label")
        self._usage_status_label = self.builder.get_object(
            "usage_status_label")
        self._insights_status_label = self.builder.get_object(
            "insights_status_label")

        # attached subscriptions
        self._attached_subscriptions_label = self.builder.get_object(
            "attached_subscriptions_label")
        self._subscriptions_listbox = self.builder.get_object(
            "subscriptions_listbox")

        # setup spoke state based on data from the Subscription DBus module
        self._update_spoke_state()

        # start the rest of spoke initialization which might take some time
        # (mainly due to waiting for various initialization threads to finish)
        # in a separate thread
        threadMgr.add(
            AnacondaThread(name=THREAD_SUBSCRIPTION_SPOKE_INIT,
                           target=self._initialize))
Ejemplo n.º 32
0
                              text_mode=anaconda.tui_mode)

    # Initialize the network now, in case the display needs it
    from pyanaconda.network import initialize_network, wait_for_connecting_NM_thread, wait_for_connected_NM

    initialize_network()
    # If required by user, wait for connection before starting the installation.
    if opts.waitfornet:
        log.info(
            "network: waiting for connectivity requested by inst.waitfornet=%d",
            opts.waitfornet)
        wait_for_connected_NM(timeout=opts.waitfornet)

    # In any case do some actions only after NM finishes its connecting.
    threadMgr.add(
        AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM,
                       target=wait_for_connecting_NM_thread))

    # now start the interface
    display.setup_display(anaconda, opts)
    if anaconda.gui_startup_failed:
        # we need to reinitialize the locale if GUI startup failed,
        # as we might now be in text mode, which might not be able to display
        # the characters from our current locale
        log.warning(
            "reinitializing locale due to failed attempt to start the GUI")
        localization.setup_locale(os.environ["LANG"],
                                  localization_proxy,
                                  text_mode=anaconda.tui_mode)

    # we now know in which mode we are going to run so store the information
Ejemplo n.º 33
0
 def __enter__(self):
     """Start to monitor the progress."""
     # Start the thread.
     threadMgr.add(
         AnacondaThread(name=self._thread_name,
                        target=self._monitor_progress))
Ejemplo n.º 34
0
    blivet.enable_installer_mode()

    # Initialize the network now, in case the display needs it
    from pyanaconda.network import networkInitialize, wait_for_connecting_NM_thread, wait_for_connected_NM

    networkInitialize(ksdata)
    # If required by user, wait for connection before starting the installation.
    if opts.waitfornet:
        log.info(
            "network: waiting for connectivity requested by inst.waitfornet=%d",
            opts.waitfornet)
        wait_for_connected_NM(timeout=opts.waitfornet)

    # In any case do some actions only after NM finishes its connecting.
    threadMgr.add(
        AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM,
                       target=wait_for_connecting_NM_thread,
                       args=(ksdata, )))

    # initialize the screen access manager before launching the UI
    from pyanaconda import screen_access
    screen_access.initSAM()
    # try to open any existing config file
    # (might be created by pre-anaconda helper tools, injected during image
    # generation, etc.)
    screen_access.sam.open_config_file()

    # now start the interface
    display.setup_display(anaconda, opts, addon_paths=addon_paths)
    if anaconda.gui_startup_failed:
        # we need to reinitialize the locale if GUI startup failed,
        # as we might now be in text mode, which might not be able to display
Ejemplo n.º 35
0
def gtk_batch_map(action, items, args=(), pre_func=None, batch_size=1):
    """
    Function that maps an action on items in a way that makes the action run in
    the main thread, but without blocking the main thread for a noticeable
    time. If a pre-processing function is given it is mapped on the items first
    before the action happens in the main thread.

    .. DANGER::
       MUST NOT BE CALLED NOR WAITED FOR FROM THE MAIN THREAD.

    :param action: any action that has to be done on the items in the main
                   thread
    :type action: (action_item, \\*args) -> None
    :param items: an iterable of items that the action should be mapped on
    :type items: iterable
    :param args: additional arguments passed to the action function
    :type args: tuple
    :param pre_func: a function that is mapped on the items before they are
                     passed to the action function
    :type pre_func: item -> action_item
    :param batch_size: how many items should be processed in one run in the main loop
    :raise AssertionError: if called from the main thread
    :return: None

    """

    assert(not threadMgr.in_main_thread())

    def preprocess(queue_instance):
        if pre_func:
            for item in items:
                queue_instance.put(pre_func(item))
        else:
            for item in items:
                queue_instance.put(item)

        queue_instance.put(TERMINATOR)

    def process_one_batch(arguments):
        (queue_instance, action, done_event) = arguments
        tstamp_start = time.time()
        tstamp = time.time()

        # process as many batches as user shouldn't notice
        while tstamp - tstamp_start < NOTICEABLE_FREEZE:
            for _i in range(batch_size):
                try:
                    action_item = queue_instance.get_nowait()
                    if action_item is TERMINATOR:
                        # all items processed, tell we are finished and return
                        done_event.set()
                        return False
                    else:
                        # run action on the item
                        action(action_item, *args)
                except queue.Empty:
                    # empty queue_instance, reschedule to run later
                    return True

            tstamp = time.time()

        # out of time but something left, reschedule to run again later
        return True

    item_queue_instance = queue.Queue()
    done_event = threading.Event()

    # we don't want to log the whole list, type and address is enough
    log.debug("Starting applying %s on %s", action, object.__repr__(items))

    # start a thread putting preprocessed items into the queue_instance
    threadMgr.add(AnacondaThread(prefix="AnaGtkBatchPre",
                                 target=preprocess,
                                 args=(item_queue_instance,)))

    run_in_loop(process_one_batch, (item_queue_instance, action, done_event))
    done_event.wait()
    log.debug("Finished applying %s on %s", action, object.__repr__(items))
Ejemplo n.º 36
0
    enable_installer_mode()

    # Initialize the network now, in case the display needs it
    from pyanaconda.network import initialize_network, wait_for_connecting_NM_thread, wait_for_connected_NM

    initialize_network()
    # If required by user, wait for connection before starting the installation.
    if opts.waitfornet:
        log.info(
            "network: waiting for connectivity requested by inst.waitfornet=%d",
            opts.waitfornet)
        wait_for_connected_NM(timeout=opts.waitfornet)

    # In any case do some actions only after NM finishes its connecting.
    threadMgr.add(
        AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM,
                       target=wait_for_connecting_NM_thread))

    # now start the interface
    display.setup_display(anaconda, opts)
    if anaconda.gui_startup_failed:
        # we need to reinitialize the locale if GUI startup failed,
        # as we might now be in text mode, which might not be able to display
        # the characters from our current locale
        log.warning(
            "reinitializing locale due to failed attempt to start the GUI")
        localization.setup_locale(os.environ["LANG"],
                                  localization_proxy,
                                  text_mode=anaconda.tui_mode)

    # we now know in which mode we are going to run so store the information
Ejemplo n.º 37
0
 def execute(self):
     """Execute the changes."""
     threadMgr.add(
         AnacondaThread(name=THREAD_CHECK_SOFTWARE,
                        target=self._check_software_selection))
Ejemplo n.º 38
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self.initialize_start()
        self._daysStore = self.builder.get_object("days")
        self._monthsStore = self.builder.get_object("months")
        self._yearsStore = self.builder.get_object("years")
        self._regionsStore = self.builder.get_object("regions")
        self._citiesStore = self.builder.get_object("cities")
        self._tzmap = self.builder.get_object("tzmap")
        self._dateBox = self.builder.get_object("dateBox")

        # we need to know it the new value is the same as previous or not
        self._old_region = None
        self._old_city = None

        self._regionCombo = self.builder.get_object("regionCombobox")
        self._cityCombo = self.builder.get_object("cityCombobox")

        self._daysFilter = self.builder.get_object("daysFilter")
        self._daysFilter.set_visible_func(self.existing_date, None)

        self._citiesFilter = self.builder.get_object("citiesFilter")
        self._citiesFilter.set_visible_func(self.city_in_region, None)

        self._hoursLabel = self.builder.get_object("hoursLabel")
        self._minutesLabel = self.builder.get_object("minutesLabel")
        self._amPmUp = self.builder.get_object("amPmUpButton")
        self._amPmDown = self.builder.get_object("amPmDownButton")
        self._amPmLabel = self.builder.get_object("amPmLabel")
        self._radioButton24h = self.builder.get_object("timeFormatRB")
        self._amPmRevealer = self.builder.get_object("amPmRevealer")

        # Set the entry completions.
        # The text_column property needs to be set here. If we set
        # it in the glade file, the completion doesn't show text.
        region_completion = self.builder.get_object("regionCompletion")
        region_completion.set_text_column(0)

        city_completion = self.builder.get_object("cityCompletion")
        city_completion.set_text_column(0)

        # create widgets for displaying/configuring date
        day_box, self._dayCombo, day_label = _new_date_field_box(self._daysFilter)
        self._dayCombo.connect("changed", self.on_day_changed)
        month_box, self._monthCombo, month_label = _new_date_field_box(self._monthsStore)
        self._monthCombo.connect("changed", self.on_month_changed)
        year_box, self._yearCombo, year_label = _new_date_field_box(self._yearsStore)
        self._yearCombo.connect("changed", self.on_year_changed)

        # get the right order for date widgets and respective formats and put
        # widgets in place
        widgets, formats = resolve_date_format(year_box, month_box, day_box)
        for widget in widgets:
            self._dateBox.pack_start(widget, False, False, 0)

        self._day_format, suffix = formats[widgets.index(day_box)]
        day_label.set_text(suffix)
        self._month_format, suffix = formats[widgets.index(month_box)]
        month_label.set_text(suffix)
        self._year_format, suffix = formats[widgets.index(year_box)]
        year_label.set_text(suffix)

        self._ntpSwitch = self.builder.get_object("networkTimeSwitch")

        self._regions_zones = get_all_regions_and_timezones()

        # Set the initial sensitivity of the AM/PM toggle based on the time-type selected
        self._radioButton24h.emit("toggled")

        if not conf.system.can_set_system_clock:
            self._hide_date_time_setting()

        threadMgr.add(AnacondaThread(name=constants.THREAD_DATE_TIME,
                                     target=self._initialize))
Ejemplo n.º 39
0
    def install(self):
        """ Install the payload. """

        if self.source_size <= 0:
            raise PayloadInstallError("Nothing to install")

        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(
            AnacondaThread(name=THREAD_LIVE_PROGRESS, target=self.progress))

        cmd = "rsync"
        # preserve: permissions, owners, groups, ACL's, xattrs, times,
        #           symlinks, hardlinks
        # go recursively, include devices and special files, don't cross
        # file system boundaries
        args = [
            "-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
            "--exclude", "/sys/", "--exclude", "/run/", "--exclude",
            "/boot/*rescue*", "--exclude", "/boot/loader/", "--exclude",
            "/boot/efi/loader/", "--exclude", "/etc/machine-id",
            INSTALL_TREE + "/",
            util.getSysroot()
        ]
        try:
            rc = util.execWithRedirect(cmd, args)
        except (OSError, RuntimeError) as e:
            msg = None
            err = str(e)
            log.error(err)
        else:
            err = None
            msg = "%s exited with code %d" % (cmd, rc)
            log.info(msg)

        if err or rc == 11:
            exn = PayloadInstallError(err or msg)
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)

        # Live needs to create the rescue image before bootloader is written
        if os.path.exists(util.getSysroot() + "/usr/sbin/new-kernel-pkg"):
            useNKP = True
        else:
            log.warning(
                "new-kernel-pkg does not exist - grubby wasn't installed?")
            useNKP = False

        for kernel in self.kernelVersionList:
            log.info("Generating rescue image for %s", kernel)
            if useNKP:
                util.execInSysroot("new-kernel-pkg",
                                   ["--rpmposttrans", kernel])
            else:
                files = glob.glob(util.getSysroot() +
                                  "/etc/kernel/postinst.d/*")
                srlen = len(util.getSysroot())
                files = sorted(
                    [f[srlen:] for f in files if os.access(f, os.X_OK)])
                for file in files:
                    util.execInSysroot(
                        file, [kernel, "/boot/vmlinuz-%s" % kernel])
Ejemplo n.º 40
0
 def run(self):
     threadMgr.add(
         AnacondaThread(name=constants.THREAD_CHECK_STORAGE,
                        target=self.checkStorage))
Ejemplo n.º 41
0
 def execute(self):
     """Execute the changes."""
     threadMgr.add(AnacondaThread(
         name=constants.THREAD_CHECK_SOFTWARE,
         target=self.checkSoftwareSelection
     ))
Ejemplo n.º 42
0
    startup_utils.initialize_locale(opts, text_mode=anaconda.tui_mode)

    # Initialize the network now, in case the display needs it
    from pyanaconda.network import initialize_network, wait_for_connecting_NM_thread, wait_for_connected_NM

    initialize_network()
    # If required by user, wait for connection before starting the installation.
    if opts.waitfornet:
        log.info(
            "network: waiting for connectivity requested by inst.waitfornet=%d",
            opts.waitfornet)
        wait_for_connected_NM(timeout=opts.waitfornet)

    # In any case do some actions only after NM finishes its connecting.
    threadMgr.add(
        AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM,
                       target=wait_for_connecting_NM_thread))

    # now start the interface
    display.setup_display(anaconda, opts)
    if anaconda.gui_startup_failed:
        # we need to reinitialize the locale if GUI startup failed,
        # as we might now be in text mode, which might not be able to display
        # the characters from our current locale
        startup_utils.reinitialize_locale(opts, text_mode=anaconda.tui_mode)

    # we now know in which mode we are going to run so store the information
    from pykickstart import constants as pykickstart_constants
    display_mode_coversion_table = {
        constants.DisplayModes.GUI:
        pykickstart_constants.DISPLAY_MODE_GRAPHICAL,
Ejemplo n.º 43
0
 def initialize(self):
     super().initialize()
     self.initialize_start()
     threadMgr.add(
         AnacondaThread(name=constants.THREAD_SOFTWARE_WATCHER,
                        target=self._initialize))
Ejemplo n.º 44
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self.initialize_start()

        # set X keyboard defaults
        # - this needs to be done early in spoke initialization so that
        #   the spoke status does not show outdated keyboard selection
        keyboard.set_x_keyboard_defaults(self._l12_module.proxy,
                                         self._xkl_wrapper)

        # make sure the x_layouts list has at least one keyboard layout
        if not self._l12_module.proxy.XLayouts:
            self._l12_module.proxy.SetXLayouts([DEFAULT_KEYBOARD])

        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if flags.can_touch_runtime_system(
                "hide runtime keyboard configuration "
                "warning", touch_live=True):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        override_cell_property(layoutColumn, layoutRenderer, "text",
                               _show_layout, self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(
            self.data, self._l12_module)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts",
                                              touch_live=True):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [
                self.builder.get_object("testingLabel"),
                self.builder.get_object("testingWindow"),
                self.builder.get_object("layoutSwitchLabel")
            ]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(
                _("Testing layouts configuration not "
                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(
            AnacondaThread(name=THREAD_KEYBOARD_INIT, target=self._wait_ready))