only list vms for nodes that are online; prevents KeyError crashes

This commit is contained in:
Hessel Bekema 2023-02-15 23:12:51 +11:00
parent 7148fc85ed
commit 9942361877

View File

@ -172,7 +172,14 @@ def setmainlayout():
def getvms(listonly = False): def getvms(listonly = False):
vms = [] vms = []
try: try:
nodes = []
for node in G.proxmox.cluster.resources.get(type='node'):
if node['status'] == 'online':
nodes.append(node['node'])
for vm in G.proxmox.cluster.resources.get(type='vm'): for vm in G.proxmox.cluster.resources.get(type='vm'):
if vm['node'] not in nodes:
continue
if 'template' in vm and vm['template']: if 'template' in vm and vm['template']:
continue continue
if G.guest_type == 'both' or G.guest_type == vm['type']: if G.guest_type == 'both' or G.guest_type == vm['type']: