As discussed in T408, new argument --ssh user@machine privkey was added. Open for discussion.
Details
- Reviewers
kparal mkrizek - Maniphest Tasks
- T408: refine formula syntax from PoC
- Commits
- rLTRNeb8edaf7183c: Argument --ssh added
manually tested with VM
Diff Detail
- Repository
- rLTRN libtaskotron
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
libtaskotron/runner.py | ||
---|---|---|
381–382 | In T408, it was proposed to have ssh_privkey in the config file and --ssh-privkey as a cmdline argument. That could be used both for --ssh and --libvirt connections. Do you think your currently proposed approach is better? | |
428–429 | An idea - will we need to have port configurable as well? Should we change the syntax to user@machine:port (where :port might be optional) right away? | |
429–434 | This should be processed immediately after calling parser.parse_args() . I suppose we will have more checks like these soon, so there should be a dedicated function for it, which will accept parser and args as input parameters and will call parser.error() if args are not valid. | |
435–436 | I'd leave this up to the code actually using the privkey to raise IOError if it is not there. Only if the code silently ignores the missing file and continues, then we should have an explicit check (a good idea for a functional test). | |
437 | This should probably be # TODO: remove this section once T408 is implemented |
libtaskotron/runner.py | ||
---|---|---|
428–429 | I noticed only now, but could you please move the whole Runner class upwards before the top-level functions definitions? Right now we have 2 class definitions, then a couple of functions definitions, then another class, then another couple of functions. It makes the file harder to navigate. Let's have all classes at top, and then all the functions. | |
436–439 | You're right, I got confused by it, sorry. Which means a comment explaining what you're catching and why would help people like me understanding it. Or we can make the code a bit more obvious: self.user, machine = self.arg_data['ssh'].split('@') if ':' in machine: self.machine, port = machine.split(':') self.port = int(port) else: self.machine = machine self.port = 22 | |
449 | Hmm, I'm not even sure why we use vars(args) in process_args(). It's quite usual to work with argparse objects like args.ssh and I don't think there would be any problem in process_args() with it. It seems we don't even want to modify the existing args but return a new, processed set. When talking about check_args(), would there be any issue with writing the test cases like this? class Empty: pass ... class TestRunner: def setup(self, monkeypatch): ... self.obj = Empty() def test_ssh_bad_usermachine(self, monkeypatch): obj.local = False obj.ssh = 'user#machine' stub_error = Dingus() stub_parser = Dingus() stub_parser.error = stub_error runner.check_args(stub_parser, obj) assert len(stub_error.calls()) == 1 You can of course also use vars(args) in check_args(), but I'm still not sure why we need it. |
In T408, it was proposed to have ssh_privkey in the config file and --ssh-privkey as a cmdline argument. That could be used both for --ssh and --libvirt connections. Do you think your currently proposed approach is better?