Files
infix/test/infamy/container.py
T
Mattias WalströmandTobias Waldekranz 60e8b24d01 infamy: Refactor xpath handling between restconf and netconf implmentation
Previous xpath may or may not been an xpath, we still called it xpath.
Remove the obscure function get_xpath() and instead transform to a
URI in restconf.py

This fix issue #490

Signed-off-by: Mattias Walström <lazzer@gmail.com>
2024-08-16 16:50:13 +02:00

36 lines
1.0 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")
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):
return self.system.call_action(f"/infix-containers:containers/container[name='{name}']/{act}")