diff --git a/wrapanapi/systems/container/podman.py b/wrapanapi/systems/container/podman.py index 6ea8fc16..a4332329 100644 --- a/wrapanapi/systems/container/podman.py +++ b/wrapanapi/systems/container/podman.py @@ -11,7 +11,7 @@ class PodmanContainer(Entity, metaclass=ABCMeta): def __init__(self, system, raw=None, **kwargs): """ - Constructor for an PodmanContainer tied to a specific host. + Constructor for an PodmanContainer tied to a specific Container. Args: system: a Podman system object @@ -19,6 +19,7 @@ def __init__(self, system, raw=None, **kwargs): """ self._name = kwargs.get("name") self._id = kwargs.get("id") + self._image = kwargs.get("image") if not self._name: raise ValueError("missing required kwargs identifier: 'name'") @@ -37,6 +38,10 @@ def name(self): def id(self): return self._id + @property + def image(self): + return self._image + @property def uuid(self): return self.id @@ -51,8 +56,8 @@ def delete(self, force=False): def stop(self): return self.raw.stop() - def cleanup(self): - return self.delete() + def cleanup(self, force=False): + return self.delete(force=force) def refresh(self): container = self._api.get(self.name) @@ -64,7 +69,7 @@ class Podman(System): def __init__( self, hostname, username, protocol="http+ssh", port=22, verify_ssl=False, **kwargs ): - super().__init__(kwargs) + super().__init__(hostname, username, protocol, port, verify_ssl, **kwargs) self.username = username self.hostname = hostname self.protocol = protocol @@ -101,10 +106,16 @@ def containers_collection(self): def containers(self): """Returns list of containers""" conInstance = [] - for cont in self.containers_collection.list(): - conInstance.append(PodmanContainer(system=self, name=cont.name, id=cont.id, raw=cont)) + for container in self.containers_collection.list(): + conInstance.append( + PodmanContainer( + system=self, raw=container, name=container.name, id=container.id, image=container.image + ) + ) return conInstance def get_container(self, key): container = self.containers_collection.get(key) - return PodmanContainer(system=self, name=container.name, id=container.id, raw=container) + return PodmanContainer( + system=self, raw=container, name=container.name, id=container.id, image=container.image + )