本文整理汇总了Python中pulp.server.managers.factory.consumer_history_manager函数的典型用法代码示例。如果您正苦于以下问题:Python consumer_history_manager函数的具体用法?Python consumer_history_manager怎么用?Python consumer_history_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了consumer_history_manager函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: bind
def bind(self, consumer_id, repo_id, distributor_id):
"""
Bind consumer to a specific distributor associated with
a repository. This call is idempotent.
@param consumer_id: uniquely identifies the consumer.
@type consumer_id: str
@param repo_id: uniquely identifies the repository.
@type repo_id: str
@param distributor_id: uniquely identifies a distributor.
@type distributor_id: str
@return: The Bind object
@rtype: SON
@raise MissingResource: when given consumer does not exist.
"""
manager = factory.consumer_manager()
manager.get_consumer(consumer_id)
manager = factory.repo_distributor_manager()
distributor = manager.get_distributor(repo_id, distributor_id)
bind = Bind(consumer_id, repo_id, distributor_id)
collection = Bind.get_collection()
try:
collection.save(bind, safe=True)
bind = self.get_bind(consumer_id, repo_id, distributor_id)
except DuplicateKeyError:
# idempotent
pass
manager = factory.consumer_agent_manager()
manager.bind(consumer_id, repo_id)
consumer_event_details = {"repo_id": repo_id, "distributor_id": distributor_id}
factory.consumer_history_manager().record_event(consumer_id, "repo_bound", consumer_event_details)
return bind
开发者ID:jlsherrill,项目名称:pulp,代码行数:31,代码来源:bind.py
示例2: unbind
def unbind(self, consumer_id, repo_id, distributor_id):
"""
Unbind consumer to a specifiec distirbutor associated with
a repository. This call is idempotent.
@param consumer_id: uniquely identifies the consumer.
@type consumer_id: str
@param repo_id: uniquely identifies the repository.
@type repo_id: str
@param distributor_id: uniquely identifies a distributor.
@type distributor_id: str
@return: The Bind object
@rtype: SON
"""
query = dict(consumer_id=consumer_id, repo_id=repo_id, distributor_id=distributor_id)
collection = Bind.get_collection()
bind = collection.find_one(query)
if bind is None:
# idempotent
return
collection.remove(bind, safe=True)
manager = factory.consumer_agent_manager()
manager.unbind(consumer_id, repo_id)
consumer_event_details = {"repo_id": repo_id, "distributor_id": distributor_id}
factory.consumer_history_manager().record_event(consumer_id, "repo_unbound", consumer_event_details)
return bind
开发者ID:jlsherrill,项目名称:pulp,代码行数:25,代码来源:bind.py
示例3: 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')
开发者ID:stpierre,项目名称:pulp,代码行数:35,代码来源:cud.py
示例4: register
def register(consumer_id,
display_name=None,
description=None,
notes=None,
capabilities=None,
rsa_pub=None):
"""
Registers a new Consumer
:param consumer_id: unique identifier for the consumer
:type consumer_id: str
:param rsa_pub: The consumer public key used for message authentication.
:type rsa_pub: str
:param display_name: user-friendly name for the consumer
:type display_name: str
:param description: user-friendly text describing the consumer
:type description: str
:param notes: key-value pairs to pragmatically tag the consumer
:type notes: dict
:param capabilities: operations supported on the consumer
:type capabilities: dict
:raises DuplicateResource: if there is already a consumer or a used with the requested ID
:raises InvalidValue: if any of the fields is unacceptable
:return: A tuple of: (consumer, certificate)
:rtype: tuple
"""
if not is_consumer_id_valid(consumer_id):
raise InvalidValue(['id'])
collection = Consumer.get_collection()
consumer = collection.find_one({'id': consumer_id})
if consumer is not None:
raise DuplicateResource(consumer_id)
if notes is not None and not isinstance(notes, dict):
raise InvalidValue(['notes'])
if capabilities is not None and not isinstance(capabilities, dict):
raise InvalidValue(['capabilities'])
# Use the ID for the display name if one was not specified
display_name = display_name or consumer_id
# Creation
consumer = Consumer(consumer_id, display_name, description, notes, capabilities, rsa_pub)
_id = collection.save(consumer, safe=True)
# Generate certificate
cert_gen_manager = factory.cert_generation_manager()
expiration_date = config.config.getint('security', 'consumer_cert_expiration')
key, certificate = cert_gen_manager.make_cert(consumer_id, expiration_date, uid=str(_id))
factory.consumer_history_manager().record_event(consumer_id, 'consumer_registered')
return consumer, Bundle.join(key, certificate)
开发者ID:credativ,项目名称:pulp,代码行数:56,代码来源:cud.py
示例5: unregister
def unregister(self, consumer_id):
"""
Unregisters given consumer.
@param consumer_id: identifies the consumer being unregistered
@type consumer_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(consumer_id)
# Remove associate bind
manager = factory.consumer_bind_manager()
manager.consumer_deleted(consumer_id)
# Remove associated profiles
manager = factory.consumer_profile_manager()
manager.consumer_deleted(consumer_id)
# Notify agent
agent_consumer = factory.consumer_agent_manager()
agent_consumer.unregistered(consumer_id)
# remove from consumer groups
group_manager = factory.consumer_group_manager()
group_manager.remove_consumer_from_groups(consumer_id)
# delete any scheduled unit installs
schedule_manager = factory.schedule_manager()
schedule_manager.delete_all_unit_install_schedules(consumer_id)
schedule_manager.delete_all_unit_update_schedules(consumer_id)
schedule_manager.delete_all_unit_uninstall_schedules(consumer_id)
# Database Updates
try:
Consumer.get_collection().remove({'id' : consumer_id}, safe=True)
except Exception:
_LOG.exception('Error updating database collection while removing '
'consumer [%s]' % consumer_id)
raise PulpExecutionException("database-error"), None, sys.exc_info()[2]
# remove the consumer from any groups it was a member of
group_manager = factory.consumer_group_manager()
group_manager.remove_consumer_from_groups(consumer_id)
factory.consumer_history_manager().record_event(consumer_id, 'consumer_unregistered')
开发者ID:bartwo,项目名称:pulp,代码行数:50,代码来源:cud.py
示例6: register
def register(self, id, display_name=None, description=None, notes=None, capabilities=None):
"""
Registers a new Consumer
@param id: unique identifier for the consumer
@type id: str
@param display_name: user-friendly name for the consumer
@type display_name: str
@param description: user-friendly text describing the consumer
@type description: str
@param notes: key-value pairs to programmatically tag the consumer
@type notes: dict
@param capabilities: operations permitted on the consumer
@type capabilities: dict
@raises DuplicateResource: if there is already a consumer or a used with the requested ID
@raises InvalidValue: if any of the fields is unacceptable
"""
if not is_consumer_id_valid(id):
raise InvalidValue(['id'])
existing_consumer = Consumer.get_collection().find_one({'id' : id})
if existing_consumer is not None:
raise DuplicateResource(id)
if notes is not None and not isinstance(notes, dict):
raise InvalidValue(['notes'])
if capabilities is not None and not isinstance(capabilities, dict):
raise InvalidValue(['capabilities'])
# Use the ID for the display name if one was not specified
display_name = display_name or id
# Generate certificate
cert_gen_manager = factory.cert_generation_manager()
expiration_date = config.config.getint('security', 'consumer_cert_expiration')
key, crt = cert_gen_manager.make_cert(id, expiration_date)
# Creation
create_me = Consumer(id, display_name, description, notes, capabilities, certificate=crt.strip())
Consumer.get_collection().save(create_me, safe=True)
factory.consumer_history_manager().record_event(id, 'consumer_registered')
create_me.certificate = Bundle.join(key, crt)
return create_me
开发者ID:jlsherrill,项目名称:pulp,代码行数:50,代码来源:cud.py
示例7: unregister
def unregister(consumer_id):
"""
Unregisters given consumer.
:param consumer_id: identifies the consumer being unregistered
:type consumer_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
"""
ConsumerManager.get_consumer(consumer_id)
# Remove associate bind
manager = factory.consumer_bind_manager()
manager.consumer_deleted(consumer_id)
# Remove associated profiles
manager = factory.consumer_profile_manager()
manager.consumer_deleted(consumer_id)
# Notify agent
agent_consumer = factory.consumer_agent_manager()
agent_consumer.unregister(consumer_id)
# remove from consumer groups
group_manager = factory.consumer_group_manager()
group_manager.remove_consumer_from_groups(consumer_id)
# delete any scheduled unit installs
schedule_manager = factory.consumer_schedule_manager()
for schedule in schedule_manager.get(consumer_id):
# using "delete" on utils skips validation that the consumer exists.
schedule_utils.delete(schedule.id)
# Database Updates
try:
Consumer.get_collection().remove({'id': consumer_id})
except Exception:
_logger.exception(
'Error updating database collection while removing consumer [%s]' % consumer_id)
raise PulpExecutionException("database-error"), None, sys.exc_info()[2]
# remove the consumer from any groups it was a member of
group_manager = factory.consumer_group_manager()
group_manager.remove_consumer_from_groups(consumer_id)
factory.consumer_history_manager().record_event(consumer_id, 'consumer_unregistered')
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:49,代码来源:cud.py
示例8: unbind
def unbind(self, consumer_id, repo_id, distributor_id):
"""
Unbind a consumer from a specific distributor associated with
a repository. This call is idempotent.
@param consumer_id: uniquely identifies the consumer.
@type consumer_id: str
@param repo_id: uniquely identifies the repository.
@type repo_id: str
@param distributor_id: uniquely identifies a distributor.
@type distributor_id: str
@return: The Bind object
@rtype: SON
"""
collection = Bind.get_collection()
query = self.bind_id(consumer_id, repo_id, distributor_id)
query['deleted'] = False
bind = collection.find_one(query)
if bind is None:
# idempotent
return
self.mark_deleted(consumer_id, repo_id, distributor_id)
details = {
'repo_id':repo_id,
'distributor_id':distributor_id
}
manager = factory.consumer_history_manager()
manager.record_event(consumer_id, 'repo_unbound', details)
return bind
开发者ID:pkilambi,项目名称:pulp,代码行数:28,代码来源:bind.py
示例9: GET
def GET(self, id):
"""
@type id: str
@param id: consumer id
"""
valid_filters = ['event_type', 'limit', 'sort', 'start_date', 'end_date']
filters = self.filters(valid_filters)
event_type = filters.get('event_type', None)
limit = filters.get('limit', None)
sort = filters.get('sort', None)
start_date = filters.get('start_date', None)
end_date = filters.get('end_date', None)
if sort is None:
sort = 'descending'
else:
sort = sort[0]
if limit:
limit = int(limit[0])
if start_date:
start_date = start_date[0]
if end_date:
end_date = end_date[0]
if event_type:
event_type = event_type[0]
results = managers.consumer_history_manager().query(consumer_id=id, event_type=event_type, limit=limit,
sort=sort, start_date=start_date, end_date=end_date)
return self.ok(results)
开发者ID:graco,项目名称:pulp,代码行数:33,代码来源:consumers.py
示例10: bind
def bind(self, consumer_id, repo_id, distributor_id):
"""
Bind consumer to a specific distributor associated with
a repository. This call is idempotent.
@param consumer_id: uniquely identifies the consumer.
@type consumer_id: str
@param repo_id: uniquely identifies the repository.
@type repo_id: str
@param distributor_id: uniquely identifies a distributor.
@type distributor_id: str
@return: The Bind object
@rtype: SON
@raise MissingResource: when given consumer does not exist.
"""
# ensure the consumer is valid
manager = factory.consumer_manager()
manager.get_consumer(consumer_id)
# ensure the repository & distributor are valid
manager = factory.repo_distributor_manager()
manager.get_distributor(repo_id, distributor_id)
# perform the bind
collection = Bind.get_collection()
try:
bind = Bind(consumer_id, repo_id, distributor_id)
collection.save(bind, safe=True)
except DuplicateKeyError:
self.__reset_bind(consumer_id, repo_id, distributor_id)
# fetch the inserted/updated bind
bind = self.get_bind(consumer_id, repo_id, distributor_id)
# update history
details = {'repo_id':repo_id, 'distributor_id':distributor_id}
manager = factory.consumer_history_manager()
manager.record_event(consumer_id, 'repo_bound', details)
return bind
开发者ID:pkilambi,项目名称:pulp,代码行数:34,代码来源:bind.py
示例11: unassociate
def unassociate(group_id, criteria):
"""
Unassociate a set of consumers, that match the passed in criteria, from a consumer group.
@param group_id: unique id of the group to unassociate consumers from
@type group_id: str
@param criteria: Criteria specifying the set of consumers to unassociate
@type criteria: L{pulp.server.db.model.criteria.Criteria}
"""
group_collection = validate_existing_consumer_group(group_id)
consumer_collection = Consumer.get_collection()
cursor = consumer_collection.query(criteria)
consumer_ids = [r['id'] for r in cursor]
if consumer_ids:
group_collection.update(
{'id': group_id},
{'$pullAll': {'consumer_ids': consumer_ids}})
details = {'group_id': group_id}
for consumer_id in consumer_ids:
manager_factory.consumer_history_manager().record_event(consumer_id,
'removed_from_group', details)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:20,代码来源:cud.py
示例12: associate
def associate(group_id, criteria):
"""
Associate a set of consumers, that match the passed in criteria, to a consumer group.
@param group_id: unique id of the group to associate consumers to
@type group_id: str
@param criteria: Criteria instance representing the set of consumers to associate
@type criteria: L{pulp.server.db.model.criteria.Criteria}
"""
group_collection = validate_existing_consumer_group(group_id)
consumer_collection = Consumer.get_collection()
cursor = consumer_collection.query(criteria)
consumer_ids = [r['id'] for r in cursor]
if consumer_ids:
group_collection.update(
{'id': group_id},
{'$addToSet': {'consumer_ids': {'$each': consumer_ids}}})
details = {'group_id': group_id}
for consumer_id in consumer_ids:
manager_factory.consumer_history_manager().record_event(consumer_id,
'added_to_group', details)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:20,代码来源:cud.py
示例13: bind
def bind(consumer_id, repo_id, distributor_id, notify_agent, binding_config):
"""
Bind consumer to a specific distributor associated with
a repository. This call is idempotent.
:param consumer_id: uniquely identifies the consumer.
:type consumer_id: str
:param repo_id: uniquely identifies the repository.
:type repo_id: str
:param distributor_id: uniquely identifies a distributor.
:type distributor_id: str
:return: The Bind object
:rtype: SON
:raise MissingResource: when given consumer does not exist.
:raise InvalidValid: when the repository or distributor id is invalid, or
if the notify_agent value is invalid
"""
# Validation
missing_values = BindManager._validate_consumer_repo(consumer_id, repo_id, distributor_id)
if missing_values:
if 'consumer_id' in missing_values:
# This is passed in via the URL so a 404 should be raised
raise MissingResource(consumer_id=missing_values['consumer_id'])
else:
# Everything else is a parameter so raise a 400
raise InvalidValue(missing_values.keys())
# ensure notify_agent is a boolean
if not isinstance(notify_agent, bool):
raise InvalidValue(['notify_agent'])
# perform the bind
collection = Bind.get_collection()
try:
bind = Bind(consumer_id, repo_id, distributor_id, notify_agent, binding_config)
collection.save(bind, safe=True)
except DuplicateKeyError:
BindManager._update_binding(consumer_id, repo_id, distributor_id, notify_agent,
binding_config)
BindManager._reset_bind(consumer_id, repo_id, distributor_id)
# fetch the inserted/updated bind
bind = BindManager.get_bind(consumer_id, repo_id, distributor_id)
# update history
details = {'repo_id': repo_id, 'distributor_id': distributor_id}
manager = factory.consumer_history_manager()
manager.record_event(consumer_id, 'repo_bound', details)
return bind
开发者ID:nbetm,项目名称:pulp,代码行数:48,代码来源:bind.py
示例14: uninstall_content
def uninstall_content(consumer_id, units, options):
"""
Uninstall content units on a consumer.
:param consumer_id: The consumer ID.
:type consumer_id: str
:param units: A list of content units to be uninstalled.
:type units: list of:
{ type_id:<str>, type_id:<dict> }
:param options: Uninstall options; based on unit type.
:type options: dict
:return: A task ID that may be used to track the agent request.
:rtype: dict
"""
# track agent operations using a pseudo task
task_id = str(uuid4())
task_tags = [
tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer_id),
tags.action_tag(tags.ACTION_AGENT_UNIT_UNINSTALL)
]
task = TaskStatus(task_id, 'agent', tags=task_tags).save()
# agent request
manager = managers.consumer_manager()
consumer = manager.get_consumer(consumer_id)
conduit = ProfilerConduit()
collated = Units(units)
for typeid, units in collated.items():
pc = AgentManager._profiled_consumer(consumer_id)
profiler, cfg = AgentManager._profiler(typeid)
units = AgentManager._invoke_plugin(
profiler.uninstall_units,
pc,
units,
options,
cfg,
conduit)
collated[typeid] = units
units = collated.join()
context = Context(consumer, task_id=task_id, consumer_id=consumer_id)
agent = PulpAgent()
agent.content.uninstall(context, units, options)
history_manager = managers.consumer_history_manager()
history_manager.record_event(consumer_id, 'content_unit_uninstalled', {'units': units})
return task
开发者ID:hgschmie,项目名称:pulp,代码行数:44,代码来源:agent.py
示例15: get
def get(self, request, consumer_id):
"""
Retrieve histroy for the specified consumer
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:param consumer_id: A consumer ID.
:type consumer_id: str
:return: Response representing the binding
:rtype: django.http.HttpResponse
"""
# Check that the consumer exists and raise a MissingResource exception, in case it doesn't.
factory.consumer_manager().get_consumer(consumer_id)
query_param = request.GET
filters = _ensure_input_encoding(query_param)
event_type = filters.get('event_type', None)
limit = filters.get('limit', None)
sort = filters.get('sort', 'descending')
start_date = filters.get('start_date', None)
end_date = filters.get('end_date', None)
if limit:
try:
limit = int(limit)
except ValueError:
raise InvalidValue('limit')
results = factory.consumer_history_manager().query(consumer_id=consumer_id,
event_type=event_type,
limit=limit,
sort=sort,
start_date=start_date,
end_date=end_date)
return generate_json_response_with_pulp_encoder(results)
开发者ID:alanoe,项目名称:pulp,代码行数:37,代码来源:consumers.py
示例16: update
def update(consumer_id, content_type, profile):
"""
Update a unit profile.
Created if not already exists.
:param consumer_id: uniquely identifies the consumer.
:type consumer_id: str
:param content_type: The profile (content) type ID.
:type content_type: str
:param profile: The unit profile
:type profile: object
"""
consumer = factory.consumer_manager().get_consumer(consumer_id)
try:
profiler, config = plugin_api.get_profiler_by_type(content_type)
except plugin_exceptions.PluginNotFound:
# Not all profile types have a type specific profiler, so let's use the baseclass
# Profiler
profiler, config = (Profiler(), {})
# Allow the profiler a chance to update the profile before we save it
if profile is None:
raise MissingValue('profile')
profile = profiler.update_profile(consumer, content_type, profile, config)
try:
p = ProfileManager.get_profile(consumer_id, content_type)
p['profile'] = profile
# We store the profile's hash anytime the profile gets altered
p['profile_hash'] = UnitProfile.calculate_hash(profile)
except MissingResource:
p = UnitProfile(consumer_id, content_type, profile)
collection = UnitProfile.get_collection()
collection.save(p)
history_manager = factory.consumer_history_manager()
history_manager.record_event(
consumer_id,
'unit_profile_changed', {'profile_content_type': content_type})
return p
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:37,代码来源:profile.py
示例17: unbind
def unbind(consumer_id, repo_id, distributor_id):
"""
Unbind a consumer from a specific distributor associated with
a repository. This call is idempotent.
:param consumer_id: uniquely identifies the consumer.
:type consumer_id: str
:param repo_id: uniquely identifies the repository.
:type repo_id: str
:param distributor_id: uniquely identifies a distributor.
:type distributor_id: str
:return: The Bind object
:rtype: SON
:raise MissingResource: if the binding does not exist
"""
# Validate that the binding exists at all before continuing.
# This will raise an exception if it it does not.
BindManager.get_bind(consumer_id, repo_id, distributor_id)
collection = Bind.get_collection()
query = BindManager.bind_id(consumer_id, repo_id, distributor_id)
query['deleted'] = False
bind = collection.find_one(query)
if bind is None:
# idempotent
return
BindManager.mark_deleted(consumer_id, repo_id, distributor_id)
details = {
'repo_id': repo_id,
'distributor_id': distributor_id
}
manager = factory.consumer_history_manager()
manager.record_event(consumer_id, 'repo_unbound', details)
return bind
开发者ID:nbetm,项目名称:pulp,代码行数:36,代码来源:bind.py
注:本文中的pulp.server.managers.factory.consumer_history_manager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论