Last active
January 3, 2024 09:08
-
-
Save happymcplaksin/4073601 to your computer and use it in GitHub Desktop.
Find VMware objects via rbvmomi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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