def set_url_metalink_properties_test(self): data = RepoConfigurationData() data.url = "https://alianceFTW/metalink?nopesir" data.type = URL_TYPE_METALINK self._check_dbus_property("RepoConfiguration", RepoConfigurationData.to_structure(data))
def set_url_mirrorlist_properties_test(self): data = RepoConfigurationData() data.url = "http://forthehorde.com/mirrorlist?url" data.type = URL_TYPE_MIRRORLIST self._check_dbus_property("RepoConfiguration", RepoConfigurationData.to_structure(data))
def set_url_base_source_properties_test(self): data = RepoConfigurationData() data.url = "http://example.com/repo" data.type = URL_TYPE_BASEURL self._check_dbus_property("RepoConfiguration", RepoConfigurationData.to_structure(data))
def convert_ks_repo_to_repo_data(ks_data): """Convert the kickstart command into a repo configuration. :param RepoData ks_data: a kickstart data :return RepoConfigurationData: a repo configuration """ if not isinstance(ks_data, RepoData): raise ValueError("Unexpected kickstart data: {}".format(type(ks_data))) repo_data = RepoConfigurationData() repo_data.name = ks_data.name repo_data.enabled = ks_data.enabled if ks_data.baseurl: repo_data.url = ks_data.baseurl repo_data.type = URL_TYPE_BASEURL elif ks_data.mirrorlist: repo_data.url = ks_data.mirrorlist repo_data.type = URL_TYPE_MIRRORLIST elif ks_data.metalink: repo_data.url = ks_data.metalink repo_data.type = URL_TYPE_METALINK else: # Handle the `repo --name=updates` use case. repo_data.url = "" repo_data.type = "NONE" if ks_data.treeinfo_origin: repo_data.origin = REPO_ORIGIN_TREEINFO elif not repo_data.url: repo_data.origin = REPO_ORIGIN_SYSTEM else: repo_data.origin = REPO_ORIGIN_USER repo_data.proxy = ks_data.proxy or "" repo_data.cost = ks_data.cost or DNF_DEFAULT_REPO_COST repo_data.included_packages = ks_data.includepkgs repo_data.excluded_packages = ks_data.excludepkgs repo_data.installation_enabled = ks_data.install repo_data.ssl_verification_enabled = not ks_data.noverifyssl repo_data.ssl_configuration.ca_cert_path = ks_data.sslcacert or "" repo_data.ssl_configuration.client_cert_path = ks_data.sslclientcert or "" repo_data.ssl_configuration.client_key_path = ks_data.sslclientkey or "" return repo_data
def test_load_data_unsupported_url(self): """Test the load_data method with an unsupported URL.""" data = RepoConfigurationData() data.type = URL_TYPE_METALINK with self.assertRaises(NoTreeInfoError) as cm: self.metadata.load_data(data) self.assertEqual(str(cm.exception), "Unsupported type of URL (METALINK).")
def test_load_data_unsupported_url(self): """Test the load_data method with an unsupported URL.""" data = RepoConfigurationData() data.type = URL_TYPE_METALINK with pytest.raises(NoTreeInfoError) as cm: self.metadata.load_data(data) assert str(cm.value) == "Unsupported type of URL (METALINK)."
def test_add_repository_metalink(self): """Test the add_repository method with metalink.""" data = RepoConfigurationData() data.name = "r1" data.type = URL_TYPE_METALINK data.url = "http://metalink" self.dnf_manager.add_repository(data) self._check_repo("r1", [ "metalink = http://metalink", ])
def test_add_repository_mirrorlist(self): """Test the add_repository method with mirrorlist.""" data = RepoConfigurationData() data.name = "r1" data.type = URL_TYPE_MIRRORLIST data.url = "http://mirror" self.dnf_manager.add_repository(data) self._check_repo("r1", [ "mirrorlist = http://mirror", ])
def test_add_repository_baseurl(self): """Test the add_repository method with baseurl.""" data = RepoConfigurationData() data.name = "r1" data.type = URL_TYPE_BASEURL data.url = "http://repo" self.dnf_manager.add_repository(data) self._check_repo("r1", [ "baseurl = http://repo", ])
def process_kickstart(self, data): """Process the kickstart data.""" repo_data = RepoConfigurationData() repo_data.name = self._url_source_name if data.url.url: repo_data.url = data.url.url repo_data.type = URL_TYPE_BASEURL elif data.url.mirrorlist: repo_data.url = data.url.mirrorlist repo_data.type = URL_TYPE_MIRRORLIST elif data.url.metalink: repo_data.url = data.url.metalink repo_data.type = URL_TYPE_METALINK repo_data.proxy = data.url.proxy repo_data.ssl_verification_enabled = not data.url.noverifyssl repo_data.ssl_configuration.ca_cert_path = data.url.sslcacert or "" repo_data.ssl_configuration.client_cert_path = data.url.sslclientcert or "" repo_data.ssl_configuration.client_key_path = data.url.sslclientkey or "" self.set_repo_configuration(repo_data)
def set_invalid_url_type_properties_test(self): data = RepoConfigurationData() data.url = "http://test" data.type = "DOES-NOT-EXISTS" with self.assertRaises(InvalidValueError): self._check_dbus_property("RepoConfiguration", RepoConfigurationData.to_structure(data)) # new value shouldn't be set old_data = self.url_source_interface.RepoConfiguration old_data = RepoConfigurationData.from_structure(old_data) self.assertEqual(old_data.url, "") self.assertEqual(old_data.type, URL_TYPE_BASEURL)
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
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
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)
def test_generate_repo_file_baseurl(self): """Test the generate_repo_file method with baseurl.""" data = RepoConfigurationData() data.name = "r1" data.type = URL_TYPE_BASEURL data.url = "http://repo" data.proxy = "http://example.com:1234" data.cost = 256 self._check_content( data, """ [r1] name = r1 enabled = 1 baseurl = http://repo proxy = http://example.com:1234 cost = 256 """)
def test_generate_repo_file_metalink(self): """Test the generate_repo_file method with metalink.""" data = RepoConfigurationData() data.name = "r1" data.enabled = False data.type = URL_TYPE_METALINK data.url = "http://metalink" data.included_packages = ["p1", "p2"] data.excluded_packages = ["p3", "p4"] self._check_content( data, """ [r1] name = r1 enabled = 0 metalink = http://metalink includepkgs = p1, p2 excludepkgs = p3, p4 """)
def test_generate_repo_file_mirrorlist(self): """Test the generate_repo_file method with mirrorlist.""" data = RepoConfigurationData() data.name = "r1" data.type = URL_TYPE_MIRRORLIST data.url = "http://mirror" data.ssl_verification_enabled = False data.proxy = "http://*****:*****@example.com:1234" self._check_content( data, """ [r1] name = r1 enabled = 1 mirrorlist = http://mirror sslverify = 0 proxy = http://example.com:1234 proxy_username = user proxy_password = pass """)
def _set_additional_repos_from_opts(self, opts): """Set additional repositories based on the Anaconda options.""" for repo_name, repo_url in opts.addRepo: try: source = SourceFactory.parse_repo_cmdline_string(repo_url) except PayloadSourceTypeUnrecognized: log.error( "Type for additional repository %s is not recognized!", repo_url) return if self.get_addon_repo(repo_name): log.warning( "Repository name %s is not unique. Only the first " "repo will be used!", repo_name) is_supported = source.is_nfs \ or source.is_http \ or source.is_https \ or source.is_ftp \ or source.is_file \ or source.is_harddrive if not is_supported: log.error( "Source type %s for additional repository %s is not supported!", source.source_type.value, repo_url) continue repo = RepoConfigurationData() repo.name = repo_name repo.enabled = True repo.type = URL_TYPE_BASEURL repo.url = repo_url repo.installation_enabled = False ks_repo = convert_repo_data_to_ks_repo(repo) self.data.repo.dataList().append(ks_repo)