Skip to content

Commit d2f0ec5

Browse files
authored
proxmox_vm_info: Do not throw exception when iterating through machines and optional api results are missing (#191)
* proxmox_vm_info: Do not throw exception when iterating through machines and optional api results are missing * changelog fragment
1 parent 6e4e92d commit d2f0ec5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- proxmox_vm_info - do not throw exception when iterating through machines and optional api results are missing (https://github.com/ansible-collections/community.proxmox/pull/191)

plugins/modules/proxmox_vm_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ def get_vms_from_nodes(self, cluster_machines, type, vmid=None, name=None, node=
177177
filtered_vms = {
178178
vm: info for vm, info in cluster_machines.items() if not (
179179
type != info["type"]
180-
or (node and info["node"] != node)
181-
or (vmid and int(info["vmid"]) != vmid)
182-
or (name is not None and info["name"] != name)
180+
or (node and info.get("node") != node)
181+
or (vmid and int(info.get("vmid", -1)) != vmid)
182+
or (name is not None and info.get("name") != name)
183183
)
184184
}
185185
# Get list of unique node names and loop through it to get info about machines.
186-
nodes = frozenset([info["node"] for vm, info in filtered_vms.items()])
186+
nodes = frozenset([info["node"] for vm, info in filtered_vms.items() if "node" in info])
187187
for this_node in nodes:
188188
# "type" is mandatory and can have only values of "qemu" or "lxc". Seems that use of reflection is safe.
189189
call_vm_getter = getattr(self.proxmox_api.nodes(this_node), type)

0 commit comments

Comments
 (0)