Files
infix/test/infamy/container.py
T
Joachim Wiberg 4202c07926 package/curios-httpd: bump to v24.05.0
- Fixes to missing BusyBox tools (cat)
 - Bump Buildroot to this year's LTS (2024.02)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00

46 lines
1.3 KiB
Python

"""Manage Infix containers"""
class Container:
"""Helper methods"""
IMAGE = "curios-httpd-v24.05.0.tar.gz"
def __init__(self, target):
self.system = target
def _find(self, name):
oper = self.system.get_data("/infix-containers:containers/container")
if not oper:
return None
for container in oper["containers"]["container"]:
if container["name"] == name:
return container
return None
def exists(self, name):
"""Check if container {name} runs on target."""
container = self._find(name)
if not container:
return False
return True
def running(self, name):
"""Check if container {name} exists and is running."""
container = self._find(name)
if container and container["running"]:
return True
return False
def action(self, name, act):
"""Call NETCONF action 'type' on container 'name'"""
return self.system.call_action_dict("infix-containers", {
"containers": {
"container": [
{
"name": f"{name}",
f"{act}": {}
}
]
}
})