summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-23 16:57:38 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-23 16:57:38 +0200
commit7762e74d928e9f23360798a21c8dd970579365b6 (patch)
tree0fd3fb95213d98d31f2e5995631170493f957193
parentf480f236d8bd43bbfc5928702a94d6b3684cbb68 (diff)
downloadvyos-1x-7762e74d928e9f23360798a21c8dd970579365b6.tar.gz
vyos-1x-7762e74d928e9f23360798a21c8dd970579365b6.zip
container: T2216: add option to "disable" a container
-rw-r--r--interface-definitions/containers.xml.in1
-rwxr-xr-xsrc/conf_mode/containers.py9
2 files changed, 9 insertions, 1 deletions
diff --git a/interface-definitions/containers.xml.in b/interface-definitions/containers.xml.in
index 286b4942a..d990e41a3 100644
--- a/interface-definitions/containers.xml.in
+++ b/interface-definitions/containers.xml.in
@@ -22,6 +22,7 @@
</properties>
</leafNode>
#include <include/generic-description.xml.i>
+ #include <include/generic-disable-node.xml.i>
<tagNode name="environment">
<properties>
<help>Add custom environment variables</help>
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py
index 97e84a5bb..5b863fa03 100755
--- a/src/conf_mode/containers.py
+++ b/src/conf_mode/containers.py
@@ -214,8 +214,15 @@ def apply(container):
# Add container
if 'name' in container:
for name, container_config in container['name'].items():
- # Check if the container has already been created
image = container_config['image']
+
+ if 'disable' in container_config:
+ # check if there is a container by that name running
+ tmp = _cmd('podman ps -a --format "{{.Names}}"')
+ if name in tmp:
+ _cmd(f'podman stop {name}')
+ continue
+
memory = container_config['memory']
restart = container_config['restart']