Tabnine Logo
NodesSpecifier.getMatchingNodes
Code IndexAdd Tabnine to your IDE (free)

How to use
getMatchingNodes
method
in
org.batfish.datamodel.questions.NodesSpecifier

Best Java code snippets using org.batfish.datamodel.questions.NodesSpecifier.getMatchingNodes (Showing top 20 results out of 315)

origin: batfish/batfish

 @Override
 public Set<String> resolve(SpecifierContext ctxt) {
  return _shorthandSpecifier.getMatchingNodes(ctxt);
 }
}
origin: batfish/batfish

/** Return the set of nodes that match this specifier */
public Set<String> getMatchingNodes(IBatfish batfish) {
 return getMatchingNodes(batfish.specifierContext());
}
origin: batfish/batfish

@Override
public NodesAnswerElement answer() {
 NodesQuestion question = (NodesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 // initRemoteBgpNeighbors(_batfish, configurations);
 SortedMap<String, Configuration> answerNodes = new TreeMap<>();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 for (String node : configurations.keySet()) {
  if (nodes.contains(node)) {
   answerNodes.put(node, configurations.get(node));
  }
 }
 return new NodesAnswerElement(answerNodes, question.getSummary());
}
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 UnusedStructuresQuestion question = (UnusedStructuresQuestion) _question;
 // Find all the filenames that produced the queried nodes. This might have false positives if
 // a file produced multiple nodes, but that was already mis-handled before. Need to rewrite
 // this question as a TableAnswerElement.
 Set<String> includeNodes = question.getNodes().getMatchingNodes(_batfish);
 Multimap<String, String> hostnameFilenameMap =
   _batfish.loadParseVendorConfigurationAnswerElement().getFileMap();
 Set<String> includeFiles =
   hostnameFilenameMap.entries().stream()
     .filter(e -> includeNodes.contains(e.getKey()))
     .map(Entry::getValue)
     .collect(Collectors.toSet());
 Multiset<Row> rows = LinkedHashMultiset.create();
 SortedMap<String, SortedMap<String, SortedMap<String, DefinedStructureInfo>>>
   definedStructures =
     _batfish.loadConvertConfigurationAnswerElementOrReparse().getDefinedStructures();
 definedStructures.entrySet().stream()
   .filter(e -> includeFiles.contains(e.getKey()))
   .forEach(e -> rows.addAll(processEntryToRows(e)));
 TableAnswerElement table = new TableAnswerElement(createMetadata(question));
 table.postProcessAnswer(_question, rows);
 return table;
}
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 UndefinedReferencesQuestion question = (UndefinedReferencesQuestion) _question;
 // Find all the filenames that produced the queried nodes. This might have false positives if
 // a file produced multiple nodes, but that was already mis-handled before. Need to rewrite
 // this question as a TableAnswerElement.
 Set<String> includeNodes = question.getNodes().getMatchingNodes(_batfish);
 Multimap<String, String> hostnameFilenameMap =
   _batfish.loadParseVendorConfigurationAnswerElement().getFileMap();
 Set<String> includeFiles =
   hostnameFilenameMap.entries().stream()
     .filter(e -> includeNodes.contains(e.getKey()))
     .map(Entry::getValue)
     .collect(Collectors.toSet());
 Multiset<Row> rows = LinkedHashMultiset.create();
 SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>>
   undefinedReferences =
     _batfish.loadConvertConfigurationAnswerElementOrReparse().getUndefinedReferences();
 undefinedReferences.entrySet().stream()
   .filter(e -> includeFiles.contains(e.getKey()))
   .forEach(e -> rows.addAll(processEntryToRows(e)));
 TableAnswerElement table = new TableAnswerElement(createMetadata());
 table.postProcessAnswer(_question, rows);
 return table;
}
origin: batfish/batfish

private SortedMap<Ip, SortedSet<NodeInterfacePair>> getDuplicateIps() {
 UniqueIpAssignmentsQuestion question = (UniqueIpAssignmentsQuestion) _question;
 Set<String> nodes = question.getNodeRegex().getMatchingNodes(_batfish);
 Map<String, Configuration> configs = _batfish.loadConfigurations();
 return nodes.stream()
origin: batfish/batfish

 @Override
 public InferRolesAnswerElement answer() {
  InferRolesQuestion question = (InferRolesQuestion) _question;
  InferRolesAnswerElement answerElement = new InferRolesAnswerElement(null, null);
  // collect relevant nodes in a list.
  Set<String> nodes = question.getNodeRegex().getMatchingNodes(_batfish);
  SortedSet<NodeRoleDimension> roleDimensions =
    new InferRoles(nodes, _batfish.getEnvironmentTopology(), question.getCaseSensitive())
      .inferRoles();
  answerElement.getRoleDimensions().addAll(roleDimensions);
  for (NodeRoleDimension dimension : roleDimensions) {
   SortedMap<String, SortedSet<String>> roleNodesMap = dimension.createRoleNodesMap(nodes);
   SortedSet<String> matchingNodes = new TreeSet<>();
   for (SortedSet<String> nodeSet : roleNodesMap.values()) {
    matchingNodes.addAll(nodeSet);
   }
   answerElement.getMatchingNodesCount().put(dimension.getName(), matchingNodes.size());
  }
  return answerElement;
 }
}
origin: batfish/batfish

TestFiltersQuestion question = (TestFiltersQuestion) _question;
Map<String, Configuration> configurations = _batfish.loadConfigurations();
Set<String> includeNodes = question.getNodes().getMatchingNodes(_batfish);
FilterSpecifier filterSpecifier = question.getFilterSpecifier();
origin: batfish/batfish

@Override
public AnswerElement answer() {
 IpsecSessionStatusQuestion question = (IpsecSessionStatusQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 NetworkConfigurations networkConfigurations = NetworkConfigurations.of(configurations);
 ValueGraph<IpsecPeerConfigId, IpsecSession> ipsecTopology =
   IpsecUtil.initIpsecTopology(configurations);
 Set<String> initiatorNodes = question.getInitiatorRegex().getMatchingNodes(_batfish);
 Set<String> responderNodes = question.getResponderRegex().getMatchingNodes(_batfish);
 TableAnswerElement answerElement = new TableAnswerElement(createTableMetaData(question));
 Multiset<IpsecSessionInfo> ipsecSessionInfos =
   rawAnswer(networkConfigurations, ipsecTopology, initiatorNodes, responderNodes);
 answerElement.postProcessAnswer(
   question,
   ipsecSessionInfos.stream()
     .filter(
       ipsecSessionInfo ->
         question.matchesStatus(ipsecSessionInfo.getIpsecSessionStatus()))
     .map(IpsecSessionStatusAnswerer::toRow)
     .collect(Collectors.toCollection(HashMultiset::create)));
 return answerElement;
}
origin: batfish/batfish

@Override
public AnswerElement answer() {
 EdgesQuestion question = (EdgesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> includeNodes = question.getNodes().getMatchingNodes(_batfish);
 Set<String> includeRemoteNodes = question.getRemoteNodes().getMatchingNodes(_batfish);
 TableAnswerElement answer = new TableAnswerElement(getTableMetadata(question.getEdgeType()));
 Topology topology = _batfish.getEnvironmentTopology();
 answer.postProcessAnswer(
   _question,
   generateRows(
     configurations, topology, includeNodes, includeRemoteNodes, question.getEdgeType()));
 return answer;
}
origin: batfish/batfish

 @Override
 public RolesAnswerElement answer() {
  RolesQuestion question = (RolesQuestion) _question;
  // collect relevant nodes in a list.
  Set<String> nodes = question.getNodeRegex().getMatchingNodes(_batfish);
  NodeRoleDimension roleDimension =
    _batfish
      .getNodeRoleDimension(question.getRoleDimension())
      .orElseThrow(
        () ->
          new BatfishException(
            "No role dimension found for " + question.getRoleDimension()));
  RolesAnswerElement answerElement =
    new RolesAnswerElement(roleDimension, roleDimension.createRoleNodesMap(nodes));
  return answerElement;
 }
}
origin: batfish/batfish

SortedSetMultimap<Long, String> asns = TreeMultimap.create();
Map<String, Configuration> configurations = _batfish.loadConfigurations();
Set<String> nodes = question.getNodeRegex().getMatchingNodes(_batfish);
for (Entry<String, Configuration> e : configurations.entrySet()) {
 String hostname = e.getKey();
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 NamedStructuresQuestion question = (NamedStructuresQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 TableMetadata tableMetadata = createMetadata(question);
 Multiset<Row> propertyRows =
   rawAnswer(question, nodes, configurations, tableMetadata.toColumnMap());
 TableAnswerElement answer = new TableAnswerElement(tableMetadata);
 answer.postProcessAnswer(question, propertyRows);
 return answer;
}
origin: batfish/batfish

@Override
public AnswerElement answer() {
 OspfPropertiesQuestion question = (OspfPropertiesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 TableMetadata tableMetadata = createTableMetadata(question);
 TableAnswerElement answer = new TableAnswerElement(tableMetadata);
 Multiset<Row> propertyRows =
   getProperties(question.getProperties(), configurations, nodes, tableMetadata.toColumnMap());
 answer.postProcessAnswer(question, propertyRows);
 return answer;
}
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 NodePropertiesQuestion question = (NodePropertiesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 TableMetadata tableMetadata = createTableMetadata(question);
 Multiset<Row> propertyRows =
   getProperties(question.getProperties(), configurations, nodes, tableMetadata.toColumnMap());
 TableAnswerElement answer = new TableAnswerElement(tableMetadata);
 answer.postProcessAnswer(question, propertyRows);
 return answer;
}
origin: batfish/batfish

@Override
public AnswerElement answer() {
 BgpProcessConfigurationQuestion question = (BgpProcessConfigurationQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 TableMetadata tableMetadata = createTableMetadata(question);
 TableAnswerElement answer = new TableAnswerElement(tableMetadata);
 Multiset<Row> propertyRows =
   getProperties(question.getProperties(), configurations, nodes, tableMetadata.toColumnMap());
 answer.postProcessAnswer(question, propertyRows);
 return answer;
}
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 AaaAuthenticationLoginQuestion question = (AaaAuthenticationLoginQuestion) _question;
 TableAnswerElement answerElement = create(question);
 Set<String> specifiedNodes = question.getNodes().getMatchingNodes(_batfish);
 SortedMap<String, Configuration> configs = _batfish.loadConfigurations();
 configs.forEach(
   (configName, config) -> {
    if (specifiedNodes.contains(configName)) {
     Row row = null;
     if (config.getVendorFamily().getCisco() != null) {
      row = getRow(configName, config.getVendorFamily().getCisco().getLines().values());
     } else if (config.getVendorFamily().getJuniper() != null) {
      row = getRow(configName, config.getVendorFamily().getJuniper().getLines().values());
     }
     if (row != null) {
      answerElement.addRow(row);
     }
    }
   });
 answerElement.setSummary(answerElement.computeSummary(question.getAssertion()));
 return answerElement;
}
origin: batfish/batfish

@Override
public TableAnswerElement answer() {
 InterfacePropertiesQuestion question = (InterfacePropertiesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 TableMetadata tableMetadata = createTableMetadata(question);
 TableAnswerElement answer = new TableAnswerElement(tableMetadata);
 Multiset<Row> propertyRows =
   getProperties(
     question.getProperties(),
     configurations,
     nodes,
     question.getInterfaces(),
     question.getOnlyActive(),
     tableMetadata.toColumnMap());
 answer.postProcessAnswer(question, propertyRows);
 return answer;
}
origin: batfish/batfish

@Override
public OutliersAnswerElement answer() {
 OutliersQuestion question = (OutliersQuestion) _question;
 _answerElement = new OutliersAnswerElement();
 _configurations = _batfish.loadConfigurations();
 _nodes = question.getNodeRegex().getMatchingNodes(_batfish);
 _verbose = question.getVerbose();
 switch (question.getHypothesis()) {
  case SAME_DEFINITION:
  case SAME_NAME:
   SortedSet<NamedStructureOutlierSet<?>> outliers = namedStructureOutliers(question);
   _answerElement.setNamedStructureOutliers(outliers);
   break;
  case SAME_SERVERS:
   _answerElement.setServerOutliers(serverOutliers(question));
   break;
  default:
   throw new BatfishException(
     "Unexpected outlier detection hypothesis " + question.getHypothesis());
 }
 return _answerElement;
}
origin: batfish/batfish

@Override
public CompareSameNameAnswerElement answer() {
 _assumeAllUnique = _batfish.debugFlagEnabled(DEBUG_FLAG_ASSUME_ALL_UNIQUE);
 _configurations = _batfish.loadConfigurations();
 _csnQuestion = (CompareSameNameQuestion) _question;
 _nodes = _csnQuestion.getNodeRegex().getMatchingNodes(_batfish);
 _answerElement = new CompareSameNameAnswerElement(null, _nodes);
 add(AsPathAccessList.class, Configuration::getAsPathAccessLists);
 add(AuthenticationKeyChain.class, Configuration::getAuthenticationKeyChains);
 add(CommunityList.class, Configuration::getCommunityLists);
 add(IkePhase1Key.class, Configuration::getIkePhase1Keys);
 add(IkePhase1Policy.class, Configuration::getIkePhase1Policies);
 add(IkePhase1Proposal.class, Configuration::getIkePhase1Proposals);
 add(Interface.class, Configuration::getAllInterfaces);
 add(Ip6AccessList.class, Configuration::getIp6AccessLists);
 add(IpAccessList.class, Configuration::getIpAccessLists);
 add(IpsecPhase2Policy.class, Configuration::getIpsecPhase2Policies);
 add(IpsecPhase2Proposal.class, Configuration::getIpsecPhase2Proposals);
 add(IpsecPeerConfig.class, Configuration::getIpsecPeerConfigs);
 add(Route6FilterList.class, Configuration::getRoute6FilterLists);
 add(RouteFilterList.class, Configuration::getRouteFilterLists);
 add(RoutingPolicy.class, Configuration::getRoutingPolicies);
 add(Vrf.class, Configuration::getVrfs);
 add(Zone.class, Configuration::getZones);
 return _answerElement;
}
org.batfish.datamodel.questionsNodesSpecifiergetMatchingNodes

Javadoc

Return the set of nodes that match this specifier

Popular methods of NodesSpecifier

  • <init>
  • autoComplete
    Prepares for calling the full auto complete function: NodesSpecifier#autoComplete(String,Set,NodeRol
  • getRegex
  • getMatchingNodesByName
  • getMatchingNodesByRole
  • getRoleDimension
  • getType
  • equals
  • nodeNameInMatchingRole
    Does this nodeName match any of roles that match our _regex?

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • getSupportFragmentManager (FragmentActivity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JList (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now