示例#1
0
文件: citrus.py 项目: pieska/pulp
    def update(self, conduit, units, options):
        """
        Update the specified content units.  Each unit must be
        of type 'repository'.  Updates only the repositories specified in
        the unit_key by repo_id.
        :param conduit: A handler conduit.
        :type conduit: pulp.agent.lib.conduit.Conduit
        :param units: A list of content unit_keys.
        :type units: list
        :param options: Unit update options.
        :type options: dict
        :return: An update report.
        :rtype: ContentReport
        """
        report = ContentReport()
        progress = HandlerProgress(conduit)
        progress.push_step('fetch_bindings')
        repo_ids = [key['repo_id'] for key in units if key]
        bindings = RemoteBinding.fetch(repo_ids)

        strategy_class = find_strategy('additive')
        strategy = strategy_class(progress)
        strategy_report = strategy.synchronize(bindings, options)

        progress.end()
        details = strategy_report.dict()
        if strategy_report.errors:
            report.set_failed(details)
        else:
            report.set_succeeded(details)
        return report
示例#2
0
文件: citrus.py 项目: pieska/pulp
    def update(self, conduit, units, options):
        """
        Update the specified content units.  Each unit must be of
        type 'node'.  Updates the entire child node.
        :param conduit: A handler conduit.
        :type conduit: pulp.agent.lib.conduit.Conduit
        :param units: A list of content unit_keys.
        :type units: list
        :param options: Unit update options.
        :type options: dict
        :return: An update report.
        :rtype: ContentReport
        """
        report = ContentReport()
        progress = HandlerProgress(conduit)
        progress.push_step('fetch_bindings')
        bindings = RemoteBinding.fetch_all()

        strategy_name = options.setdefault('strategy', 'mirror')
        strategy_class = find_strategy(strategy_name)
        strategy = strategy_class(progress)
        strategy_report = strategy.synchronize(bindings, options)

        progress.end()
        details = strategy_report.dict()
        if strategy_report.errors:
            report.set_failed(details)
        else:
            report.set_succeeded(details)
        return report