当前位置: 首页>>代码示例>>Python>>正文


Python CallRequest.updates_resource方法代码示例

本文整理汇总了Python中pulp.server.dispatch.call.CallRequest.updates_resource方法的典型用法代码示例。如果您正苦于以下问题:Python CallRequest.updates_resource方法的具体用法?Python CallRequest.updates_resource怎么用?Python CallRequest.updates_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.server.dispatch.call.CallRequest的用法示例。


在下文中一共展示了CallRequest.updates_resource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def POST(self):
        """
        Creates an async task to regenerate content applicability data for given updated
        repositories.

        body {repo_criteria:<dict>}
        """
        body = self.params()
        repo_criteria = body.get('repo_criteria', None)
        if repo_criteria is None:
            raise exceptions.MissingValue('repo_criteria')
        try:
            repo_criteria = Criteria.from_client_input(repo_criteria)
        except:
            raise exceptions.InvalidValue('repo_criteria')

        manager = manager_factory.applicability_regeneration_manager()
        regeneration_tag = action_tag('applicability_regeneration')
        call_request = CallRequest(manager.regenerate_applicability_for_repos,
                                   [repo_criteria],
                                   tags = [regeneration_tag])
        # allow only one applicability regeneration task at a time
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_PROFILE_APPLICABILITY_TYPE,
                                      dispatch_constants.RESOURCE_ANY_ID)
        return execution.execute_async(self, call_request)
开发者ID:hennessy80,项目名称:pulp,代码行数:27,代码来源:repositories.py

示例2: create_sync_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def create_sync_schedule(self, repo_id, importer_id, sync_options, schedule_data):
        """
        Create a new sync schedule for a given repository using the given importer.
        @param repo_id:
        @param importer_id:
        @param sync_options:
        @param schedule_data:
        @return:
        """

        # validate the input
        self._validate_importer(repo_id, importer_id)
        self._validate_keys(sync_options, _SYNC_OPTION_KEYS)
        if 'schedule' not in schedule_data:
            raise pulp_exceptions.MissingValue(['schedule'])

        # build the sync call request
        sync_manager = managers_factory.repo_sync_manager()
        args = [repo_id]
        kwargs = {'sync_config_override': sync_options['override_config']}
        weight = pulp_config.config.getint('tasks', 'sync_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id)]
        call_request = CallRequest(sync_manager.sync, args, kwargs, weight=weight, tags=tags, archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, sync_manager.prep_sync)

        # schedule the sync
        scheduler = dispatch_factory.scheduler()
        schedule_id = scheduler.add(call_request, **schedule_data)
        importer_manager = managers_factory.repo_importer_manager()
        importer_manager.add_sync_schedule(repo_id, schedule_id)
        return schedule_id
开发者ID:ehelms,项目名称:pulp,代码行数:36,代码来源:cud.py

示例3: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def POST(self):

        # Params
        params = self.params()
        role_id = params.get('role_id', None)
        resource = params.get('resource', None)
        operation_names = params.get('operations', None)
        
        _check_invalid_params({'role_id':role_id,
                               'resource':resource,
                               'operation_names':operation_names})

        operations = _get_operations(operation_names)
        
        # Grant permission synchronously
        role_manager = managers.role_manager()
        
        tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
                action_tag('remove_permission_from_role')]

        call_request = CallRequest(role_manager.remove_permissions_from_role,
                                   [role_id, resource, operations],
                                   tags=tags)
        call_request.updates_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id)
        
        return self.ok(execution.execute_sync(call_request))
开发者ID:ashcrow,项目名称:pulp,代码行数:28,代码来源:permissions.py

示例4: PUT

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def PUT(self, repo_id, distributor_id, schedule_id):
        distributor_manager = manager_factory.repo_distributor_manager()
        schedule_list = distributor_manager.list_publish_schedules(repo_id, distributor_id)
        if schedule_id not in schedule_list:
            raise exceptions.MissingResource(repo=repo_id, distributor=distributor_id, publish_schedule=schedule_id)

        publish_update = {}
        schedule_update = self.params()
        if 'override_config' in schedule_update:
            publish_update['override_config'] = schedule_update.pop('override_config')

        schedule_manager = manager_factory.schedule_manager()
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
                resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
                action_tag('update_publish_schedule')]
        call_request = CallRequest(schedule_manager.update_publish_schedule,
                                   [repo_id, distributor_id, schedule_id, publish_update, schedule_update],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)
        execution.execute(call_request)

        scheduler = dispatch_factory.scheduler()
        schedule = scheduler.get(schedule_id)
        obj = serialization.dispatch.scheduled_publish_obj(schedule)
        obj.update(serialization.link.current_link_obj())
        return self.ok(obj)
开发者ID:hennessy80,项目名称:pulp,代码行数:32,代码来源:repositories.py

示例5: PUT

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def PUT(self, repo_group_id, distributor_id):
        params = self.params()

        distributor_config = params.get('distributor_config', None)

        if distributor_config is None:
            raise pulp_exceptions.MissingValue(['distributor_config'])

        distributor_manager = managers_factory.repo_group_distributor_manager()

        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id),
                action_tag('update_distributor')
        ]

        call_request = CallRequest(distributor_manager.update_distributor_config,
                                   args=[repo_group_id, distributor_id, distributor_config],
                                   tags=tags,
                                   archive=True)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id)

        result = execution.execute(call_request)

        href = serialization.link.current_link_obj()
        result.update(href)

        return self.ok(result)
开发者ID:omaciel,项目名称:pulp,代码行数:30,代码来源:repo_groups.py

示例6: publish_itinerary

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
def publish_itinerary(repo_id, distributor_id, overrides=None):
    """
    Create an itinerary for repo publish.
    @param repo_id: id of the repo to publish
    @type repo_id: str
    @param distributor_id: id of the distributor to use for the repo publish
    @type distributor_id: str
    @param overrides: dictionary of options to pass to the publish manager
    @type overrides: dict or None
    @return: list of call requests
    @rtype: list
    """

    repo_publish_manager = manager_factory.repo_publish_manager()
    weight = pulp_config.config.getint('tasks', 'publish_weight')
    tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            action_tag('publish')]

    call_request = CallRequest(repo_publish_manager.publish,
                               [repo_id, distributor_id],
                               {'publish_config_override': overrides},
                               weight=weight,
                               tags=tags,
                               archive=True)

    call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)

    return [call_request]
开发者ID:ashcrow,项目名称:pulp,代码行数:30,代码来源:repo.py

示例7: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def POST(self, repo_group_id):
        params = self.params()
        distributor_id = params.get('id', None)
        overrides = params.get('override_config', None)

        if distributor_id is None:
            raise MissingValue(['id'])

        publish_manager = managers_factory.repo_group_publish_manager()

        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id),
                action_tag('publish')
        ]
        weight = pulp_config.config.getint('tasks', 'publish_weight')

        call_request = CallRequest(publish_manager.publish,
                                   args=[repo_group_id, distributor_id],
                                   kwargs={'publish_config_override' : overrides},
                                   tags=tags,
                                   weight=weight,
                                   archive=True)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id)
        call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, publish_manager.prep_publish)

        return execution.execute_async(self, call_request)
开发者ID:ehelms,项目名称:pulp,代码行数:29,代码来源:repo_groups.py

示例8: PUT

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def PUT(self, consumer_id, schedule_id):
        consumer_manager = managers.consumer_manager()
        consumer_manager.get_consumer(consumer_id)

        schedule_data = self.params()
        install_options = None
        units = schedule_data.pop('units', None)

        if 'options' in schedule_data:
            install_options = {'options': schedule_data.pop('options')}

        schedule_manager = managers.schedule_manager()

        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
                action_tag('update_unit_uninstall_schedule')]

        call_request = CallRequest(schedule_manager.update_unit_uninstall_schedule,
                                   [consumer_id, schedule_id, units, install_options, schedule_data],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)

        execution.execute(call_request)

        scheduler = dispatch_factory.scheduler()
        scheduled_call = scheduler.get(schedule_id)

        scheduled_obj = serialization.dispatch.scheduled_unit_management_obj(scheduled_call)
        scheduled_obj.update(serialization.link.current_link_obj())
        return self.ok(scheduled_obj)
开发者ID:graco,项目名称:pulp,代码行数:34,代码来源:consumers.py

示例9: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def POST(self, repo_group_id):
        # Params (validation will occur in the manager)
        params = self.params()
        distributor_type_id = params.get('distributor_type_id', None)
        distributor_config = params.get('distributor_config', None)
        distributor_id = params.get('distributor_id', None)

        distributor_manager = managers_factory.repo_group_distributor_manager()

        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id),
                action_tag('add_distributor')]
        if distributor_id is not None:
            tags.append(resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id))

        call_request = CallRequest(distributor_manager.add_distributor,
                                   [repo_group_id, distributor_type_id, distributor_config, distributor_id],
                                   weight=weight,
                                   tags=tags)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
        created = execution.execute(call_request)

        href = serialization.link.child_link_obj(created['id'])
        created.update(href)

        return self.created(href['_href'], created)
开发者ID:omaciel,项目名称:pulp,代码行数:28,代码来源:repo_groups.py

示例10: create_publish_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def create_publish_schedule(self, repo_id, distributor_id, publish_options, schedule_data):
        """
        Create a new scheduled publish for the given repository and distributor.
        @param repo_id:
        @param distributor_id:
        @param publish_options:
        @param schedule_data:
        @return:
        """

        # validate the input
        self._validate_distributor(repo_id, distributor_id)
        self._validate_keys(publish_options, _PUBLISH_OPTION_KEYS)
        if 'schedule' not in schedule_data:
            raise pulp_exceptions.MissingValue(['schedule'])

        # build the publish call
        publish_manager = managers_factory.repo_publish_manager()
        args = [repo_id, distributor_id]
        kwargs = {'publish_config_override': publish_options['override_config']}
        weight = pulp_config.config.getint('tasks', 'publish_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)]
        call_request = CallRequest(publish_manager.publish, args, kwargs, weight=weight, tags=tags, archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, publish_manager.prep_publish)

        # schedule the publish
        scheduler = dispatch_factory.scheduler()
        schedule_id = scheduler.add(call_request, **schedule_data)
        distributor_manager = managers_factory.repo_distributor_manager()
        distributor_manager.add_publish_schedule(repo_id, distributor_id, schedule_id)
        return schedule_id
开发者ID:ehelms,项目名称:pulp,代码行数:36,代码来源:cud.py

示例11: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def POST(self, repo_id):
        """
        Import an uploaded unit into the given repository.

        :param repo_id: The id of the repository the upload should be imported into
        :type  repo_id: basestring
        :return:        A json serialized dictionary with two keys. 'success_flag' indexes a boolean
                        value that indicates whether the import was successful, and 'summary' will
                        contain the summary as reported by the Importer.
        :rtype:         basestring
        """
        # Collect user input
        params = self.params()
        upload_id = params['upload_id']
        unit_type_id = params['unit_type_id']
        unit_key = params['unit_key']
        unit_metadata = params.pop('unit_metadata', None)

        # Coordinator configuration
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                action_tag('import_upload')]

        upload_manager = manager_factory.content_upload_manager()
        call_request = CallRequest(upload_manager.import_uploaded_unit,
            [repo_id, unit_type_id, unit_key, unit_metadata, upload_id],
            tags=tags, archive=True)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)

        report = execution.execute(call_request)
        return self.ok(report)
开发者ID:ashcrow,项目名称:pulp,代码行数:32,代码来源:repositories.py

示例12: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
 def POST(self, consumer_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id),
             action_tag('consumer_group_unassociate')]
     call_request = CallRequest(manager.unassociate,
                                [consumer_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     matched = execution.execute(call_request)
     return self.ok(matched)
开发者ID:jessegonzalez,项目名称:pulp,代码行数:13,代码来源:consumer_groups.py

示例13: DELETE

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    def DELETE(self, role_id, login):

        role_manager = managers.role_manager()
        tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
                action_tag('remove_user_from_role')]
        call_request = CallRequest(role_manager.remove_user_from_role,
                                   [role_id, login],
                                   tags=tags,
                                   archive=True)
        call_request.updates_resource(dispatch_constants.RESOURCE_USER_TYPE, login)
        call_request.reads_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id)
        return  self.ok(execution.execute_sync(call_request))
开发者ID:ashcrow,项目名称:pulp,代码行数:14,代码来源:roles.py

示例14: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
    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)
开发者ID:ehelms,项目名称:pulp,代码行数:55,代码来源:repositories.py

示例15: distributor_update_itinerary

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import updates_resource [as 别名]
def distributor_update_itinerary(repo_id, distributor_id, config):
    """
    Get the itinerary for updating a repository distributor.
      1. Update the distributor on the sever.
      2. (re)bind any bound consumers.
    @param repo_id: A repository ID.
    @type repo_id: str
    @return: A list of call_requests known as an itinerary.
    @rtype list
    """

    call_requests = []

    # update the distributor

    manager = managers.repo_distributor_manager()

    tags = [
        resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
        resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
        action_tag('update_distributor')
    ]

    update_request = CallRequest(
        manager.update_distributor_config,
        [repo_id, distributor_id],
        {'distributor_config': config},
        tags=tags,
        archive=True,
        kwarg_blacklist=['distributor_config'])

    update_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
    update_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)

    call_requests.append(update_request)

    # append unbind itineraries foreach bound consumer

    options = {}
    manager = managers.consumer_bind_manager()
    for bind in manager.find_by_distributor(repo_id, distributor_id):
        bind_requests = bind_itinerary(
            bind['consumer_id'],
            bind['repo_id'],
            bind['distributor_id'],
            bind['notify_agent'],
            bind['binding_config'],
            options)
        if bind_requests:
            bind_requests[0].depends_on(update_request.id)
            call_requests.extend(bind_requests)

    return call_requests
开发者ID:cliffy94,项目名称:pulp,代码行数:55,代码来源:repository.py


注:本文中的pulp.server.dispatch.call.CallRequest.updates_resource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。