grr/server/grr_response_server/databases/mysql_clients.py
def MultiReadClientMetadata(self, client_ids, cursor=None):
    """Reads ClientMetadata records for a list of clients."""
    ids = [mysql_utils.ClientIDToInt(client_id) for client_id in client_ids]
    query = ("SELECT client_id, fleetspeak_enabled, certificate, last_ping, "
             "last_clock, last_ip, last_foreman, first_seen, "
             "last_crash_timestamp, last_startup_timestamp FROM "
             "clients WHERE client_id IN ({})").format(", ".join(
                 ["%s"] * len(ids)))
    ret = {}
    cursor.execute(query, ids)
    while True:
      row = cursor.fetchone()
      if not row:
        break
      cid, fs, crt, ping, clk, ip, foreman, first, lct, lst = row
      ret[mysql_utils.IntToClientID(cid)] = rdf_objects.ClientMetadata(
          certificate=crt,
          fleetspeak_enabled=fs,
          first_seen=mysql_utils.MysqlToRDFDatetime(first),
          ping=mysql_utils.MysqlToRDFDatetime(ping),
          clock=mysql_utils.MysqlToRDFDatetime(clk),
          ip=mysql_utils.StringToRDFProto(rdf_client_network.NetworkAddress,
                                          ip),
          last_foreman_time=mysql_utils.MysqlToRDFDatetime(foreman),
          startup_info_timestamp=mysql_utils.MysqlToRDFDatetime(lst),
          last_crash_timestamp=mysql_utils.MysqlToRDFDatetime(lct))
    return ret
Reads ClientMetadata records for a list of clients.
Reads ClientMetadata records for a list of clients.
Reads ClientMetadata records for a list of clients .
def MultiReadClientMetadata(self, client_ids, cursor=None):
    ids = [mysql_utils.ClientIDToInt(client_id) for client_id in client_ids]
    query = ("SELECT client_id, fleetspeak_enabled, certificate, last_ping, "
             "last_clock, last_ip, last_foreman, first_seen, "
             "last_crash_timestamp, last_startup_timestamp FROM "
             "clients WHERE client_id IN ({})").format(", ".join(
                 ["%s"] * len(ids)))
    ret = {}
    cursor.execute(query, ids)
    while True:
      row = cursor.fetchone()
      if not row:
        break
      cid, fs, crt, ping, clk, ip, foreman, first, lct, lst = row
      ret[mysql_utils.IntToClientID(cid)] = rdf_objects.ClientMetadata(
          certificate=crt,
          fleetspeak_enabled=fs,
          first_seen=mysql_utils.MysqlToRDFDatetime(first),
          ping=mysql_utils.MysqlToRDFDatetime(ping),
          clock=mysql_utils.MysqlToRDFDatetime(clk),
          ip=mysql_utils.StringToRDFProto(rdf_client_network.NetworkAddress,
                                          ip),
          last_foreman_time=mysql_utils.MysqlToRDFDatetime(foreman),
          startup_info_timestamp=mysql_utils.MysqlToRDFDatetime(lst),
          last_crash_timestamp=mysql_utils.MysqlToRDFDatetime(lct))
    return ret
def MultiReadClientMetadata ( self , client_ids , cursor = None ) : ids = [ mysql_utils . ClientIDToInt ( client_id ) for client_id in client_ids ] query = ( "SELECT client_id, fleetspeak_enabled, certificate, last_ping, " "last_clock, last_ip, last_foreman, first_seen, " "last_crash_timestamp, last_startup_timestamp FROM " "clients WHERE client_id IN ({})" ) . format ( ", " . join ( [ "%s" ] * len ( ids ) ) ) ret = { } cursor . execute ( query , ids ) while True : row = cursor . fetchone ( ) if not row : break cid , fs , crt , ping , clk , ip , foreman , first , lct , lst = row ret [ mysql_utils . IntToClientID ( cid ) ] = rdf_objects . ClientMetadata ( certificate = crt , fleetspeak_enabled = fs , first_seen = mysql_utils . MysqlToRDFDatetime ( first ) , ping = mysql_utils . MysqlToRDFDatetime ( ping ) , clock = mysql_utils . MysqlToRDFDatetime ( clk ) , ip = mysql_utils . StringToRDFProto ( rdf_client_network . NetworkAddress , ip ) , last_foreman_time = mysql_utils . MysqlToRDFDatetime ( foreman ) , startup_info_timestamp = mysql_utils . MysqlToRDFDatetime ( lst ) , last_crash_timestamp = mysql_utils . MysqlToRDFDatetime ( lct ) ) return ret
Reads ClientMetadata records for a list of clients.
Reads ClientMetadata records for a list of clients .
"""Reads ClientMetadata records for a list of clients."""
self
client_ids
cursor