Skip to content

Commit cac5d92

Browse files
shwstpprCopilot
andauthored
Update extensions/HyperV/hyperv.py
Co-authored-by: Copilot <[email protected]>
1 parent 8376aa9 commit cac5d92

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

extensions/HyperV/hyperv.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ def status(self):
212212

213213
def statuses(self):
214214
command = 'Get-VM | Select-Object Name, State | ConvertTo-Json'
215-
vms = json.loads(self.run_ps(command))
215+
output = self.run_ps(command)
216+
if not output or output.strip() in ("", "null"):
217+
vms = []
218+
else:
219+
try:
220+
vms = json.loads(output)
221+
except json.JSONDecodeError:
222+
fail("Failed to parse VM status output: " + output)
216223
power_state = {}
217224
if isinstance(vms, dict):
218225
vms = [vms]

0 commit comments

Comments
 (0)