Created
December 4, 2014 00:23
-
-
Save hartsock/af6d92c77367a9d5d108 to your computer and use it in GitHub Desktop.
Find a virtual machine by it's datastore path
This file contains hidden or 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
si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
content = si.RetrieveContent() | |
datacenters = [entity for entity in content.rootFolder.childEntity | |
if hasattr(entity, 'vmFolder')] | |
dc = None | |
for datacenter in datacenters: | |
if datacenter.name == 'my_datacenter': | |
dc = datacenter | |
search = content.searchIndex | |
vm = search.FindByDatastorePath(dc, '[my_datastore_name] my_vm/my_vm.vmx') | |
# proof: | |
print(vm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: you will need to know,