1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #6914/17b4219b backport][stable-7] proxmox_kvm: enable 'force' restart of vm (as documented) (#6997)

proxmox_kvm: enable 'force' restart of vm (as documented) (#6914)

* enable 'force' restart of vm

* added changelog fragment

* Update changelogs/fragments/6914-proxmox_kvm-enable-force-restart.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 17b4219b8b)

Co-authored-by: Jeff Turner <jeff@torusoft.com>
This commit is contained in:
patchback[bot] 2023-07-23 22:53:02 +02:00 committed by GitHub
parent fb3768aada
commit 7d68af57af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- proxmox_kvm - enabled force restart of VM, bringing the ``force`` parameter functionality in line with what is described in the docs (https://github.com/ansible-collections/community.general/pull/6914).

View file

@ -1111,11 +1111,11 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
return False
return True
def restart_vm(self, vm, **status):
def restart_vm(self, vm, force, **status):
vmid = vm['vmid']
try:
proxmox_node = self.proxmox_api.nodes(vm['node'])
taskid = proxmox_node.qemu(vmid).status.reboot.post()
taskid = proxmox_node.qemu(vmid).status.reset.post() if force else proxmox_node.qemu(vmid).status.reboot.post()
if not self.wait_for_task(vm['node'], taskid):
self.module.fail_json(msg='Reached timeout while waiting for rebooting VM. Last line in task before timeout: %s' %
proxmox_node.tasks(taskid).log.get()[:1])
@ -1493,7 +1493,7 @@ def main():
if vm['status'] == 'stopped':
module.exit_json(changed=False, vmid=vmid, msg="VM %s is not running" % vmid, **status)
if proxmox.restart_vm(vm):
if proxmox.restart_vm(vm, force=module.params['force']):
module.exit_json(changed=True, vmid=vmid, msg="VM %s is restarted" % vmid, **status)
elif state == 'absent':