def SearchClients(query_str, token=None, limit=1000):
  client_schema = aff4.AFF4Object.classes["VFSGRRClient"].SchemaCls
  index = aff4.FACTORY.Create(
      client_index.MAIN_INDEX,
      aff4_type="ClientIndex", mode="rw", token=token)

  client_list = index.LookupClients([query_str])
  result_set = aff4.FACTORY.MultiOpen(client_list, token=token)
  results = []
  for result in result_set:
    results.append((result,
                    str(result.Get(client_schema.HOSTNAME)),
                    str(result.Get(client_schema.OS_VERSION)),
                    str(result.Get(client_schema.PING))))
    if len(results) >= limit:
      break

  return results
Search indexes for clients. Returns list (client, hostname, os version).
dataset/ETHPy150Open google/grr/grr/lib/console_utils.py/SearchClients