diff options
author | Steffen Ritter | 2022-12-06 17:25:54 +0100 |
---|---|---|
committer | Steffen Ritter | 2022-12-06 17:25:54 +0100 |
commit | b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30 (patch) | |
tree | b3c7e50d41f126323435087c7f00a1f574ebea61 | |
parent | Hopefully the last readme fix (diff) | |
download | vm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.tar.gz vm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.tar.xz vm-inspector-b4a9c0e3c5b9bf79d67f122191b0e9830dba9a30.zip |
-rwxr-xr-x | inspect.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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) + |