Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Search Folder by uuid => Instance #68

Closed
forlornlawngnome opened this issue Jul 10, 2015 · 3 comments
Closed

Search Folder by uuid => Instance #68

forlornlawngnome opened this issue Jul 10, 2015 · 3 comments

Comments

@forlornlawngnome
Copy link

The code for searching a folder in the method findByUuid allows for searching by instanceUuid which is the only unchanging and completely unique identifier for a VM. However, this implementation of it forces the instanceUuid to always be false. It would be nice if we could pass in a parameter to allow usage of instance Uuid.

Relevant code: (In VIM/Folder.rb)
def findByUuid uuid, type=RbVmomi::VIM::VirtualMachine, dc=nil
propSpecs = {
:entity => self, :uuid => uuid, :instanceUuid => false,
:vmSearch => type == RbVmomi::VIM::VirtualMachine
}
propSpecs[:datacenter] = dc if dc
x = _connection.searchIndex.FindByUuid(propSpecs)
x if x.is_a? type
end

Note the force set of :instanceUuid to false with no option to make it true

@cdickmann
Copy link
Contributor

I would suggest that you simply add such a convenience function yourself. You can easily do this by adding such a construct to your code. RbVmomi is meant as a minimalist wrapper around the API. We have a few convenience functions, but overall we encourage those not to get bloated. The underlying API has what you need, so it's best to just go ahead and use it.
RbVmomi::VIM::Folder
class RbVmomi::VIM::Folder
def findByUuidEx(...)
....
end
end

@forlornlawngnome
Copy link
Author

Bloated? You could just modify this method to include it as an optional parameter:

def findByUuid uuid, type=RbVmomi::VIM::VirtualMachine, dc=nil, instanceUuid=false
propSpecs = {
:entity => self, :uuid => uuid, :instanceUuid => instanceUuid,
:vmSearch => type == RbVmomi::VIM::VirtualMachine
}
propSpecs[:datacenter] = dc if dc
x = _connection.searchIndex.FindByUuid(propSpecs)
x if x.is_a? type
end

Such a minor change and it's a method people use a lot in all of the various languages

@rylarson
Copy link

rylarson commented Sep 1, 2015

It would probably be easier to get it added if you submitted a PR with the required tests and what not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants