Get instances of all well known flows.
775583
def GetAllWellKnownFlows(cls, token=None):
    """"""
    well_known_flows = {}
    for cls in itervalues(registry.AFF4FlowRegistry.FLOW_REGISTRY):
      if issubclass(cls, WellKnownFlow) and cls.well_known_session_id:
        well_known_flow = cls(cls.well_known_session_id, mode="rw", token=token)
        well_known_flows[cls.well_known_session_id.FlowName()] = well_known_flow

    return well_known_flows
614912
private void getActiveFlowHelper(final ArrayList<ExecutableFlow> flows,
      final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) {
    for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) {
      flows.add(ref.getSecond());
    }
  }
202410
public List<FacesConfigFlowDefinitionType<WebFacesConfigDescriptor>> getAllFlowDefinition()
   {
      List<FacesConfigFlowDefinitionType<WebFacesConfigDescriptor>> list = new ArrayList<FacesConfigFlowDefinitionType<WebFacesConfigDescriptor>>();
      List<Node> nodeList = model.get("flow-definition");
      for(Node node: nodeList)
      {
         FacesConfigFlowDefinitionType<WebFacesConfigDescriptor>  type = new FacesConfigFlowDefinitionTypeImpl<WebFacesConfigDescriptor>(this, "flow-definition", model, node);
         list.add(type);
      }
      return list;
   }
568650
def _GetCallingPrototypeAsString(self, flow_cls):
    """"""
    output = []
    output.append("flow.StartAFF4Flow(client_id=client_id, ")
    output.append("flow_name=\"%s\", " % flow_cls.__name__)
    prototypes = []
    if flow_cls.args_type:
      for type_descriptor in flow_cls.args_type.type_infos:
        if not type_descriptor.hidden:
          prototypes.append("%s=%s" %
                            (type_descriptor.name, type_descriptor.name))
    output.append(", ".join(prototypes))
    output.append(")")
    return "".join(output)
793625
private void getActiveFlowsWithExecutorHelper(
      final List<Pair<ExecutableFlow, Optional<Executor>>> flows,
      final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) {
    for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) {
      flows.add(new Pair<>(ref.getSecond(), ref
          .getFirst().getExecutor()));
    }
  }
75500
def streams(self):
        

        if not self.get_objects_by_type('stream'):
            tpld_ids = []
            for index in self.get_attribute('ps_indices').split():
                stream = XenaStream(parent=self, index='{}/{}'.format(self.index, index))
                tpld_ids.append(stream.get_attribute('ps_tpldid'))
            if tpld_ids:
                XenaStream.next_tpld_id = max([XenaStream.next_tpld_id] + [int(t) for t in tpld_ids]) + 1
        return {s.id: s for s in self.get_objects_by_type('stream')}
847975
private Collection<AbstractMockEc2Instance> getInstances(final Set<String> instanceIDs) {
        Collection<AbstractMockEc2Instance> ret = new ArrayList<AbstractMockEc2Instance>();
        for (String instanceID : instanceIDs) {
            ret.add(getMockEc2Instance(instanceID));
        }
        return ret;
    }
194808
private Map<Optional<Executor>, List<ExecutableFlow>> getFlowToExecutorMap() {
    final HashMap<Optional<Executor>, List<ExecutableFlow>> exFlowMap =
        new HashMap<>();

    for (final Pair<ExecutionReference, ExecutableFlow> runningFlow : this.runningExecutions.get()
        .values()) {
      final ExecutionReference ref = runningFlow.getFirst();
      final ExecutableFlow flow = runningFlow.getSecond();
      final Optional<Executor> executor = ref.getExecutor();

      // We can set the next check time to prevent the checking of certain
      // flows.
      if (ref.getNextCheckTime() >= DateTime.now().getMillis()) {
        continue;
      }

      List<ExecutableFlow> flows = exFlowMap.get(executor);
      if (flows == null) {
        flows = new ArrayList<>();
        exFlowMap.put(executor, flows);
      }

      flows.add(flow);
    }

    return exFlowMap;
  }
484821
public Flow[] getFlows()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getFlows");
    }
    Flow[] flows = classifications.getFlows();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.exit(tc, "getFlows", flows);
    }    
    return flows;
  }
571630
Map<Integer, Pair<ExecutionReference, ExecutableFlow>> fetchActiveFlows()
      throws ExecutorManagerException {
    try {
      return this.dbOperator.query(FetchActiveExecutableFlows.FETCH_ACTIVE_EXECUTABLE_FLOWS,
          new FetchActiveExecutableFlows());
    } catch (final SQLException e) {
      throw new ExecutorManagerException("Error fetching active flows", e);
    }
  }
320856
def get_streams(self):
        
        self._write_lock.acquire()
        try:
            return itervalues(self._stream_by_id)
        finally:
            self._write_lock.release()
434077
def packets_to_flows(self):
        """"""

        # For each packet, place it into either an existing flow or a new flow
        for packet in self.input_stream:

            # Compute flow tuple and add the packet to the flow
            flow_id = flow_utils.flow_tuple(packet)
            self._flows[flow_id].add_packet(packet)

            # Yield flows that are ready to go
            for flow in list(self._flows.values()):
                if flow.ready():
                    flow_info = flow.get_flow()
                    yield flow_info
                    del self._flows[flow_info['flow_id']]

        # All done so just dump what we have left
        print('---- NO MORE INPUT ----')
        for flow in sorted(self._flows.values(), key=lambda x: x.meta['start']):
            yield flow.get_flow()
1316076
def get_flow(self):
        """"""
        if self.meta['protocol'] == 'TCP':
            self.meta['packet_list'].sort(key=lambda packet: packet['transport']['seq'])
            for packet in self.meta['packet_list']:
                self.meta['payload'] += packet['transport']['data']

        return self.meta
784157
def getAllowedTransitions(instance):
    
    wftool = getToolByName(instance, "portal_workflow")
    transitions = wftool.getTransitionsFor(instance)
    return [trans['id'] for trans in transitions]
472047
def WriteFlowLogEntries(self, entries):
    """"""
    flow_ids = [(e.client_id, e.flow_id) for e in entries]
    for f in flow_ids:
      if f not in self.flows:
        raise db.AtLeastOneUnknownFlowError(flow_ids)

    for e in entries:
      dest = self.flow_log_entries.setdefault((e.client_id, e.flow_id), [])
      to_write = e.Copy()
      to_write.timestamp = rdfvalue.RDFDatetime.Now()
      dest.append(to_write)
1228999
def get_network_instances(self, name=''):
        """"""

        output = self._show_vrf()
        vrfs = {}
        all_vrf_interfaces = {}
        for vrf in output:
            if (vrf.get('route_distinguisher', '') == "<not set>" or
                    vrf.get('route_distinguisher', '') == 'None'):
                vrf['route_distinguisher'] = u''
            else:
                vrf['route_distinguisher'] = py23_compat.text_type(vrf['route_distinguisher'])
            interfaces = {}
            for interface_raw in vrf.get('interfaces', []):
                interface = interface_raw.split(',')
                for line in interface:
                    if line.strip() != '':
                        interfaces[py23_compat.text_type(line.strip())] = {}
                        all_vrf_interfaces[py23_compat.text_type(line.strip())] = {}

            vrfs[py23_compat.text_type(vrf['name'])] = {
                          u'name': py23_compat.text_type(vrf['name']),
                          u'type': u'L3VRF',
                          u'state': {
                              u'route_distinguisher': vrf['route_distinguisher'],
                          },
                          u'interfaces': {
                              u'interface': interfaces,
                          },
            }
        all_interfaces = self.get_interfaces_ip().keys()
        vrfs[u'default'] = {
            u'name': u'default',
            u'type': u'DEFAULT_INSTANCE',
            u'state': {
                u'route_distinguisher': u'',
            },
            u'interfaces': {
                u'interface': {
                    k: {} for k in all_interfaces if k not in all_vrf_interfaces.keys()
                },
            },
        }

        if name:
            if name in vrfs:
                return {py23_compat.text_type(name): vrfs[name]}
            return {}
        else:
            return vrfs
812191
def ReadFlowObject(self, client_id, flow_id, cursor=None):
    """"""
    query = ("SELECT " + self.FLOW_DB_FIELDS +
             "FROM flows WHERE client_id=%s AND flow_id=%s")
    cursor.execute(
        query,
        [db_utils.ClientIDToInt(client_id),
         db_utils.FlowIDToInt(flow_id)])
    result = cursor.fetchall()
    if not result:
      raise db.UnknownFlowError(client_id, flow_id)
    row, = result
    return self._FlowObjectFromRow(row)