grr/server/grr_response_server/databases/mysql_clients.py
def WriteClientMetadata(self,
                          client_id,
                          certificate=None,
                          fleetspeak_enabled=None,
                          first_seen=None,
                          last_ping=None,
                          last_clock=None,
                          last_ip=None,
                          last_foreman=None,
                          cursor=None):
    """Write metadata about the client."""

    columns = ["client_id"]
    values = [mysql_utils.ClientIDToInt(client_id)]
    if certificate:
      columns.append("certificate")
      values.append(certificate.SerializeToString())
    if fleetspeak_enabled is not None:
      columns.append("fleetspeak_enabled")
      values.append(int(fleetspeak_enabled))
    if first_seen:
      columns.append("first_seen")
      values.append(mysql_utils.RDFDatetimeToMysqlString(first_seen))
    if last_ping:
      columns.append("last_ping")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_ping))
    if last_clock:
      columns.append("last_clock")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_clock))
    if last_ip:
      columns.append("last_ip")
      values.append(last_ip.SerializeToString())
    if last_foreman:
      columns.append("last_foreman")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_foreman))

    query = ("INSERT INTO clients ({cols}) VALUES ({vals}) "
             "ON DUPLICATE KEY UPDATE {updates}").format(
                 cols=", ".join(columns),
                 vals=", ".join(["%s"] * len(columns)),
                 updates=", ".join([
                     "{c} = VALUES ({c})".format(c=col) for col in columns[1:]
                 ]))
    cursor.execute(query, values)
Write metadata about the client.
Write metadata about the client.
Write metadata about the client .
def WriteClientMetadata(self,
                          client_id,
                          certificate=None,
                          fleetspeak_enabled=None,
                          first_seen=None,
                          last_ping=None,
                          last_clock=None,
                          last_ip=None,
                          last_foreman=None,
                          cursor=None):
    columns = ["client_id"]
    values = [mysql_utils.ClientIDToInt(client_id)]
    if certificate:
      columns.append("certificate")
      values.append(certificate.SerializeToString())
    if fleetspeak_enabled is not None:
      columns.append("fleetspeak_enabled")
      values.append(int(fleetspeak_enabled))
    if first_seen:
      columns.append("first_seen")
      values.append(mysql_utils.RDFDatetimeToMysqlString(first_seen))
    if last_ping:
      columns.append("last_ping")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_ping))
    if last_clock:
      columns.append("last_clock")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_clock))
    if last_ip:
      columns.append("last_ip")
      values.append(last_ip.SerializeToString())
    if last_foreman:
      columns.append("last_foreman")
      values.append(mysql_utils.RDFDatetimeToMysqlString(last_foreman))
    query = ("INSERT INTO clients ({cols}) VALUES ({vals}) "
             "ON DUPLICATE KEY UPDATE {updates}").format(
                 cols=", ".join(columns),
                 vals=", ".join(["%s"] * len(columns)),
                 updates=", ".join([
                     "{c} = VALUES ({c})".format(c=col) for col in columns[1:]
                 ]))
    cursor.execute(query, values)
def WriteClientMetadata ( self , client_id , certificate = None , fleetspeak_enabled = None , first_seen = None , last_ping = None , last_clock = None , last_ip = None , last_foreman = None , cursor = None ) : columns = [ "client_id" ] values = [ mysql_utils . ClientIDToInt ( client_id ) ] if certificate : columns . append ( "certificate" ) values . append ( certificate . SerializeToString ( ) ) if fleetspeak_enabled is not None : columns . append ( "fleetspeak_enabled" ) values . append ( int ( fleetspeak_enabled ) ) if first_seen : columns . append ( "first_seen" ) values . append ( mysql_utils . RDFDatetimeToMysqlString ( first_seen ) ) if last_ping : columns . append ( "last_ping" ) values . append ( mysql_utils . RDFDatetimeToMysqlString ( last_ping ) ) if last_clock : columns . append ( "last_clock" ) values . append ( mysql_utils . RDFDatetimeToMysqlString ( last_clock ) ) if last_ip : columns . append ( "last_ip" ) values . append ( last_ip . SerializeToString ( ) ) if last_foreman : columns . append ( "last_foreman" ) values . append ( mysql_utils . RDFDatetimeToMysqlString ( last_foreman ) ) query = ( "INSERT INTO clients ({cols}) VALUES ({vals}) " "ON DUPLICATE KEY UPDATE {updates}" ) . format ( cols = ", " . join ( columns ) , vals = ", " . join ( [ "%s" ] * len ( columns ) ) , updates = ", " . join ( [ "{c} = VALUES ({c})" . format ( c = col ) for col in columns [ 1 : ] ] ) ) cursor . execute ( query , values )
Write metadata about the client.
Write metadata about the client .
"""Write metadata about the client."""
self
client_id
certificate
fleetspeak_enabled
first_seen
last_ping
last_clock
last_ip
last_foreman
cursor