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


Python Criteria.from_client_input方法代码示例

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


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

示例1: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def POST(self):
        """
        Determine content applicability.
        body {
        consumer_criteria:<dict> or None, 
        repo_criteria:<dict> or None, 
        unit_criteria: <dict of type_id : unit_criteria> or None,
        override_config: <dict> or None
        }

        :return: 

        When report_style is 'by_consumer' -
        A dict of applicability reports keyed by consumer ID.
            Each consumer report is:
                { <unit_type_id1> : [<ApplicabilityReport>],
                  <unit_type_id1> : [<ApplicabilityReport>]},
                }

        When report_style is 'by_units' -
        A dict of <unit_type_id1>: [<ApplicabilityReport>]
        where applicability_report.summary contains a list of applicable consumer ids.

        :rtype: dict
        """
        body = self.params()

        consumer_criteria = body.get('consumer_criteria', None)
        repo_criteria = body.get('repo_criteria', None)
        units = body.get('unit_criteria', None)
        override_config = body.get('override_config', None)

        if consumer_criteria:
            consumer_criteria = Criteria.from_client_input(consumer_criteria)

        if repo_criteria:
            repo_criteria = Criteria.from_client_input(repo_criteria)

        unit_criteria = {}
        if units:
            for type_id, criteria in units.items():
                # process if criteria is not empty
                if criteria:
                    unit_criteria[type_id] = Criteria.from_client_input(criteria)
                else:
                    unit_criteria[type_id] = criteria

        manager = managers.consumer_applicability_manager()
        report = manager.find_applicable_units(consumer_criteria, repo_criteria, unit_criteria, override_config)

        for unit_type_id, applicability_reports in report.items():
            if isinstance(applicability_reports, list):
                report[unit_type_id] = [serialization.consumer.applicability_report(r) for r in applicability_reports]
            else:
                for consumer_id, report_list in applicability_reports.items():
                    report[unit_type_id][consumer_id] = [serialization.consumer.applicability_report(r) for r in report_list]

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

示例2: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def POST(self, consumer_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.consumer_group_manager()
     manager.unassociate(consumer_group_id, criteria)
     query_manager = managers_factory.consumer_group_query_manager()
     group = query_manager.get_group(consumer_group_id)
     return self.ok(group['consumer_ids'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:9,代码来源:consumer_groups.py

示例3: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def POST(self, repo_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.repo_group_manager()
     manager.unassociate(repo_group_id, criteria)
     collection = RepoGroup.get_collection()
     group = collection.find_one({'id': repo_group_id})
     return self.ok(group['repo_ids'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:9,代码来源:repo_groups.py

示例4: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [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

示例5: post

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def post(self, request):
        """
        Dispatch a task to regenerate content applicability data for repositories that match
        the criteria passed in the body.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest

        :raises exceptions.MissingValue: if repo_critera is not a body parameter
        :raises exceptions.InvalidValue: if repo_critera (dict) has unsupported keys,
                                              the manager will raise an InvalidValue for the
                                              specific keys. Here, we create a parent exception
                                              for repo_criteria and include the specific keys as
                                              child exceptions.
        :raises exceptions.OperationPostponed: dispatch a task
        """
        class GroupCallReport(dict):
            def serialize(self):
                return self

        repo_criteria_body = request.body_as_json.get('repo_criteria', None)
        parallel = request.body_as_json.get('parallel', False)

        if repo_criteria_body is None:
            raise exceptions.MissingValue('repo_criteria')
        try:
            repo_criteria = Criteria.from_client_input(repo_criteria_body)
        except exceptions.InvalidValue, e:
            invalid_criteria = exceptions.InvalidValue('repo_criteria')
            invalid_criteria.add_child_exception(e)
            raise invalid_criteria
开发者ID:grizax,项目名称:pulp,代码行数:33,代码来源:repositories.py

示例6: _get_query_results_from_get

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def _get_query_results_from_get(self, ignore_fields=None):
        """
        Looks for query parameters that define a Criteria, and returns the
        results of a search based on that Criteria.

        @param ignore_fields:   Field names to ignore. All other fields will be
                                used in an attempt to generate a Criteria
                                instance, which will fail if unexpected field
                                names are present.
        @type  ignore_fields:   list

        @return:    list of documents from the DB that match the given criteria
                    for the collection associated with this controller
        @rtype:     list
        """
        input = web.input(field=[])
        if ignore_fields:
            for field in ignore_fields:
                input.pop(field, None)

        # rename this to 'fields' within the dict, and omit it if empty so we
        # default to getting all fields
        fields = input.pop('field')
        if fields:
            if 'id' not in fields and u'id' not in fields:
                fields.append('id')
            input['fields'] = fields

        criteria = Criteria.from_client_input(input)
        return list(self.query_method(criteria))
开发者ID:stpierre,项目名称:pulp,代码行数:32,代码来源:search.py

示例7: post

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def post(self, request):
        """
        Creates an async task to regenerate content applicability data for given consumers.

        body {consumer_criteria:<dict>}

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest

        :raises MissingValue: if some parameters are missing
        :raises InvalidValue: if some parameters are invalid
        :raises OperationPostponed: when an async operation is performed.
        """

        body = request.body_as_json
        consumer_criteria = body.get('consumer_criteria', None)
        if consumer_criteria is None:
            raise MissingValue('consumer_criteria')
        try:
            consumer_criteria = Criteria.from_client_input(consumer_criteria)
        except:
            raise InvalidValue('consumer_criteria')

        task_tags = [tags.action_tag('content_applicability_regeneration')]
        async_result = regenerate_applicability_for_consumers.apply_async_with_reservation(
            tags.RESOURCE_REPOSITORY_PROFILE_APPLICABILITY_TYPE, tags.RESOURCE_ANY_ID,
            (consumer_criteria.as_dict(),), tags=task_tags)
        raise OperationPostponed(async_result)
开发者ID:alanoe,项目名称:pulp,代码行数:30,代码来源:consumers.py

示例8: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [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

示例9: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [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_associate')]
     call_request = CallRequest(manager.associate,
                                [consumer_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     execution.execute(call_request)
     collection = ConsumerGroup.get_collection()
     group = collection.find_one({'id': consumer_group_id})
     return self.ok(group['consumer_ids'])
开发者ID:ehelms,项目名称:pulp,代码行数:15,代码来源:consumer_groups.py

示例10: GET

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def GET(self):
     valid_filters = ['tag']
     filters = self.filters(valid_filters)
     criteria_filters = {}
     tags = filters.get('tag', [])
     if tags:
         criteria_filters['tags'] = {'$all':  filters.get('tag', [])}
     criteria = Criteria.from_client_input({'filters': criteria_filters})
     serialized_task_statuses = []
     for task in TaskStatusManager.find_by_criteria(criteria):
         task.update(serialization.dispatch.spawned_tasks(task))
         serialized_task_statuses.append(task)
     return self.ok(serialized_task_statuses)
开发者ID:preethit,项目名称:pulp-1,代码行数:15,代码来源:dispatch.py

示例11: test_no_exception_for_profiler_notfound

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def test_no_exception_for_profiler_notfound(self):
     # Setup
     self.populate()
     # Test
     user_specified_unit_criteria = {'rpm': {"filters": {"name": {"$in":['zsh']}}},
                      'xxx': {"filters": {"name": {"$in":['abc']}}}
                     }
     unit_criteria = {}
     for type_id, criteria in user_specified_unit_criteria.items():
         unit_criteria[type_id] = Criteria.from_client_input(criteria)
     manager = factory.consumer_applicability_manager()
     result = manager.find_applicable_units(self.CONSUMER_CRITERIA, self.REPO_CRITERIA, unit_criteria)
     self.assertTrue(result == {})
开发者ID:bartwo,项目名称:pulp,代码行数:15,代码来源:test_applicability_manager.py

示例12: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def POST(self, repo_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.repo_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id),
             action_tag('repo_group_unassociate')]
     call_request = CallRequest(manager.unassociate,
                                [repo_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
     execution.execute(call_request)
     collection = RepoGroup.get_collection()
     group = collection.find_one({'id': repo_group_id})
     return self.ok(group['repo_ids'])
开发者ID:stpierre,项目名称:pulp,代码行数:15,代码来源:repo_groups.py

示例13: POST

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def POST(self):
        """
        Determine content applicability.
        body {
        consumer_criteria:<dict> or None, 
        repo_criteria:<dict> or None, 
        units: {<type_id1> : [{<unit1>}, {<unit2}, ..]
                <type_id2> : [{<unit1>}, {<unit2}, ..]} or None
        }

        :return: A dict of applicability reports keyed by consumer ID.
            Each consumer report is:
                { <unit_type_id1> : [<ApplicabilityReport>],
                  <unit_type_id1> : [<ApplicabilityReport>]},
                }
                
        :rtype: dict
        """
        body = self.params()

        consumer_criteria = body.get('consumer_criteria', None)
        repo_criteria = body.get('repo_criteria', None)
        units = body.get('units', None)

        if consumer_criteria:
            consumer_criteria = Criteria.from_client_input(consumer_criteria)

        if repo_criteria:
            repo_criteria = Criteria.from_client_input(repo_criteria)

        manager = managers.consumer_applicability_manager()
        report = manager.units_applicable(consumer_criteria, repo_criteria, units)

        for consumer_report in report.values():
            for unit_type_id, report_list in consumer_report.items():
                consumer_report[unit_type_id] = [serialization.consumer.applicability_report(r) for r in report_list]
        return self.ok(report)
开发者ID:graco,项目名称:pulp,代码行数:39,代码来源:consumers.py

示例14: test_profiler_no_exception

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
 def test_profiler_no_exception(self):
     # Setup
     self.populate()
     profiler, cfg = plugins.get_profiler_by_type('rpm')
     profiler.find_applicable_units = Mock(side_effect=KeyError)
     # Test
     user_specified_unit_criteria = {'rpm': {"filters": {"name": {"$in":['zsh','ksh']}}},
                                     'mock-type': {"filters": {"name": {"$in":['abc','def']}}}
                                     }
     unit_criteria = {}
     for type_id, criteria in user_specified_unit_criteria.items():
         unit_criteria[type_id] = Criteria.from_client_input(criteria)
     manager = factory.consumer_applicability_manager()
     result = manager.find_applicable_units(self.CONSUMER_CRITERIA, self.REPO_CRITERIA, unit_criteria)
     self.assertTrue(result == {})
开发者ID:bartwo,项目名称:pulp,代码行数:17,代码来源:test_applicability_manager.py

示例15: _get_consumer_criteria

# 需要导入模块: from pulp.server.db.model.criteria import Criteria [as 别名]
# 或者: from pulp.server.db.model.criteria.Criteria import from_client_input [as 别名]
    def _get_consumer_criteria(self):
        """
        Process the POST data, finding the criteria given by the user, and resolve it to Criteria
        object.

        :return: A Criteria object
        :rtype:  pulp.server.db.model.criteria.Criteria
        """
        body = self.params()

        try:
            consumer_criteria = body.get('criteria')
        except AttributeError:
            raise InvalidValue('The input to this method must be a JSON object with a '
                               "'criteria' key.")
        consumer_criteria = Criteria.from_client_input(consumer_criteria)
        return consumer_criteria
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:19,代码来源:consumers.py


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