Example #1
0
def do_show(cs, args):
    """Show specific repository detail infomation."""
    project = args.project_id
    if not project:
        project = cs.client.project
    repo = args.repository
    tag_index = repo.find(':')
    if tag_index != -1:
        tag = repo[tag_index + 1:]
        repo = repo[:tag_index]
    else:
        tag = "latest"
    if repo.find('/') == -1:
        repo = "library/" + repo
    repos = cs.repositories.list(project)
    found_repo = None
    for r in repos:
        if r['name'] == repo:
            found_repo = r
            break
    if not found_repo:
        print("Image '%s' not found." % repo)
        return
    tags = cs.repositories.list_tags(found_repo['name'])
    found_tag = None
    for t in tags:
        if t['name'] == tag:
            found_tag = t
            break
    if not found_tag:
        print("Image '%s' with tag '%s' not found." % (repo, tag))
        return
    for key in found_tag:
        found_repo['tag_' + key] = found_tag[key]
    utils.print_dict(found_repo)
Example #2
0
def do_whoami(cs, args):
    """Get current user info."""
    user = cs.users.current()
    if args.detail:
        utils.print_dict(user)
    else:
        print(user['username'])
Example #3
0
def do_user_show(cs, args):
    """Show details about the given user."""
    key = args.user
    if cs.users.is_id(key):
        id = key
    else:
        id = cs.users.get_id_by_name(key)
    _, user = cs.users.get(id)
    utils.print_dict(user)
Example #4
0
def do_user_show(cs, args):
    """Get a user's profile."""
    key = args.user
    if cs.users.is_id(key):
        id = key
    else:
        id = cs.users.get_id_by_name(key)
    user = cs.users.get(id)
    utils.print_dict(user)
Example #5
0
def do_project_show(cs, args):
    """Show details about the given project."""
    key = args.project
    if cs.projects.is_id(key):
        id = key
    else:
        id = cs.projects.get_id_by_name(key)
    _, project = cs.projects.get(id)
    utils.print_dict(project)
Example #6
0
def do_info(cs, args):
    """Get general system info."""
    info = cs.systeminfo.get()
    try:
        volumes = cs.systeminfo.get_volumes()
        info['disk_total'] = volumes['storage']['total']
        info['disk_free'] = volumes['storage']['free']
    except exp.Forbidden:
        # Only admin can get volumes
        pass
    utils.print_dict(info)
Example #7
0
def do_user_update(cs, args):
    """Update a registered user to change his profile."""
    try:
        user = cs.users.find(args.user)
    except exp.NotFound:
        print("User '%s' not found." % args.user)
    realname = args.realname or user['realname']
    email = args.email or user['email']
    comment = args.comment or user['comment']
    cs.users.update(user['user_id'], realname, email, comment)
    user = cs.users.get(user['user_id'])
    utils.print_dict(user)
Example #8
0
def do_project_show(cs, args):
    """Show specific project detail infomation."""
    key = args.project
    if cs.projects.is_id(key):
        project_id = key
    else:
        project_id = cs.projects.get_id_by_name(key)
    projects = cs.projects.list()
    for project in projects:
        if str(project['project_id']) == str(project_id):
            utils.print_dict(project)
            return
    raise exp.NotFound("Project '%s' not found" % args.project)
Example #9
0
def do_show(cs, args):
    """Show details about the given repository. """
    repo = args.repository
    tag_index = repo.find(':')
    if tag_index != -1:
        tag = repo[tag_index + 1:]
        repo = repo[:tag_index]
    else:
        tag = "latest"
    if repo.find('/') == -1:
        repo = "library/" + repo
    _, data = cs.repositories.get_manifests(repo, tag)
    utils.print_dict(data)
Example #10
0
def do_usage(cs, args):
    """Get projects number and repositories number relevant to the user."""
    data = cs.statistics.list()
    utils.print_dict(data)
Example #11
0
def do_stat(cs, args):
    """Aliased to 'statistics'. """
    _, data = cs.statistics.list()
    utils.print_dict(data)
Example #12
0
def do_statistics(cs, args):
    """Get statistics data. """
    _, data = cs.statistics.list()
    utils.print_dict(data)
Example #13
0
def do_get_repository_manifests(cs, args):
    """Get manifests of a relevant repository. """
    resp, data = cs.repositories.get_manifests(args.repository, args.tag)
    utils.print_dict(data)