Skip to content

Commit

Permalink
Fixing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Sep 19, 2024
1 parent c6fd36e commit 1bdfdab
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions wrapanapi/systems/container/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
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
raw: Raw container object if already obtained, or None
"""
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'")

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
)

0 comments on commit 1bdfdab

Please sign in to comment.