From 7e7c6a5f120f317e3e4555939a099f48cf0b27e0 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 8 May 2022 21:52:51 +0200 Subject: container: op-mode: T3852: use XML inline podman commands Reduce bloat of containers_op.py wrapper script. All commands can be passed directly to podman via the XML script. This also makes the execution faster, as no Python environment needs to be build up. --- op-mode-definitions/container.xml.in | 176 ++++++++++++++++++++++++++++++++++ op-mode-definitions/containers.xml.in | 176 ---------------------------------- 2 files changed, 176 insertions(+), 176 deletions(-) create mode 100644 op-mode-definitions/container.xml.in delete mode 100644 op-mode-definitions/containers.xml.in (limited to 'op-mode-definitions') diff --git a/op-mode-definitions/container.xml.in b/op-mode-definitions/container.xml.in new file mode 100644 index 000000000..fa66402dc --- /dev/null +++ b/op-mode-definitions/container.xml.in @@ -0,0 +1,176 @@ + + + + + + + Add container image + + + + + Pull a new image for container + + sudo podman image pull "${4}" + + + + + + + + + + Attach to a running container + + container name + + + sudo podman exec --interactive --tty "$3" /bin/sh + + + + + + + + Delete container image + + + + + Delete container image + + + + + sudo podman image rm --force "${4}" + + + + + + + + + + Generate Container Image + + + + + Name of container image (tag) + + + + + Path to Dockerfile + + <filename> + + + sudo podman build --layers --force-rm --tag "$4" $6 + + + + + + + + + + + + + + Monitor last lines of container logs + + container name + + + sudo podman logs --follow --names "$4" + + + + + + + + + + Show containers + + sudo podman ps --all + + + + Show container image + + sudo podman image ls + + + + Show logs from a given container + + container name + + + sudo podman logs --names "$4" + + + + Show available container networks + + sudo podman network ls + + + + + + + + Show logs from a given container + + container name + + + sudo podman logs --names "$4" + + + + + + + + + + Restart a given container + + container name + + + sudo podman restart "$3" + + + + + + + + Update a container image + + + + + Update container image + + container name + + + if cli-shell-api existsActive container name "$4"; then sudo podman pull $(cli-shell-api returnActiveValue container name "$4" image); else echo "Container $4 does not exist"; fi + + + + + + diff --git a/op-mode-definitions/containers.xml.in b/op-mode-definitions/containers.xml.in deleted file mode 100644 index 48501bd84..000000000 --- a/op-mode-definitions/containers.xml.in +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - Add container image - - - - - Pull a new image for container - - sudo ${vyos_op_scripts_dir}/containers_op.py --pull "${4}" - - - - - - - - - - Attach to a running container - - container name - - - sudo podman exec --interactive --tty "$3" /bin/sh - - - - - - - - Delete container image - - - - - Delete container image - - - - - sudo ${vyos_op_scripts_dir}/containers_op.py --remove "${4}" - - - - - - - - - - Generate Container Image - - - - - Name of container image (tag) - - - - - Path to Dockerfile - - <filename> - - - sudo podman build --layers --force-rm --tag "$4" $6 - - - - - - - - - - - - - - Monitor last lines of container logs - - container name - - - sudo podman logs --follow --names "$4" - - - - - - - - - - Show containers - - sudo ${vyos_op_scripts_dir}/containers_op.py --all - - - - Show container image - - sudo ${vyos_op_scripts_dir}/containers_op.py --image - - - - Show logs from a given container - - container name - - - sudo podman logs --names "$4" - - - - Show available container networks - - sudo ${vyos_op_scripts_dir}/containers_op.py --networks - - - - - - - - Show logs from a given container - - container name - - - sudo podman logs --names "$4" - - - - - - - - - - Restart a given container - - container name - - - sudo podman restart "$3" - - - - - - - - Update a container image - - - - - Update container image - - container name - - - sudo ${vyos_op_scripts_dir}/containers_op.py --update "${4}" - - - - - - -- cgit v1.2.3