Exemplo n.º 1
0
    def update(self, conduit, units, options):
        """
        Update the specified content units.  Each unit must be of
        type 'node'.  Updates the entire child node.

        Report format:
          succeeded: <bool>
          details: {
            errors: [
              { error_id: <str>,
                details: {}
              },
            ]
            repositories: [
              { repo_id: <str>,
                action: <str>,
                units: {
                  added: <int>,
                  updated: <int>,
                  removed: <int>
                }
              },
            ]
          }

        :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
        """
        summary_report = SummaryReport()
        progress_report = HandlerProgress(conduit)
        pulp_bindings = parent_bindings(options)
        bindings = RepositoryBinding.fetch_all(pulp_bindings, conduit.consumer_id)

        strategy_name = options.setdefault(constants.STRATEGY_KEYWORD, constants.MIRROR_STRATEGY)
        request = SyncRequest(
            conduit=conduit,
            progress=progress_report,
            summary=summary_report,
            bindings=bindings,
            scope=constants.NODE_SCOPE,
            options=options)
        strategy = find_strategy(strategy_name)()
        strategy.synchronize(request)

        for ne in summary_report.errors:
            log.error(ne)

        handler_report = ContentReport()
        if summary_report.succeeded():
            handler_report.set_succeeded(summary_report.dict())
        else:
            handler_report.set_failed(summary_report.dict())
        return handler_report
Exemplo n.º 2
0
    def update(self, conduit, units, options):
        """
        Update the specified content units.  Each unit must be of
        type 'node'.  Updates the entire child node.

        Report format:
          succeeded: <bool>
          details: {
            errors: [
              { error_id: <str>,
                details: {}
              },
            ]
            repositories: [
              { repo_id: <str>,
                action: <str>,
                units: {
                  added: <int>,
                  updated: <int>,
                  removed: <int>
                }
              },
            ]
          }

        :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
        """
        warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning)

        handler_report = ContentReport()
        summary_report = SummaryReport()
        progress_report = HandlerProgress(conduit)
        pulp_bindings = parent_bindings(options)

        try:
            bindings = RepositoryBinding.fetch_all(pulp_bindings,
                                                   conduit.consumer_id)
        except GetBindingsError, ne:
            log.error(ne)
            summary_report.errors.append(ne)
            handler_report.set_failed(summary_report.dict())
            return handler_report
Exemplo n.º 3
0
    def update(self, conduit, units, options):
        """
        Update the specified content units.  Each unit must be of
        type 'node'.  Updates the entire child node.

        Report format:
          succeeded: <bool>
          details: {
            errors: [
              { error_id: <str>,
                details: {}
              },
            ]
            repositories: [
              { repo_id: <str>,
                action: <str>,
                units: {
                  added: <int>,
                  updated: <int>,
                  removed: <int>
                }
              },
            ]
          }

        :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
        """
        warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning)

        handler_report = ContentReport()
        summary_report = SummaryReport()
        progress_report = HandlerProgress(conduit)
        pulp_bindings = parent_bindings(options)

        try:
            bindings = RepositoryBinding.fetch_all(pulp_bindings, conduit.consumer_id)
        except GetBindingsError, ne:
            log.error(ne)
            summary_report.errors.append(ne)
            handler_report.set_failed(summary_report.dict())
            return handler_report
Exemplo n.º 4
0
    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.

        Report format:
          succeeded: <bool>
          details: {
            errors: [
              { error_id: <str>,
                details: {}
              },
            ]
            repositories: [
              { repo_id: <str>,
                action: <str>,
                units: {
                  added: <int>,
                  updated: <int>,
                  removed: <int>
                }
              },
            ]
          }

        :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
        """
        summary_report = SummaryReport()
        progress_report = HandlerProgress(conduit)
        repo_ids = [key['repo_id'] for key in units if key]
        pulp_bindings = parent_bindings(options)
        bindings = RepositoryBinding.fetch(pulp_bindings, conduit.consumer_id,
                                           repo_ids)

        strategy_name = options.setdefault(constants.STRATEGY_KEYWORD,
                                           constants.MIRROR_STRATEGY)
        request = Request(conduit=conduit,
                          progress=progress_report,
                          summary=summary_report,
                          bindings=bindings,
                          scope=constants.REPOSITORY_SCOPE,
                          options=options)
        strategy = find_strategy(strategy_name)()
        strategy.synchronize(request)

        for ne in summary_report.errors:
            log.error(ne)

        handler_report = ContentReport()
        if summary_report.succeeded():
            handler_report.set_succeeded(summary_report.dict())
        else:
            handler_report.set_failed(summary_report.dict())
        return handler_report
Exemplo n.º 5
0
    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.

        Report format:
          succeeded: <bool>
          details: {
            errors: [
              { error_id: <str>,
                details: {}
              },
            ]
            repositories: [
              { repo_id: <str>,
                action: <str>,
                units: {
                  added: <int>,
                  updated: <int>,
                  removed: <int>
                }
              },
            ]
          }

        :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
        """
        warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning)

        summary_report = SummaryReport()
        progress_report = HandlerProgress(conduit)
        repo_ids = [key['repo_id'] for key in units if key]
        pulp_bindings = parent_bindings(options)
        bindings = RepositoryBinding.fetch(pulp_bindings, conduit.consumer_id, repo_ids)

        strategy_name = options.setdefault(constants.STRATEGY_KEYWORD, constants.MIRROR_STRATEGY)
        request = Request(
            conduit=conduit,
            progress=progress_report,
            summary=summary_report,
            bindings=bindings,
            scope=constants.REPOSITORY_SCOPE,
            options=options)
        strategy = find_strategy(strategy_name)()
        strategy.synchronize(request)

        for ne in summary_report.errors:
            log.error(ne)

        handler_report = ContentReport()
        if summary_report.succeeded():
            handler_report.set_succeeded(summary_report.dict())
        else:
            handler_report.set_failed(summary_report.dict())
        return handler_report