diff options
author | Joe Brennan <jmbrenna@google.com> | 2017-01-18 13:23:38 -0800 |
---|---|---|
committer | Joe Brennan <jmbrenna@google.com> | 2017-01-18 14:04:23 -0800 |
commit | 2d6fc5197a8da07965093a7e8a55f0177bd16d72 (patch) | |
tree | 546b072f3b822c5c27543589b8e93b23bb020039 | |
parent | b293a7f745a256d444f223bd033adbb4b79cf178 (diff) | |
download | platform_tools_test_connectivity-2d6fc5197a8da07965093a7e8a55f0177bd16d72.tar.gz platform_tools_test_connectivity-2d6fc5197a8da07965093a7e8a55f0177bd16d72.tar.bz2 platform_tools_test_connectivity-2d6fc5197a8da07965093a7e8a55f0177bd16d72.zip |
Added the ability to have put identify files in ssh_configs
Created the ability to have a path to an identity file
in the ssh_config in the config files for ACTS.
Bug: 34386514
Test: Verfied connecting to ssh server with an identity
file specified and without the identity file
specified.
Change-Id: I8660c9c98502eda41b5ad64a835c2c1940fdf1c8
-rw-r--r-- | acts/framework/acts/controllers/utils_lib/ssh/settings.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/acts/framework/acts/controllers/utils_lib/ssh/settings.py b/acts/framework/acts/controllers/utils_lib/ssh/settings.py index b206db6016..b8331bdd4a 100644 --- a/acts/framework/acts/controllers/utils_lib/ssh/settings.py +++ b/acts/framework/acts/controllers/utils_lib/ssh/settings.py @@ -11,8 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - """Create a SshSettings from a dictionary from an ACTS config Args: @@ -21,6 +19,8 @@ Args: Returns: An instance of SshSettings or None """ + + def from_config(config): if config is None: return None # Having no settings is not an error @@ -28,11 +28,12 @@ def from_config(config): user = config.get('user', None) host = config.get('host', None) port = config.get('port', 22) + identity_file = config.get('identity_file', None) if user is None or host is None: raise ValueError('Malformed SSH config did not include user and ' 'host keys: %s' % config) - return SshSettings(host, user, port=port) + return SshSettings(host, user, port=port, identity_file=identity_file) class SshSettings(object): @@ -59,7 +60,8 @@ class SshSettings(object): host_file='/dev/null', connect_timeout=30, alive_interval=300, - executable='/usr/bin/ssh'): + executable='/usr/bin/ssh', + identity_file=None): self.username = username self.hostname = hostname self.executable = executable @@ -67,6 +69,7 @@ class SshSettings(object): self.host_file = host_file self.connect_timeout = connect_timeout self.alive_interval = alive_interval + self.identity_file = identity_file def construct_ssh_options(self): """Construct the ssh options. @@ -97,4 +100,6 @@ class SshSettings(object): current_flags['-a'] = None current_flags['-x'] = None current_flags['-p'] = self.port + if self.identity_file: + current_flags['-i'] = self.identity_file return current_flags |