Example #1
0
def setup_options(argv):

    u = """[options] <email>
Create/edit a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("dn", "s", "Change the users dn", None)
    all_opts.append(opt)
    opt = cbOpts("access_id", "a", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-secret option", None)
    all_opts.append(opt)
    opt = cbOpts("access_secret", "p", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-id option", None)
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the report", ",")
    all_opts.append(opt)
    opt = cbOpts("group", "g", "Change the users group", None)
    all_opts.append(opt)

    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    o.canonical_id = None
    o.url = None

    return (o, args, parser)
Example #2
0
def setup_options(argv):

    u = """[options] <email pattern>
List a Nimbus user

Use % for a wild card
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts(
        "report", "r", "Report the selected columns from the following: " +
        pycb.tools.report_options_to_string(g_report_options),
        pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts(
        "delim", "D",
        "Character between columns in the batch mode report.  This options is only relevant when used with -b",
        ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #3
0
def setup_options(argv):

    u = """[options] <email>
Create/edit a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("dn", "s", "Change the users dn", None)
    all_opts.append(opt)
    opt = cbOpts("access_id", "a", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-secret option", None)
    all_opts.append(opt)
    opt = cbOpts("access_secret", "p", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-id option", None)
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the report", ",")
    all_opts.append(opt)
    opt = cbOpts("group", "g", "Change the users group", None)
    all_opts.append(opt)

    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    o.canonical_id = None
    o.url = None

    return (o, args, parser)
Example #4
0
def setup_options(argv):

    u = """[options] <email>
Remove a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #5
0
def setup_options(argv):

    u = """[options] <email>
Create a new nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #6
0
def setup_options(argv):

    u = """[options] <admin name> <repo dir>
Create a base repository directory with public write permissions
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    if len(args) < 2:
        pynimbusauthz.parse_args(parser, all_opts, ["--help"])

    return (o, args)
Example #7
0
def setup_options(argv):
    u = """[options] [file]
Import Nimbus users

If file is not specified, standard input will be used"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts('dryrun', 'd', 'Don\'t actually do anything, just print', False, 
            flag=True)
    all_opts.append(opt)

    opt = cbOpts('delim', 'D', 'Character between columns of input data', ',')
    all_opts.append(opt)
    
    #opt = cbOpts('fields', 'f', 'Specify field order in output, from the following: '+
    #        _fields_csv, None)
    #all_opts.append(opt)

    #opt = cbOpts('ignore', 'i', 'Ignore specified user(s)')
    #all_opts.append(opt)

    opt = cbOpts('update', 'u', 'Perform updates of existing users', False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts('remove', 'r', 'Remove users that exist locally but not in input file', 
            False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts('changes_only', 'c', 'Only report changed and unmatched users', 
            False, flag=True)
    all_opts.append(opt)
    
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args, parser)
Example #8
0
def setup_options(argv):

    u = """[action(s)] [options]
Deletes state.  Dangerous program.  Interactive unless using --force.
    """
    
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    
    for opt in all_opts:
        if opt.long == "--batch":
            all_opts.remove(opt)
    # modified list, need another loop..
    for opt in all_opts:
        if opt.long == "--quiet":
            all_opts.remove(opt)
    
    opt = cbOpts("all", "a", "Reset all database state: IaaS, IaaS accounting, IaaS/Cumulus users, Cumulus files", False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts("accounting", "m", "Resets " + ACCOUNTING_HELP, False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts("vmstate", "e", "Resets " + VMSTATE_HELP, False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts("users", "u", "Resets " + USERS_HELP, False, flag=True)
    all_opts.append(opt)
    
    opt = cbOpts("force", "f", "Skips confirmation question", False, flag=True)
    all_opts.append(opt)
    
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)
    return (o, args, parser)
Example #9
0
def setup_options(argv):

    u = """[options] <email>
Remove a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("web_id", "w", "Set the web user name to remove.  If not set and the user is to be removed from webapp, a username will be created from the email address.", None)
    all_opts.append(opt)
    opt = cbOpts("web", "W", "Remove user from webapp", False, flag=True)
    all_opts.append(opt)
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #10
0
def setup_options(argv):

    u = """[options] <display name> <formated integer quota | UNLIMITED> 
Sets a quota for the given cumulus user
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #11
0
def setup_options(argv):

    u = """[options] <display name> <formated integer quota | UNLIMITED> 
Sets a quota for the given cumulus user
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #12
0
def setup_options(argv):

    u = """[options] <email>
Remove a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts(
        "web_id", "w",
        "Set the web user name to remove.  If not set and the user is to be removed from webapp, a username will be created from the email address.",
        None)
    all_opts.append(opt)
    opt = cbOpts("web", "W", "Remove user from webapp", False, flag=True)
    all_opts.append(opt)
    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #13
0
def setup_options(argv):

    u = """[options] <filename> <image name>
Upload an image to the public repository.  The program uses ~/.s3cfg to
get your configuration information.
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("repo", "r", "The bucket where cloud client images are stored", "Repo")
    all_opts.append(opt)
    opt = cbOpts("prefix", "p", "The prefix used for images in the cloud client bucket", "VMS")
    all_opts.append(opt)
    opt = cbOpts("delete", "d", "Remove the image", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) < 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #14
0
def setup_options(argv):

    u = """[options] <email pattern>
List a Nimbus user

Use % for a wild card
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the batch mode report.  This options is only relevant when used with -b", ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #15
0
def setup_options(argv):

    u = """[options] <email pattern>
Create/edit a nimbus user

User % for a wild card
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the report", ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        raise CLIError('ECMDLINE', "You must provide exactly 1 argument: %d" % (len(args)))
        pynimbusauthz.parse_args(parser, [], ["--help"])

    return (o, args, parser)
Example #16
0
def setup_options(argv):

    u = """[options] <display name>
Remove a user from the system.
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("all", "a", "Destroy all associated user data as well (including files that they own)", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #17
0
def setup_options(argv):
    u = """[options] <owner> <filename> <data>
Create a file reference in the sytem"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type", "t", "The type of file to add.", "s3", vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #18
0
def setup_options(argv):

    u = """[options]
Submit a transfer request
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("nonblock", "n", "Do not block waiting for completion", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("reattach", "a", "Reattach", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)
    return (o, args, parser)
Example #19
0
def setup_options(argv):

    u = """[options] [<display name pattern>]
Get a listing of cumulus users.
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts("delim", "d", "The column separater for the report.", ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #20
0
def setup_options(argv):
    u = """[options] [<pattern>]

list files known to the system.  If no pattern is used all files are 
returned."""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type", "t", "list only files of the given type", "s3", vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #21
0
def setup_options(argv):
    u = """[options] [file]
Import Nimbus users

If file is not specified, standard input will be used"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts('dryrun',
                 'd',
                 'Don\'t actually do anything, just print',
                 False,
                 flag=True)
    all_opts.append(opt)

    opt = cbOpts('delim', 'D', 'Character between columns of input data', ',')
    all_opts.append(opt)

    #opt = cbOpts('fields', 'f', 'Specify field order in output, from the following: '+
    #        _fields_csv, None)
    #all_opts.append(opt)

    #opt = cbOpts('ignore', 'i', 'Ignore specified user(s)')
    #all_opts.append(opt)

    opt = cbOpts('update',
                 'u',
                 'Perform updates of existing users',
                 False,
                 flag=True)
    all_opts.append(opt)

    opt = cbOpts('remove',
                 'r',
                 'Remove users that exist locally but not in input file',
                 False,
                 flag=True)
    all_opts.append(opt)

    opt = cbOpts('changes_only',
                 'c',
                 'Only report changed and unmatched users',
                 False,
                 flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args, parser)
Example #22
0
def setup_options(argv):
    u = """[options] <filename>

Get information on a particular file"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("all", "a", "list all users in the acl", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("type", "t", "The type of file to add.", "s3", vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #23
0
def setup_options(argv):
    u = """[options] <canonical username pattern>

List cumulus authz user accounts"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("alias", "a", "list all user alias as well", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("type", "t", "list alias only of the given type", None, vals=pynimbusauthz.alias_types.keys().append(None))
    all_opts.append(opt)
    opt = cbOpts("bya", "s", "lookup user by alias", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #24
0
def setup_options(argv):
    u = """[options] <owner> <filename> <data>
Create a file reference in the sytem"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type",
                 "t",
                 "The type of file to add.",
                 "s3",
                 vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #25
0
def setup_options(argv):
    u = """<old path> <new path>
        This tool allows you to change the physical location of files
        in your repository.  It changes the base path where files are 
        physically located.  The internal name and location is changed
        leaving the external logical name in tact. 

        All instances of <old path> are substituted with <new path>.
        Paths that do not match <old path> are left intact.
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)
    if len(args) != 2:
        raise AuthzException('CLI_PARAMETER', 'You must specify an old path and a new path.  See --help')

    return (o, args)
Example #26
0
def setup_options(argv):

    u = """[options]
Submit a transfer request
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("nonblock",
                 "n",
                 "Do not block waiting for completion",
                 False,
                 flag=True)
    all_opts.append(opt)
    opt = cbOpts("reattach", "a", "Reattach", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)
    return (o, args, parser)
Example #27
0
def setup_options(argv):

    u = """[options] <display name>
Remove a user from the system.
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts(
        "all",
        "a",
        "Destroy all associated user data as well (including files that they own)",
        False,
        flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #28
0
def setup_options(argv):

    u = """[options] [<display name pattern>]
Get a listing of cumulus users.
"""
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts(
        "report", "r", "Report the selected columns from the following: " +
        pycb.tools.report_options_to_string(g_report_options),
        pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts("delim", "d", "The column separater for the report.", ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #29
0
def setup_options(argv):
    u = """<canonical username> <filename> <r | w | R | W>

Change the permissions of any user on a file
r : The user can read the file.
w : The user can write the file.
R : The user can read the ACL.
W : The user can alter the ACL.
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type", "t", "The type of file to add.", "s3", vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #30
0
def setup_options(argv):
    u = """[options] [<pattern>]

list files known to the system.  If no pattern is used all files are 
returned."""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type",
                 "t",
                 "list only files of the given type",
                 "s3",
                 vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #31
0
def setup_options(argv):

    u = """[action(s)] [options]
Deletes state.  Dangerous program.  Interactive unless using --force.
    """

    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    for opt in all_opts:
        if opt.long == "--batch":
            all_opts.remove(opt)
    # modified list, need another loop..
    for opt in all_opts:
        if opt.long == "--quiet":
            all_opts.remove(opt)

    opt = cbOpts(
        "all",
        "a",
        "Reset all database state: IaaS, IaaS accounting, IaaS/Cumulus users, Cumulus files",
        False,
        flag=True)
    all_opts.append(opt)

    opt = cbOpts("accounting",
                 "m",
                 "Resets " + ACCOUNTING_HELP,
                 False,
                 flag=True)
    all_opts.append(opt)

    opt = cbOpts("vmstate", "e", "Resets " + VMSTATE_HELP, False, flag=True)
    all_opts.append(opt)

    opt = cbOpts("users", "u", "Resets " + USERS_HELP, False, flag=True)
    all_opts.append(opt)

    opt = cbOpts("force", "f", "Skips confirmation question", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)
    return (o, args, parser)
Example #32
0
def setup_options(argv):
    u = """[options] <canonical username pattern>

List cumulus authz user accounts"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("alias", "a", "list all user alias as well", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("type",
                 "t",
                 "list alias only of the given type",
                 None,
                 vals=pynimbusauthz.alias_types.keys().append(None))
    all_opts.append(opt)
    opt = cbOpts("bya", "s", "lookup user by alias", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #33
0
def setup_options(argv):
    u = """[options] <filename>

Get information on a particular file"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("all", "a", "list all users in the acl", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("type",
                 "t",
                 "The type of file to add.",
                 "s3",
                 vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #34
0
def setup_options(argv):
    u = """[options] [<canonical username>]

Manage cumulus authz user accounts
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("new", "n", "Add a new top level user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("friendlyname", "F", "Associate the friendly name with the new user or alias", None)
    all_opts.append(opt)
    opt = cbOpts("alias", "a", "Add a user with the given alias, or use this alias name for other operations", None)
    all_opts.append(opt)
    opt = cbOpts("type", "t", "The type of alias to add.  Only relevant when operating on an alias", "s3", vals=pynimbusauthz.alias_types.keys())
    all_opts.append(opt)
    opt = cbOpts("remove", "r", "Remove a user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("genkey", "g", "Generate alias data (a password).  This is only relvant when adding a new alias", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("setkey", "k", "Set alias data (a password).  This is only relvant when adding a new alias", None)
    all_opts.append(opt)
    opt = cbOpts("remove_alias", "x", "Remove the user alias of the given type", None)
    all_opts.append(opt)
    opt = cbOpts("force", "f", "Force the most extreme case, eg: delete all user information including files that are owned by the user.", False, flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    if not o.new and len(args) < 1:
        raise AuthzException('CLI_PARAMETER', "You must provide a uuid for the user")
    if o.remove and len(args) < 1:
        raise AuthzException('CLI_PARAMETER', "You must provide tell me what user to remove")
    if o.alias == None and o.genkey:
        raise AuthzException('CLI_PARAMETER', "You must specify the alias that you are changing")
    if o.alias == None and o.setkey != None:
        raise AuthzException('CLI_PARAMETER', "You must specify the alias that you are changing")

    if o.alias != None and o.friendlyname == None:
        o.friendlyname = o.alias

    return (o, args)
Example #35
0
def setup_options(argv):

    u = """[options] <display name>
Create a new cumulus users
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("password", "p", "Set the secret key associated with this cumulus account.  If not specified one will be generated.", None)
    all_opts.append(opt)
    opt = cbOpts("exist", "e", "Update an existing user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("canonical_id", "c", "Use this canonical user ID.  If not specified a new one will be generated.  If you are not trying to tie the cumulus account with some other Nimbus account, then you probably do not need to specify this option.", None)
    all_opts.append(opt)
    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)
    opt = cbOpts("delim", "d", "The column separater for the report.", ",")
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #36
0
def setup_options(argv):
    u = """<canonical username> <filename> <r | w | R | W>

Change the permissions of any user on a file
r : The user can read the file.
w : The user can write the file.
R : The user can read the ACL.
W : The user can alter the ACL.
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("type",
                 "t",
                 "The type of file to add.",
                 "s3",
                 vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)
    opt = cbOpts("parent", "p", "The parent object of the file.", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    return (o, args)
Example #37
0
def setup_options(argv):
    u = """[options] <canonical username> 

Manage cumulus authz user accounts
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("type", "t", "The file types that will have a quota.", "s3", vals=pynimbusauthz.object_types.keys())
    all_opts.append(opt)

    opt = cbOpts("report", "r", "Display current usage for the user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("quota", "x", "The limit (an integer of UNLIMITED)", None)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    if len(args) != 1:
        print "You must provide a user name"
        sys.exit(1)

    return (o, args)
Example #38
0
def setup_options(argv):

    u = """[options] <email>
Create/edit a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts("dn", "s", "This is used when the user already has a cert.  This option will use the given DN instead of generating a new cert", None)
    all_opts.append(opt)
    opt = cbOpts("canonical_id", "i", "Specify the canonical ID string to user for this new user.  If the ID already exists an error will be returned.", None)
    all_opts.append(opt)
    opt = cbOpts("cert", "c", "Instead of generating a new key pair use this certificate.  This must be used with the --key option", None)
    all_opts.append(opt)
    opt = cbOpts("key", "k", "Instead of generating a new key pair use this key.  This must be used with the --cert option", None)
    all_opts.append(opt)
    opt = cbOpts("cn", "n", "This is used to set the common name when generating a new certificate.  If none is specified the email address is used.  This can be optionally used in conjunction with --key and --cert", None)
    all_opts.append(opt)
    opt = cbOpts("access_id", "a", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-secret option", None)
    all_opts.append(opt)
    opt = cbOpts("access_secret", "p", "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-id option", None)
    all_opts.append(opt)
    opt = cbOpts("dest", "d", "The directory to put all of the new files into.", None)
    all_opts.append(opt)
    opt = cbOpts("group", "g", "Put this user in the given group", "01", vals=("01", "02", "03", "04"))
    all_opts.append(opt)
    opt = cbOpts("web_id", "w", "Set the web user name.  If not set and a web user is desired a username will be created from the email address.", None)
    all_opts.append(opt)
    opt = cbOpts("web", "W", "Insert user into webapp for key(s) pickup", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("nocloud_properties", "P", "Do not make the cloud.properties file", False, flag=False)
    all_opts.append(opt)
    opt = cbOpts("nocert", "C", "Do not add a DN", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the report", ",")
    all_opts.append(opt)
    opt = cbOpts("noaccess", "A", "Do not add access tokens", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("report", "r", "Report the selected columns from the following: " + pycb.tools.report_options_to_string(g_report_options), pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    if o.cert == None and o.key != None or o.cert != None and o.key == None:
        raise CLIError('ECMDLINE', "key and cert must be used together %s %s" % (str(o.cert), str(o.key)))
    if o.access_id == None and o.access_secret != None or o.access_id != None and o.access_secret == None:
        raise CLIError('ECMDLINE', "secret and access-id must be used together")
    if not o.web and o.nocert and o.noaccess:
        raise CLIError('ECMDLINE', "you must want this tool to do something")
    if o.dest == None:
        nh = get_nimbus_home() + "/var/ca/"
        o.dest = tempfile.mkdtemp(suffix='cert', prefix='tmp', dir=nh)
    else:
        try:
            os.mkdir(o.dest)
        except:
            pass

    if o.cert != None:
        if not os.path.isfile(o.cert):
            raise CLIError('ECMDLINE', "No such cert file %s" % (o.cert))
        if not os.path.isfile(o.key):
            raise CLIError('ECMDLINE', "No such cert file %s" % (o.key))
    if o.cert != None and o.nocert:
        raise CLIError('ECMDLINE', "why specify a cert and use nocert?")
    if o.dn != None and o.nocert:
        raise CLIError('ECMDLINE', "why specify a dn and use nocert?")

    o.url = None
    o.cloud_properties = None

    return (o, args, parser)
Example #39
0
def setup_options(argv):

    u = """[options] <email>
Create/edit a nimbus user
    """
    (parser, all_opts) = pynimbusauthz.get_default_options(u)

    opt = cbOpts(
        "dn", "s",
        "This is used when the user already has a cert.  This option will use the given DN instead of generating a new cert",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "canonical_id", "i",
        "Specify the canonical ID string to user for this new user.  If the ID already exists an error will be returned.",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "cert", "c",
        "Instead of generating a new key pair use this certificate.  This must be used with the --key option",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "key", "k",
        "Instead of generating a new key pair use this key.  This must be used with the --cert option",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "cn", "n",
        "This is used to set the common name when generating a new certificate.  If none is specified the email address is used.  This can be optionally used in conjunction with --key and --cert",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "access_id", "a",
        "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-secret option",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "access_secret", "p",
        "Instead of generating a new access id/secret pair, use this one.  This must be used with the --access-id option",
        None)
    all_opts.append(opt)
    opt = cbOpts("dest", "d",
                 "The directory to put all of the new files into.", None)
    all_opts.append(opt)
    opt = cbOpts("group", "g", "Put this user in the given group", "01")
    all_opts.append(opt)
    opt = cbOpts(
        "web_id", "w",
        "Set the web user name.  If not set and a web user is desired a username will be created from the email address.",
        None)
    all_opts.append(opt)
    opt = cbOpts("web",
                 "W",
                 "Insert user into webapp for key(s) pickup",
                 False,
                 flag=True)
    all_opts.append(opt)
    opt = cbOpts("nocloud_properties",
                 "P",
                 "Do not make the cloud.properties file",
                 False,
                 flag=False)
    all_opts.append(opt)
    opt = cbOpts("nocert", "C", "Do not add a DN", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("delim", "D", "Character between columns in the report", ",")
    all_opts.append(opt)
    opt = cbOpts("noaccess", "A", "Do not add access tokens", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts(
        "report", "r", "Report the selected columns from the following: " +
        pycb.tools.report_options_to_string(g_report_options),
        pycb.tools.report_options_to_string(g_report_options))
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    # def verify_opts(o, args, parser):
    if len(args) != 1:
        pynimbusauthz.parse_args(parser, [], ["--help"])

    if o.cert == None and o.key != None or o.cert != None and o.key == None:
        raise CLIError(
            'ECMDLINE', "key and cert must be used together %s %s" %
            (str(o.cert), str(o.key)))
    if o.access_id == None and o.access_secret != None or o.access_id != None and o.access_secret == None:
        raise CLIError('ECMDLINE',
                       "secret and access-id must be used together")
    if not o.web and o.nocert and o.noaccess:
        raise CLIError('ECMDLINE', "you must want this tool to do something")
    if o.dest == None:
        nh = get_nimbus_home() + "/var/ca/"
        o.dest = tempfile.mkdtemp(suffix='cert', prefix='tmp', dir=nh)
    else:
        o.dest = os.path.abspath(o.dest)
        try:
            os.mkdir(o.dest)
        except:
            pass

    if o.cert != None:
        if not os.path.isfile(o.cert):
            raise CLIError('ECMDLINE', "No such cert file %s" % (o.cert))
        if not os.path.isfile(o.key):
            raise CLIError('ECMDLINE', "No such cert file %s" % (o.key))
    if o.cert != None and o.nocert:
        raise CLIError('ECMDLINE', "why specify a cert and use nocert?")
    if o.dn != None and o.nocert:
        raise CLIError('ECMDLINE', "why specify a dn and use nocert?")

    o.url = None
    o.cloud_properties = None

    return (o, args, parser)
Example #40
0
def setup_options(argv):
    u = """[options] [<canonical username>]

Manage cumulus authz user accounts
"""

    (parser, all_opts) = pynimbusauthz.get_default_options(u)
    opt = cbOpts("new", "n", "Add a new top level user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts("friendlyname", "F",
                 "Associate the friendly name with the new user or alias",
                 None)
    all_opts.append(opt)
    opt = cbOpts(
        "alias", "a",
        "Add a user with the given alias, or use this alias name for other operations",
        None)
    all_opts.append(opt)
    opt = cbOpts(
        "type",
        "t",
        "The type of alias to add.  Only relevant when operating on an alias",
        "s3",
        vals=pynimbusauthz.alias_types.keys())
    all_opts.append(opt)
    opt = cbOpts("remove", "r", "Remove a user", False, flag=True)
    all_opts.append(opt)
    opt = cbOpts(
        "genkey",
        "g",
        "Generate alias data (a password).  This is only relvant when adding a new alias",
        False,
        flag=True)
    all_opts.append(opt)
    opt = cbOpts(
        "setkey", "k",
        "Set alias data (a password).  This is only relvant when adding a new alias",
        None)
    all_opts.append(opt)
    opt = cbOpts("remove_alias", "x",
                 "Remove the user alias of the given type", None)
    all_opts.append(opt)
    opt = cbOpts(
        "force",
        "f",
        "Force the most extreme case, eg: delete all user information including files that are owned by the user.",
        False,
        flag=True)
    all_opts.append(opt)

    (o, args) = pynimbusauthz.parse_args(parser, all_opts, argv)

    if not o.new and len(args) < 1:
        raise AuthzException('CLI_PARAMETER',
                             "You must provide a uuid for the user")
    if o.remove and len(args) < 1:
        raise AuthzException('CLI_PARAMETER',
                             "You must provide tell me what user to remove")
    if o.alias == None and o.genkey:
        raise AuthzException(
            'CLI_PARAMETER',
            "You must specify the alias that you are changing")
    if o.alias == None and o.setkey != None:
        raise AuthzException(
            'CLI_PARAMETER',
            "You must specify the alias that you are changing")

    if o.alias != None and o.friendlyname == None:
        o.friendlyname = o.alias

    return (o, args)