Merge lp://staging/~jimbaker/pyjuju/ssh-passthrough into lp://staging/pyjuju

Proposed by Jim Baker
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 412
Merged at revision: 420
Proposed branch: lp://staging/~jimbaker/pyjuju/ssh-passthrough
Merge into: lp://staging/pyjuju
Diff against target: 393 lines (+219/-17)
6 files modified
juju/control/__init__.py (+20/-4)
juju/control/command.py (+2/-1)
juju/control/ssh.py (+32/-9)
juju/control/tests/test_ssh.py (+64/-2)
juju/control/tests/test_utils.py (+48/-1)
juju/control/utils.py (+53/-0)
To merge this branch: bzr merge lp://staging/~jimbaker/pyjuju/ssh-passthrough
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
William Reade (community) Approve
Review via email: mp+79888@code.staging.launchpad.net

Description of the change

Implements the ability to passthrough args to an underlying command, in particular to support juju ssh. This support enables using juju ssh in the following ways:

$ juju ssh mysql/0 ls /

$ juju ssh -L8080:localhost:80 wordpress/0

and so forth, any options are simply passed through, along with the ssh command.

This requires working around argparse a bit, but only through its public API. In particular, main now uses parse_known_args to see if the command module in question supports the passthrough function; it if it does, that function is used to further decorate options from any extra args. Then command execution proceeds as before.

To post a comment you must log in.
Revision history for this message
William Reade (fwereade) wrote :

[0] trivial

+ "[passthru ssh options] unit_or_machine [command]"),

s/passthru/passthrough

[1] trivial

+ # workding with ssh, for example), so consume the rest and

s/workding/working

[2] less trivial

I didn't see any way to handle potential conflicts in args (specifically -o ControlMaster/ControlPath, which I think are the only ones we need to worry about at the moment). Not really a big deal, but something it might be worth logging a "low" bug against, to make it clear that the limitation is known but not a priority?

anyway, +1

review: Approve
Revision history for this message
Jim Baker (jimbaker) wrote :

> [0] trivial
>
> + "[passthru ssh options] unit_or_machine [command]"),
>
> s/passthru/passthrough

Thanks, let's keep it consistent. (Both seem to be used, but passthrough more so. Or perhaps pass-through.)

>
> [1] trivial
>
> + # workding with ssh, for example), so consume the rest and
>
> s/workding/working

Ack

>
> [2] less trivial
>
> I didn't see any way to handle potential conflicts in args (specifically -o
> ControlMaster/ControlPath, which I think are the only ones we need to worry
> about at the moment). Not really a big deal, but something it might be worth
> logging a "low" bug against, to make it clear that the limitation is known but
> not a priority?

Indeed, it's possible for the user to escape the walled garden and use ssh flags in bad ways as well as good. Passthrough flags are presented later to ssh, and can thereby override juju's default usage. In the particular example you cite, this enables the user to know what is best for a given scenario. For example, multiplexing a connection would not be so ideal if there's significant data transfer. Until now this was a moot point, but with tunnel support, this need could actually arise, and it can be simply solved by passing in -o "ControlMaster no".

I don't think it's a low bug, just simply a matter of adding to the documentation of this command.

>
> anyway, +1

Thanks!

Revision history for this message
Jim Baker (jimbaker) wrote :

> I don't think it's a low bug, just simply a matter of adding to the
> documentation of this command.

To be precise: it should be fixed in the context of this branch.

Revision history for this message
Jim Baker (jimbaker) wrote :

>
> > I don't think it's a low bug, just simply a matter of adding to the
> > documentation of this command.
>
> To be precise: it should be fixed in the context of this branch.

irc discussion:

<jimbaker> fwereade, i think i'm going to change my mind on the doc stuff related to juju ssh. the command itself is not documented. really we need to incorporate more detailed docs on each subcommand in juju
<jimbaker> fwereade, so that should be done in a separate branch/bug
<fwereade> jimbaker, sounds sensible to me

410. By Jim Baker

Fix doc typo

411. By Jim Baker

Merged trunk

412. By Jim Baker

Addressed review points

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

Nice work jim. lgtm, a minor

[0]

+def parse_passthrough_args(args, flags_taking_arg=frozenset()):

the frozenset seems like overkill when an empty tuple suffices.

[1]

re the same function.

Is supporting long options just a matter of an additional conditional
clause for peeked.startswith("--") ? If so it seems better to just
implement support for it now.

[2] re the conflict william brought up, experimenting with the ssh cli it doesn't actually appear to be a problem in practice the user specified option will take precedence as its specified last.

review: Approve
Revision history for this message
Jim Baker (jimbaker) wrote :

> Nice work jim. lgtm, a minor
>
> [0]
>
> +def parse_passthrough_args(args, flags_taking_arg=frozenset()):
>
> the frozenset seems like overkill when an empty tuple suffices.

Sure, definite overkill.

>
> [1]
>
> re the same function.
>
> Is supporting long options just a matter of an additional conditional
> clause for peeked.startswith("--") ? If so it seems better to just
> implement support for it now.

It's not quite so simple, and so far the universe of commands that need this passthrough support is as far as I know is just ssh/scp. So I'd suggest punting that support until we identify them.
>
>
> [2] re the conflict william brought up, experimenting with the ssh cli it
> doesn't actually appear to be a problem in practice the user specified option
> will take precedence as its specified last.

My experience too.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: