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


Python CallRequest.reads_resource方法代码示例

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


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

示例1: PUT

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_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

示例2: POST

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

        # Params
        params = self.params()
        login = params.get('login', None)
        resource = params.get('resource', None)
        operation_names = params.get('operations', None)
        
        _check_invalid_params({'login':login,
                               'resource':resource,
                               'operation_names':operation_names})
            
        operations = _get_operations(operation_names)
        
        # Grant permission synchronously
        permission_manager = managers.permission_manager()
        tags = [resource_tag(dispatch_constants.RESOURCE_PERMISSION_TYPE, resource),
                resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login),
                action_tag('grant_permission_to_user')]

        call_request = CallRequest(permission_manager.grant,
                                   [resource, login, operations],
                                   tags=tags)
        call_request.reads_resource(dispatch_constants.RESOURCE_USER_TYPE, login)
        call_request.updates_resource(dispatch_constants.RESOURCE_PERMISSION_TYPE, resource)
        
        return self.ok(execution.execute_sync(call_request))
开发者ID:ashcrow,项目名称:pulp,代码行数:29,代码来源:permissions.py

示例3: DELETE

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
 def DELETE(self, consumer_id, content_type):
     """
     Delete an association between the specified
     consumer and profile.  Designed to be idempotent.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param content_type: The content type ID.
     @type content_type: str
     @return: The deleted model object:
         {consumer_id:<str>, content_type:<str>, profile:<dict>}
         Or, None if bind does not exist.
     @rtype: dict
     """
     manager = managers.consumer_profile_manager()
     args = [
         consumer_id,
         content_type,
     ]
     tags = [
         resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
     ]
     call_request = CallRequest(manager.delete,
                                args=args,
                                tags=tags)
     call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
     return self.ok(execution.execute(call_request))
开发者ID:cliffy94,项目名称:pulp,代码行数:28,代码来源:consumers.py

示例4: PUT

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
    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')

        manager = managers.consumer_profile_manager()
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, content_type),
                action_tag('profile_update')]

        call_request = CallRequest(manager.update,
                                   [consumer_id, content_type],
                                   {'profile': profile},
                                   tags=tags,
                                   weight=0,
                                   kwarg_blacklist=['profile'])
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

        call_report = CallReport.from_call_request(call_request)
        call_report.serialize_result = False

        consumer = execution.execute_sync(call_request, call_report)
        link = serialization.link.child_link_obj(consumer_id, content_type)
        consumer.update(link)

        return self.ok(consumer)
开发者ID:graco,项目名称:pulp,代码行数:37,代码来源:consumers.py

示例5: create_publish_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_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

示例6: POST

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
    def POST(self, repo_id, distributor_id):
        distributor_manager = manager_factory.repo_distributor_manager()
        distributor_manager.get_distributor(repo_id, distributor_id)

        schedule_options = self.params()
        publish_options = {'override_config': schedule_options.pop('override_config', {})}

        schedule_manager = manager_factory.schedule_manager()
        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
                action_tag('create_publish_schedule')]
        call_request = CallRequest(schedule_manager.create_publish_schedule,
                                   [repo_id, distributor_id, publish_options, schedule_options],
                                   weight=weight,
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
        schedule_id = execution.execute_sync(call_request)

        scheduler = dispatch_factory.scheduler()
        schedule = scheduler.get(schedule_id)
        obj = serialization.dispatch.scheduled_publish_obj(schedule)
        obj.update(serialization.link.child_link_obj(schedule_id))
        return self.created(obj['_href'], obj)
开发者ID:hennessy80,项目名称:pulp,代码行数:28,代码来源:repositories.py

示例7: create_unit_install_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
    def create_unit_install_schedule(self, consumer_id, units, install_options, schedule_data ):
        """
        Create a schedule for installing content units on a consumer.
        @param consumer_id: unique id for the consumer
        @param units: list of unit type and unit key dicts
        @param install_options: options to pass to the install manager
        @param schedule_data: scheduling data
        @return: schedule id
        """
        self._validate_consumer(consumer_id)
        self._validate_keys(install_options, _UNIT_INSTALL_OPTION_KEYS)
        if 'schedule' not in schedule_data:
            raise pulp_exceptions.MissingValue(['schedule'])

        manager = managers_factory.consumer_agent_manager()
        args = [consumer_id]
        kwargs = {'units': units,
                  'options': install_options.get('options', {})}
        weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                action_tag('unit_install'), action_tag('scheduled_unit_install')]
        call_request = CallRequest(manager.install_content, args, kwargs, weight=weight, tags=tags, archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

        scheduler = dispatch_factory.scheduler()
        schedule_id = scheduler.add(call_request, **schedule_data)
        return schedule_id
开发者ID:ehelms,项目名称:pulp,代码行数:29,代码来源:cud.py

示例8: consumer_content_update_itinerary

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
def consumer_content_update_itinerary(consumer_id, units, options):
    """
    Create an itinerary for consumer content update.
    @param consumer_id: unique id of the consumer
    @type consumer_id: str
    @param units: units to update
    @type units: list or tuple
    @param options: options to pass to the update manager
    @type options: dict or None
    @return: list of call requests
    @rtype: list
    """
    manager = managers_factory.consumer_agent_manager()
    args = [consumer_id]
    kwargs = {'units': units, 'options': options}
    weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
    tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
            action_tag('unit_update')]
    call_request = CallRequest(
        manager.update_content,
        args,
        kwargs,
        weight=weight,
        tags=tags,
        archive=True,
        asynchronous=True,
        kwarg_blacklist=['options'])
    call_request.add_control_hook(dispatch_constants.CALL_CANCEL_CONTROL_HOOK, cancel_agent_request)
    call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
    return [call_request]
开发者ID:ashcrow,项目名称:pulp,代码行数:32,代码来源:consumer.py

示例9: create_sync_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_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

示例10: POST

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

        schedule_data = self.params()
        units = schedule_data.pop('units', None)
        uninstall_options = {'options': schedule_data.pop('options', {})}

        if not units:
            raise MissingValue(['units'])

        schedule_manager = managers.schedule_manager()

        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                action_tag('create_unit_uninstall_schedule')]

        call_request = CallRequest(schedule_manager.create_unit_uninstall_schedule,
                                   [consumer_id, units, uninstall_options, schedule_data],
                                   weight=weight,
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

        schedule_id = execution.execute_sync(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.child_link_obj(schedule_id))
        return self.created(scheduled_obj['_href'], scheduled_obj)
开发者ID:graco,项目名称:pulp,代码行数:34,代码来源:consumers.py

示例11: DELETE

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_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

示例12: DELETE

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

        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('delete_unit_update_schedule')]

        call_request = CallRequest(schedule_manager.delete_unit_update_schedule,
                                   [consumer_id, schedule_id],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
        call_request.deletes_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)
        result = execution.execute(call_request)
        return self.ok(result)
开发者ID:graco,项目名称:pulp,代码行数:20,代码来源:consumers.py

示例13: _create_schedule

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
    def _create_schedule(self, management_method, management_action_name, consumer_id, units, options, schedule_data):
        self._validate_consumer(consumer_id)
        schedule_utils.validate_keys(options, _UNIT_OPTION_KEYS)
        if 'schedule' not in schedule_data:
            raise pulp_exceptions.MissingValue(['schedule'])

        args = [consumer_id]
        kwargs = {'units': units,
                  'options': options.get('options', {})}
        weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                action_tag(management_action_name),
                action_tag('scheduled_' + management_action_name)]
        call_request = CallRequest(management_method, args, kwargs, weight=weight, tags=tags, archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

        scheduler = dispatch_factory.scheduler()
        schedule_id = scheduler.add(call_request, **schedule_data)
        return schedule_id
开发者ID:ryanschneider,项目名称:pulp,代码行数:21,代码来源:consumer.py

示例14: DELETE

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
    def DELETE(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)

        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('delete_publish_schedule')]
        call_request = CallRequest(schedule_manager.delete_publish_schedule,
                                   [repo_id, distributor_id, schedule_id],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
        call_request.deletes_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)
        result = execution.execute(call_request)
        return self.ok(result)
开发者ID:hennessy80,项目名称:pulp,代码行数:22,代码来源:repositories.py

示例15: consumer_content_install_itinerary

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import reads_resource [as 别名]
def consumer_content_install_itinerary(consumer_id, units, options):
    """
    Create an itinerary for consumer content installation.
    @param consumer_id: unique id of the consumer
    @type consumer_id: str
    @param units: units to install
    @type units: list or tuple
    @param options: options to pass to the install manager
    @type options: dict or None
    @return: list of call requests
    @rtype: list
    """
    manager = managers_factory.consumer_agent_manager()
    args = [consumer_id]
    kwargs = {'units': units, 'options': options}
    weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
    tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
            action_tag('unit_install')]
    call_request = CallRequest(manager.install_content, args, kwargs, weight=weight, tags=tags, archive=True, asynchronous=True)
    call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
    return [call_request]
开发者ID:bartwo,项目名称:pulp,代码行数:23,代码来源:consumer.py


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