grr/server/grr_response_server/rdfvalues/flow_objects.py
def FlowResponseForLegacyResponse(legacy_msg):
  """Helper function to convert legacy client replies to flow responses."""
  if legacy_msg.type == legacy_msg.Type.MESSAGE:
    response = FlowResponse(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id,
        payload=legacy_msg.payload)
  elif legacy_msg.type == legacy_msg.Type.STATUS:
    legacy_status = legacy_msg.payload
    if legacy_status.status not in status_map:
      raise ValueError(
          "Unable to convert returned status: %s" % legacy_status.status)
    response = FlowStatus(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id,
        status=status_map[legacy_status.status],
        error_message=legacy_status.error_message,
        backtrace=legacy_status.backtrace,
        cpu_time_used=legacy_status.cpu_time_used,
        network_bytes_sent=legacy_status.network_bytes_sent)
  elif legacy_msg.type == legacy_msg.Type.ITERATOR:
    response = FlowIterator(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id)
  else:
    raise ValueError("Unknown message type: %d" % legacy_msg.type)

  # TODO(amoser): The current datastore api uses task ids as keys (instead of
  # the much more intuitive (client_id, flow_id, request_id) so we need to
  # propagate the task_id here. This can be removed once client messages are
  # stored properly.
  try:
    response.task_id = legacy_msg.task_id
  except ValueError:
    pass

  return response
Helper function to convert legacy client replies to flow responses.
Helper function to convert legacy client replies to flow responses.
Helper function to convert legacy client replies to flow responses .
def FlowResponseForLegacyResponse(legacy_msg):
  if legacy_msg.type == legacy_msg.Type.MESSAGE:
    response = FlowResponse(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id,
        payload=legacy_msg.payload)
  elif legacy_msg.type == legacy_msg.Type.STATUS:
    legacy_status = legacy_msg.payload
    if legacy_status.status not in status_map:
      raise ValueError(
          "Unable to convert returned status: %s" % legacy_status.status)
    response = FlowStatus(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id,
        status=status_map[legacy_status.status],
        error_message=legacy_status.error_message,
        backtrace=legacy_status.backtrace,
        cpu_time_used=legacy_status.cpu_time_used,
        network_bytes_sent=legacy_status.network_bytes_sent)
  elif legacy_msg.type == legacy_msg.Type.ITERATOR:
    response = FlowIterator(
        client_id=_ClientIDFromSessionID(legacy_msg.session_id),
        flow_id=legacy_msg.session_id.Basename(),
        request_id=legacy_msg.request_id,
        response_id=legacy_msg.response_id)
  else:
    raise ValueError("Unknown message type: %d" % legacy_msg.type)
  try:
    response.task_id = legacy_msg.task_id
  except ValueError:
    pass
  return response
def FlowResponseForLegacyResponse ( legacy_msg ) : if legacy_msg . type == legacy_msg . Type . MESSAGE : response = FlowResponse ( client_id = _ClientIDFromSessionID ( legacy_msg . session_id ) , flow_id = legacy_msg . session_id . Basename ( ) , request_id = legacy_msg . request_id , response_id = legacy_msg . response_id , payload = legacy_msg . payload ) elif legacy_msg . type == legacy_msg . Type . STATUS : legacy_status = legacy_msg . payload if legacy_status . status not in status_map : raise ValueError ( "Unable to convert returned status: %s" % legacy_status . status ) response = FlowStatus ( client_id = _ClientIDFromSessionID ( legacy_msg . session_id ) , flow_id = legacy_msg . session_id . Basename ( ) , request_id = legacy_msg . request_id , response_id = legacy_msg . response_id , status = status_map [ legacy_status . status ] , error_message = legacy_status . error_message , backtrace = legacy_status . backtrace , cpu_time_used = legacy_status . cpu_time_used , network_bytes_sent = legacy_status . network_bytes_sent ) elif legacy_msg . type == legacy_msg . Type . ITERATOR : response = FlowIterator ( client_id = _ClientIDFromSessionID ( legacy_msg . session_id ) , flow_id = legacy_msg . session_id . Basename ( ) , request_id = legacy_msg . request_id , response_id = legacy_msg . response_id ) else : raise ValueError ( "Unknown message type: %d" % legacy_msg . type ) try : response . task_id = legacy_msg . task_id except ValueError : pass return response
Helper function to convert legacy client replies to flow responses.
Helper function to convert legacy client replies to flow responses .
"""Helper function to convert legacy client replies to flow responses.""" # TODO(amoser): The current datastore api uses task ids as keys (instead of # the much more intuitive (client_id, flow_id, request_id) so we need to # propagate the task_id here. This can be removed once client messages are # stored properly.
legacy_msg