diff options
Diffstat (limited to 'test/lib/base.py')
-rw-r--r-- | test/lib/base.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/test/lib/base.py b/test/lib/base.py index c0830a34..29920451 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -17,6 +17,7 @@ from fabric.api import local, lcd from fabric import colors from fabric.utils import indent from fabric.state import env, output +from docker import Client import netaddr import os @@ -208,10 +209,14 @@ class Container(object): self.ip_addrs.append((intf_name, ip_addr, bridge.name)) try_several_times(lambda :local(str(c))) - def local(self, cmd, capture=False, flag=''): - return local("docker exec {0} {1} {2}".format(flag, - self.docker_name(), - cmd), capture) + def local(self, cmd, capture=False, stream=False, detach=False): + if stream: + dckr = Client(timeout=120, version='auto') + i = dckr.exec_create(container=self.docker_name(), cmd=cmd) + return dckr.exec_start(i['Id'], tty=True, stream=stream, detach=detach) + else: + flag = '-d' if detach else '' + return local('docker exec {0} {1} {2}'.format(flag, self.docker_name(), cmd), capture) def get_pid(self): if self.is_running: |