• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python factory.repo_manager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp.server.managers.factory.repo_manager函数的典型用法代码示例。如果您正苦于以下问题:Python repo_manager函数的具体用法?Python repo_manager怎么用?Python repo_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了repo_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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', [],
                          {})
开发者ID:credativ,项目名称:pulp,代码行数:7,代码来源:test_dependency.py


示例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)
开发者ID:stpierre,项目名称:pulp,代码行数:54,代码来源:unit_association.py


示例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', {})
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:12,代码来源:test_dependency_manager.py


示例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"])
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例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)
开发者ID:ryanschneider,项目名称:pulp,代码行数:31,代码来源:repositories.py


示例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))
开发者ID:credativ,项目名称:pulp,代码行数:29,代码来源:test_factory.py


示例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])
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:33,代码来源:test_contents_controller.py


示例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)
开发者ID:beav,项目名称:pulp_docker,代码行数:28,代码来源:importer.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: 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)
开发者ID:hgschmie,项目名称:pulp,代码行数:30,代码来源:repositories.py


示例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'])
开发者ID:hgschmie,项目名称:pulp,代码行数:33,代码来源:repositories.py


示例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)
开发者ID:preethit,项目名称:pulp-1,代码行数:26,代码来源:repositories.py


示例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)
开发者ID:ryanschneider,项目名称:pulp,代码行数:26,代码来源:test_consumer_controller.py


示例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)
开发者ID:credativ,项目名称:pulp,代码行数:27,代码来源:repository.py


示例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()
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:7,代码来源:test_server_managers_content_upload.py


示例16: 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]['repo_id'], self.REPO_ID)
     self.assertEquals(bindings[0]['distributor_id'], self.DISTRIBUTOR_ID)
     self.assertEquals(bindings[0]['consumer_actions'], [])
开发者ID:pkilambi,项目名称:pulp,代码行数:33,代码来源:test_consumer_controller.py


示例17: test_post

    def test_post(self, _reserve_resource, mock_apply_async):
        # Setup
        task_id = str(uuid.uuid4())
        mock_apply_async.return_value = AsyncResult(task_id)
        _reserve_resource.return_value = ReservedResourceApplyAsync()
        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
        body = {
            'upload_id' : upload_id,
            'unit_type_id' : 'dummy-type',
            'unit_key' : {'name' : 'foo'},
            'unit_metadata' : {'stuff' : 'bar'},
        }
        status, body = self.post('/v2/repositories/repo-upload/actions/import_upload/', body)

        # Verify
        self.assertEqual(202, status)
        assert_body_matches_async_task(body, mock_apply_async.return_value)
        exepcted_call_args = ['repo-upload', 'dummy-type',
                              {'name': 'foo'}, {'stuff': 'bar'}, 
                              upload_id]
        self.assertEqual(exepcted_call_args, mock_apply_async.call_args[0][0])
开发者ID:aweiteka,项目名称:pulp,代码行数:29,代码来源:test_contents_controller.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: DELETE

    def DELETE(self, id):
        repo_manager = manager_factory.repo_manager()
        resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id), action_tag("delete")]

        call_request = CallRequest(repo_manager.delete_repo, [id], resources=resources, tags=tags, archive=True)
        return execution.execute_ok(self, call_request)
开发者ID:ehelms,项目名称:pulp,代码行数:7,代码来源:repositories.py


示例20: populate

 def populate(self):
     config = {"key1": "value1", "key2": None}
     manager = factory.repo_manager()
     repo = manager.create_repo(self.REPO_ID)
     manager = factory.repo_distributor_manager()
     manager.add_distributor(self.REPO_ID, "mock-distributor", config, True, distributor_id=self.DISTRIBUTOR_ID)
     manager = factory.consumer_manager()
     manager.register(self.CONSUMER_ID)
开发者ID:pkilambi,项目名称:pulp,代码行数:8,代码来源:test_agent_manager.py



注:本文中的pulp.server.managers.factory.repo_manager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.repo_query_manager函数代码示例发布时间:2022-05-25
下一篇:
Python factory.repo_importer_manager函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap