Esempio n. 1
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    if not _is_valid_configuration():
        return 1

    args = docopt.docopt(
        __doc__,
        version='dcos version {}'.format(dcoscli.version),
        options_first=True)

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    if not _config_log_level_environ(args['--log-level']):
        return 1

    err = util.configure_logger_from_environ()
    if err is not None:
        emitter.publish(err)
        return 1

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    executable = subcommand.command_executables(command, util.dcos_path())

    subproc = Popen([executable,  command] + args['<args>'],
                    stderr=PIPE)

    return analytics.wait_and_track(subproc)
Esempio n. 2
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(__doc__,
                         version='dcos version {}'.format(dcoscli.version),
                         options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    executable = subcommand.command_executables(command)

    subproc = Popen([executable, command] + args['<args>'], stderr=PIPE)
    if dcoscli.version != 'SNAPSHOT':
        return analytics.wait_and_track(subproc)
    else:
        return analytics.wait_and_capture(subproc)[0]
Esempio n. 3
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(
        __doc__,
        version='dcos version {}'.format(dcoscli.version),
        options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    executable = subcommand.command_executables(command)

    subproc = Popen([executable,  command] + args['<args>'],
                    stderr=PIPE)
    if dcoscli.version != 'SNAPSHOT':
        return analytics.wait_and_track(subproc)
    else:
        return analytics.wait_and_capture(subproc)[0]
Esempio n. 4
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(
        _doc(),
        version='dcos version {}'.format(dcoscli.version),
        options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    config = util.get_config()
    set_ssl_info_env_vars(config)

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    executable = subcommand.command_executables(command)

    cluster_id = None
    if dcoscli.version != 'SNAPSHOT' and command and \
            command not in ["config", "help"]:
        try:
            cluster_id = mesos.DCOSClient().metadata().get('CLUSTER_ID')
        except DCOSAuthenticationException:
                raise
        except:
            msg = 'Unable to get the cluster_id of the cluster.'
            logger.exception(msg)

    # the call to retrieve cluster_id must happen before we run the subcommand
    # so that if you have auth enabled we don't ask for user/pass multiple
    # times (with the text being out of order) before we can cache the auth
    # token
    subproc = Popen([executable,  command] + args['<args>'],
                    stderr=PIPE)

    if dcoscli.version != 'SNAPSHOT':
        return analytics.wait_and_track(subproc, cluster_id)
    else:
        return analytics.wait_and_capture(subproc)[0]
Esempio n. 5
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(_doc(),
                         version='dcos version {}'.format(dcoscli.version),
                         options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    config = util.get_config()
    set_ssl_info_env_vars(config)

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    executable = subcommand.command_executables(command)

    cluster_id = None
    if dcoscli.version != 'SNAPSHOT' and command and \
            command not in ["config", "help"]:
        try:
            cluster_id = mesos.DCOSClient().metadata().get('CLUSTER_ID')
        except DCOSAuthenticationException:
            raise
        except:
            msg = 'Unable to get the cluster_id of the cluster.'
            logger.exception(msg)

    # the call to retrieve cluster_id must happen before we run the subcommand
    # so that if you have auth enabled we don't ask for user/pass multiple
    # times (with the text being out of order) before we can cache the auth
    # token
    subproc = Popen([executable, command] + args['<args>'], stderr=PIPE)

    if dcoscli.version != 'SNAPSHOT':
        return analytics.wait_and_track(subproc, cluster_id)
    else:
        return analytics.wait_and_capture(subproc)[0]
Esempio n. 6
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(
        default_doc("dcos"),
        version='dcos version {}'.format(dcoscli.version),
        options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    config = util.get_config()
    set_ssl_info_env_vars(config)

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    cluster_id = None
    if dcoscli.version != 'SNAPSHOT' and command and \
            command not in ["config", "help"]:
        try:
            cluster_id = mesos.DCOSClient().metadata().get('CLUSTER_ID')
        except DCOSAuthenticationException:
                raise
        except:
            msg = 'Unable to get the cluster_id of the cluster.'
            logger.exception(msg)

    # send args call to segment.io
    with ThreadPoolExecutor(max_workers=2) as reporting_executor:
        analytics.segment_track_cli(reporting_executor, config, cluster_id)

        # the call to retrieve cluster_id must happen before we run the
        # subcommand so that if you have auth enabled we don't ask for
        # user/pass multiple times (with the text being out of order)
        # before we can cache the auth token
        if command in subcommand.default_subcommands():
            sc = SubcommandMain(command, args['<args>'])
        else:
            executable = subcommand.command_executables(command)
            sc = subcommand.SubcommandProcess(
                executable, command, args['<args>'])

        exitcode, err = sc.run_and_capture()

        if err:
            analytics.track_err(
                reporting_executor, exitcode, err, config, cluster_id)

        return exitcode
Esempio n. 7
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    args = docopt.docopt(default_doc("dcos"),
                         version='dcos version {}'.format(dcoscli.version),
                         options_first=True)

    log_level = args['--log-level']
    if log_level and not _config_log_level_environ(log_level):
        return 1

    if args['--debug']:
        os.environ[constants.DCOS_DEBUG_ENV] = 'true'

    util.configure_process_from_environ()

    if args['<command>'] != 'config' and \
       not auth.check_if_user_authenticated():
        auth.force_auth()

    config = util.get_config()
    set_ssl_info_env_vars(config)

    command = args['<command>']
    http.silence_requests_warnings()

    if not command:
        command = "help"

    cluster_id = None
    if dcoscli.version != 'SNAPSHOT' and command and \
            command not in ["config", "help"]:
        try:
            cluster_id = mesos.DCOSClient().metadata().get('CLUSTER_ID')
        except DCOSAuthenticationException:
            raise
        except:
            msg = 'Unable to get the cluster_id of the cluster.'
            logger.exception(msg)

    # send args call to segment.io
    with ThreadPoolExecutor(max_workers=2) as reporting_executor:
        analytics.segment_track_cli(reporting_executor, config, cluster_id)

        # the call to retrieve cluster_id must happen before we run the
        # subcommand so that if you have auth enabled we don't ask for
        # user/pass multiple times (with the text being out of order)
        # before we can cache the auth token
        if command in subcommand.default_subcommands():
            sc = SubcommandMain(command, args['<args>'])
        else:
            executable = subcommand.command_executables(command)
            sc = subcommand.SubcommandProcess(executable, command,
                                              args['<args>'])

        exitcode, err = sc.run_and_capture()

        if err:
            analytics.track_err(reporting_executor, exitcode, err, config,
                                cluster_id)

        return exitcode