Пример #1
0
def dispatch(args):
    """ Dispatches the selected mode based on command line args. """
    if args.action == 'hash-password':
        # TODO(cmaloney): Import a function from the auth stuff to do the hashing and guarantee it
        # always matches
        byte_str = do_hash_password(args.password).encode('ascii')
        sys.stdout.buffer.write(byte_str + b'\n')
        sys.exit(0)

    if args.action == 'generate-node-upgrade-script':
        status = backend.generate_node_upgrade_script(
            args.installed_cluster_version)
        sys.exit(status)

    if args.action == 'generate-node-upgrade-win-script':
        status = backend.generate_node_upgrade_win_script(
            args.installed_cluster_version)
        sys.exit(status)

    if args.action in dispatch_dict_simple:
        action = dispatch_dict_simple[args.action]
        if action[1] is not None:
            print_header(action[1])
        sys.exit(action[0](args))

    print("Internal Error: No known way to dispatch {}".format(args.action))
    sys.exit(1)
Пример #2
0
def dispatch(args):
    """ Dispatches the selected mode based on command line args. """
    if args.action == 'set-superuser-password':
        password_hash = do_hash_password(args.password)
        messages = backend.create_config_from_post(
            {'superuser_password_hash': password_hash},
            dcos_installer.constants.CONFIG_PATH)
        if messages:
            log.error("Unable to save password: {}".format(messages))
            sys.exit(1)
        sys.exit(0)

    if args.action == 'hash-password':
        # TODO(cmaloney): Import a function from the auth stuff to do the hashing and guarantee it
        # always matches
        byte_str = do_hash_password(args.password).encode('ascii')
        sys.stdout.buffer.write(byte_str + b'\n')
        sys.exit(0)

    if args.action == 'generate-node-upgrade-script':
        status = backend.generate_node_upgrade_script(
            args.installed_cluster_version)
        sys.exit(status)

    if args.action in dispatch_dict_simple:
        action = dispatch_dict_simple[args.action]
        if action[1] is not None:
            print_header(action[1])
        sys.exit(action[0](args))

    # Dispatches CLI options which are installer actions ran through AIO event loop
    if args.action in dispatch_dict_aio:
        action = dispatch_dict_aio[args.action]
        if do_validate_config(args) != 0:
            sys.exit(1)
        if action[1] is not None:
            print_header(action[1])
        errors = run_loop(action[0], args)
        if not args.cli_telemetry_disabled:
            installer_analytics.send(
                action=args.action,
                install_method="cli",
                num_errors=errors,
            )
        sys.exit(1 if errors > 0 else 0)

    print("Internal Error: No known way to dispatch {}".format(args.action))
    sys.exit(1)
Пример #3
0
def dispatch(args):
    """ Dispatches the selected mode based on command line args. """
    if args.action == 'set-superuser-password':
        password_hash = do_hash_password(args.password)
        messages = backend.create_config_from_post(
            {'superuser_password_hash': password_hash},
            dcos_installer.constants.CONFIG_PATH)
        if messages:
            log.error("Unable to save password: {}".format(messages))
            sys.exit(1)
        sys.exit(0)

    if args.action == 'hash-password':
        # TODO(cmaloney): Import a function from the auth stuff to do the hashing and guarantee it
        # always matches
        byte_str = do_hash_password(args.password).encode('ascii')
        sys.stdout.buffer.write(byte_str + b'\n')
        sys.exit(0)

    if args.action == 'generate-node-upgrade-script':
        status = backend.generate_node_upgrade_script(args.installed_cluster_version)
        sys.exit(status)

    if args.action in dispatch_dict_simple:
        action = dispatch_dict_simple[args.action]
        if action[1] is not None:
            print_header(action[1])
        sys.exit(action[0](args))

    # Dispatches CLI options which are installer actions ran through AIO event loop
    if args.action in dispatch_dict_aio:
        action = dispatch_dict_aio[args.action]
        if do_validate_config(args) != 0:
            sys.exit(1)
        if action[1] is not None:
            print_header(action[1])
        errors = run_loop(action[0], args)
        if not args.cli_telemetry_disabled:
            installer_analytics.send(
                action=args.action,
                install_method="cli",
                num_errors=errors,
            )
        sys.exit(1 if errors > 0 else 0)

    print("Internal Error: No known way to dispatch {}".format(args.action))
    sys.exit(1)