-
Notifications
You must be signed in to change notification settings - Fork 199
add custom options to sshdriver #1073
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 63.2% // Head: 63.2% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1073 +/- ##
======================================
Coverage 63.2% 63.2%
======================================
Files 152 152
Lines 11346 11352 +6
======================================
+ Hits 7174 7180 +6
Misses 4172 4172
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your commit is missing the Signed-off-by line. See https://labgrid.readthedocs.io/en/latest/development.html#developer-s-certificate-of-origin
labgrid/driver/sshdriver.py
Outdated
@@ -48,6 +49,9 @@ def on_activate(self): | |||
if not self.networkservice.password: | |||
self.ssh_prefix += ["-o", "PasswordAuthentication=no"] | |||
|
|||
if self.options: | |||
self.ssh_prefix += self.options.split(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.python.org/3/library/shlex.html#shlex.split is probably better in this case.
As some special cases around quoting are not easily handled even with shlex.split
, we should support optionally having a list instead of a string. In that case, they could simply be passed along.
labgrid/driver/sshdriver.py
Outdated
@@ -30,6 +30,7 @@ class SSHDriver(CommandMixin, Driver, CommandProtocol, FileTransferProtocol): | |||
bindings = {"networkservice": "NetworkService", } | |||
priorities = {CommandProtocol: 10, FileTransferProtocol: 10} | |||
keyfile = attr.ib(default="", validator=attr.validators.instance_of(str)) | |||
options = attr.ib(default="", validator=attr.validators.instance_of(str)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it should be called extra_options
, to indicate that it cannot be used to replace the options set by labgrid? @Emantor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, will be done
a63e430
to
20f4c34
Compare
added the possibility to define custom option for the SSHDriver in the environment yaml Signed-off-by: Nikolaj Rahbel <[email protected]>
self.ssh_prefix += shlex.split(self.extra_options) | ||
elif isinstance(self.extra_options, list) and len(self.extra_options) > 0: | ||
for eo in self.extra_options: | ||
self.ssh_prefix += shlex.split(eo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we split each option in the list? This makes it impossible to pass options with spaces.
extra_options: | ||
- "-o option1" | ||
- "-o options2" | ||
- "-4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems inconsistent. Why use an explicit list if not to exactly device the argv elements?
Description
added the possibility to define custom option for the SSHDriver in the environment yaml. The motivation for this change was to be able to overwrite host key algorithms in test context.
Checklist