Skip to content
New issue

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

Add support to check the power state of r/virtual_machine #916

Closed
uutest74 opened this issue Dec 2, 2019 · 13 comments · Fixed by #1407
Closed

Add support to check the power state of r/virtual_machine #916

uutest74 opened this issue Dec 2, 2019 · 13 comments · Fixed by #1407
Assignees
Labels
acknowledged Status: Issue or Pull Request Acknowledged area/vm Area: Virtual Machines enhancement Type: Enhancement
Milestone

Comments

@uutest74
Copy link

uutest74 commented Dec 2, 2019

Hi
How to check power state of VM and power on using terraform?
in this issue #327
you say that no plan to add power state of vm to terraform. I dont know why it so difficult to add this property to tfstate, simple option in vsphere_virtual_machine and 2 function from govmomi to power control vm...

But may be we can use null_resource for that? i dont know how to check power sate in triggers

P.S. In infrastructure as code concept if VM crashes and poweroff, how we power on it? Ansible not capable, Terraform aslo say all OK.... only manual...

@aareet aareet added the question/vsphere Question: VMware vSphere label Jan 17, 2020
@hashibot
Copy link

This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.

@hashibot hashibot added the stale Status: Stale label Jul 16, 2020
@arizvisa
Copy link
Contributor

arizvisa commented Aug 6, 2020

As per referenced issue, Terraform doesn't understand the concept of power off versus on. It's either on, or non-existent.

Nonetheless, you can use a null resource with the govc client using the vm.power command to flip it back on.

@ghost ghost removed stale Status: Stale labels Aug 6, 2020
@bill-rich bill-rich added the enhancement Type: Enhancement label Aug 18, 2020
@bill-rich
Copy link
Contributor

Given some recent changes and new use cases, we will actually be supporting power state management in VMs soon. It is high on our backlog.

@bill-rich bill-rich added the acknowledged Status: Issue or Pull Request Acknowledged label Aug 18, 2020
@eizedev
Copy link

eizedev commented Dec 9, 2020

@bill-rich
Any updates on this?
We also need the ability to change power state of a virtual machine during runtime and/or keep specific VMs powered off by default so they can be powered on later.
Thanks

@sumitmaggo
Copy link
Contributor

@bill-rich Any idea by when this enhancement will be taken up or already in progress?

@sumitmaggo
Copy link
Contributor

@uutest74 Have you been able to get around this power state management issue? Also, do you know what all changes will be needed to get this functionality into vsphere provider? Any help here would be really appreciated. Thanks in advance.

@arizvisa
Copy link
Contributor

@sumitmaggo, you might be able to use a provisioner in a "null_resource" (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) which uses the govc client (like govc vm.power) to power on the VM.

To determine the vm properties (and check the vm state), you'd combine that "null_resource" provisioner with an "external" provider (https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source) that queries the vm properties using govc vm.info with its -json=true parameter, so that you can access vm properties via the "result" output.

I haven't fiddled with tf v0.13 or v0.14's new lifecycle stuff, though (still on v0.12), so I'm not exactly 100% on this...

@sumitmaggo
Copy link
Contributor

@arizvisa Thanks for the details. Meanwhile I have created a pull request for checking the power state for VM and will wait for any feedback for the same.

@eizedev
Copy link

eizedev commented Apr 30, 2021

@bill-rich

Any updates on this?

We also need the ability to change power state of a virtual machine during runtime and/or keep specific VMs powered off by default so they can be powered on later.

Thanks

Anything new here?
Thanks

@lostplan
Copy link

+1 to this 🥺

I also have a use-case where I need to keep VMs powered down until required.

@arizvisa
Copy link
Contributor

@lostplan, it seems that PR #1407 is working on that. It might be beneficial to help facilitate the merging of that particular PR by testing it and giving opinions so that people don't lose interest and it stalls out.

@tenthirtyam tenthirtyam changed the title How to check power state of VM and power on using terraform? Add support to check the power state a virtual Feb 4, 2022
@tenthirtyam tenthirtyam changed the title Add support to check the power state a virtual Add support to check the power state a virtual machine resource Feb 4, 2022
@tenthirtyam tenthirtyam added needs-review Status: Pull Request Needs Review and removed question/vsphere Question: VMware vSphere needs-review Status: Pull Request Needs Review labels Feb 8, 2022
@tenthirtyam tenthirtyam changed the title Add support to check the power state a virtual machine resource Add support to check the power state of virtual_machine resource Feb 19, 2022
@tenthirtyam tenthirtyam added the area/vm Area: Virtual Machines label Feb 22, 2022
@tenthirtyam tenthirtyam added this to the v2.2.0 milestone Feb 24, 2022
@tenthirtyam tenthirtyam self-assigned this Feb 28, 2022
@tenthirtyam tenthirtyam changed the title Add support to check the power state of virtual_machine resource Add support to check the power state of r/virtual_machine Feb 28, 2022
@tenthirtyam tenthirtyam modified the milestones: v2.2.0, v2.1.1 Mar 8, 2022
@github-actions
Copy link

This functionality has been released in v2.1.1 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Apr 9, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
acknowledged Status: Issue or Pull Request Acknowledged area/vm Area: Virtual Machines enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants