From 9942361877aaafab0dfed4ea61e8a8e569cf982f Mon Sep 17 00:00:00 2001 From: Hessel Bekema Date: Wed, 15 Feb 2023 23:12:51 +1100 Subject: [PATCH] only list vms for nodes that are online; prevents KeyError crashes --- vdiclient.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vdiclient.py b/vdiclient.py index 2d89327..b461339 100644 --- a/vdiclient.py +++ b/vdiclient.py @@ -172,7 +172,14 @@ def setmainlayout(): def getvms(listonly = False): vms = [] 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'): + if vm['node'] not in nodes: + continue if 'template' in vm and vm['template']: continue if G.guest_type == 'both' or G.guest_type == vm['type']: