Skip to content

Commit

Permalink
SshTransport: ensure that connection port and timeout are numeric types.
Browse files Browse the repository at this point in the history
Should solve errors like::

    gservers: [2017-03-29 21:28:58] DEBUG   : Connecting to host ‘BLAHBLAH.something.org' (port 22) as user ‘A_PERSON' via SSH (timeout 30s)...
    gservers: [2017-03-29 21:28:59] ERROR   : Could not create ssh connection to BLAHBLAH.something.org: TypeError: %d format: a number is required, not str

Thanks to Kyle Robertson for reporting.
  • Loading branch information
riccardomurri committed Mar 31, 2017
1 parent d1e3aa9 commit ac192a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gc3libs/backends/transport.py
Expand Up @@ -478,7 +478,7 @@ def set_connection_params(self, hostname, username=None, keyfile=None,
self.username = username

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

Expand All @@ -489,8 +489,8 @@ def set_connection_params(self, hostname, username=None, keyfile=None,
self.keyfile = keyfile

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

Expand Down Expand Up @@ -529,8 +529,8 @@ def connect(self):
gc3libs.log.warning(
"Could not read 'known hosts' SSH keys (%s: %s)."
" I'm ignoring the error and continuing anyway,"
" but this may mean trouble later on."
% (err.__class__.__name__, err))
" but this could mean trouble later on.",
err.__class__.__name__, err)
pass
else:
gc3libs.log.info("Ignoring ssh host key file.")
Expand Down Expand Up @@ -560,7 +560,7 @@ def connect(self):
except Exception as ex:
gc3libs.log.error(
"Could not create ssh connection to %s: %s: %s",
self.remote_frontend, ex.__class__.__name__, str(ex))
self.remote_frontend, ex.__class__.__name__, ex)
self._is_open = False

# Try to understand why the ssh connection failed.
Expand Down

0 comments on commit ac192a5

Please sign in to comment.