Ejemplo n.º 1
0
def test_uses_deprecated_config():
    with env(), util.tempdir() as tempdir:
        os.environ.pop('DCOS_CONFIG', None)
        os.environ[constants.DCOS_DIR_ENV] = tempdir
        assert config.get_config_dir_path() == tempdir

        # create old global config toml
        global_toml = create_global_config(tempdir)
        assert config.get_global_config_path() == global_toml
        assert config.uses_deprecated_config() is True

        # create clusters subdir
        _create_clusters_dir(tempdir)
        assert config.uses_deprecated_config() is False
Ejemplo n.º 2
0
def _set(name, value):
    """
    :returns: process status
    :rtype: int
    """

    toml, msg = config.set_val(name, value)
    emitter.publish(DefaultError(msg))

    if name == "core.dcos_url" and config.uses_deprecated_config():
        notice = (
            "Setting-up a cluster through this command is being deprecated. "
            "To setup the CLI to talk to your cluster, please run "
            "`dcos cluster setup <dcos_url>`.")
        emitter.publish(DefaultError(notice))

    return 0
Ejemplo n.º 3
0
def install(pkg, global_=False):
    """Installs the dcos cli subcommand

    :param pkg: the package to install
    :type pkg: Package
    :param global_: whether to install the CLI globally
    :type global_: bool
    :rtype: None
    """

    if global_ or config.uses_deprecated_config():
        pkg_dir = global_package_dir(pkg.name())
    else:
        pkg_dir = _cluster_package_dir(pkg.name())

    util.ensure_dir_exists(pkg_dir)

    _write_package_json(pkg, pkg_dir)

    _install_cli(pkg, pkg_dir)
Ejemplo n.º 4
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    http.silence_requests_warnings()

    args = docopt.docopt(default_doc("dcos"), 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['--version']:
        return _get_versions()

    command = args['<command>']

    if not command:
        return dcos_help()

    if config.uses_deprecated_config():
        if constants.DCOS_CONFIG_ENV in os.environ:
            msg = ('{} is deprecated, please consider using '
                   '`dcos cluster setup <dcos_url>`.')
            err = errors.DefaultError(msg.format(constants.DCOS_CONFIG_ENV))
            emitter.publish(err)

        cluster.move_to_cluster_config()

    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, _ = sc.run_and_capture()
    return exitcode
Ejemplo n.º 5
0
def _main():
    signal.signal(signal.SIGINT, signal_handler)

    http.silence_requests_warnings()

    args = docopt.docopt(default_doc("dcos"), 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 config.uses_deprecated_config():
        cluster.move_to_cluster_config()

    if args['--version']:
        return _get_versions()

    command = args['<command>']

    if not command:
        if args['--help']:
            command = "help"
        else:
            return dcos_help()

    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, _ = sc.run_and_capture()
    return exitcode