示例#1
0
    def PUT(self, repo_id, distributor_id):
        """
        Used to update a repo distributor instance. This requires update permissions.
        The expected parameters are 'distributor_config', which is a dictionary containing configuration
        values accepted by the distributor type, and 'delta', which is a dictionary containing other
        configuration values for the distributor (like the auto_publish flag, for example). Currently,
        the only supported key in the delta is 'auto_publish', which should have a boolean value.

        :param repo_id:         The repository ID
        :type  repo_id:         str
        :param distributor_id:  The unique distributor ID of the distributor instance to update.
        :type  distributor_id:  str
        """
        params = self.params()
        delta = params.get('delta', None)
        # validate
        manager = manager_factory.repo_distributor_manager()
        manager.get_distributor(repo_id, distributor_id)
        config = params.get('distributor_config')
        if config is None:
            _LOG.error(
                'Missing configuration when updating distributor [%s] on repository [%s]',
                distributor_id,
                repo_id)
            raise exceptions.MissingValue(['distributor_config'])
        # update
        call_requests = distributor_update_itinerary(repo_id, distributor_id, config, delta)
        execution.execute_multiple(call_requests)
示例#2
0
 def PUT(self, repo_id, distributor_id):
     params = self.params()
     # validate
     manager = manager_factory.repo_distributor_manager()
     manager.get_distributor(repo_id, distributor_id)
     config = params.get('distributor_config')
     if config is None:
         _LOG.error(
             'Missing configuration when updating distributor [%s] on repository [%s]',
             distributor_id,
             repo_id)
         raise exceptions.MissingValue(['distributor_config'])
     # update
     call_requests = distributor_update_itinerary(repo_id, distributor_id, config)
     execution.execute_multiple(call_requests)
示例#3
0
 def PUT(self, repo_id, distributor_id):
     params = self.params()
     # validate
     manager = manager_factory.repo_distributor_manager()
     manager.get_distributor(repo_id, distributor_id)
     config = params.get('distributor_config')
     if config is None:
         _LOG.error(
             'Missing configuration when updating distributor [%s] on repository [%s]',
             distributor_id, repo_id)
         raise exceptions.MissingValue(['distributor_config'])
     # update
     call_requests = distributor_update_itinerary(repo_id, distributor_id,
                                                  config)
     execution.execute_multiple(call_requests)
示例#4
0
文件: cud.py 项目: ashcrow/pulp
    def update_repo_and_plugins(self, repo_id, repo_delta, importer_config,
                                distributor_configs):
        """
        Aggregate method that will update one or more of the following:
        * Repository metadata
        * Importer config
        * Zero or more distributors on the repository

        All of the above pieces do not need to be specified. If a piece is
        omitted it's configuration is not touched, nor is it removed from
        the repository. The same holds true for the distributor_configs dict,
        not every distributor must be represented.

        This call will attempt the updates in the order listed above. If an
        exception occurs during any of these steps, the updates stop and the
        exception is immediately raised. Any updates that have already taken
        place are not rolled back.

        This call will call out to RepoImporterManager.update_importer_config.
        Documentation for that method, especially possible exceptions, should be
        consulted for more information.

        Distributor updates will happen asynchronously as there could be a
        very large number of consumers to update and the repo update call
        is usually made synchronously.

        :param repo_id: unique identifier for the repo
        :type  repo_id: str

        :param repo_delta: list of attributes and their new values to change;
               if None, no attempt to update the repo's metadata will be made
        :type  repo_delta: dict, None

        :param importer_config: new configuration to use for the repo's importer;
               if None, no attempt will be made to update the importer
        :type  importer_config: dict, None

        :param distributor_configs: mapping of distributor ID to the new configuration
               to set for it
        :type  distributor_configs: dict, None

        :return: updated repository object, same as returned from update_repo
        """

        # Repo Update
        if repo_delta is None:
            repo_delta = {}
        repo = self.update_repo(repo_id, repo_delta)

        # Importer Update
        if importer_config is not None:
            importer_manager = manager_factory.repo_importer_manager()
            importer_manager.update_importer_config(repo_id, importer_config)

        # Distributor Update
        if distributor_configs is not None:
            distributor_manager = manager_factory.repo_distributor_manager()
            for dist_id, dist_config in distributor_configs.items():
                # Update the distributor config to ensure that errors are reported immediately
                distributor_manager.update_distributor_config(repo_id, dist_id, dist_config)
                # Use the itinerary to update the bindings on the consumers.
                # This will duplicate the distributor update command.
                # The duplication should be removed once we have a tasking system that
                # supports a better method of tracking grouped tasks
                call_requests = distributor_update_itinerary(repo_id, dist_id, dist_config)
                # The requests may not run immediately which is fine.  Since we have
                # no overall tracking of these requests we  have to eat the exception.
                try:
                    execution.execute_multiple(call_requests)
                except MultipleOperationsPostponed:
                    pass

        return repo