From 4d22d0790d362e2e28ba3772ecc6255ae278d3a9 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 20:04:43 +0200 Subject: [PATCH] Correctly handle exception when no VM name returned by proxmox (#4508) (#4529) (cherry picked from commit 8076f16aa95b880094187cb788d6c9ea34ac3da3) Co-authored-by: Marcin --- changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml | 2 ++ plugins/modules/cloud/misc/proxmox_kvm.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml diff --git a/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml b/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml new file mode 100644 index 0000000000..94efa9133b --- /dev/null +++ b/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_kvm - fix a bug when getting a state of VM without name will fail (https://github.com/ansible-collections/community.general/pull/4508). diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 6bfb9e2e19..f80848c4c4 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -1397,7 +1397,7 @@ def main(): module.fail_json(msg='VM with name = %s does not exist in cluster' % name) vm = proxmox.get_vm(vmid) if not name: - name = vm['name'] + name = vm.get('name', '(unnamed)') current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status'] status['status'] = current if status: