summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-11 10:54:24 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-11 12:13:00 +0000
commitf1b7d2919da032d819f47eb9a4e5373d75cf863d (patch)
tree27e074dfebf02375c6c7c9b4efc5960cc6157fd4 /lib
parentAdding CSV export format to container list command. (diff)
downloadcompute-tools-f1b7d2919da032d819f47eb9a4e5373d75cf863d.tar.xz
compute-tools-f1b7d2919da032d819f47eb9a4e5373d75cf863d.zip
Adding JSON export format to container list command.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/container/list36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/container/list b/lib/container/list
index 0347c78..a07b85b 100755
--- a/lib/container/list
+++ b/lib/container/list
@@ -117,6 +117,18 @@ List ()
echo "${HOST}${CSV_SEPARATOR}${CONTAINER}${CSV_SEPARATOR}${STATE}${CSV_SEPARATOR}${ADDRESS}"
;;
+ json)
+
+cat << EOF
+ {
+ "name": "${CONTAINER}",
+ "status": "${STATE}",
+ "ipv4Address": "${ADDRESS}",
+ },
+EOF
+
+ ;;
+
shell)
echo "${CONTAINER}"
;;
@@ -147,6 +159,21 @@ Host${CSV_SEPARATOR}Container${CSV_SEPARATOR}Status${CSV_SEPARATOR}IPv4-Address
EOF
;;
+
+ json)
+
+cat << EOF
+{
+ "container-tools": {
+ "version": "${VERSION}",
+ },
+ "host": {
+ "name": "${HOST}",
+ },
+ "container": [
+EOF
+
+ ;;
esac
CONTAINERS="$(cd "${MACHINES}" 2>/dev/null && find -maxdepth 1 -type d -and -not -name '.container-tools' -and -not -name 'container-tools' -and -not -name 'lost+found' -and -not -name '.snap' -and -not -name '.snapshot' -printf '%P\n' | sort)"
@@ -226,4 +253,13 @@ cat << EOF
EOF
;;
+
+ json)
+
+cat << EOF
+ ],
+}
+EOF
+
+ ;;
esac