-
Notifications
You must be signed in to change notification settings - Fork 914
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 datacenter and URL to the output of "govc vm.info" command. #2855
Comments
Howdy 🖐 bschonec ! Thank you for your interest in this project. We value your feedback and will respond soon. If you want to contribute to this project, please make yourself familiar with the |
Am I understanding correctly that you lose the Ansible context (variables) after executing the
This is harder than it sounds, unfortunately. The vCenter inventory is a hierarchical tree structure. There is no "direct" reference between a IMHO One would have to traverse the inventory upwards from the cc/ @dougm in case he has a better option. |
The URL and the datacenter are provided to govc on the command line. When then VM is found, why not just spit out those two (or all) command-line values in the JSON output? |
I'm still not 100% clear on the request since those parameters are known to the caller anyways. Any matching response from govc will be based on these parameters. So why do you see the need to change the code and make it part of the API if those values are known upfront? |
This issue is stale because it has been open for 90 days with no |
In order to find a VM one needs to know which datacenter to search. In my case, I have multiple datacenters in my infrastructure so I have to search all of them so that I know I've searched everywhere. Take a look at the vmware dictionary (above). Ansible needs to query each datacenter with the govc binary via a loop in code. If the VM isn't found then the next datacenter(s) need(s) to be queried until the VM is found. You're left with an array of dicts that MIGHT contain the VM found. You then need to loop around all of the elements in the array to see if the VM is found. If the VM is found in the element of the array then it would be nice to have the information you need to reconnect to the VMware infrastructure in order to do work on that VM (in my case, take a snapshot). |
/remove-lifecycle stale |
This issue is stale because it has been open for 90 days with no |
I'm trying to keep this request alive because it's not possible in ansible to 'remember' the datacenter when using a loop. There's no functionality to provide "If vm is found then set a variable and break out of a loop". It would seem to me that'd it be pretty simple to return the datacenter when the VM is found. |
This issue is stale because it has been open for 90 days with no |
Use Case:
I'm using Ansible to find a VM that could be in one of many datacenters or VMWare installations so that I can then create or delete a VM snapshot. Looping around a list, I do a:
./govc vm.info -u {{ url }} -dc={{ datacenter}} -json my_VM_to_find
for each item in my list. govc then returns a hash with "VirtualMachines" value of either null or the information about the VM.
Unfortunately, the datacenter and URL used in the Ansible command are lost in the resulting output making it very difficult to determine where the VM was found.
It would be extremely helpful to return the URL and datacenter in the JSON output of vm.info.
Example-ish Ansible code:
At this point, I have a six-element variable that contains either the found VM or "{"VirtualMachines":null}". Unfortunately, the URL and datacenter information are lost and I have no easy way to determine where that VM is.
The text was updated successfully, but these errors were encountered: