Skip to content

Instantly share code, notes, and snippets.

@happymcplaksin
Last active January 3, 2024 09:08
Show Gist options
  • Save happymcplaksin/4073601 to your computer and use it in GitHub Desktop.
Save happymcplaksin/4073601 to your computer and use it in GitHub Desktop.
Find VMware objects via rbvmomi
# Return all objects which match one of the types. types can be a
# string or an array
#
# For example:
# find_all(vim,'VirtualMachine')
def find_all(vim,types,startobj=vim.rootFolder)
# Allow types to be a string or an array.
types = [types].flatten
return vim.serviceContent.viewManager.CreateContainerView({:container => startobj, :type => types, :recursive => true}).view
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment