-
Notifications
You must be signed in to change notification settings - Fork 175
Can't find a VM in a folder #117
Comments
It looks like
If you're expecting |
Hm, yea that is odd. Are there other APIs I could be missing? Such as to resolve a name to a UUID then do the recursive search on UUID? |
this has been an issue for a while. I've seen other users of rbvmomi use helper methods like this:
|
@swalberg I will definitely be adding this functionality, but it probably won't be this week. If you need this functionality really soon, I'd suggest doing what @sdorsett mentioned ☝️ for now. At least until I can add this functionality. It's a bummer that this is the case, but it's the best I can offer at the moment. |
the other way I've seen this done is to use a view to perform the search since it has a
|
@sdorsett yea we're doing something close to that right now and the problem is that it's really slow. Can take a minute or more in one of our DCs vs seconds when we use the index. I will look at that search that @sdorsett just mentioned... |
@swalberg Thanks for adding that that is slow. I'll make sure to consider that when evaluating possible solutions to this. |
Just did a quick test of the |
I talked to a coworker that has done some tweaking of our rbvmomi based auditing scripts and he recommended maybe trying something like this to filter what is being returned with the vm objects:
|
if you look at the returned vm object it will only contain a 'name' property:
...but you can still call any typical methods through .obj of this object:
|
Sorry I dropped the ball on this one... Playing around with it now and filtering the properties doesn't seem to help at all. Some co-workers who use powershell say that |
Thanks for the update. I'll see if I can find someone on the PowerCLI team that may have a few pointers on possible issues. |
Hi, Do we know if we plan to have a fix for this? I have tried to use the helper, but it is not returning the VM I am looking for. |
So far I seem to have something based on @sdorsett's work.
The key is not to look at |
This PR makes use of the [ContainerView](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.view.ViewManager.html) to retrieve a cut down list of servers from which the desired object can be found, after which the object itself can be downloaded. Previously, we'd download each VM (about 3.5K and several round trips to the server) to find the VM we want. From ``` sean~/play/knife-vsphere (find_speed %)$ time knife vsphere vm disk list myserver 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 1m56.153s user 0m9.536s sys 0m1.713s ``` to ``` sean~/play/knife-vsphere (find_speed *%)$ time be knife vsphere vm disk list myserver /Users/sean/.gem/ruby/2.4.1/gems/builder-3.2.2/lib/builder/xchar.rb:111: warning: constant ::Fixnum is deprecated 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 0m2.929s user 0m1.038s sys 0m0.236s ``` This'll have to be retrofitted to the other commands, which we can do over time. See vmware-archive/rbvmomi#117 for some more context
This PR makes use of the [ContainerView](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.view.ViewManager.html) to retrieve a cut down list of servers from which the desired object can be found, after which the object itself can be downloaded. Previously, we'd download each VM (about 3.5K and several round trips to the server) to find the VM we want. From ``` sean~/play/knife-vsphere (find_speed %)$ time knife vsphere vm disk list myserver 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 1m56.153s user 0m9.536s sys 0m1.713s ``` to ``` sean~/play/knife-vsphere (find_speed *%)$ time be knife vsphere vm disk list myserver /Users/sean/.gem/ruby/2.4.1/gems/builder-3.2.2/lib/builder/xchar.rb:111: warning: constant ::Fixnum is deprecated 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 0m2.929s user 0m1.038s sys 0m0.236s ``` This'll have to be retrofitted to the other commands, which we can do over time. See vmware-archive/rbvmomi#117 for some more context
This PR makes use of the [ContainerView](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.view.ViewManager.html) to retrieve a cut down list of servers from which the desired object can be found, after which the object itself can be downloaded. Previously, we'd download each VM (about 3.5K and several round trips to the server) to find the VM we want. From ``` sean~/play/knife-vsphere (find_speed %)$ time knife vsphere vm disk list myserver 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 1m56.153s user 0m9.536s sys 0m1.713s ``` to ``` sean~/play/knife-vsphere (find_speed *%)$ time be knife vsphere vm disk list myserver /Users/sean/.gem/ruby/2.4.1/gems/builder-3.2.2/lib/builder/xchar.rb:111: warning: constant ::Fixnum is deprecated 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 0m2.929s user 0m1.038s sys 0m0.236s ``` This'll have to be retrofitted to the other commands, which we can do over time. See vmware-archive/rbvmomi#117 for some more context
* Improve the speed of finding an individual VM This PR makes use of the [ContainerView](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.view.ViewManager.html) to retrieve a cut down list of servers from which the desired object can be found, after which the object itself can be downloaded. Previously, we'd download each VM (about 3.5K and several round trips to the server) to find the VM we want. From ``` sean~/play/knife-vsphere (find_speed %)$ time knife vsphere vm disk list myserver 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 1m56.153s user 0m9.536s sys 0m1.713s ``` to ``` sean~/play/knife-vsphere (find_speed *%)$ time be knife vsphere vm disk list myserver /Users/sean/.gem/ruby/2.4.1/gems/builder-3.2.2/lib/builder/xchar.rb:111: warning: constant ::Fixnum is deprecated 0 Hard disk 1 nosnapshots_ds4 64.00 GiB real 0m2.929s user 0m1.038s sys 0m0.236s ``` This'll have to be retrofitted to the other commands, which we can do over time. See vmware-archive/rbvmomi#117 for some more context * Use the new finding on property set * Add this to vm state, too * Add same thing to vm config * Add vm lookup to snapshot
Just want to share my result with latest rbvmomi 1.12.0, the issue is still there, vm template in folder cannot be found. I use vcenter kitchen driver and the only way to work is to place vm template in the root folder which is not allowed to have in most production vmware vcenter farms. |
I'll look into this again and see if I can figure out what's going on. |
@nimDevOps if you downgrade to the older |
@jrgarcia Thanks! I will wait for your suggestions/findings. |
Do you have any updates on this ? |
I'm trying to use the index to find a VM by its name in vsphere (as opposed to anything reported by the agent) rather than the current method of recursively finding all VMs and comparing the name.
dc.vmFolder.find('foo')
seems to work as long as the object is in the root and not a folder. However the otherfind
methods don't seem to care.This object is in a
Discovered virtual machine
folder.This is similar to #46. Doesn't seem to matter if I call
dc.find_vm 'foo'
ordc.vmFolder.find('foo')
.The text was updated successfully, but these errors were encountered: