本文整理汇总了Python中pulp.server.managers.factory.repo_manager函数的典型用法代码示例。如果您正苦于以下问题:Python repo_manager函数的具体用法?Python repo_manager怎么用?Python repo_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了repo_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resolve_dependencies_by_unit_no_importer
def test_resolve_dependencies_by_unit_no_importer(self):
# Setup
manager_factory.repo_manager().create_repo('empty')
# Test
self.assertRaises(MissingResource, self.manager.resolve_dependencies_by_units, 'empty', [],
{})
示例2: unassociate_all_by_ids
def unassociate_all_by_ids(self, repo_id, unit_type_id, unit_id_list, owner_type, owner_id):
"""
Removes the association between a repo and a number of units. Only the
association made by the given owner will be removed. It is possible the
repo will still have a manually created association will for the unit.
@param repo_id: identifies the repo
@type repo_id: str
@param unit_type_id: identifies the type of units being removed
@type unit_type_id: str
@param unit_id_list: list of unique identifiers for units within the given type
@type unit_id_list: list of str
@param owner_type: category of the caller who created the association;
must be one of the OWNER_* variables in this module
@type owner_type: str
@param owner_id: identifies the caller who created the association, either
the importer ID or user login
@type owner_id: str
"""
spec = {'repo_id' : repo_id,
'unit_type_id' : unit_type_id,
'unit_id' : {'$in' : unit_id_list},
'owner_type' : owner_type,
'owner_id' : owner_id,
}
unit_coll = RepoContentUnit.get_collection()
unit_coll.remove(spec, safe=True)
unique_count = sum(1 for unit_id in unit_id_list
if not self.association_exists(repo_id, unit_id, unit_type_id))
# update the count of associated units on the repo object
if unique_count:
manager_factory.repo_manager().update_unit_count(
repo_id, -unique_count)
try:
repo_query_manager = manager_factory.repo_query_manager()
repo = repo_query_manager.get_repository(repo_id)
content_query_manager = manager_factory.content_query_manager()
content_units = content_query_manager.get_multiple_units_by_ids(unit_type_id, unit_id_list)
importer_manager = manager_factory.repo_importer_manager()
importer = importer_manager.get_importer(repo_id)
importer.remove_units(repo, content_units)
except:
_LOG.exception('Exception informing importer for [%s] of unassociation' % repo_id)
示例3: setUp
def setUp(self):
super(DependencyManagerTests, self).setUp()
mock_plugins.install()
database.update_database([TYPE_1_DEF])
self.repo_id = 'dep-repo'
self.manager = manager_factory.dependency_manager()
manager_factory.repo_manager().create_repo(self.repo_id)
manager_factory.repo_importer_manager().set_importer(self.repo_id, 'mock-importer', {})
示例4: test_post_with_repos
def test_post_with_repos(self):
# Setup
manager_factory.repo_manager().create_repo("add-me")
data = {"id": "with-repos", "repo_ids": ["add-me"]}
# Test
status, body = self.post("/v2/repo_groups/", data)
# Verify
self.assertEqual(201, status)
found = RepoGroup.get_collection().find_one({"id": data["id"]})
self.assertEqual(found["repo_ids"], data["repo_ids"])
示例5: POST
def POST(self):
# Pull the repo data out of the request body (validation will occur
# in the manager)
repo_data = self.params()
id = repo_data.get('id', None)
display_name = repo_data.get('display_name', None)
description = repo_data.get('description', None)
notes = repo_data.get('notes', None)
importer_type_id = repo_data.get('importer_type_id', None)
importer_repo_plugin_config = repo_data.get('importer_config', None)
distributors = repo_data.get('distributors', None)
# Creation
repo_manager = manager_factory.repo_manager()
resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {id: dispatch_constants.RESOURCE_CREATE_OPERATION}}
args = [id, display_name, description, notes, importer_type_id, importer_repo_plugin_config, distributors]
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id),
action_tag('create')]
call_request = CallRequest(repo_manager.create_and_configure_repo,
args,
resources=resources,
weight=weight,
tags=tags)
repo = execution.execute_sync(call_request)
repo.update(serialization.link.child_link_obj(id))
return self.created(id, repo)
示例6: test_syntactic_sugar_methods
def test_syntactic_sugar_methods(self):
"""
Tests the syntactic sugar methods for retrieving specific managers.
"""
# Setup
factory.initialize()
# Test
self.assertTrue(isinstance(factory.authentication_manager(), AuthenticationManager))
self.assertTrue(isinstance(factory.cert_generation_manager(), CertGenerationManager))
self.assertTrue(isinstance(factory.certificate_manager(), CertificateManager))
self.assertTrue(isinstance(factory.password_manager(), PasswordManager))
self.assertTrue(isinstance(factory.permission_manager(), PermissionManager))
self.assertTrue(isinstance(factory.permission_query_manager(), PermissionQueryManager))
self.assertTrue(isinstance(factory.role_manager(), RoleManager))
self.assertTrue(isinstance(factory.role_query_manager(), RoleQueryManager))
self.assertTrue(isinstance(factory.user_manager(), UserManager))
self.assertTrue(isinstance(factory.user_query_manager(), UserQueryManager))
self.assertTrue(isinstance(factory.repo_manager(), RepoManager))
self.assertTrue(isinstance(factory.repo_unit_association_manager(),
RepoUnitAssociationManager))
self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager))
self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager))
self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager))
self.assertTrue(isinstance(factory.content_manager(), ContentManager))
self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager))
self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager))
self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager))
self.assertTrue(isinstance(factory.topic_publish_manager(), TopicPublishManager))
示例7: test_post_with_override_config
def test_post_with_override_config(self, mock_get_worker_for_reservation, mock_uuid,
mock_apply_async):
# Setup
uuid_list = [uuid.uuid4() for i in range(10)]
mock_uuid.uuid4.side_effect = copy.deepcopy(uuid_list)
expected_async_result = AsyncResult(str(uuid_list[0]))
mock_get_worker_for_reservation.return_value = Worker('some_queue', datetime.datetime.now())
upload_id = self.upload_manager.initialize_upload()
self.upload_manager.save_data(upload_id, 0, 'string data')
repo_manager = manager_factory.repo_manager()
repo_manager.create_repo('repo-upload')
importer_manager = manager_factory.repo_importer_manager()
importer_manager.set_importer('repo-upload', 'dummy-importer', {})
# Test
test_override_config = {'key1': 'value1', 'key2': 'value2'}
body = {
'upload_id' : upload_id,
'unit_type_id' : 'dummy-type',
'unit_key' : {'name' : 'foo'},
'unit_metadata' : {'stuff' : 'bar'},
'override_config': test_override_config,
}
status, body = self.post('/v2/repositories/repo-upload/actions/import_upload/', body)
# Verify
self.assertEqual(202, status)
assert_body_matches_async_task(body, expected_async_result)
exepcted_call_args = ['repo-upload', 'dummy-type',
{'name': 'foo'}, {'stuff': 'bar'},
upload_id, test_override_config]
self.assertEqual(exepcted_call_args, mock_apply_async.call_args[0][0])
示例8: remove_units
def remove_units(self, repo, units, config):
"""
Removes content units from the given repository.
This method also removes the tags associated with images in the repository.
This call will not result in the unit being deleted from Pulp itself.
:param repo: metadata describing the repository
:type repo: pulp.plugins.model.Repository
:param units: list of objects describing the units to import in
this call
:type units: list of pulp.plugins.model.AssociatedUnit
:param config: plugin configuration
:type config: pulp.plugins.config.PluginCallConfiguration
"""
repo_manager = manager_factory.repo_manager()
scratchpad = repo_manager.get_repo_scratchpad(repo.id)
tags = scratchpad.get(u'tags', [])
unit_ids = set([unit.unit_key[u'image_id'] for unit in units])
for tag_dict in tags[:]:
if tag_dict[constants.IMAGE_ID_KEY] in unit_ids:
tags.remove(tag_dict)
scratchpad[u'tags'] = tags
repo_manager.set_repo_scratchpad(repo.id, scratchpad)
示例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
示例10: put
def put(self, request, repo_id):
"""
Update a repository. This call will return synchronously unless a distributor is updated.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:param repo_id: id of repository to be updated
:type repo_id: str
:return: Response containing a serialized dict for the updated repo.
:rtype : django.http.HttpResponse
:raises pulp_exceptions.OperationPostponed: if a distributor is updated, dispatch a task
"""
delta = request.body_as_json.get('delta', None)
importer_config = request.body_as_json.get('importer_config', None)
distributor_configs = request.body_as_json.get('distributor_configs', None)
repo_manager = manager_factory.repo_manager()
task_result = repo_manager.update_repo_and_plugins(repo_id, delta, importer_config,
distributor_configs)
repo = task_result.return_value
repo['_href'] = reverse('repo_resource', kwargs={'repo_id': repo_id})
_convert_repo_dates_to_strings(repo)
# Tasks are spawned if a distributor is updated, raise that as a result
if task_result.spawned_tasks:
raise pulp_exceptions.OperationPostponed(task_result)
result = task_result.serialize()
return generate_json_response_with_pulp_encoder(result)
示例11: post
def post(self, request):
"""
Create a new repo. 'id' field in body is required.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:return: Response containing a serialized dict for the created repo.
:rtype : django.http.HttpResponse
"""
# Pull the repo data out of the request body (validation will occur
# in the manager)
repo_data = request.body_as_json
repo_id = repo_data.get('id', None)
display_name = repo_data.get('display_name', None)
description = repo_data.get('description', None)
notes = repo_data.get('notes', None)
importer_type_id = repo_data.get('importer_type_id', None)
importer_repo_plugin_config = repo_data.get('importer_config', None)
distributors = repo_data.get('distributors', None)
# Creation
repo_manager = manager_factory.repo_manager()
args = [repo_id, display_name, description, notes]
kwargs = {'importer_type_id': importer_type_id,
'importer_repo_plugin_config': importer_repo_plugin_config,
'distributor_list': distributors}
repo = repo_manager.create_and_configure_repo(*args, **kwargs)
repo['_href'] = reverse('repo_resource', kwargs={'repo_id': repo_id})
response = generate_json_response_with_pulp_encoder(repo)
return generate_redirect_response(response, repo['_href'])
示例12: POST
def POST(self):
# Pull the repo data out of the request body (validation will occur
# in the manager)
repo_data = self.params()
id = repo_data.get("id", None)
display_name = repo_data.get("display_name", None)
description = repo_data.get("description", None)
notes = repo_data.get("notes", None)
importer_type_id = repo_data.get("importer_type_id", None)
importer_repo_plugin_config = repo_data.get("importer_config", None)
distributors = repo_data.get("distributors", None)
# Creation
repo_manager = manager_factory.repo_manager()
args = [id, display_name, description, notes]
kwargs = {
"importer_type_id": importer_type_id,
"importer_repo_plugin_config": importer_repo_plugin_config,
"distributor_list": distributors,
}
repo = repo_manager.create_and_configure_repo(*args, **kwargs)
repo.update(serialization.link.child_link_obj(id))
return self.created(id, repo)
示例13: test_get_with_bindings
def test_get_with_bindings(self):
"""
Test consumer with bindings.
"""
# Setup
manager = factory.repo_manager()
repo = manager.create_repo(self.REPO_ID)
manager = factory.repo_distributor_manager()
manager.add_distributor(self.REPO_ID, self.DISTRIBUTOR_TYPE_ID, {}, True, distributor_id=self.DISTRIBUTOR_ID)
manager = factory.consumer_manager()
manager.register(self.CONSUMER_ID)
manager = factory.consumer_bind_manager()
bind = manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
# Test
params = {"bindings": True}
path = "/v2/consumers/%s/" % self.CONSUMER_ID
status, body = self.get(path, params=params)
# Verify
self.assertEqual(200, status)
self.assertEqual(self.CONSUMER_ID, body["id"])
self.assertTrue("_href" in body)
self.assertTrue(body["_href"].endswith(path))
self.assertTrue("bindings" in body)
bindings = body["bindings"]
self.assertEquals(len(bindings), 1)
self.assertEquals(bindings[0], self.REPO_ID)
示例14: delete
def delete(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 TaskRequest object with the details of any errors or spawned tasks
:rtype TaskRequest
"""
# delete repository
manager = managers.repo_manager()
manager.delete_repo(repo_id)
# append unbind itineraries foreach bound consumer
options = {}
manager = managers.consumer_bind_manager()
additional_tasks = []
errors = []
for bind in manager.find_by_repo(repo_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:
errors.append(e)
示例15: setUp
def setUp(self):
base.PulpServerTests.setUp(self)
mock_plugins.install()
self.upload_manager = manager_factory.content_upload_manager()
self.repo_manager = manager_factory.repo_manager()
self.importer_manager = manager_factory.repo_importer_manager()