Esempio n. 1
0
def validate_args(args):
    if args.version is True:  # --version with no second argument
        print_version_info()
        exit_success()

    if args.version and args.command not in ["install", "packages"]:
        user_error("Cannot specify version number in '{}' command".format(
            args.command))

    if "hosts" in args and args.hosts:
        log.debug("validate_args, hosts in args, args.hosts='{}'".format(
            args.hosts))
        args.hosts = resolve_hosts(args.hosts)
    if "clients" in args and args.clients:
        args.clients = resolve_hosts(args.clients)
    if "bootstrap" in args and args.bootstrap:
        args.bootstrap = [
            strip_user(host_info)
            for host_info in resolve_hosts(args.bootstrap, private_ips=True)
        ]
    if "hub" in args and args.hub:
        args.hub = resolve_hosts(args.hub)

    if not args.command:
        user_error("Invalid or missing command")
    args.command = args.command.strip()
    validate_command(args.command, args)
Esempio n. 2
0
def validate_args(args):
    if args.version is True:  # --version with no second argument
        print_version_info()
        exit_success()

    if args.version and args.command not in ["install", "packages"]:
        user_error("Cannot specify version number in '{}' command".format(
            args.command))

    if args.hosts:
        args.hosts = file_or_comma_list(args.hosts)
    if args.clients:
        args.clients = file_or_comma_list(args.clients)
    if args.bootstrap:
        args.bootstrap = [
            strip_user(host_info)
            for host_info in file_or_comma_list(args.bootstrap)
        ]
    if args.hub:
        args.hub = file_or_comma_list(args.hub)

    args.command = args.command.strip()
    if not args.command:
        user_error("Invalid or missing command")
    validate_command(args.command, args)
Esempio n. 3
0
def validate_args(args):
    if args.version is True:  # --version with no second argument
        print_version_info()
        exit_success()

    if args.version and args.command not in ["install", "packages"]:
        user_error("Cannot specify version number in '{}' command".format(args.command))

    if args.hosts:
        args.hosts = file_or_comma_list(args.hosts)
    if args.clients:
        args.clients = file_or_comma_list(args.clients)
    if args.bootstrap:
        args.bootstrap = [strip_user(host_info) for host_info in file_or_comma_list(args.bootstrap)]
    if args.hub:
        args.hub = file_or_comma_list(args.hub)

    args.command = args.command.strip()
    if not args.command:
        user_error("Invalid or missing command")
    validate_command(args.command, args)
Esempio n. 4
0
def validate_args(args):
    if args.version is True:  # --version with no second argument
        print_version_info()
        exit_success()

    if args.version and args.command not in ["install", "packages"]:
        user_error("Cannot specify version number in '{}' command".format(command))
    if any(x for x in [args.hub, args.bootstrap] if "," in (x or "")):
        user_error("--hub and --bootstrap do not support lists (cannot contain commas)")

    if args.hosts:
        args.hosts = file_or_comma_list(args.hosts)
    if args.clients:
        args.clients = file_or_comma_list(args.clients)
    if args.bootstrap:
        args.bootstrap = file_or_single_host(args.bootstrap)
    if args.hub:
        args.hub = file_or_single_host(args.hub)

    args.command = args.command.strip()
    if not args.command:
        user_error("Invalid or missing command")
    validate_command(args.command, args)