summaryrefslogtreecommitdiff
path: root/contrib/python/podman
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/podman')
-rw-r--r--contrib/python/podman/libs/errors.py17
-rw-r--r--contrib/python/podman/libs/tunnel.py18
2 files changed, 24 insertions, 11 deletions
diff --git a/contrib/python/podman/libs/errors.py b/contrib/python/podman/libs/errors.py
index c28afd940..b98210481 100644
--- a/contrib/python/podman/libs/errors.py
+++ b/contrib/python/podman/libs/errors.py
@@ -5,14 +5,21 @@ from varlink import VarlinkError
class VarlinkErrorProxy(VarlinkError):
"""Class to Proxy VarlinkError methods."""
- def __init__(self, obj):
+ def __init__(self, message, namespaced=False):
"""Construct proxy from Exception."""
- self._obj = obj
+ super().__init__(message.as_dict(), namespaced)
+ self._message = message
self.__module__ = 'libpod'
- def __getattr__(self, item):
- """Return item from proxied Exception."""
- return getattr(self._obj, item)
+ def __getattr__(self, method):
+ """Return attribute from proxied Exception."""
+ if hasattr(self._message, method):
+ return getattr(self._message, method)
+
+ try:
+ return self._message.parameters()[method]
+ except KeyError:
+ raise AttributeError('No such attribute: {}'.format(method))
class ContainerNotFound(VarlinkErrorProxy):
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)))