Starts a hunt with a given id.
555506
def StartHunt(hunt_id):
  """"""

  hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)
  num_hunt_clients = data_store.REL_DB.CountHuntFlows(hunt_id)

  if hunt_obj.hunt_state != hunt_obj.HuntState.PAUSED:
    raise OnlyPausedHuntCanBeStartedError(hunt_obj)

  data_store.REL_DB.UpdateHuntObject(
      hunt_id,
      hunt_state=hunt_obj.HuntState.STARTED,
      start_time=rdfvalue.RDFDatetime.Now(),
      num_clients_at_start_time=num_hunt_clients,
  )
  hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)

  if hunt_obj.args.hunt_type == hunt_obj.args.HuntType.STANDARD:
    _ScheduleGenericHunt(hunt_obj)
  elif hunt_obj.args.hunt_type == hunt_obj.args.HuntType.VARIABLE:
    _ScheduleVariableHunt(hunt_obj)
  else:
    raise UnknownHuntTypeError("Invalid hunt type for hunt %s: %r" %
                               (hunt_id, hunt_obj.args.hunt_type))

  return hunt_obj
1016734
def CountHuntResults(self,
                       hunt_id,
                       with_tag=None,
                       with_type=None,
                       cursor=None):
    """"""
    hunt_id_int = db_utils.HuntIDToInt(hunt_id)

    query = "SELECT COUNT(*) FROM flow_results WHERE hunt_id = %s "

    args = [hunt_id_int]

    if with_tag is not None:
      query += "AND tag = %s "
      args.append(with_tag)

    if with_type is not None:
      query += "AND type = %s "
      args.append(with_type)

    cursor.execute(query, args)
    return cursor.fetchone()[0]
893030
public void setId(String id) {
        logger.entering(id);
        this.id = id;
        logger.exiting();
    }
496647
def StopHuntIfCrashLimitExceeded(hunt_id):
  """"""
  hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)

  # Do nothing if the hunt is already stopped.
  if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED:
    return hunt_obj

  if hunt_obj.crash_limit:
    hunt_counters = data_store.REL_DB.ReadHuntCounters(hunt_id)
    if hunt_counters.num_crashed_clients >= hunt_obj.crash_limit:
      # Remove our rules from the forman and cancel all the started flows.
      # Hunt will be hard-stopped and it will be impossible to restart it.
      reason = ("Hunt %s reached the crashes limit of %d "
                "and was stopped.") % (hunt_obj.hunt_id, hunt_obj.crash_limit)
      StopHunt(hunt_obj.hunt_id, reason=reason)

  return hunt_obj
468127
public Object lookup(String id,String toFind)
    {
	return lookup(id,new MyWrapper(toFind));
    }
410947
def Get(self):
    """"""

    args = hunt_pb2.ApiGetHuntArgs(hunt_id=self.hunt_id)
    data = self._context.SendRequest("GetHunt", args)
    return Hunt(data=data, context=self._context)
283865
public static String start(String id) {
        if(idLocal.get()!=null){
            return null;
        }else{
            MDC.put("sessionId", id);
            if(LOG.isDebugEnabled())
                LOG.debug("Initialize session id = "+id);
            idLocal.set(id);
            return id;
        }
    }
885770
def _RunActions(self, rule, client_id):
    
    actions_count = 0

    for action in rule.actions:
      try:
        # Say this flow came from the foreman.
        token = self.token.Copy()
        token.username = "Foreman"

        if action.HasField("hunt_id"):
          if self._CheckIfHuntTaskWasAssigned(client_id, action.hunt_id):
            logging.info(
                "Foreman: ignoring hunt %s on client %s: was started "
                "here before", client_id, action.hunt_id)
          else:
            logging.info("Foreman: Starting hunt %s on client %s.",
                         action.hunt_id, client_id)

            flow_cls = registry.AFF4FlowRegistry.FlowClassByName(
                action.hunt_name)
            flow_cls.StartClients(action.hunt_id, [client_id])
            actions_count += 1
        else:
          flow.StartAFF4Flow(
              client_id=client_id,
              flow_name=action.flow_name,
              token=token,
              **action.argv.ToDict())
          actions_count += 1
      # There could be all kinds of errors we don't know about when starting the
      # flow/hunt so we catch everything here.
      except Exception as e:  # pylint: disable=broad-except
        logging.exception("Failure running foreman action on client %s: %s",
                          action.hunt_id, e)

    return actions_count
1078900
def start(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/start', params, 'POST')
1003035
def Get(self):
    """"""

    args = user_pb2.ApiGetHuntApprovalArgs(
        hunt_id=self.hunt_id,
        approval_id=self.approval_id,
        username=self.username)
    result = self._context.SendRequest("GetHuntApproval", args)
    return HuntApproval(
        data=result, username=self._context.username, context=self._context)
1144165
public final void setId(final ID id) {
    Assert.notNull(id, "The identifier for Rule ({0}) cannot be null!", getClass().getName());
    this.id = id;
  }
561107
def ReadHuntObject(self, hunt_id, cursor=None):
    """"""
    query = ("SELECT {columns} "
             "FROM hunts WHERE hunt_id = %s".format(
                 columns=_HUNT_COLUMNS_SELECT))

    nr_results = cursor.execute(query, [db_utils.HuntIDToInt(hunt_id)])
    if nr_results == 0:
      raise db.UnknownHuntError(hunt_id)

    return self._HuntObjectFromRow(cursor.fetchone())
962960
def CountHuntResultsByType(self, hunt_id, cursor=None):
    """"""
    hunt_id_int = db_utils.HuntIDToInt(hunt_id)

    query = ("SELECT type, COUNT(*) FROM flow_results "
             "WHERE hunt_id = %s GROUP BY type")

    cursor.execute(query, [hunt_id_int])
    return dict(cursor.fetchall())
86483
private Response<SearchResult> searchForId(final String id) throws LdapException {
        val filter = LdapUtils.newLdaptiveSearchFilter(this.searchFilter,
            LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
            CollectionUtils.wrap(id));
        return LdapUtils.executeSearchOperation(this.connectionFactory, this.baseDn, filter);
    }
322610
private void fireSearchStartEvent(SearchEvent event) {
		showWindow();
		for (SearchHandler handler : searchHandlers) {
			handler.onSearchStart(event);
		}
	}
349969
def match_id(self, el, ids):
        """"""

        found = True
        for i in ids:
            if i != self.get_attribute_by_name(el, 'id', ''):
                found = False
                break
        return found
1012080
def set_by_Id(self, Id, is_added):
        """"""
        row = self.collection.index_from_id(Id)
        if row is None:
            return
        self._set_id(Id, is_added, self.index(row, 0))