예제 #1
0
 def DELETE(self, id):
     # validate
     manager_factory.repo_query_manager().get_repository(id)
     # delete
     call_requests = repo_delete_itinerary(id)
     _LOG.info('Itinerary: %s', [r.id for r in call_requests])
     execution.execute_multiple(call_requests)
예제 #2
0
 def DELETE(self, consumer_id, repo_id, distributor_id):
     """
     Delete a bind association between the specified
     consumer and repo-distributor.  Designed to be idempotent.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param repo_id: A repo ID.
     @type repo_id: str
     @param distributor_id: A distributor ID.
     @type distributor_id: str
     @return: The list of call_reports
     @rtype: list
     """
     body = self.params()
     # validate resources
     manager = managers.consumer_bind_manager()
     binding = manager.get_bind(consumer_id, repo_id, distributor_id)
     notify_agent = binding['notify_agent']
     # delete (unbind)
     forced = body.get('force', False)
     options = body.get('options', {})
     if forced or not notify_agent:
         call_requests = forced_unbind_itinerary(consumer_id, repo_id,
                                                 distributor_id, options)
     else:
         call_requests = unbind_itinerary(consumer_id, repo_id,
                                          distributor_id, options)
     execution.execute_multiple(call_requests)
예제 #3
0
 def DELETE(self, repo_id, distributor_id):
     # validate resources
     manager = manager_factory.repo_distributor_manager()
     manager.get_distributor(repo_id, distributor_id)
     # delete
     call_requests = distributor_delete_itinerary(repo_id, distributor_id)
     execution.execute_multiple(call_requests)
예제 #4
0
    def POST(self, consumer_id):
        """
        Create a bind association between the specified
        consumer by id included in the URL path and a repo-distributor
        specified in the POST body: {repo_id:<str>, distributor_id:<str>}.
        Designed to be idempotent so only MissingResource is expected to
        be raised by manager.
        @param consumer_id: The consumer to bind.
        @type consumer_id: str
        @return: The list of call_reports
        @rtype: list
        """
        # validate consumer
        consumer_manager = managers.consumer_manager()
        consumer_manager.get_consumer(consumer_id)

        # get other options and validate them
        body = self.params()
        repo_id = body.get('repo_id')
        distributor_id = body.get('distributor_id')
        binding_config = body.get('binding_config', None)
        options = body.get('options', {})
        notify_agent = body.get('notify_agent', True)

        managers.repo_query_manager().get_repository(repo_id)
        managers.repo_distributor_manager().get_distributor(
            repo_id, distributor_id)

        # bind
        call_requests = bind_itinerary(consumer_id, repo_id, distributor_id,
                                       notify_agent, binding_config, options)
        execution.execute_multiple(call_requests)
예제 #5
0
 def POST(self, group_id):
     """
     Create a bind association between the specified
     consumer by id included in the URL path and a repo-distributor
     specified in the POST body: {repo_id:<str>, distributor_id:<str>}.
     Designed to be idempotent so only MissingResource is expected to
     be raised by manager.
     @param group_id: The consumer group to bind.
     @type group_id: str
     @return: The created bind model object:
         {consumer_group_id:<str>, repo_id:<str>, distributor_id:<str>}
     @rtype: dict
     """
     body = self.params()
     repo_id = body.get('repo_id')
     distributor_id = body.get('distributor_id')
     binding_config = body.get('binding_config', None)
     options = body.get('options', {})
     notify_agent = body.get('notify_agent', True)
     call_requests = consumer_group_bind_itinerary(
         group_id=group_id,
         repo_id=repo_id,
         distributor_id=distributor_id,
         notify_agent=notify_agent,
         binding_config=binding_config,
         agent_options=options)
     execution.execute_multiple(call_requests)
예제 #6
0
파일: consumers.py 프로젝트: graco/pulp
 def DELETE(self, consumer_id, repo_id, distributor_id):
     """
     Delete a bind association between the specified
     consumer and repo-distributor.  Designed to be idempotent.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param repo_id: A repo ID.
     @type repo_id: str
     @param distributor_id: A distributor ID.
     @type distributor_id: str
     @return: The list of call_reports
     @rtype: list
     """
     body = self.params()
     # validate resources
     manager = managers.consumer_bind_manager()
     binding = manager.get_bind(consumer_id, repo_id, distributor_id)
     notify_agent = binding['notify_agent']
     # delete (unbind)
     forced = body.get('force', False)
     options = body.get('options', {})
     if forced or not notify_agent:
         call_requests = forced_unbind_itinerary(
             consumer_id,
             repo_id,
             distributor_id,
             options)
     else:
         call_requests = unbind_itinerary(
             consumer_id,
             repo_id,
             distributor_id,
             options)
     execution.execute_multiple(call_requests)
예제 #7
0
파일: consumers.py 프로젝트: graco/pulp
    def POST(self, consumer_id):
        """
        Create a bind association between the specified
        consumer by id included in the URL path and a repo-distributor
        specified in the POST body: {repo_id:<str>, distributor_id:<str>}.
        Designed to be idempotent so only MissingResource is expected to
        be raised by manager.
        @param consumer_id: The consumer to bind.
        @type consumer_id: str
        @return: The list of call_reports
        @rtype: list
        """
        # validate consumer
        consumer_manager = managers.consumer_manager()
        consumer_manager.get_consumer(consumer_id)

        # get other options and validate them
        body = self.params()
        repo_id = body.get('repo_id')
        distributor_id = body.get('distributor_id')
        binding_config = body.get('binding_config', None)
        options = body.get('options', {})
        notify_agent = body.get('notify_agent', True)

        managers.repo_query_manager().get_repository(repo_id)
        managers.repo_distributor_manager().get_distributor(repo_id, distributor_id)

        # bind
        call_requests = bind_itinerary(consumer_id, repo_id, distributor_id, notify_agent, binding_config, options)
        execution.execute_multiple(call_requests)
예제 #8
0
 def DELETE(self, repo_id, distributor_id):
     # validate resources
     manager = manager_factory.repo_distributor_manager()
     manager.get_distributor(repo_id, distributor_id)
     # delete
     call_requests = distributor_delete_itinerary(repo_id, distributor_id)
     execution.execute_multiple(call_requests)
예제 #9
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)
예제 #10
0
 def DELETE(self, id):
     # validate
     manager_factory.repo_query_manager().get_repository(id)
     # delete
     call_requests = repo_delete_itinerary(id)
     _LOG.info('Itinerary: %s', [r.id for r in call_requests])
     execution.execute_multiple(call_requests)
예제 #11
0
파일: repositories.py 프로젝트: ehelms/pulp
    def POST(self, repo_id):

        # TODO: Add timeout support

        # Params
        params = self.params()
        overrides = params.get("override_config", None)

        # Execute the sync asynchronously
        repo_sync_manager = manager_factory.repo_sync_manager()

        sync_weight = pulp_config.config.getint("tasks", "sync_weight")
        sync_tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag("sync")]

        sync_call_request = CallRequest(
            repo_sync_manager.sync,
            [repo_id],
            {"sync_config_override": overrides},
            weight=sync_weight,
            tags=sync_tags,
            archive=True,
        )
        sync_call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        sync_call_request.add_life_cycle_callback(
            dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, repo_sync_manager.prep_sync
        )

        call_requests = [sync_call_request]

        repo_publish_manager = manager_factory.repo_publish_manager()
        auto_publish_tags = [
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            action_tag("auto_publish"),
            action_tag("publish"),
        ]
        auto_distributors = repo_publish_manager.auto_distributors(repo_id)

        for distributor in auto_distributors:
            distributor_id = distributor["id"]
            publish_call_request = CallRequest(
                repo_publish_manager.publish, [repo_id, distributor_id], tags=auto_publish_tags, archive=True
            )
            publish_call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
            publish_call_request.add_life_cycle_callback(
                dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, repo_publish_manager.prep_publish
            )
            publish_call_request.depends_on(sync_call_request)

            call_requests.append(publish_call_request)

        # this raises an exception that is handled by the middleware,
        # so no return is needed
        execution.execute_multiple(call_requests)
예제 #12
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)
예제 #13
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)
예제 #14
0
 def uninstall(self, consumer_group_id):
     """
     Uninstall content (units) from the consumers in a consumer group.
     Expected body: {units:[], options:<dict>}
     where unit is: {type_id:<str>, unit_key={}} and the
     options is a dict of uninstall options.
     @param consumer_group_id: A consumer group ID.
     @type consumer_group_id: str
     @return: list of call requests
     @rtype: list
     """
     body = self.params()
     units = body.get('units')
     options = body.get('options')
     call_requests = consumer_group_content_uninstall_itinerary(consumer_group_id, units, options)
     execution.execute_multiple(call_requests)
예제 #15
0
 def DELETE(self, group_id, repo_id, distributor_id):
     """
     Delete a bind association between the specified
     consumer and repo-distributor.  Designed to be idempotent.
     @param group_id: A consumer group ID.
     @type group_id: str
     @param repo_id: A repo ID.
     @type repo_id: str
     @param distributor_id: A distributor ID.
     @type distributor_id: str
     @return: The deleted bind model object:
         {consumer_group_id:<str>, repo_id:<str>, distributor_id:<str>}
         Or, None if bind does not exist.
     @rtype: dict
     """
     call_requests = consumer_group_unbind_itinerary(group_id, repo_id, distributor_id, {})
     execution.execute_multiple(call_requests)
예제 #16
0
    def POST(self, repo_id):

        # TODO: Add timeout support

        # Params
        params = self.params()
        overrides = params.get('override_config', None)

        # Check for repo existence and let the missing resource bubble up
        manager_factory.repo_query_manager().get_repository(repo_id)

        # Execute the sync asynchronously

        call_requests = sync_with_auto_publish_itinerary(repo_id, overrides)

        # this raises an exception that is handled by the middleware,
        # so no return is needed
        execution.execute_multiple(call_requests)
예제 #17
0
    def POST(self, repo_id):

        # TODO: Add timeout support

        # Params
        params = self.params()
        overrides = params.get('override_config', None)

        # Check for repo existence and let the missing resource bubble up
        manager_factory.repo_query_manager().get_repository(repo_id)

        # Execute the sync asynchronously

        call_requests = sync_with_auto_publish_itinerary(repo_id, overrides)

        # this raises an exception that is handled by the middleware,
        # so no return is needed
        execution.execute_multiple(call_requests)
예제 #18
0
파일: consumers.py 프로젝트: pkilambi/pulp
 def POST(self, consumer_id):
     """
     Create a bind association between the specified
     consumer by id included in the URL path and a repo-distributor
     specified in the POST body: {repo_id:<str>, distributor_id:<str>}.
     Designed to be idempotent so only MissingResource is expected to
     be raised by manager.
     @param consumer_id: The consumer to bind.
     @type consumer_id: str
     @return: The list of call_reports
     @rtype: list
     """
     # validate resources
     manager = managers.consumer_manager()
     manager.get_consumer(consumer_id)
     # bind
     body = self.params()
     repo_id = body.get('repo_id')
     distributor_id = body.get('distributor_id')
     options = body.get('options', {})
     call_requests = bind_itinerary(consumer_id, repo_id, distributor_id, options)
     execution.execute_multiple(call_requests)
예제 #19
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