grr/server/grr_response_server/db_compat.py
def ProcessHuntFlowError(flow_obj,
                         error_message=None,
                         backtrace=None,
                         status_msg=None):
  """Processes error and status message for a given hunt-induced flow."""

  if not hunt.IsLegacyHunt(flow_obj.parent_hunt_id):
    resources = _FlowStatusToClientResources(flow_obj, status_msg)

    def UpdateFn(hunt_obj):
      hunt_obj.num_failed_clients += 1
      hunt_obj.client_resources_stats.RegisterResources(resources)
      return hunt_obj

    hunt_obj = data_store.REL_DB.UpdateHuntObject(flow_obj.parent_hunt_id,
                                                  UpdateFn)
    hunt_obj = hunt.StopHuntIfAverageLimitsExceeded(hunt_obj)
    return

  hunt_urn = rdfvalue.RDFURN("hunts").Add(flow_obj.parent_hunt_id)
  client_urn = rdf_client.ClientURN(flow_obj.client_id)

  error = rdf_hunts.HuntError(client_id=flow_obj.client_id, backtrace=backtrace)
  if error_message is not None:
    error.log_message = error_message
  with data_store.DB.GetMutationPool() as pool:
    grr_collections.HuntErrorCollection.StaticAdd(
        hunt_urn.Add("ErrorClients"), error, mutation_pool=pool)
    grr_collections.ClientUrnCollection.StaticAdd(
        hunt_urn.Add("CompletedClients"), client_urn, mutation_pool=pool)

  if status_msg is not None:
    with aff4.FACTORY.Open(hunt_urn, mode="rw") as fd:
      # Legacy AFF4 code expects token to be set.
      fd.token = access_control.ACLToken(username=fd.creator)
      fd.GetRunner().SaveResourceUsage(flow_obj.client_id, status_msg)
Processes error and status message for a given hunt-induced flow.
Processes error and status message for a given hunt-induced flow.
Processes error and status message for a given hunt - induced flow .
def ProcessHuntFlowError(flow_obj,
                         error_message=None,
                         backtrace=None,
                         status_msg=None):
  if not hunt.IsLegacyHunt(flow_obj.parent_hunt_id):
    resources = _FlowStatusToClientResources(flow_obj, status_msg)
    def UpdateFn(hunt_obj):
      hunt_obj.num_failed_clients += 1
      hunt_obj.client_resources_stats.RegisterResources(resources)
      return hunt_obj
    hunt_obj = data_store.REL_DB.UpdateHuntObject(flow_obj.parent_hunt_id,
                                                  UpdateFn)
    hunt_obj = hunt.StopHuntIfAverageLimitsExceeded(hunt_obj)
    return
  hunt_urn = rdfvalue.RDFURN("hunts").Add(flow_obj.parent_hunt_id)
  client_urn = rdf_client.ClientURN(flow_obj.client_id)
  error = rdf_hunts.HuntError(client_id=flow_obj.client_id, backtrace=backtrace)
  if error_message is not None:
    error.log_message = error_message
  with data_store.DB.GetMutationPool() as pool:
    grr_collections.HuntErrorCollection.StaticAdd(
        hunt_urn.Add("ErrorClients"), error, mutation_pool=pool)
    grr_collections.ClientUrnCollection.StaticAdd(
        hunt_urn.Add("CompletedClients"), client_urn, mutation_pool=pool)
  if status_msg is not None:
    with aff4.FACTORY.Open(hunt_urn, mode="rw") as fd:
      fd.token = access_control.ACLToken(username=fd.creator)
      fd.GetRunner().SaveResourceUsage(flow_obj.client_id, status_msg)
def ProcessHuntFlowError ( flow_obj , error_message = None , backtrace = None , status_msg = None ) : if not hunt . IsLegacyHunt ( flow_obj . parent_hunt_id ) : resources = _FlowStatusToClientResources ( flow_obj , status_msg ) def UpdateFn ( hunt_obj ) : hunt_obj . num_failed_clients += 1 hunt_obj . client_resources_stats . RegisterResources ( resources ) return hunt_obj hunt_obj = data_store . REL_DB . UpdateHuntObject ( flow_obj . parent_hunt_id , UpdateFn ) hunt_obj = hunt . StopHuntIfAverageLimitsExceeded ( hunt_obj ) return hunt_urn = rdfvalue . RDFURN ( "hunts" ) . Add ( flow_obj . parent_hunt_id ) client_urn = rdf_client . ClientURN ( flow_obj . client_id ) error = rdf_hunts . HuntError ( client_id = flow_obj . client_id , backtrace = backtrace ) if error_message is not None : error . log_message = error_message with data_store . DB . GetMutationPool ( ) as pool : grr_collections . HuntErrorCollection . StaticAdd ( hunt_urn . Add ( "ErrorClients" ) , error , mutation_pool = pool ) grr_collections . ClientUrnCollection . StaticAdd ( hunt_urn . Add ( "CompletedClients" ) , client_urn , mutation_pool = pool ) if status_msg is not None : with aff4 . FACTORY . Open ( hunt_urn , mode = "rw" ) as fd : fd . token = access_control . ACLToken ( username = fd . creator ) fd . GetRunner ( ) . SaveResourceUsage ( flow_obj . client_id , status_msg )
Processes error and status message for a given hunt-induced flow.
Processes error and status message for a given hunt - induced flow .
"""Processes error and status message for a given hunt-induced flow.""" # Legacy AFF4 code expects token to be set.
flow_obj
error_message
backtrace
status_msg