本文整理汇总了Python中pulp.server.db.model.consumer.ConsumerGroup类的典型用法代码示例。如果您正苦于以下问题:Python ConsumerGroup类的具体用法?Python ConsumerGroup怎么用?Python ConsumerGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsumerGroup类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: tearDown
def tearDown(self):
super(self.__class__, self).tearDown()
Consumer.get_collection().remove()
ConsumerGroup.get_collection().remove()
Repo.get_collection().remove()
RepoDistributor.get_collection().remove()
Bind.get_collection().remove()
mock_plugins.reset()
开发者ID:cliffy94,项目名称:pulp,代码行数:8,代码来源:test_consumer_group_controller.py
示例2: setUp
def setUp(self):
super(self.__class__, self).setUp()
Consumer.get_collection().remove()
ConsumerGroup.get_collection().remove()
Repo.get_collection().remove()
RepoDistributor.get_collection().remove()
Bind.get_collection().remove()
plugin_api._create_manager()
mock_plugins.install()
开发者ID:cliffy94,项目名称:pulp,代码行数:9,代码来源:test_consumer_group_controller.py
示例3: create_consumer_group
def create_consumer_group(self, group_id, display_name=None, description=None, consumer_ids=None, notes=None):
"""
Create a new consumer group.
@param group_id: unique id of the consumer group
@param display_name: display name of the consumer group
@type display_name: str or None
@param description: description of the consumer group
@type description: str or None
@param consumer_ids: list of ids for consumers initially belonging to the consumer group
@type consumer_ids: list or None
@param notes: notes for the consumer group
@type notes: dict or None
@return: SON representation of the consumer group
@rtype: L{bson.SON}
"""
if group_id is None or _CONSUMER_GROUP_ID_REGEX.match(group_id) is None:
raise InvalidValue(['group_id'])
collection = ConsumerGroup.get_collection()
consumer_group = ConsumerGroup(group_id, display_name, description, consumer_ids, notes)
try:
collection.insert(consumer_group, safe=True)
except DuplicateKeyError:
raise pulp_exceptions.DuplicateResource(group_id), None, sys.exc_info()[2]
group = collection.find_one({'id': group_id})
return group
开发者ID:ashcrow,项目名称:pulp,代码行数:26,代码来源:cud.py
示例4: GET
def GET(self, consumer_group_id):
collection = ConsumerGroup.get_collection()
group = collection.find_one({'id': consumer_group_id})
if group is None:
raise pulp_exceptions.MissingResource(consumer_group=consumer_group_id)
group.update(serialization.link.current_link_obj())
return self.ok(group)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:7,代码来源:consumer_groups.py
示例5: find_all
def find_all(self):
"""
Returns all consumersitory groups in the database or an empty list if
none exist.
@return: list of database representations of all consumersitory groups
@rtype: list
"""
groups = list(ConsumerGroup.get_collection().find())
return groups
开发者ID:nareshbatthula,项目名称:pulp,代码行数:10,代码来源:query.py
示例6: find_by_criteria
def find_by_criteria(criteria):
"""
Return a list of consumersitory groups that match the provided criteria.
@param criteria: A Criteria object representing a search you want
to perform
@type criteria: pulp.server.db.model.criteria.Criteria
@return: list of consumer group instances
@rtype: list
"""
return ConsumerGroup.get_collection().query(criteria)
开发者ID:nareshbatthula,项目名称:pulp,代码行数:12,代码来源:query.py
示例7: create_consumer_group
def create_consumer_group(group_id, display_name=None, description=None, consumer_ids=None,
notes=None):
"""
Create a new consumer group.
:param group_id: unique id of the consumer group
:type group_id: str
:param display_name: display name of the consumer group
:type display_name: str or None
:param description: description of the consumer group
:type description: str or None
:param consumer_ids: list of ids for consumers initially belonging to the consumer group
:type consumer_ids: list or None
:param notes: notes for the consumer group
:type notes: dict or None
:return: SON representation of the consumer group
:rtype: bson.SON
"""
validation_errors = []
if group_id is None:
validation_errors.append(PulpCodedException(error_codes.PLP1002, field='group_id'))
elif _CONSUMER_GROUP_ID_REGEX.match(group_id) is None:
validation_errors.append(PulpCodedException(error_codes.PLP1003, field='group_id'))
if consumer_ids:
# Validate that all the consumer_ids exist and raise an exception if they don't
consumer_collection = Consumer.get_collection()
matched_consumers = consumer_collection.find({'id': {'$in': consumer_ids}})
if matched_consumers.count() is not len(consumer_ids):
# Create a set of all the matched consumer_ids
matched_consumers_set = set()
for consumer in matched_consumers:
matched_consumers_set.add(consumer.get('id'))
# find the missing items
for consumer_id in (set(consumer_ids)).difference(matched_consumers_set):
validation_errors.append(PulpCodedException(error_codes.PLP1001,
consumer_id=consumer_id))
if validation_errors:
raise pulp_exceptions.PulpCodedValidationException(validation_errors)
collection = ConsumerGroup.get_collection()
consumer_group = ConsumerGroup(group_id, display_name, description, consumer_ids, notes)
try:
collection.insert(consumer_group, safe=True)
except DuplicateKeyError:
raise pulp_exceptions.PulpCodedValidationException(
[PulpCodedException(error_codes.PLP1004, type=ConsumerGroup.collection_name,
object_id=group_id)])
group = collection.find_one({'id': group_id})
return group
开发者ID:aweiteka,项目名称:pulp,代码行数:52,代码来源:cud.py
示例8: get
def get(self, request):
"""
List the available consumer groups.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:return: Response containing a list of consumer groups
:rtype: django.http.HttpResponse
"""
collection = ConsumerGroup.get_collection()
cursor = collection.find({})
groups = [serialize(group) for group in cursor]
return generate_json_response_with_pulp_encoder(groups)
开发者ID:credativ,项目名称:pulp,代码行数:13,代码来源:consumer_groups.py
示例9: POST
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)
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,代码行数:13,代码来源:consumer_groups.py
示例10: get_group
def get_group(self, consumer_group_id):
"""
Returns the consumersitory group with the given ID, raising an exception
if one does not exist.
@param consumer_group_id: identifies the group
@type consumer_group_id: str
@return: database representation of the consumer group
@raise MissingResource: if there is no group with the given ID
"""
group = ConsumerGroup.get_collection().find_one({"id": consumer_group_id})
if group is None:
raise MissingResource(consumer_group=consumer_group_id)
return group
开发者ID:nareshbatthula,项目名称:pulp,代码行数:16,代码来源:query.py
示例11: validate_existing_consumer_group
def validate_existing_consumer_group(group_id):
"""
Validate the existence of a consumer group, given its id.
Returns the consumer group db collection upon successful validation,
raises an exception upon failure
@param group_id: unique id of the consumer group to validate
@type group_id: str
@return: consumer group db collection
@rtype: L{pulp.server.db.connection.PulpCollection}
@raise: L{pulp.server.exceptions.MissingResource}
"""
collection = ConsumerGroup.get_collection()
consumer_group = collection.find_one({'id': group_id})
if consumer_group is not None:
return collection
raise pulp_exceptions.MissingResource(consumer_group=group_id)
开发者ID:nbetm,项目名称:pulp,代码行数:16,代码来源:cud.py
示例12: remove_consumer_from_groups
def remove_consumer_from_groups(self, consumer_id, group_ids=None):
"""
Remove a consumer from the list of consumer groups provided.
If no consumer groups are specified, remove the consumer from all consumer groups
its currently in.
(idempotent: useful when deleting consumersitories)
@param consumer_id: unique id of the consumer to remove from consumer groups
@type consumer_id: str
@param group_ids: list of consumer group ids to remove the consumer from
@type group_ids: list of None
"""
spec = {}
if group_ids is not None:
spec = {'id': {'$in': group_ids}}
collection = ConsumerGroup.get_collection()
collection.update(spec, {'$pull': {'consumer_ids': consumer_id}}, multi=True, safe=True)
开发者ID:nbetm,项目名称:pulp,代码行数:16,代码来源:cud.py
示例13: tearDown
def tearDown(self):
PulpItineraryTests.tearDown(self)
Consumer.get_collection().remove()
ConsumerGroup.get_collection().remove()
mock_plugins.reset()
开发者ID:bartwo,项目名称:pulp,代码行数:5,代码来源:test_consumer_group_itineraries.py
示例14: setUp
def setUp(self):
PulpItineraryTests.setUp(self)
Consumer.get_collection().remove()
ConsumerGroup.get_collection().remove()
mock_plugins.install()
mock_agent.install()
开发者ID:bartwo,项目名称:pulp,代码行数:6,代码来源:test_consumer_group_itineraries.py
示例15: clean
def clean(self):
super(ConsumerGroupAssociationTests, self).clean()
ConsumerGroup.get_collection().remove()
开发者ID:cliffy94,项目名称:pulp,代码行数:3,代码来源:test_consumer_group_controller.py
示例16: tearDown
def tearDown(self):
super(ConsumerGroupTests, self).tearDown()
self.manager = None
Consumer.get_collection().remove(safe=True)
ConsumerGroup.get_collection().remove(safe=True)
开发者ID:bartwo,项目名称:pulp,代码行数:5,代码来源:test_consumer_group_manager.py
示例17: setUp
def setUp(self):
super(ConsumerGroupTests, self).setUp()
self.collection = ConsumerGroup.get_collection()
self.manager = cud.ConsumerGroupManager()
开发者ID:bartwo,项目名称:pulp,代码行数:4,代码来源:test_consumer_group_manager.py
注:本文中的pulp.server.db.model.consumer.ConsumerGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论