diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-06-27 21:37:42 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2018-07-13 11:29:28 -0700 |
commit | 44b523c946c88e540b50d7ba59f441b5f8e0bad0 (patch) | |
tree | 744c09508b139c1aca3d7fc995fad7ff354e3667 /contrib/python/podman/libs/tunnel.py | |
parent | 14a6d51a8432fc0c3324fec02e8729d3032f2af2 (diff) | |
download | podman-44b523c946c88e540b50d7ba59f441b5f8e0bad0.tar.gz podman-44b523c946c88e540b50d7ba59f441b5f8e0bad0.tar.bz2 podman-44b523c946c88e540b50d7ba59f441b5f8e0bad0.zip |
remote python client for podman
* Use podman library for access
* Verbose error checking
* Planned windows and macosx ports
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'contrib/python/podman/libs/tunnel.py')
-rw-r--r-- | contrib/python/podman/libs/tunnel.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/python/podman/libs/tunnel.py b/contrib/python/podman/libs/tunnel.py index 42fd3356b..9effdff6c 100644 --- a/contrib/python/podman/libs/tunnel.py +++ b/contrib/python/podman/libs/tunnel.py @@ -1,5 +1,6 @@ """Cache for SSH tunnels.""" import collections +import logging import os import subprocess import threading @@ -96,9 +97,15 @@ class Tunnel(object): def bore(self, id): """Create SSH tunnel from given context.""" + ssh_opts = '-nNT' + if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + ssh_opts += 'v' + else: + ssh_opts += 'q' + cmd = [ 'ssh', - '-nNTq', + ssh_opts, '-L', '{}:{}'.format(self.context.local_socket, self.context.remote_socket), @@ -106,15 +113,14 @@ class Tunnel(object): self.context.identity_file, 'ssh://{}@{}'.format(self.context.username, self.context.hostname), ] - - if os.environ.get('PODMAN_DEBUG'): - cmd.append('-vvv') + logging.debug('Tunnel cmd "{}"'.format(' '.join(cmd))) self._tunnel = subprocess.Popen(cmd, close_fds=True) - for i in range(5): + for i in range(10): + # TODO: Make timeout configurable if os.path.exists(self.context.local_socket): break - time.sleep(1) + time.sleep(0.5) else: raise TimeoutError('Failed to create tunnel using: {}'.format( ' '.join(cmd))) |