grr/server/grr_response_server/databases/mysql_clients.py
def _ResponseToClientsFullInfo(self, response):
    """Creates a ClientFullInfo object from a database response."""
    c_full_info = None
    prev_cid = None
    for row in response:
      (cid, fs, crt, ping, clk, ip, foreman, first, last_client_ts,
       last_crash_ts, last_startup_ts, client_obj, client_startup_obj,
       last_startup_obj, label_owner, label_name) = row

      if cid != prev_cid:
        if c_full_info:
          yield mysql_utils.IntToClientID(prev_cid), c_full_info

        metadata = 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(
                last_startup_ts),
            last_crash_timestamp=mysql_utils.MysqlToRDFDatetime(last_crash_ts))

        if client_obj is not None:
          l_snapshot = rdf_objects.ClientSnapshot.FromSerializedString(
              client_obj)
          l_snapshot.timestamp = mysql_utils.MysqlToRDFDatetime(last_client_ts)
          l_snapshot.startup_info = rdf_client.StartupInfo.FromSerializedString(
              client_startup_obj)
          l_snapshot.startup_info.timestamp = l_snapshot.timestamp
        else:
          l_snapshot = rdf_objects.ClientSnapshot(
              client_id=mysql_utils.IntToClientID(cid))

        if last_startup_obj is not None:
          startup_info = rdf_client.StartupInfo.FromSerializedString(
              last_startup_obj)
          startup_info.timestamp = mysql_utils.MysqlToRDFDatetime(
              last_startup_ts)
        else:
          startup_info = None

        prev_cid = cid
        c_full_info = rdf_objects.ClientFullInfo(
            metadata=metadata,
            labels=[],
            last_snapshot=l_snapshot,
            last_startup_info=startup_info)

      if label_owner and label_name:
        c_full_info.labels.append(
            rdf_objects.ClientLabel(name=label_name, owner=label_owner))

    if c_full_info:
      yield mysql_utils.IntToClientID(prev_cid), c_full_info
Creates a ClientFullInfo object from a database response.
Creates a ClientFullInfo object from a database response.
Creates a ClientFullInfo object from a database response .
def _ResponseToClientsFullInfo(self, response):
    c_full_info = None
    prev_cid = None
    for row in response:
      (cid, fs, crt, ping, clk, ip, foreman, first, last_client_ts,
       last_crash_ts, last_startup_ts, client_obj, client_startup_obj,
       last_startup_obj, label_owner, label_name) = row
      if cid != prev_cid:
        if c_full_info:
          yield mysql_utils.IntToClientID(prev_cid), c_full_info
        metadata = 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(
                last_startup_ts),
            last_crash_timestamp=mysql_utils.MysqlToRDFDatetime(last_crash_ts))
        if client_obj is not None:
          l_snapshot = rdf_objects.ClientSnapshot.FromSerializedString(
              client_obj)
          l_snapshot.timestamp = mysql_utils.MysqlToRDFDatetime(last_client_ts)
          l_snapshot.startup_info = rdf_client.StartupInfo.FromSerializedString(
              client_startup_obj)
          l_snapshot.startup_info.timestamp = l_snapshot.timestamp
        else:
          l_snapshot = rdf_objects.ClientSnapshot(
              client_id=mysql_utils.IntToClientID(cid))
        if last_startup_obj is not None:
          startup_info = rdf_client.StartupInfo.FromSerializedString(
              last_startup_obj)
          startup_info.timestamp = mysql_utils.MysqlToRDFDatetime(
              last_startup_ts)
        else:
          startup_info = None
        prev_cid = cid
        c_full_info = rdf_objects.ClientFullInfo(
            metadata=metadata,
            labels=[],
            last_snapshot=l_snapshot,
            last_startup_info=startup_info)
      if label_owner and label_name:
        c_full_info.labels.append(
            rdf_objects.ClientLabel(name=label_name, owner=label_owner))
    if c_full_info:
      yield mysql_utils.IntToClientID(prev_cid), c_full_info
def _ResponseToClientsFullInfo ( self , response ) : c_full_info = None prev_cid = None for row in response : ( cid , fs , crt , ping , clk , ip , foreman , first , last_client_ts , last_crash_ts , last_startup_ts , client_obj , client_startup_obj , last_startup_obj , label_owner , label_name ) = row if cid != prev_cid : if c_full_info : yield mysql_utils . IntToClientID ( prev_cid ) , c_full_info metadata = 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 ( last_startup_ts ) , last_crash_timestamp = mysql_utils . MysqlToRDFDatetime ( last_crash_ts ) ) if client_obj is not None : l_snapshot = rdf_objects . ClientSnapshot . FromSerializedString ( client_obj ) l_snapshot . timestamp = mysql_utils . MysqlToRDFDatetime ( last_client_ts ) l_snapshot . startup_info = rdf_client . StartupInfo . FromSerializedString ( client_startup_obj ) l_snapshot . startup_info . timestamp = l_snapshot . timestamp else : l_snapshot = rdf_objects . ClientSnapshot ( client_id = mysql_utils . IntToClientID ( cid ) ) if last_startup_obj is not None : startup_info = rdf_client . StartupInfo . FromSerializedString ( last_startup_obj ) startup_info . timestamp = mysql_utils . MysqlToRDFDatetime ( last_startup_ts ) else : startup_info = None prev_cid = cid c_full_info = rdf_objects . ClientFullInfo ( metadata = metadata , labels = [ ] , last_snapshot = l_snapshot , last_startup_info = startup_info ) if label_owner and label_name : c_full_info . labels . append ( rdf_objects . ClientLabel ( name = label_name , owner = label_owner ) ) if c_full_info : yield mysql_utils . IntToClientID ( prev_cid ) , c_full_info
Creates a ClientFullInfo object from a database response.
Creates a ClientFullInfo object from a database response .
"""Creates a ClientFullInfo object from a database response."""
self
response