示例#1
0
 def setUp(self):
     self.qstring = '?foo'
     self.url_modify = RepoURLModifier(query_auth_token=self.qstring[1:])
     self.metadata_files = metadata.MetadataFiles('http://pulpproject.org',
                                                  '/a/b/c',
                                                  DownloaderConfig(),
                                                  self.url_modify)
示例#2
0
    def test_get_requests_auth_token(self, fake_request):
        qstring = '?foo'
        listener = Mock()
        base_url = 'http://host'
        units = [
            Unit(),
            Unit(),
            Unit(),
        ]
        # set each unit to use a different base url
        for n, unit in enumerate(units):
            unit.base_url = '%s:%s/' % (base_url, n)
            unit.filename = 'file%d' % n
            unit.download_path = unit.filename
            unit.relativepath = unit.filename

        # test
        url_modify = RepoURLModifier(query_auth_token=qstring[1:])
        packages = Packages(base_url, None, units, '', listener, url_modify)
        requests = list(packages.get_requests())

        calls = fake_request.call_args_list
        self.assertEqual(len(requests), len(units))
        for n, call in enumerate(calls):
            unit_base_url = '%s:%s/' % (base_url, n)
            expected = urljoin(unit_base_url, units[n].download_path) + qstring
            self.assertEqual(call[1]['url'], expected)
        self.assertEqual(len(requests), len(units))
示例#3
0
 def __init__(self,
              base_url,
              nectar_conf,
              units,
              dst_dir,
              listener,
              url_modify=None):
     """
     :param base_url: The repository base url.
     :type base_url: str
     :param units: An iterable of units to download.
     :type units: iterable
     :param dst_dir: The absolute path to where the packages are to be downloaded.
     :type dst_dir: str
     :param listener: A nectar listener.
     :type listener: nectar.listener.DownloadListener
     :param url_modify: Optional URL modifier
     :type url_modify: pulp_rpm.plugins.importers.yum.utils.RepoURLModifier
     """
     self.base_url = base_url
     self.units = units
     self.dst_dir = dst_dir
     self.listener = ContainerListener(listener)
     self.primary = create_downloader(base_url, nectar_conf)
     self.container = ContentContainer()
     self.url_modify = url_modify or RepoURLModifier()
示例#4
0
    def __init__(self, repo, conduit, config):
        """
        :param repo: the repository to sync
        :type repo: pulp.server.db.model.Repository
        :param conduit: provides access to relevant Pulp functionality
        :type conduit: pulp.plugins.conduits.repo_sync.RepoSyncConduit
        :param config: plugin configuration
        :type config: pulp.plugins.config.PluginCallConfiguration
        """
        self.cancelled = False
        self.working_dir = common_utils.get_working_directory()
        self.content_report = ContentReport()
        self.distribution_report = DistributionReport()
        self.progress_report = {
            'metadata': {
                'state': 'NOT_STARTED'
            },
            'content': self.content_report,
            'distribution': self.distribution_report,
            'errata': {
                'state': 'NOT_STARTED'
            },
            'comps': {
                'state': 'NOT_STARTED'
            },
            'purge_duplicates': {
                'state': 'NOT_STARTED'
            },
        }
        self.conduit = conduit
        self.set_progress()
        self.repo = repo
        self.config = config
        self.nectar_config = nectar_utils.importer_config_to_nectar_config(
            config.flatten())
        self.skip_repomd_steps = False
        self.current_revision = 0
        self.downloader = None
        self.tmp_dir = None

        url_modify_config = {}
        if config.get('query_auth_token'):
            url_modify_config['query_auth_token'] = config.get(
                'query_auth_token')
            skip_config = self.config.get(constants.CONFIG_SKIP, [])

            for type_id in ids.QUERY_AUTH_TOKEN_UNSUPPORTED:
                if type_id not in skip_config:
                    skip_config.append(type_id)
            self.config.override_config[constants.CONFIG_SKIP] = skip_config
            _logger.info(
                _('The following unit types do not support query auth tokens and will be skipped:'
                  ' {skipped_types}').format(
                      skipped_types=ids.QUERY_AUTH_TOKEN_UNSUPPORTED))
        self._url_modify = RepoURLModifier(**url_modify_config)
示例#5
0
    def __init__(self,
                 repo_url,
                 nectar_config,
                 package_model_iterator,
                 dst_dir,
                 event_listener=None,
                 url_modify=None):
        self.repo_url = repo_url
        self.package_model_iterator = package_model_iterator
        self.dst_dir = dst_dir

        self.downloader = nectar_factory.create_downloader(
            repo_url, nectar_config, event_listener)
        self._url_modify = url_modify or RepoURLModifier()