def sync_repo(self, repo, conduit, config): """ Synchronize the content of the specified repository. The implementation is delegated to the strategy object which is selected based on the 'strategy' option passed specified in the configuration. :param repo: A repository object. :type repo: pulp.plugins.model.Repository :param conduit: Provides access to relevant Pulp functionality. :param config: pulp.server.conduits.repo_sync.RepoSyncConduit :return: A report describing the result. :rtype: pulp.server.plugins.model.SyncReport """ summary_report = SummaryReport() try: downloader = self._downloader(config) strategy_name = config.get(constants.STRATEGY_KEYWORD) strategy_class = find_strategy(strategy_name) listener = ProgressListener(conduit) progress_report = RepositoryProgress(repo.id, listener) strategy = strategy_class(conduit, config, downloader, progress_report, summary_report) progress_report.begin_importing() strategy.synchronize(repo.id) except Exception, e: summary_report.errors.append(CaughtException(e, repo.id))
def sync_repo(self, repo, conduit, config): """ Synchronize the content of the specified repository. The implementation is delegated to the strategy object which is selected based on the 'strategy' option passed specified in the configuration. :param repo: A repository object. :type repo: pulp.plugins.model.Repository :param conduit: Provides access to relevant Pulp functionality. :param config: pulp.server.conduits.repo_sync.RepoSyncConduit :return: A report describing the result. :rtype: pulp.server.plugins.model.SyncReport """ warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning) summary_report = SummaryReport() downloader = None try: downloader = self._downloader(config) strategy_name = config.get(constants.STRATEGY_KEYWORD, constants.DEFAULT_STRATEGY) progress_report = RepositoryProgress(repo.id, ProgressListener(conduit)) request = Request(self.cancel_event, conduit=conduit, config=config, downloader=downloader, progress=progress_report, summary=summary_report, repo=repo) strategy = find_strategy(strategy_name)() strategy.synchronize(request) except Exception, e: summary_report.errors.append(CaughtException(e, repo.id))
def request(self, cancel_on=0): conduit = TestConduit() progress = RepositoryProgress(REPO_ID, ProgressListener(conduit)) summary = SummaryReport() request = TestRequest(cancel_on=cancel_on, importer=TestImporter(), conduit=conduit, config={}, downloader=Mock(), progress=progress, summary=summary, repo=TestRepo(REPO_ID, self.tmp_dir)) return request
def started(self, bindings): """ Indicate the handler synchronization has started. State set to: STARTED. :param bindings: List of bindings used to populate the report. :type bindings: list """ self.state = self.STARTED for bind in bindings: repo_id = bind['repo_id'] p = RepositoryProgress(repo_id, self) self.progress.append(p) self._updated()
def request(self, cancel_on=0): conduit = TestConduit() progress = RepositoryProgress(REPO_ID, ProgressListener(conduit)) summary = SummaryReport() cancel_event = CancelEvent(cancel_on) request = strategies.Request( cancel_event, conduit=conduit, config={}, downloader=Mock(), progress=progress, summary=summary, repo=TestRepo(REPO_ID, self.tmp_dir) ) return request