示例#1
0
    def add_additional_repositories_to_ksdata(self):
        from pyanaconda.kickstart import RepoData

        for add_repo in self.additional_repos:
            name, repo_url = self._get_additional_repo_name(add_repo)
            try:
                source = SourceFactory.parse_repo_cmdline_string(repo_url)
            except PayloadSourceTypeUnrecognized:
                log.error("Type for additional repository %s is not recognized!", add_repo)
                return

            repo = RepoData(name=name, baseurl=repo_url, install=False)

            if source.is_nfs or source.is_http or source.is_https or source.is_ftp \
                    or source.is_file:
                repo.enabled = True
            elif source.is_harddrive:
                repo.enabled = True
                repo.partition = source.partition
                repo.iso_path = source.path
                repo.baseurl = "file://"
            else:
                log.error("Source type %s for additional repository %s is not supported!",
                          source.source_type.value, add_repo)
                continue

            self._check_repo_name_uniqueness(repo)
            self.ksdata.repo.dataList().append(repo)
示例#2
0
    def add_additional_repositories_to_ksdata(self):
        from pyanaconda.kickstart import RepoData

        for add_repo in self.additional_repos:
            name, repo_url = self._get_additional_repo_name(add_repo)
            try:
                source = SourceFactory.parse_repo_cmdline_string(repo_url)
            except PayloadSourceTypeUnrecognized:
                log.error(
                    "Type for additional repository %s is not recognized!",
                    add_repo)
                return

            repo = RepoData(name=name, baseurl=repo_url, install=False)

            if source.is_nfs or source.is_http or source.is_https or source.is_ftp \
                    or source.is_file:
                repo.enabled = True
            elif source.is_harddrive:
                repo.enabled = True
                repo.partition = source.partition
                repo.iso_path = source.path
                repo.baseurl = "file://"
            else:
                log.error(
                    "Source type %s for additional repository %s is not supported!",
                    source.source_type.value, add_repo)
                continue

            self._check_repo_name_uniqueness(repo)
            self.ksdata.repo.dataList().append(repo)
示例#3
0
    def test_convert_repo_origin(self):
        """Test the conversion of the repo origin."""
        ks_repo = RepoData()
        ks_repo.name = "repo-name"

        # Test the system origin.
        repo_data = convert_ks_repo_to_repo_data(ks_repo)
        assert repo_data.origin == REPO_ORIGIN_SYSTEM

        ks_repo = convert_repo_data_to_ks_repo(repo_data)
        assert ks_repo.treeinfo_origin is False

        # Test the user origin.
        ks_repo.baseurl = "http://url"

        repo_data = convert_ks_repo_to_repo_data(ks_repo)
        assert repo_data.origin == REPO_ORIGIN_USER

        ks_repo = convert_repo_data_to_ks_repo(repo_data)
        assert ks_repo.treeinfo_origin is False

        # Test the treeinfo origin.
        ks_repo.treeinfo_origin = True

        repo_data = convert_ks_repo_to_repo_data(ks_repo)
        assert repo_data.origin == REPO_ORIGIN_TREEINFO

        ks_repo = convert_repo_data_to_ks_repo(repo_data)
        assert ks_repo.treeinfo_origin is True
示例#4
0
def convert_repo_data_to_ks_repo(repo_data):
    """Convert the repo configuration into a kickstart command.

    :param RepoConfigurationData repo_data: a repo configuration
    :return RepoData: a kickstart data
    """
    if not isinstance(repo_data, RepoConfigurationData):
        raise ValueError("Unexpected data: {}".format(type(repo_data)))

    ks_data = RepoData()
    ks_data.name = repo_data.name
    ks_data.enabled = repo_data.enabled

    if repo_data.type == URL_TYPE_BASEURL:
        ks_data.baseurl = repo_data.url
    elif repo_data.type == URL_TYPE_MIRRORLIST:
        ks_data.mirrorlist = repo_data.url
    elif repo_data.type == URL_TYPE_METALINK:
        ks_data.metalink = repo_data.url

    ks_data.proxy = repo_data.proxy
    ks_data.noverifyssl = not repo_data.ssl_verification_enabled
    ks_data.sslcacert = repo_data.ssl_configuration.ca_cert_path
    ks_data.sslclientcert = repo_data.ssl_configuration.client_cert_path
    ks_data.sslclientkey = repo_data.ssl_configuration.client_key_path

    if repo_data.cost != DNF_DEFAULT_REPO_COST:
        ks_data.cost = repo_data.cost

    ks_data.includepkgs = repo_data.included_packages
    ks_data.excludepkgs = repo_data.excluded_packages
    ks_data.install = repo_data.installation_enabled

    return ks_data