Exemple #1
0
    def POST(self, repo_id):

        # Params (validation will occur in the manager)
        params = self.params()
        importer_type = params.get('importer_type_id', None)
        importer_config = params.get('importer_config', None)

        if importer_type is None:
            _LOG.exception('Missing importer type adding importer to repository [%s]' % repo_id)
            raise exceptions.MissingValue(['importer_type'])

        # Note: If an importer exists, it's removed, so no need to handle 409s.
        # Note: If the plugin raises an exception during initialization, let it
        #  bubble up and be handled like any other 500.

        importer_manager = manager_factory.repo_importer_manager()
        resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}}
        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                action_tag('add_importer')]

        call_request = CallRequest(importer_manager.set_importer,
                                   [repo_id, importer_type, importer_config],
                                   resources=resources,
                                   weight=weight,
                                   tags=tags)
        return execution.execute_sync_created(self, call_request, 'importer')
Exemple #2
0
 def PUT(self, consumer_id, content_type):
     """
     Update the association of a profile with a consumer by content type ID.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param content_type: A content unit type ID.
     @type content_type: str
     @return: The updated model object:
         {consumer_id:<str>, content_type:<str>, profile:<dict>}
     @rtype: dict
     """
     body = self.params()
     profile = body.get('profile')
     resources = {
         dispatch_constants.RESOURCE_CONSUMER_TYPE:
             {consumer_id:dispatch_constants.RESOURCE_READ_OPERATION},
     }
     args = [
         consumer_id,
         content_type,
         profile,
     ]
     manager = managers.consumer_profile_manager()
     call_request = CallRequest(
         manager.update,
         args,
         resources=resources,
         weight=0)
     link = serialization.link.child_link_obj(consumer_id, content_type)
     result = execution.execute_sync_created(self, call_request, link)
     return result
Exemple #3
0
    def POST(self, repo_id):

        # Params (validation will occur in the manager)
        params = self.params()
        importer_type = params.get('importer_type_id', None)
        importer_config = params.get('importer_config', None)

        if importer_type is None:
            _LOG.error(
                'Missing importer type adding importer to repository [%s]' %
                repo_id)
            raise exceptions.MissingValue(['importer_type'])

        # Note: If an importer exists, it's removed, so no need to handle 409s.
        # Note: If the plugin raises an exception during initialization, let it
        #  bubble up and be handled like any other 500.

        importer_manager = manager_factory.repo_importer_manager()
        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            action_tag('add_importer')
        ]

        call_request = CallRequest(importer_manager.set_importer,
                                   [repo_id, importer_type],
                                   {'repo_plugin_config': importer_config},
                                   weight=weight,
                                   tags=tags,
                                   kwarg_blacklist=['repo_plugin_config'])
        call_request.updates_resource(
            dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        return execution.execute_sync_created(self, call_request, 'importer')
Exemple #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 created bind model object:
         {consumer_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")
     resources = {
         dispatch_constants.RESOURCE_CONSUMER_TYPE: {consumer_id: dispatch_constants.RESOURCE_READ_OPERATION},
         dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_READ_OPERATION},
         dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {
             distributor_id: dispatch_constants.RESOURCE_READ_OPERATION
         },
     }
     args = [consumer_id, repo_id, distributor_id]
     manager = managers.consumer_bind_manager()
     call_request = CallRequest(manager.bind, args, resources=resources, weight=0)
     link = serialization.link.child_link_obj(consumer_id, repo_id, distributor_id)
     result = execution.execute_sync_created(self, call_request, link)
     return result
Exemple #5
0
 def POST(self):
     body = self.params()
     id = body.get("id")
     display_name = body.get("display_name")
     description = body.get("description")
     notes = body.get("notes")
     manager = managers.consumer_manager()
     resources = {dispatch_constants.RESOURCE_CONSUMER_TYPE: {id: dispatch_constants.RESOURCE_CREATE_OPERATION}}
     args = [id, display_name, description, notes]
     weight = pulp_config.config.getint("tasks", "create_weight")
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, id), action_tag("create")]
     call_request = CallRequest(manager.register, args, resources=resources, weight=weight, tags=tags)
     return execution.execute_sync_created(self, call_request, id)
Exemple #6
0
    def POST(self, consumer_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 itempotent so only MissingResource is expected to
        be raised by manager.
        @param consumer_group_id: The consumer to bind.
        @type consumer_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')

        collection = ConsumerGroup.get_collection()
        consumer_group = collection.find_one({'id': consumer_group_id})

        resources = {
            dispatch_constants.RESOURCE_CONSUMER_TYPE: {
                consumer_group_id: dispatch_constants.RESOURCE_READ_OPERATION
            },
            dispatch_constants.RESOURCE_REPOSITORY_TYPE: {
                repo_id: dispatch_constants.RESOURCE_READ_OPERATION
            },
            dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {
                distributor_id: dispatch_constants.RESOURCE_READ_OPERATION
            },
        }
        args = [
            consumer_group_id,
            repo_id,
            distributor_id,
        ]
        manager = managers_factory.consumer_group_manager()
        call_request = CallRequest(manager.bind,
                                   args,
                                   resources=resources,
                                   weight=0)

        link = serialization.link.child_link_obj(consumer_group_id, repo_id,
                                                 distributor_id)
        result = execution.execute_sync_created(self, call_request, link)
        return result
Exemple #7
0
    def POST(self):

        # Pull all the user data
        user_data = self.params()
        login = user_data.get('login', None)
        password = user_data.get('password', None)
        name = user_data.get('name', None)
        roles = user_data.get('roles', None)

        # Creation
        manager = managers.user_manager()
        resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_CREATE_OPERATION}}
        args = [login, password, name, roles]
        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login),
                action_tag('create')]
        call_request = CallRequest(manager.create_user,
                                   args,
                                   resources=resources,
                                   weight=weight,
                                   tags=tags,
                                   obfuscate_args=True)
        return execution.execute_sync_created(self, call_request, login)