summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-01-09 14:42:06 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-01-09 15:39:37 -0600
commitf440fbc9ba9019b25fb9f059357052701d990ef3 (patch)
treeaa5fa3aa205371c23663e978507ee57b4fbc4a32 /src
parent2fc4f15353eb9ec3788693b87cd2b8fee1d4eafa (diff)
downloadvyos-1x-f440fbc9ba9019b25fb9f059357052701d990ef3.tar.gz
vyos-1x-f440fbc9ba9019b25fb9f059357052701d990ef3.zip
container: T4880: expose add_image/delete_image functions in op-mode
Encapsulating the add/delete image commands in the op-mode script allows automatic generation of corresponding API schema definitions.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/container.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/op_mode/container.py b/src/op_mode/container.py
index ecefc556e..d48766a0c 100755
--- a/src/op_mode/container.py
+++ b/src/op_mode/container.py
@@ -35,6 +35,19 @@ def _get_raw_data(command: str) -> list:
data = json.loads(json_data)
return data
+def add_image(name: str):
+ from vyos.util import rc_cmd
+
+ rc, output = rc_cmd(f'podman image pull {name}')
+ if rc != 0:
+ raise vyos.opmode.InternalError(output)
+
+def delete_image(name: str):
+ from vyos.util import rc_cmd
+
+ rc, output = rc_cmd(f'podman image rm --force {name}')
+ if rc != 0:
+ raise vyos.opmode.InternalError(output)
def show_container(raw: bool):
command = 'podman ps --all'