summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-04-21 18:55:23 +0200
committerChristian Poessinger <christian@poessinger.com>2021-04-21 19:09:53 +0200
commit38d0e8bd71b83a954dd372b66ba7f7a1c3ef7c78 (patch)
tree23c8cd6c743b6bf33df471e6d891ec08e5eedefc
parent6ea6a759e249b27aca03216fae534a534856e2c8 (diff)
downloadvyos-1x-38d0e8bd71b83a954dd372b66ba7f7a1c3ef7c78.tar.gz
vyos-1x-38d0e8bd71b83a954dd372b66ba7f7a1c3ef7c78.zip
containers: T2216: add op-mode "show container network" command
-rw-r--r--op-mode-definitions/containers.xml.in8
-rwxr-xr-xsrc/op_mode/containers_op.sh11
2 files changed, 17 insertions, 2 deletions
diff --git a/op-mode-definitions/containers.xml.in b/op-mode-definitions/containers.xml.in
index 06f98b24e..a530bcff4 100644
--- a/op-mode-definitions/containers.xml.in
+++ b/op-mode-definitions/containers.xml.in
@@ -44,10 +44,16 @@
<children>
<leafNode name="image">
<properties>
- <help>Delete container image</help>
+ <help>Show available container images</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/containers_op.sh --show-images</command>
</leafNode>
+ <leafNode name="network">
+ <properties>
+ <help>Show available container networks</help>
+ </properties>
+ <command>sudo ${vyos_op_scripts_dir}/containers_op.sh --show-networks</command>
+ </leafNode>
</children>
</node>
</children>
diff --git a/src/op_mode/containers_op.sh b/src/op_mode/containers_op.sh
index bdc0ead98..9c410bd7f 100755
--- a/src/op_mode/containers_op.sh
+++ b/src/op_mode/containers_op.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Expect 2 args or "show-containers" or "show-images"
-if [[ $# -ne 2 ]] && [[ $1 != "--show-containers" ]] && [[ $1 != "--show-images" ]] ; then
+if [[ $# -ne 2 ]] && [[ $1 != "--show-containers" ]] && [[ $1 != "--show-images" ]] && [[ $1 != "--show-networks" ]] ; then
echo "Image not set or not found"
exit 1
fi
@@ -29,6 +29,10 @@ show_images() {
sudo podman image ls
}
+# Show networks
+show_networks() {
+ sudo podman network ls
+}
if [ "$OPTION" = "--pull" ]; then
pull_image
@@ -45,6 +49,11 @@ if [ "$OPTION" = "--show-containers" ]; then
exit 0
fi
+if [ "$OPTION" = "--show-networks" ]; then
+ show_networks
+ exit 0
+fi
+
if [ "$OPTION" = "--show-images" ]; then
show_images
exit 0