containers: Missing properties + string represenation
This commit is contained in:
parent
d27ff28f53
commit
aa7271c159
|
@ -13,7 +13,6 @@ class Container:
|
||||||
def __init__(self, data: dict):
|
def __init__(self, data: dict):
|
||||||
self._data = data
|
self._data = data
|
||||||
self.id = data['Id']
|
self.id = data['Id']
|
||||||
self.name = data['Name'].replace('/', '')
|
|
||||||
|
|
||||||
self._state = data.get('State')
|
self._state = data.get('State')
|
||||||
self._config = data.get('Config')
|
self._config = data.get('Config')
|
||||||
|
@ -87,6 +86,11 @@ class Container:
|
||||||
"""Is the container running?"""
|
"""Is the container running?"""
|
||||||
return self._state.get('Running', False)
|
return self._state.get('Running', False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
"""Container name"""
|
||||||
|
return self._data['Name'].replace('/', '')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def service_name(self) -> str:
|
def service_name(self) -> str:
|
||||||
"""Name of the container/service"""
|
"""Name of the container/service"""
|
||||||
|
@ -169,6 +173,12 @@ class Container:
|
||||||
|
|
||||||
return self.id == other.id
|
return self.id == other.id
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "<Container {}>".format(self.name)
|
||||||
|
|
||||||
|
|
||||||
class Mount:
|
class Mount:
|
||||||
"""Represents a volume mount (volume or bind)"""
|
"""Represents a volume mount (volume or bind)"""
|
||||||
|
|
Loading…
Reference in New Issue