本文整理汇总了Python中pulp.server.managers.factory.consumer_bind_manager函数的典型用法代码示例。如果您正苦于以下问题:Python consumer_bind_manager函数的具体用法?Python consumer_bind_manager怎么用?Python consumer_bind_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了consumer_bind_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: bind
def bind(self, consumer_id, repo_id, distributor_id, options):
"""
Request the agent to perform the specified bind. This method will be called
after the server-side representation of the binding has been created.
:param consumer_id: The consumer ID.
:type consumer_id: str
:param repo_id: A repository ID.
:type repo_id: str
:param distributor_id: A distributor ID.
:type distributor_id: str
:param options: The options are handler specific.
:type options: dict
"""
# agent request
consumer_manager = managers.consumer_manager()
binding_manager = managers.consumer_bind_manager()
consumer = consumer_manager.get_consumer(consumer_id)
binding = binding_manager.get_bind(consumer_id, repo_id, distributor_id)
agent_bindings = self.__bindings([binding])
agent = PulpAgent(consumer)
agent.consumer.bind(agent_bindings, options)
# request tracking
action_id = factory.context().call_request_id
consumer_manager = managers.consumer_bind_manager()
consumer_manager.action_pending(
consumer_id,
repo_id,
distributor_id,
Bind.Action.BIND,
action_id)
开发者ID:ashcrow,项目名称:pulp,代码行数:34,代码来源:agent.py
示例2: test_bind
def test_bind(self):
# Setup
self.populate()
# Test
options = {}
itinerary = bind_itinerary(
self.CONSUMER_ID,
self.REPO_ID,
self.DISTRIBUTOR_ID,
self.NOTIFY_AGENT,
self.BINDING_CONFIG,
options)
call_reports = self.coordinator.execute_multiple_calls(itinerary)
# Verify
self.assertEqual(len(call_reports), 2)
self.assertEqual(call_reports[0].call_request_tags, self.BIND_TAGS)
self.assertEqual(call_reports[1].call_request_tags, self.AGENT_BIND_TAGS)
for call in call_reports:
self.assertNotEqual(call.state, dispatch_constants.CALL_REJECTED_RESPONSE)
# run task #1 (actual bind)
self.run_next()
# verify bind created
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEquals(len(binds), 1)
bind = binds[0]
self.assertEqual(bind['consumer_id'], self.CONSUMER_ID)
self.assertEqual(bind['repo_id'], self.REPO_ID)
self.assertEqual(bind['distributor_id'], self.DISTRIBUTOR_ID)
self.assertEqual(bind['notify_agent'], self.NOTIFY_AGENT)
self.assertEqual(bind['binding_config'], self.BINDING_CONFIG)
# run task #2 (notify consumer)
self.run_next()
# verify pending consumer request (pending)
request_id = call_reports[1].call_request_id
bind = manager.get_bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
actions = bind['consumer_actions']
self.assertEqual(len(actions), 1)
self.assertEqual(actions[0]['id'], request_id)
self.assertEqual(actions[0]['action'], Bind.Action.BIND)
self.assertEqual(actions[0]['status'], Bind.Status.PENDING)
self.assertTrue(isinstance(actions[0]['timestamp'], float))
# verify agent notified
self.assertTrue(mock_agent.Consumer.bind.called)
# simulated asynchronous task result
report = DispatchReport()
self.coordinator.complete_call_success(request_id, report.dict())
# verify pending consumer request (confirmed)
manager = factory.consumer_bind_manager()
bind = manager.get_bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
self.assertEqual(len(bind['consumer_actions']), 0)
开发者ID:ashcrow,项目名称:pulp,代码行数:60,代码来源:test_bind_itineraries.py
示例3: bind
def bind(consumer_id, repo_id, distributor_id, options):
"""
Request the agent to perform the specified bind. This method will be called
after the server-side representation of the binding has been created.
:param consumer_id: The consumer ID.
:type consumer_id: str
:param repo_id: A repository ID.
:type repo_id: str
:param distributor_id: A distributor ID.
:type distributor_id: str
:param options: The options are handler specific.
:type options: dict
:return: The task created by the bind
:rtype: dict
"""
# track agent operations using a pseudo task
task_id = str(uuid4())
tags = [
resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
action_tag(ACTION_AGENT_BIND)
]
task = TaskStatusManager.create_task_status(task_id, 'agent', tags=tags)
# agent request
consumer_manager = managers.consumer_manager()
binding_manager = managers.consumer_bind_manager()
consumer = consumer_manager.get_consumer(consumer_id)
binding = binding_manager.get_bind(consumer_id, repo_id, distributor_id)
agent_bindings = AgentManager._bindings([binding])
context = Context(
consumer,
task_id=task_id,
action='bind',
consumer_id=consumer_id,
repo_id=repo_id,
distributor_id=distributor_id)
agent = PulpAgent()
agent.consumer.bind(context, agent_bindings, options)
# bind action tracking
consumer_manager = managers.consumer_bind_manager()
consumer_manager.action_pending(
consumer_id,
repo_id,
distributor_id,
Bind.Action.BIND,
task_id)
return task
开发者ID:preethit,项目名称:pulp-1,代码行数:52,代码来源:agent.py
示例4: test_consumer_unregister_cleanup
def test_consumer_unregister_cleanup(self):
# Setup
self.test_bind()
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEquals(len(binds), 1)
# Test
manager = factory.consumer_manager()
manager.unregister(self.CONSUMER_ID)
# Verify
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEquals(len(binds), 0)
开发者ID:ehelms,项目名称:pulp,代码行数:13,代码来源:test_bind_manager.py
示例5: test_remove_distributor_cleanup
def test_remove_distributor_cleanup(self):
# Setup
self.test_bind()
manager = factory.consumer_bind_manager()
binds = manager.find_by_distributor(self.REPO_ID, self.DISTRIBUTOR_ID)
self.assertEquals(len(binds), 1)
# Test
manager = factory.repo_distributor_manager()
manager.remove_distributor(self.REPO_ID, self.DISTRIBUTOR_ID)
# Verify
manager = factory.consumer_bind_manager()
binds = manager.find_by_distributor(self.REPO_ID, self.DISTRIBUTOR_ID)
self.assertEquals(len(binds), 0)
开发者ID:ehelms,项目名称:pulp,代码行数:13,代码来源:test_bind_manager.py
示例6: test_remove_repo_cleanup
def test_remove_repo_cleanup(self):
# Setup
self.test_bind()
manager = factory.consumer_bind_manager()
binds = manager.find_by_repo(self.REPO_ID)
self.assertEquals(len(binds), 1)
# Test
manager = factory.repo_manager()
manager.delete_repo(self.REPO_ID)
# Verify
manager = factory.consumer_bind_manager()
binds = manager.find_by_repo(self.REPO_ID)
self.assertEquals(len(binds), 0)
开发者ID:ehelms,项目名称:pulp,代码行数:13,代码来源:test_bind_manager.py
示例7: test_consumer_unregister_cleanup
def test_consumer_unregister_cleanup(self, *unused):
self.populate()
manager = factory.consumer_bind_manager()
manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID, self.NOTIFY_AGENT, self.BINDING_CONFIG)
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEqual(len(binds), 1)
# Test
manager = factory.consumer_manager()
manager.unregister(self.CONSUMER_ID)
# Verify
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEqual(len(binds), 0)
开发者ID:nbetm,项目名称:pulp,代码行数:14,代码来源:test_bind.py
示例8: test_unbind
def test_unbind(self, mock_repo_qs):
# Setup
self.populate()
manager = factory.consumer_bind_manager()
manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID, self.NOTIFY_AGENT, self.BINDING_CONFIG)
# Test
manager = factory.consumer_bind_manager()
manager.unbind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
# Verify
collection = Bind.get_collection()
bind_id = dict(consumer_id=self.CONSUMER_ID, repo_id=self.REPO_ID, distributor_id=self.DISTRIBUTOR_ID)
bind = collection.find_one(bind_id)
self.assertTrue(bind is not None)
self.assertTrue(bind["deleted"])
开发者ID:nbetm,项目名称:pulp,代码行数:15,代码来源:test_bind.py
示例9: repo_delete_itinerary
def repo_delete_itinerary(repo_id):
"""
Get the itinerary for deleting a repository.
1. Delete the repository on the sever.
2. Unbind any bound consumers.
@param repo_id: A repository ID.
@type repo_id: str
@return: A list of call_requests known as an itinerary.
@rtype list
"""
call_requests = []
# delete repository
manager = managers.repo_manager()
resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag("delete")]
delete_request = CallRequest(manager.delete_repo, [repo_id], resources=resources, tags=tags, archive=True)
call_requests.append(delete_request)
# append unbind itineraries foreach bound consumer
options = {}
manager = managers.consumer_bind_manager()
for bind in manager.find_by_repo(repo_id):
unbind_requests = unbind_itinerary(bind["consumer_id"], bind["repo_id"], bind["distributor_id"], options)
if unbind_requests:
unbind_requests[0].depends_on(delete_request.id)
call_requests.extend(unbind_requests)
return call_requests
开发者ID:slagle,项目名称:pulp,代码行数:35,代码来源:repository.py
示例10: expand_consumers
def expand_consumers(options, consumers):
"""
Expand a list of users based on flags specified in the
post body or query parameters. The _href is always added by the
serialization function used.
Supported options:
details - synonym for: (bindings=True,)
bindings - include bindings
@param options: The (expanding) options.
@type options: dict
@param consumers: A list of consumers
@type consumers: list
@return: A list of expanded consumers.
@rtype: list
"""
if options.get('details', False):
options['bindings'] = True
# add bindings
if options.get('bindings', False):
ids = [c['id'] for c in consumers]
manager = managers.consumer_bind_manager()
criteria = Criteria({'consumer_id': {'$in': ids}})
bindings = manager.find_by_criteria(criteria)
collated = {}
for b in bindings:
lst = collated.setdefault(b['consumer_id'], [])
lst.append(b)
for _consumer in consumers:
_consumer['bindings'] = \
[serialization.binding.serialize(b, False)
for b in collated.get(_consumer['id'], [])]
return consumers
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:32,代码来源:consumers.py
示例11: GET
def GET(self, consumer_id, repo_id=None):
"""
Fetch all bind objects referencing the specified consumer_id. Optionally,
specify a repo_id to fetch all bind objects for the consumer_id to the repo_id
:param consumer_id: The specified consumer.
:type consumer_id: str
:param repo_id: The repository to retrieve bindings for (optional)
:type repo_id: str
:return: A list of dictionaries that represent pulp.server.db.model.consumer.Bind objects
:rtype: list
"""
# Check to make sure the resources exist
missing_resources = {}
if repo_id is not None:
repo = managers.repo_query_manager().find_by_id(repo_id)
if repo is None:
missing_resources['repo_id'] = repo_id
# If get_consumer raises MissingResource we might miss reporting a bad repo_id
try:
managers.consumer_manager().get_consumer(consumer_id)
except MissingResource:
missing_resources['consumer_id'] = consumer_id
if len(missing_resources) > 0:
raise MissingResource(**missing_resources)
manager = managers.consumer_bind_manager()
bindings = manager.find_by_consumer(consumer_id, repo_id)
bindings = [serialization.binding.serialize(b) for b in bindings]
return self.ok(bindings)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:32,代码来源:consumers.py
示例12: test_delete
def test_delete(self):
# Setup
self.populate()
manager = factory.consumer_bind_manager()
bind = manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
# Test
manager.delete(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
开发者ID:domcleal,项目名称:pulp,代码行数:7,代码来源:test_bind_manager.py
示例13: test_consumer_unregister_cleanup
def test_consumer_unregister_cleanup(self):
# Setup
self.populate()
# Test
manager = factory.consumer_bind_manager()
manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEquals(len(binds), 1)
# Test
manager = factory.consumer_manager()
manager.unregister(self.CONSUMER_ID)
# Verify
manager = factory.consumer_bind_manager()
binds = manager.find_by_consumer(self.CONSUMER_ID)
self.assertEquals(len(binds), 0)
开发者ID:domcleal,项目名称:pulp,代码行数:16,代码来源:test_bind_manager.py
示例14: distributor_delete
def distributor_delete(repo_id, distributor_id):
"""
Get the itinerary for deleting a repository distributor.
1. Delete the distributor on the sever.
2. Unbind any bound consumers.
:param repo_id: A repository ID.
:type repo_id: str
:param distributor_id: A distributor id
:type distributor_id: str
:return: Any errors that may have occurred and the list of tasks spawned for each consumer
:rtype TaskResult
"""
# delete distributor
manager = managers.repo_distributor_manager()
manager.remove_distributor(repo_id, distributor_id)
# append unbind itineraries foreach bound consumer
unbind_errors = []
additional_tasks = []
options = {}
manager = managers.consumer_bind_manager()
for bind in manager.find_by_distributor(repo_id, distributor_id):
try:
report = consumer.unbind(bind["consumer_id"], bind["repo_id"], bind["distributor_id"], options)
if report:
additional_tasks.extend(report.spawned_tasks)
except Exception, e:
unbind_errors.append(e)
开发者ID:credativ,项目名称:pulp,代码行数:30,代码来源:repository.py
示例15: test_find_by_criteria
def test_find_by_criteria(self, mock_repo_qs):
self.populate()
manager = factory.consumer_bind_manager()
manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID,
self.NOTIFY_AGENT, self.BINDING_CONFIG)
# Test
criteria = Criteria({'consumer_id': self.CONSUMER_ID})
bindings = manager.find_by_criteria(criteria)
bind = bindings[0]
self.assertEqual(len(bindings), 1)
self.assertEqual(bind['consumer_id'], self.CONSUMER_ID)
self.assertEqual(bind['repo_id'], self.REPO_ID)
self.assertEqual(bind['distributor_id'], self.DISTRIBUTOR_ID)
self.assertEqual(bind['notify_agent'], self.NOTIFY_AGENT)
self.assertEqual(bind['binding_config'], self.BINDING_CONFIG)
# Test ($in)
criteria = Criteria({'consumer_id': {'$in': [self.CONSUMER_ID]}})
bindings = manager.find_by_criteria(criteria)
bind = bindings[0]
self.assertEqual(len(bindings), 1)
self.assertEqual(bind['consumer_id'], self.CONSUMER_ID)
self.assertEqual(bind['repo_id'], self.REPO_ID)
self.assertEqual(bind['distributor_id'], self.DISTRIBUTOR_ID)
self.assertEqual(bind['notify_agent'], self.NOTIFY_AGENT)
self.assertEqual(bind['binding_config'], self.BINDING_CONFIG)
开发者ID:alanoe,项目名称:pulp,代码行数:25,代码来源:test_bind.py
示例16: force_unbind
def force_unbind(consumer_id, repo_id, distributor_id, options):
"""
Get the unbind itinerary.
A forced unbind immediately deletes the binding instead
of marking it deleted and going through that lifecycle.
It is intended to be used to clean up orphaned bindings
caused by failed/unconfirmed unbind actions on the consumer.
The itinerary is:
1. Delete the binding on the server.
2. Request that the consumer (agent) perform the unbind.
:param consumer_id: A consumer ID.
:type consumer_id: str
:param repo_id: A repository ID.
:type repo_id: str
:param distributor_id: A distributor ID.
:type distributor_id: str
:param options: Unbind options passed to the agent handler.
:type options: dict
:returns TaskResult containing the result of the unbind & any spawned tasks or a dictionary
of the unbind result if no tasks were spawned.
:rtype: TaskResult
"""
bind_manager = managers.consumer_bind_manager()
binding = bind_manager.get_bind(consumer_id, repo_id, distributor_id)
bind_manager.delete(consumer_id, repo_id, distributor_id, True)
response = None
if binding['notify_agent']:
agent_manager = managers.consumer_agent_manager()
task = agent_manager.unbind(consumer_id, repo_id, distributor_id, options)
response = TaskResult(spawned_tasks=[task])
return response
开发者ID:preethit,项目名称:pulp-1,代码行数:34,代码来源:consumer.py
示例17: populate
def populate(self, strategy=constants.DEFAULT_STRATEGY, ssl=False):
PluginTestBase.populate(self)
# register child
manager = managers.consumer_manager()
manager.register(self.PULP_ID, notes={constants.STRATEGY_NOTE_KEY: strategy})
manager = managers.repo_importer_manager()
# add importer
importer_conf = {
constants.MANIFEST_URL_KEYWORD: 'http://redhat.com',
constants.STRATEGY_KEYWORD: constants.DEFAULT_STRATEGY,
constants.PROTOCOL_KEYWORD: 'file',
}
manager.set_importer(self.REPO_ID, constants.HTTP_IMPORTER, importer_conf)
# add distributors
if ssl:
dist_conf = self.dist_conf_with_ssl()
else:
dist_conf = self.dist_conf()
manager = managers.repo_distributor_manager()
manager.add_distributor(
self.REPO_ID,
constants.HTTP_DISTRIBUTOR,
dist_conf,
False,
constants.HTTP_DISTRIBUTOR)
manager.add_distributor(self.REPO_ID, FAKE_DISTRIBUTOR, {}, False, FAKE_DISTRIBUTOR)
# bind
conf = {constants.STRATEGY_KEYWORD: strategy}
manager = managers.consumer_bind_manager()
manager.bind(self.PULP_ID, self.REPO_ID, constants.HTTP_DISTRIBUTOR, False, conf)
开发者ID:bartwo,项目名称:pulp,代码行数:30,代码来源:test_plugins.py
示例18: expand_consumers
def expand_consumers(options, consumers):
"""
Expand a list of users based on flags specified in the
post body or query parameters. The _href is always added by the
serialization function used.
Supported options:
details - synonym for: (bindings=True,)
bindings - include bindings
@param options: The (expanding) options.
@type options: dict
@param consumers: A list of consumers
@type consumers: list
@return: A list of expanded consumers.
@rtype: list
"""
if options.get('details', False):
options['bindings'] = True
# add bindings
if options.get('bindings', False):
ids = [c['id'] for c in consumers]
manager = managers.consumer_bind_manager()
bindings = manager.find_by_consumer_list(ids)
for consumer in consumers:
id = consumer['id']
consumer['bindings'] = \
[b['repo_id'] for b in bindings.get(id, [])]
return consumers
开发者ID:ryanschneider,项目名称:pulp,代码行数:27,代码来源:consumers.py
示例19: delete
def delete(repo_id, dist_id):
"""
Removes a distributor from a repository and unbinds any bound consumers.
:param distributor: distributor to be deleted
:type distributor: pulp.server.db.model.Distributor
:return: result containing any errors and tasks spawned
:rtype pulp.server.async.tasks.TaskResult
"""
distributor = model.Distributor.objects.get_or_404(repo_id=repo_id, distributor_id=dist_id)
managers.repo_publish_schedule_manager().delete_by_distributor_id(repo_id, dist_id)
# Call the distributor's cleanup method
dist_instance, plugin_config = plugin_api.get_distributor_by_id(distributor.distributor_type_id)
call_config = PluginCallConfiguration(plugin_config, distributor.config)
repo = model.Repository.objects.get_repo_or_missing_resource(repo_id)
dist_instance.distributor_removed(repo.to_transfer_repo(), call_config)
distributor.delete()
unbind_errors = []
additional_tasks = []
options = {}
bind_manager = managers.consumer_bind_manager()
for bind in bind_manager.find_by_distributor(repo_id, dist_id):
try:
report = bind_manager.unbind(bind['consumer_id'], bind['repo_id'],
bind['distributor_id'], options)
if report:
additional_tasks.extend(report.spawned_tasks)
except Exception, e:
unbind_errors.append(e)
开发者ID:maxamillion,项目名称:pulp,代码行数:35,代码来源:distributor.py
示例20: test_forced_unbind_agent_not_notified
def test_forced_unbind_agent_not_notified(self):
# Setup
self.populate()
manager = factory.consumer_bind_manager()
bind = manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID,
False, self.BINDING_CONFIG)
# Test
options = {}
itinerary = forced_unbind_itinerary(
self.CONSUMER_ID,
self.REPO_ID,
self.DISTRIBUTOR_ID,
options)
call_reports = self.coordinator.execute_multiple_calls(itinerary)
# Verify
self.assertEqual(len(call_reports), 1)
self.assertEqual(call_reports[0].call_request_tags, self.UNBIND_TAGS)
for call in call_reports:
self.assertNotEqual(call.state, dispatch_constants.CALL_REJECTED_RESPONSE)
# run task #1 (actual delete)
self.run_next()
# verify bind deleted
collection = Bind.get_collection()
bind = collection.find_one(self.QUERY)
self.assertTrue(bind is None)
# verify agent notified
self.assertFalse(mock_agent.Consumer.unbind.called)
开发者ID:ashcrow,项目名称:pulp,代码行数:34,代码来源:test_bind_itineraries.py
注:本文中的pulp.server.managers.factory.consumer_bind_manager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论