Example #1
0
    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))
Example #2
0
    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)
            progress_report = RepositoryProgress(repo.id, ProgressListener(conduit))
            request = SyncRequest(
                importer=self,
                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))
Example #3
0
 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
     """
     try:
         downloader = self._downloader(config)
         strategy_name = config.get(constants.STRATEGY_KEYWORD)
         strategy_class = find_strategy(strategy_name)
         listener = ProgressListener(conduit)
         progress = RepositoryProgress(repo.id, listener)
         self.strategy = strategy_class(conduit, config, downloader, progress)
         progress.begin_importing()
         report = self.strategy.synchronize(repo.id)
         details = dict(report=report.dict())
     except Exception, e:
         msg = repr(e)
         log.exception(repo.id)
         details = dict(exception=msg)
 def test_strategy_factory(self):
     for name, strategy in strategies.STRATEGIES.items():
         self.assertEqual(strategies.find_strategy(name), strategy)
     self.assertRaises(strategies.StrategyUnsupported, strategies.find_strategy, '---')