Skip to content

Commit

Permalink
Fix issue #621.
Browse files Browse the repository at this point in the history
Do not overwrite connection parameters like `username` or `keyfile`
when `SshTransport.set_connection_params` is called for late object
initialization.
  • Loading branch information
Sergio Maffioletti authored and riccardomurri committed Aug 14, 2017
1 parent 381c4bb commit 02e3afe
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gc3libs/backends/transport.py
Expand Up @@ -456,6 +456,13 @@ def __init__(self, remote_frontend,
self._is_open = False
self.transport_channel = None

# init connection params
self.username = None
self.keyfile = None
self.port = gc3libs.Default.SSH_PORT
self.timeout = gc3libs.Default.SSH_CONNECT_TIMEOUT
self.proxy_command = None

# use SSH options, if available
self._ssh_config = paramiko.SSHConfig()
config_filename = os.path.expanduser(ssh_config or gc3libs.Default.SSH_CONFIG_FILE)
Expand Down Expand Up @@ -527,25 +534,24 @@ def set_connection_params(self, hostname, username=None, keyfile=None,
self.remote_frontend = ssh_options.get('hostname', hostname)

if username is None:
self.username = ssh_options.get('user', None)
self.username = ssh_options.get('user', self.username)
else:
assert type(username) in types.StringTypes
self.username = username

if port is None:
self.port = int(ssh_options.get('port', gc3libs.Default.SSH_PORT))
self.port = int(ssh_options.get('port', self.port))
else:
self.port = int(port)

if keyfile is None:
self.keyfile = ssh_options.get('identityfile', None)
self.keyfile = ssh_options.get('identityfile', self.keyfile)
else:
assert type(keyfile) in types.StringTypes
self.keyfile = keyfile

if timeout is None:
self.timeout = float(ssh_options.get('connecttimeout',
gc3libs.Default.SSH_CONNECT_TIMEOUT))
self.timeout = float(ssh_options.get('connecttimeout', self.timeout))
else:
self.timeout = float(timeout)

Expand Down

0 comments on commit 02e3afe

Please sign in to comment.