本文整理汇总了Python中pulp.server.managers.factory.repo_distributor_manager函数的典型用法代码示例。如果您正苦于以下问题:Python repo_distributor_manager函数的具体用法?Python repo_distributor_manager怎么用?Python repo_distributor_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了repo_distributor_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: POST
def POST(self, consumer_id):
"""
Create a bind association between the specified
consumer by id included in the URL path and a repo-distributor
specified in the POST body: {repo_id:<str>, distributor_id:<str>}.
Designed to be idempotent so only MissingResource is expected to
be raised by manager.
@param consumer_id: The consumer to bind.
@type consumer_id: str
@return: The list of call_reports
@rtype: list
"""
# validate consumer
consumer_manager = managers.consumer_manager()
consumer_manager.get_consumer(consumer_id)
# get other options and validate them
body = self.params()
repo_id = body.get('repo_id')
distributor_id = body.get('distributor_id')
binding_config = body.get('binding_config', None)
options = body.get('options', {})
notify_agent = body.get('notify_agent', True)
managers.repo_query_manager().get_repository(repo_id)
managers.repo_distributor_manager().get_distributor(repo_id, distributor_id)
# bind
call_requests = bind_itinerary(consumer_id, repo_id, distributor_id, notify_agent, binding_config, options)
execution.execute_multiple(call_requests)
开发者ID:graco,项目名称:pulp,代码行数:30,代码来源:consumers.py
示例2: _validate_consumer_repo
def _validate_consumer_repo(consumer_id, repo_id, distributor_id):
"""
Validate that the given consumer, repository, and distributor are present.
Rather than raising an exception, this method returns a dictionary of missing
values and allows the caller to decide what exception to raise.
:param consumer_id: The consumer id to validate
:type consumer_id: str
:param repo_id: The repository id to validate
:type repo_id: str
:param distributor_id: The distributor_id to validate
:type distributor_id: str
:return: A dictionary containing the missing values, or an empty dict if everything is valid
:rtype: dict
"""
missing_values = {}
try:
factory.consumer_manager().get_consumer(consumer_id)
except MissingResource:
missing_values['consumer_id'] = consumer_id
try:
model.Repository.objects.get_repo_or_missing_resource(repo_id)
except MissingResource:
missing_values['repo_id'] = repo_id
try:
factory.repo_distributor_manager().get_distributor(repo_id, distributor_id)
except MissingResource:
missing_values['distributor_id'] = distributor_id
return missing_values
开发者ID:nbetm,项目名称:pulp,代码行数:32,代码来源:bind.py
示例3: verify_group_resources
def verify_group_resources(group_id, repo_id, distributor_id):
"""
Confirm the group, repository, and distributor exist.
:param group_id: The consumer group id to verify the existence of
:type group_id: str
:param repo_id: The repository id to confirm the existence of
:type repo_id: str
:param distributor_id: The distributor id to confirm the existence of on the repository
:type distributor_id: str
:return: A dictionary of the missing resources
:rtype: dict
"""
missing_resources = {}
group_manager = factory.consumer_group_query_manager()
repo_manager = factory.repo_query_manager()
distributor_manager = factory.repo_distributor_manager()
try:
group_manager.get_group(group_id)
except pulp_exceptions.MissingResource:
missing_resources['group_id'] = group_id
repo = repo_manager.find_by_id(repo_id)
if repo is None:
missing_resources['repo_id'] = repo_id
try:
distributor_manager.get_distributor(repo_id, distributor_id)
except pulp_exceptions.MissingResource:
missing_resources['distributor_id'] = distributor_id
return missing_resources
开发者ID:credativ,项目名称:pulp,代码行数:29,代码来源:consumer_groups.py
示例4: _process_repos
def _process_repos(repos, importers=False, distributors=False):
"""
Apply standard processing to a collection of repositories being returned to a client. Adds
the object link and optionally adds related importers and distributors.
:param repos: collection of repositories
:type repos: list, tuple
:param importers: if True, adds related importers under the attribute "importers".
:type importers: bool
:param distributors: if True, adds related distributors under the attribute "distributors"
:type distributors: bool
:return: the same list that was passed in, just for convenience. The list itself is not
modified- only its members are modified in-place.
:rtype: list of Repo instances
"""
if importers:
_merge_related_objects(
'importers', manager_factory.repo_importer_manager(), repos)
if distributors:
_merge_related_objects(
'distributors', manager_factory.repo_distributor_manager(), repos)
for repo in repos:
repo['_href'] = reverse('repo_resource', kwargs={'repo_id': repo['id']})
_convert_repo_dates_to_strings(repo)
# Remove internally used scratchpad from repo details
if 'scratchpad' in repo:
del repo['scratchpad']
return repos
开发者ID:hgschmie,项目名称:pulp,代码行数:33,代码来源:repositories.py
示例5: _bindings
def _bindings(bindings):
"""
Build the bindings needed by the agent. The returned bindings will be
the payload created by the appropriate distributor.
:param bindings: a list of binding object retrieved from the database
:type bindings: list
:return: list of binding objects to send to the agent
:rtype: list
"""
agent_bindings = []
for binding in bindings:
repo_id = binding['repo_id']
manager = managers.repo_distributor_manager()
distributor = manager.get_distributor(
binding['repo_id'],
binding['distributor_id'])
details = manager.create_bind_payload(
binding['repo_id'],
binding['distributor_id'],
binding['binding_config'])
type_id = distributor['distributor_type_id']
agent_binding = dict(type_id=type_id, repo_id=repo_id, details=details)
agent_bindings.append(agent_binding)
return agent_bindings
开发者ID:preethit,项目名称:pulp-1,代码行数:25,代码来源:agent.py
示例6: 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
示例7: test_delete_with_plugin_error
def test_delete_with_plugin_error(self):
"""
Tests deleting a repo where one (or more) of the plugins raises an error.
"""
# Setup
self.manager.create_repo('doomed')
importer_manager = manager_factory.repo_importer_manager()
distributor_manager = manager_factory.repo_distributor_manager()
importer_manager.set_importer('doomed', 'mock-importer', {})
distributor_manager.add_distributor('doomed', 'mock-distributor', {}, True,
distributor_id='dist-1')
# Setup both mocks to raise errors on removal
mock_plugins.MOCK_IMPORTER.importer_removed.side_effect = Exception('Splat')
mock_plugins.MOCK_DISTRIBUTOR.distributor_removed.side_effect = Exception('Pow')
# Test
try:
self.manager.delete_repo('doomed')
self.fail('No exception raised during repo delete')
except exceptions.PulpExecutionException:
pass
# Cleanup - need to manually clear the side effects
mock_plugins.MOCK_IMPORTER.importer_removed.side_effect = None
mock_plugins.MOCK_DISTRIBUTOR.distributor_removed.side_effect = None
开发者ID:beav,项目名称:pulp,代码行数:29,代码来源:test_cud.py
示例8: POST
def POST(self, repo_id):
# Params (validation will occur in the manager)
params = self.params()
distributor_type = params.get('distributor_type_id', None)
distributor_config = params.get('distributor_config', None)
distributor_id = params.get('distributor_id', None)
auto_publish = params.get('auto_publish', False)
# Update the repo
distributor_manager = manager_factory.repo_distributor_manager()
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
action_tag('add_distributor')]
if distributor_id is not None:
tags.append(resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id))
call_request = CallRequest(distributor_manager.add_distributor,
[repo_id, distributor_type],
{'repo_plugin_config': distributor_config, 'auto_publish': auto_publish,
'distributor_id': distributor_id},
weight=weight,
tags=tags,
kwarg_blacklist=['repo_plugin_config'])
call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
if distributor_id is not None:
call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
return execution.execute_created(self, call_request, distributor_id)
开发者ID:hennessy80,项目名称:pulp,代码行数:28,代码来源:repositories.py
示例9: __bindings
def __bindings(self, bindings):
"""
Build the bindings needed by the agent.
@param bindings: A list of binding IDs.
Each binding is:
{consumer_id:<str>, repo_id:<str>, distributor_id:<str>}
@type bindings: list
@return A list of agent bindings.
Each binding is: {type_id:<str>, repo_id:<str>, details:<dict>}
@rtype: list
"""
agent_bindings = []
for binding in bindings:
repo_id = binding['repo_id']
manager = managers.repo_distributor_manager()
distributor = manager.get_distributor(
binding['repo_id'],
binding['distributor_id'])
details = manager.create_bind_payload(
binding['repo_id'],
binding['distributor_id'])
type_id = distributor['distributor_type_id']
agent_binding = dict(type_id=type_id, repo_id=repo_id, details=details)
agent_bindings.append(agent_binding)
return agent_bindings
开发者ID:domcleal,项目名称:pulp,代码行数:25,代码来源:agent.py
示例10: POST
def POST(self, repo_id):
# Params (validation will occur in the manager)
params = self.params()
distributor_type = params.get('distributor_type_id', None)
distributor_config = params.get('distributor_config', None)
distributor_id = params.get('distributor_id', None)
auto_publish = params.get('auto_publish', False)
# Update the repo
distributor_manager = manager_factory.repo_distributor_manager()
resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}}
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
action_tag('add_distributor')]
if distributor_id is not None:
resources.update({dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {distributor_id: dispatch_constants.RESOURCE_CREATE_OPERATION}})
tags.append(resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id))
call_request = CallRequest(distributor_manager.add_distributor,
[repo_id, distributor_type, distributor_config, auto_publish, distributor_id],
resources=resources,
weight=weight,
tags=tags)
return execution.execute_created(self, call_request, distributor_id)
开发者ID:ryanschneider,项目名称:pulp,代码行数:25,代码来源:repositories.py
示例11: create_publish_schedule
def create_publish_schedule(self, repo_id, distributor_id, publish_options, schedule_data):
"""
Create a new scheduled publish for the given repository and distributor.
@param repo_id:
@param distributor_id:
@param publish_options:
@param schedule_data:
@return:
"""
# validate the input
self._validate_distributor(repo_id, distributor_id)
self._validate_keys(publish_options, _PUBLISH_OPTION_KEYS)
if 'schedule' not in schedule_data:
raise pulp_exceptions.MissingValue(['schedule'])
# build the publish call
publish_manager = managers_factory.repo_publish_manager()
args = [repo_id, distributor_id]
kwargs = {'publish_config_override': publish_options['override_config']}
weight = pulp_config.config.getint('tasks', 'publish_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)]
call_request = CallRequest(publish_manager.publish, args, kwargs, weight=weight, tags=tags, archive=True)
call_request.reads_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, publish_manager.prep_publish)
# schedule the publish
scheduler = dispatch_factory.scheduler()
schedule_id = scheduler.add(call_request, **schedule_data)
distributor_manager = managers_factory.repo_distributor_manager()
distributor_manager.add_publish_schedule(repo_id, distributor_id, schedule_id)
return schedule_id
开发者ID:ehelms,项目名称:pulp,代码行数:34,代码来源:cud.py
示例12: verify
def verify(self, num_units=PluginTestBase.NUM_UNITS):
# repository
manager = managers.repo_query_manager()
manager.get_repository(self.REPO_ID)
# importer
manager = managers.repo_importer_manager()
importer = manager.get_importer(self.REPO_ID)
manifest_url = importer['config'][constants.MANIFEST_URL_KEYWORD]
self.assertTrue(manifest_url.endswith('%s/manifest.json.gz' % self.REPO_ID))
# distributor
manager = managers.repo_distributor_manager()
manager.get_distributor(self.REPO_ID, FAKE_DISTRIBUTOR)
self.assertRaises(MissingResource, manager.get_distributor, self.REPO_ID, constants.HTTP_DISTRIBUTOR)
# check units
manager = managers.repo_unit_association_query_manager()
units = manager.get_units(self.REPO_ID)
units = dict([(u['metadata']['N'], u) for u in units])
self.assertEqual(len(units), num_units)
for n in range(0, num_units):
unit = units[n]
unit_id = self.UNIT_ID % n
metadata = unit['metadata']
storage_path = metadata['_storage_path'].replace('//', '/')
self.assertEqual(unit['unit_type_id'], self.UNIT_TYPE_ID)
self.assertEqual(unit['repo_id'], self.REPO_ID)
self.assertEqual(unit['owner_id'], constants.HTTP_IMPORTER)
file_path = '.'.join((unit_id, self.UNIT_TYPE_ID))
self.assertEqual(storage_path, os.path.join(self.childfs, 'content', file_path))
self.assertTrue(os.path.exists(storage_path))
fp = open(storage_path)
content = fp.read()
fp.close()
self.assertEqual(content, unit_id)
开发者ID:bartwo,项目名称:pulp,代码行数:33,代码来源:test_plugins.py
示例13: GET
def GET(self, id):
"""
Looks for query parameters 'importers' and 'distributors', and will add
the corresponding fields to the repository returned. Query parameter
'details' is equivalent to passing both 'importers' and 'distributors'.
"""
query_params = web.input()
query_manager = manager_factory.repo_query_manager()
repo = query_manager.find_by_id(id)
if repo is None:
raise exceptions.MissingResource(id)
repo.update(serialization.link.current_link_obj())
if query_params.get('details', False):
query_params['importers'] = True
query_params['distributors'] = True
if query_params.get('importers', False):
repo = _merge_related_objects('importers', manager_factory.repo_importer_manager(), (repo,))[0]
if query_params.get('distributors', False):
repo = _merge_related_objects('distributors', manager_factory.repo_distributor_manager(), (repo,))[0]
return self.ok(repo)
开发者ID:ryanschneider,项目名称:pulp,代码行数:25,代码来源:repositories.py
示例14: 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
示例15: DELETE
def DELETE(self, repo_id, distributor_id):
# validate resources
manager = manager_factory.repo_distributor_manager()
manager.get_distributor(repo_id, distributor_id)
# delete
call_requests = distributor_delete_itinerary(repo_id, distributor_id)
execution.execute_multiple(call_requests)
开发者ID:domcleal,项目名称:pulp,代码行数:7,代码来源:repositories.py
示例16: PUT
def PUT(self, repo_id, distributor_id):
"""
Used to update a repo distributor instance. This requires update permissions.
The expected parameters are 'distributor_config', which is a dictionary containing configuration
values accepted by the distributor type, and 'delta', which is a dictionary containing other
configuration values for the distributor (like the auto_publish flag, for example). Currently,
the only supported key in the delta is 'auto_publish', which should have a boolean value.
:param repo_id: The repository ID
:type repo_id: str
:param distributor_id: The unique distributor ID of the distributor instance to update.
:type distributor_id: str
"""
params = self.params()
delta = params.get('delta', None)
# validate
manager = manager_factory.repo_distributor_manager()
manager.get_distributor(repo_id, distributor_id)
config = params.get('distributor_config')
if config is None:
_LOG.error(
'Missing configuration when updating distributor [%s] on repository [%s]',
distributor_id,
repo_id)
raise exceptions.MissingValue(['distributor_config'])
# update
call_requests = distributor_update_itinerary(repo_id, distributor_id, config, delta)
execution.execute_multiple(call_requests)
开发者ID:hennessy80,项目名称:pulp,代码行数:28,代码来源:repositories.py
示例17: 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
示例18: setUp
def setUp(self):
super(RepoConfigConduitTests, self).setUp()
mock_plugins.install()
manager_factory.initialize()
self.repo_manager = manager_factory.repo_manager()
self.distributor_manager = manager_factory.repo_distributor_manager()
# Populate the database with a repo with units
self.repo_manager.create_repo('repo-1')
self.distributor_manager.add_distributor('repo-1', 'mock-distributor', {"relative_url": "/a/bc/d"},
True, distributor_id='dist-1')
self.distributor_manager.add_distributor('repo-1', 'mock-distributor', {"relative_url": "/a/c"},
True, distributor_id='dist-2')
self.repo_manager.create_repo('repo-2')
self.distributor_manager.add_distributor('repo-2', 'mock-distributor', {"relative_url": "/a/bc/e"},
True, distributor_id='dist-3')
self.repo_manager.create_repo('repo-3')
self.distributor_manager.add_distributor('repo-3', 'mock-distributor', {},
True, distributor_id='dist-4')
self.repo_manager.create_repo('repo-4')
self.distributor_manager.add_distributor('repo-4', 'mock-distributor', {"relative_url": "/repo-5"},
True, distributor_id='dist-5')
self.conduit = RepoConfigConduit('rpm')
开发者ID:fdammeke,项目名称:pulp,代码行数:25,代码来源:test_repo_config_conduit.py
示例19: populate
def populate(self):
config = {"key1": "value1", "key2": None}
manager = factory.repo_distributor_manager()
manager.add_distributor(self.REPO_ID, "mock-distributor", config, True, distributor_id=self.DISTRIBUTOR_ID)
manager = factory.consumer_manager()
for consumer_id in self.ALL_CONSUMERS:
manager.register(consumer_id)
开发者ID:nbetm,项目名称:pulp,代码行数:7,代码来源:test_bind.py
示例20: 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
注:本文中的pulp.server.managers.factory.repo_distributor_manager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论