Example #1
0
 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
Example #2
0
    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)
        except DuplicateKeyError:
            raise pulp_exceptions.DuplicateResource(group_id), None, sys.exc_info()[2]
        group = collection.find_one({'id': group_id})
        return group
Example #3
0
 def create_repo_group(self, 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:  L{bson.SON}
     """
     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
Example #4
0
 def test_constructor(self):
     try:
         RepoGroup('contructor_group')
     except:
         self.fail(traceback.format_exc())