You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On an ESX 5.5 system, if I log in with a user that has Read-Only access one VM on the host, a Get of RegisteredVirtualMachines will throw an exception at registeredVirtualMachines.Add(this.Open((string)runningVirtualMachine[0]));
In my use case, it is ok for me to skip VMs that I don't have access to because I am looking for a specific VM I do have access to. In my local build, I surrounded registeredVirtualMachines.Add(this.Open((string)runningVirtualMachine[0])); with an additional try block and "continue" on any exception for that one line.
I doubt this is the best solution but would like to find some solution where I can get the list of VMs without crashing the library if there is a VM in inventory that I don't have access to.
In case you are interested, the patch that works for my specific use case is:
It all depends what we think this interface should do in this case, in general. Just ignoring the VM would be wrong because from the API consumer POV they would not be getting all registered machines without any explanation why. Maybe we can replace Open by something else, ie. the VMs added here would not be "opened", but in a state that requires them to be "opened" to do something useful?
I don't know the other uses of the collection returned by "RegisteredVirtualMachines" (or also Powered). My use is just get me a collection of VM's with their path and name, and I will loop through that collection until I find the member that has the name or path that I want. Maybe your idea of just return the names and paths so the caller can "Open" or whatever a specific member would be good. It also might speed things up because right now getting RegisteredVirtualMachines takes about 10 seconds to return and I only have 77 VMs. However to get the VM's name, I think I need to open() the VM.
On an ESX 5.5 system, if I log in with a user that has Read-Only access one VM on the host, a Get of RegisteredVirtualMachines will throw an exception at registeredVirtualMachines.Add(this.Open((string)runningVirtualMachine[0]));
In my use case, it is ok for me to skip VMs that I don't have access to because I am looking for a specific VM I do have access to. In my local build, I surrounded registeredVirtualMachines.Add(this.Open((string)runningVirtualMachine[0])); with an additional try block and "continue" on any exception for that one line.
I doubt this is the best solution but would like to find some solution where I can get the list of VMs without crashing the library if there is a VM in inventory that I don't have access to.
In case you are interested, the patch that works for my specific use case is:
The text was updated successfully, but these errors were encountered: