We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I try to bulk hibernate all VMs on a node, rather than shutting them down to reboot this node. That would save the vmstates.
Feature Idea
proxmox_kvm
- name: hibernate all vms community.general.proxmox_kvm: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" vmid: "{{ vmid }}" state: hibernate
possible solution could be:
[...] def suspend_vm(self, vm, timeout, todisk): vmid = vm['vmid'] proxmox_node = self.proxmox_api.nodes(vm['node']) taskid = proxmox_node.qemu(vmid).status.suspend.post(todisk=(1 if todisk else 0), timeout=timeout) if not self.wait_for_task(vm['node'], taskid): self.module.fail_json(msg='Reached timeout while waiting for suspending VM. Last line in task before timeout: %s' % proxmox_node.tasks(taskid).log.get()[:1]) return False return True def resume_vm(self, vm): vmid = vm['vmid'] proxmox_node = self.proxmox_api.nodes(vm['node']) taskid = proxmox_node.qemu(vmid).status.resume.post() if not self.wait_for_task(vm['node'], taskid): self.module.fail_json(msg='Reached timeout while waiting for suspending VM. Last line in task before timeout: %s' % proxmox_node.tasks(taskid).log.get()[:1]) return False return True [...] def main(): module_args = proxmox_auth_argument_spec() kvm_args = dict( [...] state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted', 'current', 'template', 'paused', 'hibernated']), [...] elif state == 'started': if not vmid: module.fail_json(msg='VM with name = %s does not exist in cluster' % name) status = {} try: vm = proxmox.get_vm(vmid) current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status'] status['status'] = current if current == 'running' and status['qmpstatus'] == 'running': module.exit_json(changed=False, vmid=vmid, msg="VM %s is already running" % vmid, **status) if status['qmpstatus'] == 'paused' or \ (current == 'stopped' and status['qmpstatus'] == 'stopped' and status['lock'] == 'suspended'): proxmox.resume_vm(vm) module.exit_json(changed=True, vmid=vmid, msg="VM %s resumed" % vmid, **status) if proxmox.start_vm(vm): module.exit_json(changed=True, vmid=vmid, msg="VM %s started" % vmid, **status) except Exception as e: module.fail_json(vmid=vmid, msg="starting of VM %s failed with exception: %s" % (vmid, e), **status) [...] elif state in ['paused', 'hibernated']: if not vmid: module.fail_json(msg='VM with name = %s does not exist in cluster' % name) status = {} try: vm = proxmox.get_vm(vmid) 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 not running" % vmid, **status) proxmox.suspend_vm(vm, force=module.params['force'], timeout=module.params['timeout'], todisk=(state == 'hibernated')) module.exit_json(changed=True, vmid=vmid, msg="VM %s is suspending" % vmid, **status) except Exception as e: module.fail_json(vmid=vmid, msg="suspending of VM %s failed with exception: %s" % (vmid, e), **status)
The text was updated successfully, but these errors were encountered:
Files identified in the description:
plugins/modules/proxmox_kvm.py
If these files are incorrect, please update the component name section of the description or use the !component bot command.
component name
!component
click here for bot help
Sorry, something went wrong.
cc @Ajpantuso @Thulium-Drake @UnderGreen @helldorado @joshainglis @karmab @krauthosting click here for bot help
Hi @ff05 thanks for your contribution!
Would you be willing to raise a Pull Request with your suggested change?
Hi @russoz I raised the request here #9653
No branches or pull requests
Summary
I try to bulk hibernate all VMs on a node, rather than shutting them down to reboot this node.
That would save the vmstates.
Issue Type
Feature Idea
Component Name
proxmox_kvm
Additional Information
possible solution could be:
Code of Conduct
The text was updated successfully, but these errors were encountered: