def ls(args):
    """
    Print a table of all volumes and their datastores when called with no args.
    If args.l is True then show all metadata in a table.
    If args.c is not empty only display columns given in args.c (implies -l).
    """
    if args.c:
        (header, rows) = ls_dash_c(args.c)
    else:
        header = all_ls_headers()
        rows = generate_ls_rows()

    print cli_table.create(header, rows)
def ls(args):
    """
    Print a table of all volumes and their datastores when called with no args.
    If args.l is True then show all metadata in a table.
    If args.c is not empty only display columns given in args.c (implies -l).
    """
    if args.c:
        (header, rows) = ls_dash_c(args.c)
    else:
        header = all_ls_headers()
        rows = generate_ls_rows()

    print cli_table.create(header, rows)
def tenant_ls(args):
    """ Handle tenant ls command """
    error_info, tenant_list = auth_api._tenant_ls()
    if error_info:
        return operation_fail(error_info.msg)

    header = tenant_ls_headers()
    rows = generate_tenant_ls_rows(tenant_list)
    print(cli_table.create(header, rows))
Exemplo n.º 4
0
def tenant_ls(args):
    """ Handle tenant ls command """
    error_info, tenant_list = get_tenant_list_from_db()
    if error_info:
        return operation_fail(error_info)

    header = tenant_ls_headers()
    rows = generate_tenant_ls_rows(tenant_list)
    print(cli_table.create(header, rows)) 
def tenant_vm_ls(args):
    """ Handle tenant vm ls command """
    error_info, vms = auth_api._tenant_vm_ls(args.name)
    if error_info:
        return operation_fail(error_info.msg)

    header = tenant_vm_ls_headers()
    rows = generate_tenant_vm_ls_rows(vms)
    print(cli_table.create(header, rows))
def tenant_access_ls(args):
    """ Handle tenant access ls command """
    name = args.name
    error_info, privileges = auth_api._tenant_access_ls(name)
    if error_info:
        return operation_fail(error_info.msg)

    header = tenant_access_ls_headers()
    rows = generate_tenant_access_ls_rows(privileges)
    print(cli_table.create(header, rows))
Exemplo n.º 7
0
def tenant_access_ls(args):
    """ Handle tenant access ls command """
    error_info, tenant = get_tenant_from_db(args.name)
    if error_info:
        return operation_fail(error_info)

    privileges = tenant.privileges

    header = tenant_access_ls_headers()
    rows = generate_tenant_access_ls_rows(privileges)
    print(cli_table.create(header, rows))
Exemplo n.º 8
0
def tenant_access_ls(args):
    """ Handle tenant access ls command """
    error_info, tenant = get_tenant_from_db(args.name)
    if error_info:
        return operation_fail(error_info)

    privileges = tenant.privileges 
    
    header = tenant_access_ls_headers()
    rows = generate_tenant_access_ls_rows(privileges)
    print(cli_table.create(header, rows))
def policy_ls(args):
    volumes = vsan_policy.list_volumes_and_policies()
    policies = vsan_policy.get_policies()
    header = ['Policy Name', 'Policy Content', 'Active']
    rows = []
    used_policies = {}
    for v in volumes:
        policy_name = v['policy']
        if policy_name in used_policies:
            used_policies[policy_name] = used_policies[policy_name] + 1
        else:
            used_policies[policy_name] = 1

    for name, content in policies.iteritems():
        if name in used_policies:
            active = 'In use by {0} volumes'.format(used_policies[name])
        else:
            active = 'Unused'
        rows.append([name, content.strip(), active])

    print cli_table.create(header, rows)
def policy_ls(args):
    volumes = vsan_policy.list_volumes_and_policies()
    policies = vsan_policy.get_policies()
    header = ['Policy Name', 'Policy Content', 'Active']
    rows = []
    used_policies = {}
    for v in volumes:
        policy_name = v['policy']
        if policy_name in used_policies:
            used_policies[policy_name] = used_policies[policy_name] + 1
        else:
            used_policies[policy_name] = 1

    for name, content in policies.iteritems():
        if name in used_policies:
            active = 'In use by {0} volumes'.format(used_policies[name])
        else:
            active = 'Unused'
        rows.append([name, content.strip(), active])

    print cli_table.create(header, rows)
Exemplo n.º 11
0
def tenant_vm_ls(args):
    """ Handle tenant vm ls command """
    error_info, tenant = get_tenant_from_db(args.name)
    if error_info:
        return operation_fail(error_info)

    if not tenant:
        error_info = "Tenant {0} does not exist".format(args.name)
        return operation_fail(error_info)

    header = tenant_vm_ls_headers()
    rows = generate_tenant_vm_ls_rows(tenant.vms)
    print(cli_table.create(header, rows))
Exemplo n.º 12
0
def tenant_vm_ls(args):
    """ Handle tenant vm ls command """
    error_info, tenant = get_tenant_from_db(args.name)
    if error_info:
        return operation_fail(error_info)
    
    if not tenant:
        error_info = "Tenant {0} does not exist".format(args.name)
        return operation_fail(error_info)
   
    header = tenant_vm_ls_headers()
    rows = generate_tenant_vm_ls_rows(tenant.vms)
    print(cli_table.create(header, rows))
def tenant_vm_ls(args):
    """ Handle tenant vm ls command """

    # Handling _DEFAULT tenant case separately to print info message
    # instead of printing empty list
    if (args.name == auth_data_const.DEFAULT_TENANT):
        print("{0} tenant contains all VMs which were not added to other tenants".format(auth_data_const.DEFAULT_TENANT))
        return

    error_info, vms = auth_api._tenant_vm_ls(args.name)
    if error_info:
        return operation_fail(error_info.msg)

    header = tenant_vm_ls_headers()
    rows = generate_tenant_vm_ls_rows(vms)
    print(cli_table.create(header, rows))