示例#1
0
    def set_source_cdrom(self):
        """ Switch to cdrom install source """
        # clean any old HDD ISO sources
        self._tear_down_existing_source()

        cdrom_source_proxy = create_source(constants.SOURCE_TYPE_CDROM)

        set_source(self.payload.proxy, cdrom_source_proxy)
示例#2
0
    def set_source_closest_mirror(self):
        """ Switch to the closest mirror install source """
        # clean any old HDD ISO sources
        self._tear_down_existing_source()

        repo_files_source_proxy = create_source(constants.SOURCE_TYPE_CLOSEST_MIRROR)

        set_source(self.payload.proxy, repo_files_source_proxy)
示例#3
0
    def set_source_hmc(self):
        """ Switch to install source via HMC """
        # clean any old HDD ISO sources
        self._tear_down_existing_source()

        hmc_source_proxy = create_source(constants.SOURCE_TYPE_HMC)

        set_source(self.payload.proxy, hmc_source_proxy)
示例#4
0
    def create_proxy(self):
        """Create and set up a DBus source.

        :return: a DBus proxy of a source
        """
        source_proxy = create_source(SOURCE_TYPE_HDD)
        source_proxy.SetPartition(self.partition)
        source_proxy.SetDirectory(self.path)
        return source_proxy
示例#5
0
def set_source_cdn(payload):
    """Switch to the CDN installation source.

    :param payload: Anaconda payload instance
    """
    _tear_down_existing_source(payload)

    new_source_proxy = create_source(SOURCE_TYPE_CDN)
    set_source(payload.proxy, new_source_proxy)
示例#6
0
    def create_proxy(self):
        """Create and set up a DBus source.

        :return: a DBus proxy of a source
        """
        source_proxy = create_source(SOURCE_TYPE_NFS)
        source_url = create_nfs_url(self.server, self.path, self.options)
        source_proxy.SetURL(source_url)
        return source_proxy
示例#7
0
    def create_source_test(self, proxy_getter):
        """Test the create_source function."""
        payloads_proxy = PAYLOADS.get_proxy()
        payloads_proxy.CreateSource.return_value = "/my/source"

        source_proxy = PAYLOADS.get_proxy("/my/source")
        source_proxy.Type = SOURCE_TYPE_CDROM

        self.assertEqual(create_source(SOURCE_TYPE_CDROM), source_proxy)
        payloads_proxy.CreateSource.assert_called_once_with(SOURCE_TYPE_CDROM)
示例#8
0
def switch_source(payload, source_type):
    """Switch to an installation source.

    :param payload: Anaconda payload instance
    :param source_type: installation source type
    """
    _tear_down_existing_source(payload)

    new_source_proxy = create_source(source_type)
    set_source(payload.proxy, new_source_proxy)
示例#9
0
    def set_from_opts(self, opts):
        """Add the flatpak source if available."""
        flatpak_source = create_source(SOURCE_TYPE_FLATPAK)

        if not flatpak_source.IsAvailable():
            log.debug("The flatpak source is not available.")
            return

        sources = self.proxy.Sources
        sources.append(get_object_path(flatpak_source))
        self.proxy.SetSources(sources)
示例#10
0
    def set_source_nfs(self, server, directory, opts):
        """ Switch to NFS install source """
        # clean any old HDD ISO sources
        self._tear_down_existing_source()

        nfs_url = create_nfs_url(server, directory, opts)

        nfs_source_proxy = create_source(constants.SOURCE_TYPE_NFS)
        nfs_source_proxy.URL = nfs_url

        set_source(self.payload.proxy, nfs_source_proxy)
示例#11
0
    def create_proxy(self):
        """Create and set up a DBus source.

        :return: a DBus proxy of a source
        """
        source_proxy = create_source(SOURCE_TYPE_URL)

        repo_configuration = RepoConfigurationData()
        repo_configuration.type = URL_TYPE_BASEURL
        repo_configuration.url = self.path

        source_proxy.SetRepoConfiguration(
            RepoConfigurationData.to_structure(repo_configuration))

        return source_proxy
示例#12
0
    def create_proxy(self):
        """Create and set up a DBus source.

        :return: a DBus proxy of a source
        """
        source_proxy = create_source(SOURCE_TYPE_URL)

        repo_configuration = RepoConfigurationData()
        repo_configuration.type = self.url_type
        repo_configuration.url = self.url

        source_proxy.RepoConfiguration = \
            RepoConfigurationData.to_structure(repo_configuration)

        return source_proxy
示例#13
0
    def set_source_url(self, url, url_type=constants.URL_TYPE_BASEURL, proxy=None):
        """ Switch to install source specified by URL """
        # clean any old HDD ISO sources
        self._tear_down_existing_source()

        url_source_proxy = create_source(constants.SOURCE_TYPE_URL)

        repo_conf = RepoConfigurationData()
        repo_conf.url = url
        repo_conf.type = url_type
        repo_conf.proxy = proxy or ""

        url_source_proxy.SetRepoConfiguration(
            RepoConfigurationData.to_structure(repo_conf)
        )

        set_source(self.payload.proxy, url_source_proxy)
示例#14
0
    def set_source_hdd_iso(self, device_name, iso_path):
        """ Switch to the HDD ISO install source

        :param device_name: name of the partition hosting the ISO
        :type device_name: string
        :param iso_path: full path to the source ISO file
        :type iso_path: string
        """
        self._tear_down_existing_source()

        new_source_proxy = create_source(constants.SOURCE_TYPE_HDD)
        new_source_proxy.Partition = device_name
        # the / gets stripped off by payload.ISO_image
        new_source_proxy.Directory = "/" + iso_path

        # protect current device_name
        mark_protected_device(device_name)

        set_source(self.payload.proxy, new_source_proxy)
示例#15
0
    def update_base_repo(self, fallback=True, checkmount=True):
        """Update the base repository from the DBus source."""
        log.info("Configuring the base repo")
        self._reset_configuration()

        disabled_treeinfo_repo_names = self._cleanup_old_treeinfo_repositories()

        # Find the source and its type.
        source_proxy = self.get_source_proxy()
        source_type = source_proxy.Type

        # Change the default source to CDROM if there is a valid install media.
        # FIXME: Set up the default source earlier.
        if checkmount and self._is_source_default() and find_optical_install_media():
            source_type = SOURCE_TYPE_CDROM
            source_proxy = create_source(source_type)
            set_source(self.proxy, source_proxy)

        # Set up the source.
        set_up_sources(self.proxy)

        # Read in all the repos from the installation environment, make a note of which
        # are enabled, and then disable them all.  If the user gave us a method, we want
        # to use that instead of the default repos.
        self._base.read_all_repos()

        # Enable or disable updates.
        self.set_updates_enabled(self._updates_enabled)

        # Repo files are always loaded from the system.
        # When reloaded their state needs to be synchronized with the user configuration.
        # So we disable them now and enable them later if required.
        enabled = []
        with self._repos_lock:
            for repo in self._base.repos.iter_enabled():
                enabled.append(repo.id)
                repo.disable()

        # Add a new repo.
        if source_type not in SOURCE_REPO_FILE_TYPES:
            # Get the repo configuration of the first source.
            data = RepoConfigurationData.from_structure(
                self.proxy.GetRepoConfigurations()[0]
            )

            log.debug("Using the repo configuration: %s", data)

            # Get the URL.
            install_tree_url = data.url if data.type == URL_TYPE_BASEURL else ""
            mirrorlist = data.url if data.type == URL_TYPE_MIRRORLIST else ""
            metalink = data.url if data.type == URL_TYPE_METALINK else ""

            # Fallback to the installation root.
            base_repo_url = install_tree_url

            try:
                self._refresh_install_tree(data)
                self._base.conf.releasever = self._get_release_version(install_tree_url)
                base_repo_url = self._get_base_repo_location(install_tree_url)
                log.debug("releasever from %s is %s", base_repo_url, self._base.conf.releasever)

                self._load_treeinfo_repositories(base_repo_url, disabled_treeinfo_repo_names, data)
            except configparser.MissingSectionHeaderError as e:
                log.error("couldn't set releasever from base repo (%s): %s", source_type, e)

            try:
                base_ksrepo = self.data.RepoData(
                    name=constants.BASE_REPO_NAME,
                    baseurl=base_repo_url,
                    mirrorlist=mirrorlist,
                    metalink=metalink,
                    noverifyssl=not data.ssl_verification_enabled,
                    proxy=data.proxy,
                    sslcacert=data.ssl_configuration.ca_cert_path,
                    sslclientcert=data.ssl_configuration.client_cert_path,
                    sslclientkey=data.ssl_configuration.client_key_path
                )
                self._add_repo_to_dnf(base_ksrepo)
                self._fetch_md(base_ksrepo.name)
            except (MetadataError, PayloadError) as e:
                log.error("base repo (%s/%s) not valid -- removing it",
                          source_type, base_repo_url)
                log.error("reason for repo removal: %s", e)
                with self._repos_lock:
                    self._base.repos.pop(constants.BASE_REPO_NAME, None)
                if not fallback:
                    with self._repos_lock:
                        for repo in self._base.repos.iter_enabled():
                            self._disable_repo(repo.id)
                    return

                # Fallback to the default source
                #
                # This is at the moment CDN on RHEL
                # and closest mirror everywhere else.
                tear_down_sources(self.proxy)

                source_type = conf.payload.default_source
                source_proxy = create_source(source_type)
                set_source(self.proxy, source_proxy)

                set_up_sources(self.proxy)

        # We need to check this again separately in case REPO_FILES were set above.
        if source_type in SOURCE_REPO_FILE_TYPES:

            # If this is a kickstart install, just return now as we normally do not
            # want to read the on media repo files in such a case. On the other hand,
            # the local repo files are a valid use case if the system is subscribed
            # and the CDN is selected as the installation source.
            if self.source_type == SOURCE_TYPE_CDN and is_module_available(SUBSCRIPTION):
                # only check if the Subscription module is available & CDN is the
                # installation source
                subscription_proxy = SUBSCRIPTION.get_proxy()
                load_cdn_repos = subscription_proxy.IsSubscriptionAttached
            else:
                # if the Subscription module is not available, we simply can't use
                # the CDN repos, making our decision here simple
                load_cdn_repos = False
            if flags.automatedInstall and not load_cdn_repos:
                return

            # Otherwise, fall back to the default repos that we disabled above
            with self._repos_lock:
                for (id_, repo) in self._base.repos.items():
                    if id_ in enabled:
                        log.debug("repo %s: fall back enabled from default repos", id_)
                        repo.enable()

        for repo in self.addons:
            ksrepo = self.get_addon_repo(repo)

            if ksrepo.is_harddrive_based():
                ksrepo.baseurl = self._setup_harddrive_addon_repo(ksrepo)

            log.debug("repo %s: mirrorlist %s, baseurl %s, metalink %s",
                      ksrepo.name, ksrepo.mirrorlist, ksrepo.baseurl, ksrepo.metalink)
            # one of these must be set to create new repo
            if not (ksrepo.mirrorlist or ksrepo.baseurl or ksrepo.metalink or
                    ksrepo.name in self._base.repos):
                raise PayloadSetupError("Repository %s has no mirror, baseurl or "
                                        "metalink set and is not one of "
                                        "the pre-defined repositories" %
                                        ksrepo.name)

            self._add_repo_to_dnf(ksrepo)

        with self._repos_lock:

            # disable unnecessary repos
            for repo in self._base.repos.iter_enabled():
                id_ = repo.id
                if 'source' in id_ or 'debuginfo' in id_:
                    self._disable_repo(id_)
                elif constants.isFinal and 'rawhide' in id_:
                    self._disable_repo(id_)

            # fetch md for enabled repos
            enabled_repos = self._enabled_repos
            for repo_name in self.addons:
                if repo_name in enabled_repos:
                    self._fetch_md(repo_name)
示例#16
0
    def update_base_repo(self, fallback=True, try_media=True):
        """Update the base repository from the DBus source."""
        log.debug("Tearing down sources")
        tear_down_sources(self.proxy)
        self._tear_down_additional_sources()

        log.debug("Preparing the DNF base")
        self.tx_id = None

        self._dnf_manager.clear_cache()
        self._dnf_manager.reset_substitution()
        self._dnf_manager.configure_base(self.get_packages_configuration())
        self._dnf_manager.configure_proxy(self._get_proxy_url())
        self._dnf_manager.dump_configuration()
        self._dnf_manager.read_system_repositories()

        log.info("Configuring the base repo")
        # Find the source and its type.
        source_proxy = self.get_source_proxy()
        source_type = source_proxy.Type

        # Change the default source to CDROM if there is a valid install media.
        # FIXME: Set up the default source earlier.
        if try_media and self._is_source_default(
        ) and find_optical_install_media():
            source_type = SOURCE_TYPE_CDROM
            source_proxy = create_source(source_type)
            set_source(self.proxy, source_proxy)

        # Set up the source.
        set_up_sources(self.proxy)

        # Add a new repo.
        if source_type not in SOURCE_REPO_FILE_TYPES:
            try:
                self._add_base_repository()
            except DNFManagerError as e:
                # Fail if the fallback is not enabled.
                if not fallback:
                    raise e

                # Fallback to the default source
                #
                # This is at the moment CDN on RHEL
                # and closest mirror everywhere else.
                tear_down_sources(self.proxy)

                source_type = conf.payload.default_source
                source_proxy = create_source(source_type)
                set_source(self.proxy, source_proxy)

                set_up_sources(self.proxy)

        # We need to check this again separately in case REPO_FILES were set above.
        if source_type in SOURCE_REPO_FILE_TYPES:
            # Remove all treeinfo repositories.
            self._remove_treeinfo_repositories()

            # If this is a kickstart install, just return now as we normally do not
            # want to read the on media repo files in such a case. On the other hand,
            # the local repo files are a valid use case if the system is subscribed
            # and the CDN is selected as the installation source.
            if flags.automatedInstall and not self._is_cdn_set_up():
                return

            # Otherwise, fall back to the default repos that we disabled above
            self._enable_system_repositories()

        self._include_additional_repositories()
        self._validate_enabled_repositories()
示例#17
0
    def create_proxy(self):
        """Create and set up a DBus source.

        :return: a DBus proxy of a source
        """
        return create_source(SOURCE_TYPE_HMC)