grr/server/grr_response_server/db_compat.py
def ProcessHuntFlowDone(flow_obj, status_msg=None):
  """Notifis hunt about a given hunt-induced flow completion."""

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

    def UpdateFn(hunt_obj):
      hunt_obj.num_successful_clients += 1
      if flow_obj.num_replies_sent:
        hunt_obj.num_clients_with_results += 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)
    hunt.CompleteHuntIfExpirationTimeReached(hunt_obj)
    return

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

  # Update the counter metrics separately from collections to minimize
  # contention.
  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)

    if flow_obj.num_replies_sent:
      fd.context.clients_with_results_count += 1

    fd.context.completed_clients_count += 1
    fd.context.results_count += flow_obj.num_replies_sent

    fd.GetRunner().SaveResourceUsage(flow_obj.client_id, status_msg)

  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.RegisterCompletedClient(client_urn)
    if flow_obj.num_replies_sent:
      fd.RegisterClientWithResults(client_urn)

    fd.StopHuntIfAverageLimitsExceeded()
Notifis hunt about a given hunt-induced flow completion.
Notifis hunt about a given hunt-induced flow completion.
Notifis hunt about a given hunt - induced flow completion .
def ProcessHuntFlowDone(flow_obj, 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_successful_clients += 1
      if flow_obj.num_replies_sent:
        hunt_obj.num_clients_with_results += 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)
    hunt.CompleteHuntIfExpirationTimeReached(hunt_obj)
    return
  hunt_urn = rdfvalue.RDFURN("hunts").Add(flow_obj.parent_hunt_id)
  client_urn = rdf_client.ClientURN(flow_obj.client_id)
  with aff4.FACTORY.Open(hunt_urn, mode="rw") as fd:
    fd.token = access_control.ACLToken(username=fd.creator)
    if flow_obj.num_replies_sent:
      fd.context.clients_with_results_count += 1
    fd.context.completed_clients_count += 1
    fd.context.results_count += flow_obj.num_replies_sent
    fd.GetRunner().SaveResourceUsage(flow_obj.client_id, status_msg)
  with aff4.FACTORY.Open(hunt_urn, mode="rw") as fd:
    fd.token = access_control.ACLToken(username=fd.creator)
    fd.RegisterCompletedClient(client_urn)
    if flow_obj.num_replies_sent:
      fd.RegisterClientWithResults(client_urn)
    fd.StopHuntIfAverageLimitsExceeded()
def ProcessHuntFlowDone ( flow_obj , 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_successful_clients += 1 if flow_obj . num_replies_sent : hunt_obj . num_clients_with_results += 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 ) hunt . CompleteHuntIfExpirationTimeReached ( hunt_obj ) return hunt_urn = rdfvalue . RDFURN ( "hunts" ) . Add ( flow_obj . parent_hunt_id ) client_urn = rdf_client . ClientURN ( flow_obj . client_id ) with aff4 . FACTORY . Open ( hunt_urn , mode = "rw" ) as fd : fd . token = access_control . ACLToken ( username = fd . creator ) if flow_obj . num_replies_sent : fd . context . clients_with_results_count += 1 fd . context . completed_clients_count += 1 fd . context . results_count += flow_obj . num_replies_sent fd . GetRunner ( ) . SaveResourceUsage ( flow_obj . client_id , status_msg ) with aff4 . FACTORY . Open ( hunt_urn , mode = "rw" ) as fd : fd . token = access_control . ACLToken ( username = fd . creator ) fd . RegisterCompletedClient ( client_urn ) if flow_obj . num_replies_sent : fd . RegisterClientWithResults ( client_urn ) fd . StopHuntIfAverageLimitsExceeded ( )
Notifis hunt about a given hunt-induced flow completion.
Notifis hunt about a given hunt - induced flow completion .
"""Notifis hunt about a given hunt-induced flow completion.""" # Update the counter metrics separately from collections to minimize # contention. # Legacy AFF4 code expects token to be set. # Legacy AFF4 code expects token to be set.
flow_obj
status_msg