|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import gzip |
4 | | -import json |
| 4 | +import json as jsonlib |
5 | 5 | import lzma |
6 | 6 | import struct |
7 | 7 | import subprocess |
@@ -189,12 +189,12 @@ def vm_inventory(self) -> Iterator[VirtualMachineRecord]: |
189 | 189 |
|
190 | 190 | @export(output="none") |
191 | 191 | @arg("path", help="config path") |
192 | | - @arg("--as-json", action="store_true", help="format as json") |
193 | | - def esxconf(self, path: str, as_json: bool) -> None: |
| 192 | + @arg("-j", "--json", action="store_true", help="output in JSON format") |
| 193 | + def esxconf(self, path: str, json: bool) -> None: |
194 | 194 | obj = self._cfg(path) |
195 | 195 |
|
196 | | - if as_json: |
197 | | - print(json.dumps(obj, indent=4, sort_keys=True)) |
| 196 | + if json: |
| 197 | + print(jsonlib.dumps(obj, indent=4, sort_keys=True)) |
198 | 198 | else: |
199 | 199 | print(obj) |
200 | 200 |
|
@@ -578,11 +578,11 @@ def parse_config_store(fh: BinaryIO) -> dict[str, Any]: |
578 | 578 | identifier["creation_time"] = row.CreationTime |
579 | 579 | identifier["version"] = row.Version |
580 | 580 | identifier["success"] = row.Success |
581 | | - identifier["auto_conf_value"] = json.loads(row.AutoConfValue) if row.AutoConfValue else None |
582 | | - identifier["user_value"] = json.loads(row.UserValue) if row.UserValue else None |
583 | | - identifier["vital_value"] = json.loads(row.VitalValue) if row.VitalValue else None |
584 | | - identifier["cached_value"] = json.loads(row.CachedValue) if row.CachedValue else None |
585 | | - identifier["desired_value"] = json.loads(row.DesiredValue) if row.DesiredValue else None |
| 581 | + identifier["auto_conf_value"] = jsonlib.loads(row.AutoConfValue) if row.AutoConfValue else None |
| 582 | + identifier["user_value"] = jsonlib.loads(row.UserValue) if row.UserValue else None |
| 583 | + identifier["vital_value"] = jsonlib.loads(row.VitalValue) if row.VitalValue else None |
| 584 | + identifier["cached_value"] = jsonlib.loads(row.CachedValue) if row.CachedValue else None |
| 585 | + identifier["desired_value"] = jsonlib.loads(row.DesiredValue) if row.DesiredValue else None |
586 | 586 | identifier["revision"] = row.Revision |
587 | 587 |
|
588 | 588 | return store |
|
0 commit comments