Created
April 28, 2014 12:40
-
-
Save complexsplit/11370646 to your computer and use it in GitHub Desktop.
Searching datastores w/ pyVmomi
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
from pyVim.connect import SmartConnect, Disconnect | |
from pyVmomi import vim, vmodl | |
import argparse | |
import atexit | |
import sys | |
import pprint | |
si = SmartConnect(host="192.168.1.7", user="root", pwd="vmware") | |
servcontent = si.RetrieveServiceContent() | |
rf = servcontent.rootFolder | |
dc = rf.childEntity # what does this return? hint: look at the docs, or MOB | |
hostdatastorebrowser = dc[0].datastore[0].browser | |
# following is optional. without a SearchSpec, it will just find everything. | |
# searchspec = vim.Host.DatastoreBrowserSearchSpec() | |
# what if we wanted to find only .vmx files? | |
task = hostdatastorebrowser.SearchDatastore_Task(datastorePath='[datastore1]') | |
pp = pprint.PrettyPrinter() | |
pp.pprint(task.info.result) | |
print task.info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment