Add exec command

This commit is contained in:
jpic 2020-08-02 22:19:13 +02:00
parent 222eda3746
commit f127f27ecd

View File

@ -84,6 +84,28 @@ class Container:
"""Start the container""" """Start the container"""
await target.exec('podman', 'logs', self.full_name) await target.exec('podman', 'logs', self.full_name)
async def exec(self, target, cmd=None):
"""Execute a command in the container"""
cmd = cmd or 'bash'
if cmd.endswith('sh'):
import os
os.execvp(
'/usr/bin/podman',
[
'podman',
'exec',
'-it',
self.full_name,
cmd,
]
)
result = await target.exec(
'podman',
'exec',
self.full_name,
cmd,
)
async def down(self, target): async def down(self, target):
"""Start the container""" """Start the container"""
await target.exec('podman', 'rm', '-f', self.full_name, raises=False) await target.exec('podman', 'rm', '-f', self.full_name, raises=False)