本文整理汇总了Python中pulp.server.managers.factory.consumer_profile_manager函数的典型用法代码示例。如果您正苦于以下问题:Python consumer_profile_manager函数的具体用法?Python consumer_profile_manager怎么用?Python consumer_profile_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了consumer_profile_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PUT
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)
示例2: populate
def populate(self):
manager = factory.consumer_manager()
for id in self.CONSUMER_IDS:
manager.register(id)
manager = factory.consumer_profile_manager()
for id in self.CONSUMER_IDS:
manager.create(id, 'rpm', self.PROFILE)
示例3: DELETE
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()
resources = {
dispatch_constants.RESOURCE_CONSUMER_TYPE:
{consumer_id:dispatch_constants.RESOURCE_READ_OPERATION},
}
args = [
consumer_id,
content_type,
]
tags = [
resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
]
call_request = CallRequest(manager.delete,
args=args,
resources=resources,
tags=tags)
return self.ok(execution.execute(call_request))
示例4: unregister
def unregister(self, id):
"""
Unregisters given consumer.
@param id: identifies the consumer being unregistered
@type id: str
@raises MissingResource: if the given consumer does not exist
@raises OperationFailed: if any part of the unregister process fails;
the exception will contain information on which sections failed
@raises PulpExecutionException: if error during updating database collection
"""
self.get_consumer(id)
# Remove associate bind
manager = factory.consumer_bind_manager()
manager.consumer_deleted(id)
# Remove associated profiles
manager = factory.consumer_profile_manager()
manager.consumer_deleted(id)
# Notify agent
agent_consumer = factory.consumer_agent_manager()
agent_consumer.unregistered(id)
# Database Updates
try:
Consumer.get_collection().remove({'id' : id}, safe=True)
except Exception:
_LOG.exception('Error updating database collection while removing consumer [%s]' % id)
raise PulpExecutionException("database-error"), None, sys.exc_info()[2]
factory.consumer_history_manager().record_event(id, 'consumer_unregistered')
示例5: test_get_profiles_none
def test_get_profiles_none(self):
# Setup
self.populate()
# Test
manager = factory.consumer_profile_manager()
profiles = manager.get_profiles(self.CONSUMER_ID)
self.assertEquals(len(profiles), 0)
示例6: test_missing_consumer
def test_missing_consumer(self):
# Test
manager = factory.consumer_profile_manager()
# self.CONSUMER_ID is not an existing consumer, as it is not built during setUp(), so this
# should raise MissingResource
self.assertRaises(MissingResource, manager.update, self.CONSUMER_ID, self.TYPE_1,
self.PROFILE_1)
示例7: units_applicable
def units_applicable(self, criteria, units):
"""
Detemine and report which of the specified content units
is applicable to consumers specified by the I{criteria}.
@param criteria: The consumer selection criteria.
@type criteria: list
@param units: A list of content units to be installed.
@type units: list of:
{ type_id:<str>, unit_key:<dict> }
@return: A dict:
{consumer_id:[<ApplicabilityReport>]}
@rtype: list
"""
result = {}
conduit = ProfilerConduit()
manager = managers.consumer_query_manager()
ids = [c['id'] for c in manager.find_by_criteria(criteria)]
manager = managers.consumer_profile_manager()
profiles = manager.find_profiles(ids)
for id in ids:
for unit in units:
typeid = unit['type_id']
profiler, cfg = self.__profiler(typeid)
pc = self.__profiled_consumer(id)
report = profiler.unit_applicable(pc, unit, cfg, conduit)
report.unit = unit
ulist = result.setdefault(id, [])
ulist.append(report)
return result
示例8: post
def post(self, request, consumer_id):
"""
Associate a profile with a consumer by content type ID.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:param consumer_id: A consumer ID.
:type consumer_id: str
:raises MissingValue: if some parameter were not provided
:return: Response representing the created profile
:rtype: django.http.HttpResponse
"""
body = request.body_as_json
content_type = body.get('content_type')
profile = body.get('profile')
manager = factory.consumer_profile_manager()
new_profile = manager.create(consumer_id, content_type, profile)
if content_type is None:
raise MissingValue('content_type')
link = add_link_profile(new_profile)
response = generate_json_response_with_pulp_encoder(new_profile)
redirect_response = generate_redirect_response(response, link['_href'])
return redirect_response
示例9: PUT
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
示例10: test_delete_not_found
def test_delete_not_found(self):
# Setup
manager = factory.consumer_profile_manager()
# Test
path = '/v2/consumers/%s/profiles/unknown/' % self.CONSUMER_ID
status, body = self.delete(path)
self.assertEqual(status, 404)
示例11: populate_profile
def populate_profile(self, id, env):
manager = managers.consumer_profile_manager()
profile = []
for i in range(0, env.profile_units):
p = PROFILE_TEMPLATE.copy()
p['name'] = 'unit_%d' % i
profile.append(p)
manager.create(id, self.TYPE_ID, profile)
示例12: test_get_profile_not_found
def test_get_profile_not_found(self):
# Setup
self.populate()
# Test
manager = factory.consumer_profile_manager()
manager.create(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
# Verify
self.assertRaises(MissingResource, manager.get_profile, self.CONSUMER_ID, self.TYPE_1)
示例13: GET
def GET(self, consumer_id, content_type):
"""
@param consumer_id: The consumer ID.
@type consumer_id: str
"""
manager = managers.consumer_profile_manager()
profile = manager.get_profile(consumer_id, content_type)
serialized = serialization.consumer.profile(profile)
return self.ok(serialized)
示例14: test_get_profile
def test_get_profile(self):
# Setup
self.populate()
# Test
manager = factory.consumer_profile_manager()
manager.create(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
manager.create(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
profile = manager.get_profile(self.CONSUMER_ID, self.TYPE_1)
self.assertTrue(profile is not None)
示例15: GET
def GET(self, consumer_id):
"""
Get all profiles associated with a consumer.
@param consumer_id: The consumer ID.
@type consumer_id: str
@return: A list of profiles:
profile is: {consumer_id:<str>, content_type:<str>, profile:<dict>}
@return: list
"""
manager = managers.consumer_profile_manager()
profiles = manager.get_profiles(consumer_id)
profiles = [serialization.consumer.profile(p) for p in profiles]
return self.ok(profiles)