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

Python repo_group.RepoGroup类代码示例

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

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



在下文中一共展示了RepoGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: GET

 def GET(self, repo_group_id):
     collection = RepoGroup.get_collection()
     group = collection.find_one({'id': repo_group_id})
     if group is None:
         raise pulp_exceptions.MissingResource(repo_group=repo_group_id)
     group.update(serialization.link.current_link_obj())
     return self.ok(group)
开发者ID:stpierre,项目名称:pulp,代码行数:7,代码来源:repo_groups.py


示例2: find_with_distributor_type

    def find_with_distributor_type(self, distributor_type_id):
        """
        Returns a list of repository groups, including a list of distributor
        instances, for all groups that have a configured distributor of the
        given type. The distributor list will be stored in the group under
        the key "distributors"

        @return: list of group objects from the database with an extra key
                 added holding the distributor instances
        """

        group_coll = RepoGroup.get_collection()
        group_distributor_coll = RepoGroupDistributor.get_collection()

        groups_by_id = {}

        spec = {'distributor_type_id' : distributor_type_id}
        group_distributors = list(group_distributor_coll.find(spec))
        for gd in group_distributors:
            group = groups_by_id.get(gd['repo_group_id'], None)
            if group is None:
                group = group_coll.find_one({'id' : gd['repo_group_id']})
                groups_by_id[gd['repo_group_id']] = group

            dists = group.setdefault('distributors', [])
            dists.append(gd)

        return groups_by_id.values()
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:28,代码来源:query.py


示例3: POST

 def POST(self, repo_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.repo_group_manager()
     manager.unassociate(repo_group_id, criteria)
     collection = RepoGroup.get_collection()
     group = collection.find_one({'id': repo_group_id})
     return self.ok(group['repo_ids'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:7,代码来源:repo_groups.py


示例4: create_repo_group

 def create_repo_group(group_id, display_name=None, description=None, repo_ids=None, notes=None):
     """
     Create a new repo group.
     :param group_id: unique id of the repo group
     :param display_name: display name of the repo group
     :type  display_name: str or None
     :param description: description of the repo group
     :type  description: str or None
     :param repo_ids: list of ids for repos initially belonging to the repo group
     :type  repo_ids: list or None
     :param notes: notes for the repo group
     :type  notes: dict or None
     :return: SON representation of the repo group
     :rtype: bson.SON
     """
     if repo_ids:
         # Check if ids in repo_ids belong to existing repositories
         repo_query_manager = manager_factory.repo_query_manager()
         for repo_id in repo_ids:
             repo_query_manager.get_repository(repo_id)
     # Create repo group
     collection = RepoGroup.get_collection()
     repo_group = RepoGroup(group_id, display_name, description, repo_ids, notes)
     try:
         collection.insert(repo_group, safe=True)
     except DuplicateKeyError:
         raise pulp_exceptions.DuplicateResource(group_id), None, sys.exc_info()[2]
     group = collection.find_one({'id': group_id})
     return group
开发者ID:beav,项目名称:pulp,代码行数:29,代码来源:cud.py


示例5: create_repo_group

    def create_repo_group(group_id, display_name=None, description=None, repo_ids=None, notes=None):
        """
        Create a new repo group.
        :param group_id: unique id of the repo group
        :param display_name: display name of the repo group
        :type  display_name: str or None
        :param description: description of the repo group
        :type  description: str or None
        :param repo_ids: list of ids for repos initially belonging to the repo group
        :type  repo_ids: list or None
        :param notes: notes for the repo group
        :type  notes: dict or None
        :return: SON representation of the repo group
        :rtype: bson.SON
        """
        # Check if ids in repo_ids belong to existing repositories
        existing_repos = model.Repository.objects(repo_id__in=repo_ids)
        if repo_ids and existing_repos.count() != len(repo_ids):
            existing_repo_ids = set([repo.repo_id for repo in existing_repos])
            non_existing_repo_ids = list(set(repo_ids) - existing_repo_ids)
            raise pulp_exceptions.MissingResource(repositories=non_existing_repo_ids)

        # Create repo group
        collection = RepoGroup.get_collection()
        repo_group = RepoGroup(group_id, display_name, description, repo_ids, notes)
        try:
            collection.insert(repo_group, safe=True)
        except DuplicateKeyError:
            raise pulp_exceptions.DuplicateResource(group_id), None, sys.exc_info()[2]
        group = collection.find_one({"id": group_id})
        return group
开发者ID:nbetm,项目名称:pulp,代码行数:31,代码来源:cud.py


示例6: find_all

    def find_all(self):
        """
        Returns all repository groups in the database or an empty list if
        none exist.

        @return: list of database representations of all repository groups
        @rtype:  list
        """
        groups = list(RepoGroup.get_collection().find())
        return groups
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:10,代码来源:query.py


示例7: find_by_criteria

    def find_by_criteria(criteria):
        """
        Return a list of repository groups that match the provided criteria.

        @param criteria:    A Criteria object representing a search you want
                            to perform
        @type  criteria:    pulp.server.db.model.criteria.Criteria

        @return:    list of repo group instances
        @rtype:     list
        """
        return RepoGroup.get_collection().query(criteria)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:12,代码来源:query.py


示例8: POST

 def POST(self, repo_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.repo_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id),
             action_tag('repo_group_unassociate')]
     call_request = CallRequest(manager.unassociate,
                                [repo_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
     execution.execute(call_request)
     collection = RepoGroup.get_collection()
     group = collection.find_one({'id': repo_group_id})
     return self.ok(group['repo_ids'])
开发者ID:stpierre,项目名称:pulp,代码行数:13,代码来源:repo_groups.py


示例9: test_update

    def test_update(self):
        # Setup
        group_id = 'update-me'
        self.manager.create_repo_group(group_id, display_name='Original')

        # Test
        changed = {'display_name' : 'Updated'}
        status, body = self.put('/v2/repo_groups/%s/' % group_id, changed)

        # Verify
        self.assertEqual(200, status)

        found = RepoGroup.get_collection().find_one({'id' : group_id})
        self.assertEqual(changed['display_name'], found['display_name'])
开发者ID:cliffy94,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例10: 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


示例11: test_post

    def test_post(self):
        # Setup
        data = {"id": "post-group", "display_name": "Post Group", "description": "Post Description"}

        # Test
        status, body = self.post("/v2/repo_groups/", data)

        # Verify
        self.assertEqual(201, status)

        found = RepoGroup.get_collection().find_one({"id": data["id"]})
        self.assertTrue(found is not None)
        for k, v in data.items():
            self.assertEqual(found[k], v)
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例12: test_delete

    def test_delete(self):
        # Setup
        group_id = "doomed"
        self.manager.create_repo_group(group_id)

        # Test
        status, body = self.delete("/v2/repo_groups/%s/" % group_id)

        # Verify
        self.assertEqual(200, status)

        found = RepoGroup.get_collection().find_one({"id": group_id})
        self.assertTrue(found is None)
        self.assertEqual(body, None)
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例13: test_update

    def test_update(self):
        # Setup
        group_id = "update-me"
        self.manager.create_repo_group(group_id, display_name="Original")

        # Test
        changed = {"display_name": "Updated"}
        status, body = self.put("/v2/repo_groups/%s/" % group_id, changed)

        # Verify
        self.assertEqual(200, status)

        found = RepoGroup.get_collection().find_one({"id": group_id})
        self.assertEqual(changed["display_name"], found["display_name"])
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例14: test_update_notes

    def test_update_notes(self):
        group_id = "update-me"
        self.manager.create_repo_group(group_id, display_name="Original", notes={"a": "A", "b": "B"})

        # Test
        changed = {"notes": {"b": ""}}
        status, body = self.put("/v2/repo_groups/%s/" % group_id, changed)

        # Verify
        self.assertEqual(200, status)

        found = RepoGroup.get_collection().find_one({"id": group_id})
        self.assertTrue("a" in found["notes"])
        self.assertTrue("b" not in found["notes"])
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_repo_group_controller.py


示例15: test_update_notes

    def test_update_notes(self):
        group_id = 'update-me'
        self.manager.create_repo_group(group_id, display_name='Original',
            notes={'a':'A', 'b':'B'})

        # Test
        changed = {'notes' : {'b':''}}
        status, body = self.put('/v2/repo_groups/%s/' % group_id, changed)

        # Verify
        self.assertEqual(200, status)

        found = RepoGroup.get_collection().find_one({'id' : group_id})
        self.assertTrue('a' in found['notes'])
        self.assertTrue('b' not in found['notes'])
开发者ID:cliffy94,项目名称:pulp,代码行数:15,代码来源:test_repo_group_controller.py


示例16: get

    def get(self, request):
        """
        Return a serialized response containing a list of repo groups.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest

        :return: Response containing a serialized list of dicts, one for each repo group
        :rtype: django.http.HttpResponse
        """

        collection = RepoGroupModel.get_collection()
        cursor = collection.find({})
        groups = [_add_group_link(group) for group in cursor]
        return generate_json_response_with_pulp_encoder(groups)
开发者ID:jeremycline,项目名称:pulp,代码行数:15,代码来源:repo_groups.py


示例17: validate_existing_repo_group

def validate_existing_repo_group(group_id):
    """
    Validate the existence of a repo group, given its id.
    Returns the repo group db collection upon successful validation,
    raises an exception upon failure
    @param group_id: unique id of the repo group to validate
    @type  group_id: str
    @return: repo group db collection
    @rtype:  L{pulp.server.db.connection.PulpCollection}
    @raise:  L{pulp.server.exceptions.MissingResource}
    """
    collection = RepoGroup.get_collection()
    repo_group = collection.find_one({'id': group_id})
    if repo_group is not None:
        return collection
    raise pulp_exceptions.MissingResource(repo_group=group_id)
开发者ID:ashcrow,项目名称:pulp,代码行数:16,代码来源:cud.py


示例18: remove_repo_from_groups

 def remove_repo_from_groups(self, repo_id, group_ids=None):
     """
     Remove a repo from the list of repo groups provided.
     If no repo groups are specified, remove the repo from all repo groups
     its currently in.
     (idempotent: useful when deleting repositories)
     @param repo_id: unique id of the repo to remove from repo groups
     @type  repo_id: str
     @param group_ids: list of repo group ids to remove the repo from
     @type  group_ids: list of None
     """
     spec = {}
     if group_ids is not None:
         spec = {'id': {'$in': group_ids}}
     collection = RepoGroup.get_collection()
     collection.update(spec, {'$pull': {'repo_ids': repo_id}}, multi=True, safe=True)
开发者ID:ashcrow,项目名称:pulp,代码行数:16,代码来源:cud.py


示例19: get_group

    def get_group(self, repo_group_id):
        """
        Returns the repository group with the given ID, raising an exception
        if one does not exist.

        @param repo_group_id: identifies the group
        @type  repo_group_id: str

        @return: database representation of the repo group

        @raise MissingResource: if there is no group with the given ID
        """
        group = RepoGroup.get_collection().find_one({'id' : repo_group_id})
        if group is None:
            raise MissingResource(repo_group=repo_group_id)
        return group
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:16,代码来源:query.py


示例20: 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:cliffy94,项目名称:pulp,代码行数:17,代码来源:test_repo_group_controller.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python repo_group.RepoGroupDistributor类代码示例发布时间:2022-05-25
下一篇:
Python migration_tracker.MigrationTracker类代码示例发布时间: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