Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable additional ssh arguments #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mesos/cli/cmds/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
help="""Name of the task."""
).completer = completion_helpers.task

parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there are no arguments for this that are mesos specific yet, I'd like to just pass all the options directly to ssh itself. That way, you don't need to remember to pass in a special arg.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Makes sense. Will look into this.

'-s', "--ssh_args", type=str,
help="""provide any additional ssh arguments (for example: -s "-l login_name -p port")""")

@cli.init(parser)
def main(args):
Expand All @@ -45,12 +48,17 @@ def main(args):

task = MASTER.task(args.task)

cmd = [
"ssh",
cmd = ["ssh"]

if args.ssh_args is not None:
cmd += args.ssh_args.split()

cmd += [
"-t",
task.slave["hostname"],
"cd {0} && bash".format(task.directory)
]

if task.directory == "":
print(term.red + "warning: the task no longer exists on the " +
"target slave. Will not enter sandbox" + term.white + "\n\n")
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ def test_sandbox(self):
'cd {0} && bash'.format(DIR)
])

@utils.patch_args([
"mesos-ssh",
"-s",
"-l a-login-name -p a-port",
"app-215.3e6a099c-fcba-11e3-8b67-b6f6cc110ef2"
])
def test_sandbox_with_ssh_args(self):
with mock.patch("os.execvp") as m:
mesos.cli.cmds.ssh.main()

m.assert_called_with("ssh", [
'ssh',
'-l',
'a-login-name',
'-p',
'a-port',
'-t',
'10.141.141.10',
'cd {0} && bash'.format(DIR)
])

@utils.patch_args([
"mesos-ssh",
"app-215.2e6508c3-fafd-11e3-a955-b6f6cc110ef2"
Expand Down