I am adding a search feature into my app, and I'm looking for the best way to
search "everything". Below is my current method. If there a more efficient
method using the current library?
# search term
search = "esx"
pattern = re.compile(search, flags=re.IGNORECASE)
print "searching..."
items = server.get_hosts()
for item in items:
if pattern.search(items[item]):
print "host: %s" % items[item]
items = server.get_datastores()
for item in items:
if pattern.search(items[item]):
print "datastore: %s" % items[item]
items = server.get_clusters()
for item in items:
if pattern.search(items[item]):
print "cluster: %s" % items[item]
items = server.get_resource_pools()
for item in items:
if pattern.search(items[item]):
print "resource_pools: %s" % items[item]
vms = server.get_registered_vms()
for vm in vms:
if pattern.search(vm):
print "vm: %s" % vm
Original issue reported on code.google.com by j...@hogenmiller.net on 25 Sep 2012 at 9:32
Original issue reported on code.google.com by
j...@hogenmiller.net
on 25 Sep 2012 at 9:32