示例#1
0
class RepositoriesModel(object):
    def __init__(self, **kargs):
        try:
            self.host_repositories = Repositories()
        except:
            self.host_repositories = None

    def get_list(self):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        return self.host_repositories.getRepositories().keys()

    def create(self, params):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        repo_id = params.get('repo_id', None)

        # Create a repo_id if not given by user. The repo_id will follow
        # the format kimchi_repo_<integer>, where integer is the number of
        # seconds since the Epoch (January 1st, 1970), in UTC.
        if repo_id is None:
            repo_id = "kimchi_repo_%s" % int(time.time())
            while repo_id in self.get_list():
                repo_id = "kimchi_repo_%s" % int(time.time())
            params.update({'repo_id': repo_id})

        if repo_id in self.get_list():
            raise InvalidOperation("KCHREPOS0006E", {'repo_id': repo_id})
        self.host_repositories.addRepository(params)
        return repo_id
示例#2
0
文件: host.py 项目: hlwanghl/kimchi
class RepositoriesModel(object):
    def __init__(self, **kargs):
        self.host_repositories = Repositories()

    def get_list(self):
        return self.host_repositories.getRepositories().keys()

    def create(self, params):
        repo_id = params.get('repo_id', None)

        # Create a repo_id if not given by user. The repo_id will follow
        # the format kimchi_repo_<integer>, where integer is the number of
        # seconds since the Epoch (January 1st, 1970), in UTC.
        if repo_id is None:
            repo_id = "kimchi_repo_%s" % int(time.time())
            while repo_id in self.get_list():
                repo_id = "kimchi_repo_%s" % int(time.time())
            params.update({'repo_id': repo_id})

        if repo_id in self.get_list():
            raise InvalidOperation("KCHREPOS0006E", {'repo_id': repo_id})
        self.host_repositories.addRepository(params)
        return repo_id
示例#3
0
class RepositoriesModel(object):
    def __init__(self, **kargs):
        try:
            self.host_repositories = Repositories()
        except:
            self.host_repositories = None

    def get_list(self):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        return sorted(self.host_repositories.getRepositories())

    def create(self, params):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        return self.host_repositories.addRepository(params)
示例#4
0
class RepositoriesModel(object):
    def __init__(self, **kargs):
        try:
            self.host_repositories = Repositories()
        except:
            self.host_repositories = None

    def get_list(self):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        return sorted(self.host_repositories.getRepositories())

    def create(self, params):
        if self.host_repositories is None:
            raise InvalidOperation('KCHREPOS0014E')

        return self.host_repositories.addRepository(params)