mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[FIX] proxmox_kvm: fetch vm status from node-specific API endpoint to ensure fresh state (#7953)
* proxmox_kvm: fetch vm status from node-specific API endpoint to ensure fresh state, fixes #7817 * changelog fragments * Fix changelog fragment. --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
05bf5ee1df
commit
248e2ff321
2 changed files with 14 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- proxmox_kvm - fixed status check getting from node-specific API endpoint (https://github.com/ansible-collections/community.general/issues/7817).
|
|
@ -1547,8 +1547,9 @@ def main():
|
|||
status = {}
|
||||
try:
|
||||
vm = proxmox.get_vm(vmid)
|
||||
status['status'] = vm['status']
|
||||
if vm['status'] == 'running':
|
||||
current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status']
|
||||
status['status'] = current
|
||||
if current == 'running':
|
||||
module.exit_json(changed=False, vmid=vmid, msg="VM %s is already running" % vmid, **status)
|
||||
|
||||
if proxmox.start_vm(vm):
|
||||
|
@ -1563,9 +1564,9 @@ def main():
|
|||
status = {}
|
||||
try:
|
||||
vm = proxmox.get_vm(vmid)
|
||||
|
||||
status['status'] = vm['status']
|
||||
if vm['status'] == 'stopped':
|
||||
current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status']
|
||||
status['status'] = current
|
||||
if current == 'stopped':
|
||||
module.exit_json(changed=False, vmid=vmid, msg="VM %s is already stopped" % vmid, **status)
|
||||
|
||||
proxmox.stop_vm(vm, force=module.params['force'], timeout=module.params['timeout'])
|
||||
|
@ -1595,8 +1596,9 @@ def main():
|
|||
|
||||
status = {}
|
||||
vm = proxmox.get_vm(vmid)
|
||||
status['status'] = vm['status']
|
||||
if vm['status'] == 'stopped':
|
||||
current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status']
|
||||
status['status'] = current
|
||||
if current == 'stopped':
|
||||
module.exit_json(changed=False, vmid=vmid, msg="VM %s is not running" % vmid, **status)
|
||||
|
||||
if proxmox.restart_vm(vm, force=module.params['force']):
|
||||
|
@ -1613,8 +1615,9 @@ def main():
|
|||
module.exit_json(changed=False, vmid=vmid)
|
||||
|
||||
proxmox_node = proxmox.proxmox_api.nodes(vm['node'])
|
||||
status['status'] = vm['status']
|
||||
if vm['status'] == 'running':
|
||||
current = proxmox_node.qemu(vmid).status.current.get()['status']
|
||||
status['status'] = current
|
||||
if current == 'running':
|
||||
if module.params['force']:
|
||||
proxmox.stop_vm(vm, True, timeout=module.params['timeout'])
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue