Skip to content

Commit

Permalink
Merge pull request #538 from mesosphere/branden/node-id
Browse files Browse the repository at this point in the history
Rename `node --slave` -> `node --mesos-id`
  • Loading branch information
tamarrow committed Mar 22, 2016
2 parents 64ccfa7 + faf559f commit 883d3bc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
7 changes: 4 additions & 3 deletions cli/dcoscli/data/help/node.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Manage DCOS nodes
Usage:
dcos node --info
dcos node [--json]
dcos node log [--follow --lines=N --leader --master --slave=<slave-id>]
dcos node log [--follow --lines=N --leader --master --mesos-id=<mesos-id> --slave=<slave-id>]
dcos node ssh [--option SSHOPT=VAL ...]
[--config-file=<path>]
[--user=<user>]
[--master-proxy]
(--leader | --master | --slave=<slave-id>)
(--leader | --master | --mesos-id=<mesos-id> | --slave=<slave-id>)

Options:
-h, --help Show this screen
Expand All @@ -23,7 +23,8 @@ Options:
configuration, the private slaves are unreachable from the public
internet. You can access them using this option, which will first hop
from the publicly available master.
--slave=<slave-id> Access the slave with the provided ID
--slave=<slave-id> Deprecated. Please use --mesos-id.
--mesos-id=<mesos-id> Access the node with the provided Mesos ID
--option SSHOPT=VAL SSH option (see `man ssh_config`)
--config-file=<path> Path to SSH config file
--user=<user> SSH user [default: core]
Expand Down
10 changes: 7 additions & 3 deletions cli/dcoscli/node/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def _main():
raise DCOSException(
'--master has been deprecated. Please use --leader.'
)
elif args.get('--slave'):
raise DCOSException(
'--slave has been deprecated. Please use --mesos-id.'
)

return cmds.execute(_cmds(), args)

Expand Down Expand Up @@ -60,12 +64,12 @@ def _cmds():

cmds.Command(
hierarchy=['node', 'log'],
arg_keys=['--follow', '--lines', '--leader', '--slave'],
arg_keys=['--follow', '--lines', '--leader', '--mesos-id'],
function=_log),

cmds.Command(
hierarchy=['node', 'ssh'],
arg_keys=['--leader', '--slave', '--option', '--config-file',
arg_keys=['--leader', '--mesos-id', '--option', '--config-file',
'--user', '--master-proxy'],
function=_ssh),

Expand Down Expand Up @@ -126,7 +130,7 @@ def _log(follow, lines, leader, slave):
"""

if not (leader or slave):
raise DCOSException('You must choose one of --leader or --slave.')
raise DCOSException('You must choose one of --leader or --mesos-id.')

lines = util.parse_int(lines)

Expand Down
7 changes: 4 additions & 3 deletions cli/tests/data/help/node.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Manage DCOS nodes
Usage:
dcos node --info
dcos node [--json]
dcos node log [--follow --lines=N --leader --master --slave=<slave-id>]
dcos node log [--follow --lines=N --leader --master --mesos-id=<mesos-id> --slave=<slave-id>]
dcos node ssh [--option SSHOPT=VAL ...]
[--config-file=<path>]
[--user=<user>]
[--master-proxy]
(--leader | --master | --slave=<slave-id>)
(--leader | --master | --mesos-id=<mesos-id> | --slave=<slave-id>)

Options:
-h, --help Show this screen
Expand All @@ -23,7 +23,8 @@ Options:
configuration, the private slaves are unreachable from the public
internet. You can access them using this option, which will first hop
from the publicly available master.
--slave=<slave-id> Access the slave with the provided ID
--slave=<slave-id> Deprecated. Please use --mesos-id.
--mesos-id=<mesos-id> Access the node with the provided Mesos ID
--option SSHOPT=VAL SSH option (see `man ssh_config`)
--config-file=<path> Path to SSH config file
--user=<user> SSH user [default: core]
Expand Down
20 changes: 15 additions & 5 deletions cli/tests/integrations/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_node_table():


def test_node_log_empty():
stderr = b"You must choose one of --leader or --slave.\n"
stderr = b"You must choose one of --leader or --mesos-id.\n"
assert_command(['dcos', 'node', 'log'], returncode=1, stderr=stderr)


Expand All @@ -53,12 +53,12 @@ def test_node_log_leader():

def test_node_log_slave():
slave_id = _node()[0]['id']
assert_lines(['dcos', 'node', 'log', '--slave={}'.format(slave_id)], 10)
assert_lines(['dcos', 'node', 'log', '--mesos-id={}'.format(slave_id)], 10)


def test_node_log_missing_slave():
returncode, stdout, stderr = exec_command(
['dcos', 'node', 'log', '--slave=bogus'])
['dcos', 'node', 'log', '--mesos-id=bogus'])

assert returncode == 1
assert stdout == b''
Expand All @@ -69,7 +69,7 @@ def test_node_log_leader_slave():
slave_id = _node()[0]['id']

returncode, stdout, stderr = exec_command(
['dcos', 'node', 'log', '--leader', '--slave={}'.format(slave_id)])
['dcos', 'node', 'log', '--leader', '--mesos-id={}'.format(slave_id)])

assert returncode == 0
assert stderr == b''
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_node_ssh_leader():

def test_node_ssh_slave():
slave_id = mesos.DCOSClient().get_state_summary()['slaves'][0]['id']
_node_ssh(['--slave={}'.format(slave_id), '--master-proxy'])
_node_ssh(['--mesos-id={}'.format(slave_id), '--master-proxy'])


def test_node_ssh_option():
Expand Down Expand Up @@ -151,6 +151,16 @@ def test_master_arg_deprecation_notice():
returncode=1)


def test_slave_arg_deprecation_notice():
stderr = b"--slave has been deprecated. Please use --mesos-id.\n"
assert_command(['dcos', 'node', 'log', '--slave=bogus'],
stderr=stderr,
returncode=1)
assert_command(['dcos', 'node', 'ssh', '--slave=bogus'],
stderr=stderr,
returncode=1)


def _node_ssh_output(args):
cli_test_ssh_key_path = os.environ['CLI_TEST_SSH_KEY_PATH']

Expand Down

0 comments on commit 883d3bc

Please sign in to comment.