summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Ritter2022-12-06 17:25:54 +0100
committerSteffen Ritter2022-12-06 17:25:54 +0100
commitb4a9c0e3c5b9bf79d67f122191b0e9830dba9a30 (patch)
treeb3c7e50d41f126323435087c7f00a1f574ebea61
parentHopefully the last readme fix (diff)
downloadvm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.tar.gz
vm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.tar.xz
vm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.zip
Add argument to format output as jsonHEADmaster
-rwxr-xr-xinspect.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/inspect.py b/inspect.py
index a6a3e9e..e89ffbd 100755
--- a/inspect.py
+++ b/inspect.py
@@ -4,6 +4,7 @@ import argparse
import logging
import os
import sys
+import json
from tools import libvmdk, libvslvm, lklfuse, nbdfuse, subfiles, unmount, rmdir
from tools.inspect_apps import (
@@ -27,6 +28,8 @@ parser.add_argument("-b", "--backend", type=str, default="nbdfuse",
"local filesystem (default: nbdfuse)")
parser.add_argument("-v", "--verbose", action="store_true",
help="print debug messages")
+parser.add_argument("--json", action="store_true",
+ help="format output as json")
args = parser.parse_args()
@@ -114,8 +117,14 @@ if lvm_mp:
unmount(image_mp)
rmdir(image_mp)
-print({
+output = {
"name": os_info.get("name", ""),
"version": os_info.get("version", ""),
"apps": apps
-})
+}
+
+if args.json:
+ print(json.dumps(output, indent = 2))
+else:
+ print(output)
+