@Test public void testCheckTopologyInvalidNode() { Map<String, Configuration> configs = new HashMap<>(); configs.put( "h1", BatfishTestUtils.createTestConfiguration("h1", ConfigurationFormat.HOST, "eth0")); SortedSet<Edge> edges = new TreeSet<>(Collections.singletonList(Edge.of("h1", "eth0", "h2", "e0"))); Topology topology = new Topology(edges); _thrown.expect(BatfishException.class); _thrown.expectMessage("Topology contains a non-existent node 'h2'"); Batfish.checkTopology(configs, topology); }
static void checkTopology(Map<String, Configuration> configurations, Topology topology) { for (Edge edge : topology.getEdges()) { if (!configurations.containsKey(edge.getNode1())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode1())); } if (!configurations.containsKey(edge.getNode2())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode2())); } Configuration config1 = configurations.get(edge.getNode1()); Configuration config2 = configurations.get(edge.getNode2()); if (!config1.getAllInterfaces().containsKey(edge.getInt1())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt1(), edge.getNode1())); } if (!config2.getAllInterfaces().containsKey(edge.getInt2())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt2(), edge.getNode2())); } } }
Batfish extends PluginConsumer implements IBatfish { static void checkTopology(Map<String, Configuration> configurations, Topology topology) { for (Edge edge : topology.getEdges()) { if (!configurations.containsKey(edge.getNode1())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode1())); } if (!configurations.containsKey(edge.getNode2())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode2())); } Configuration config1 = configurations.get(edge.getNode1()); Configuration config2 = configurations.get(edge.getNode2()); if (!config1.getAllInterfaces().containsKey(edge.getInt1())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt1(), edge.getNode1())); } if (!config2.getAllInterfaces().containsKey(edge.getInt2())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt2(), edge.getNode2())); } } } }
Batfish extends PluginConsumer implements IBatfish { static void checkTopology(Map<String, Configuration> configurations, Topology topology) { for (Edge edge : topology.getEdges()) { if (!configurations.containsKey(edge.getNode1())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode1())); } if (!configurations.containsKey(edge.getNode2())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode2())); } Configuration config1 = configurations.get(edge.getNode1()); Configuration config2 = configurations.get(edge.getNode2()); if (!config1.getAllInterfaces().containsKey(edge.getInt1())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt1(), edge.getNode1())); } if (!config2.getAllInterfaces().containsKey(edge.getInt2())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt2(), edge.getNode2())); } } } Batfish(
      Settings settings,
      Cache<NetworkSnapshot, SortedMap<String, Configuration>> cachedConfigurations,
      Cache<NetworkSnapshot, DataPlane> cachedDataPlanes,
      Map<NetworkSnapshot, SortedMap<String, BgpAdvertisementsByVrf>> cachedEnvironmentBgpTables,
      Cache<NetworkSnapshot, Map<String, VendorConfiguration>> cachedVendorConfigurations,
      @Nullable StorageProvider alternateStorageProvider,
      @Nullable IdResolver alternateIdResolver); }
Batfish extends PluginConsumer implements IBatfish { static void checkTopology(Map<String, Configuration> configurations, Topology topology) { for (Edge edge : topology.getEdges()) { if (!configurations.containsKey(edge.getNode1())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode1())); } if (!configurations.containsKey(edge.getNode2())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode2())); } Configuration config1 = configurations.get(edge.getNode1()); Configuration config2 = configurations.get(edge.getNode2()); if (!config1.getAllInterfaces().containsKey(edge.getInt1())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt1(), edge.getNode1())); } if (!config2.getAllInterfaces().containsKey(edge.getInt2())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt2(), edge.getNode2())); } } } Batfish(
      Settings settings,
      Cache<NetworkSnapshot, SortedMap<String, Configuration>> cachedConfigurations,
      Cache<NetworkSnapshot, DataPlane> cachedDataPlanes,
      Map<NetworkSnapshot, SortedMap<String, BgpAdvertisementsByVrf>> cachedEnvironmentBgpTables,
      Cache<NetworkSnapshot, Map<String, VendorConfiguration>> cachedVendorConfigurations,
      @Nullable StorageProvider alternateStorageProvider,
      @Nullable IdResolver alternateIdResolver); static Flattener flatten(
      String input,
      BatfishLogger logger,
      Settings settings,
      Warnings warnings,
      ConfigurationFormat format,
      String header); static void logWarnings(BatfishLogger logger, Warnings warnings); static ParserRuleContext parse(
      BatfishCombinedParser<?, ?> parser, BatfishLogger logger, GrammarSettings settings); Answer answer(); static Warnings buildWarnings(Settings settings); @Override DataPlaneAnswerElement computeDataPlane(NetworkSnapshot snapshot); @Override boolean debugFlagEnabled(String flag); @Override Map<Location, LocationInfo> getLocationInfo(NetworkSnapshot snapshot); Map<String, Configuration> getConfigurations(
      Map<String, VendorConfiguration> vendorConfigurations,
      SnapshotRuntimeData runtimeData,
      ConvertConfigurationAnswerElement answerElement); @Override NetworkId getContainerName(); @Override DataPlanePlugin getDataPlanePlugin(); @Override Environment getEnvironment(); @Override BatfishLogger getLogger(); @Override NodeRolesData getNodeRolesData(); @Override Optional<NodeRoleDimension> getNodeRoleDimension(@Nullable String dimension); @Override Map<String, String> getQuestionTemplates(boolean verbose); @Override @Nullable ReferenceLibrary getReferenceLibraryData(); Settings getSettings(); @Override ImmutableConfiguration getSettingsConfiguration(); @Override NetworkSnapshot getSnapshot(); @Override NetworkSnapshot getReferenceSnapshot(); @Override String getTaskId(); String getTerminatingExceptionMessage(); @Nonnull @Override TopologyProvider getTopologyProvider(); @Override PluginClientType getType(); @Override InitInfoAnswerElement initInfo(
      NetworkSnapshot snapshot, boolean summary, boolean verboseError); @Override InitInfoAnswerElement initInfoBgpAdvertisements(
      NetworkSnapshot snapshot, boolean summary, boolean verboseError); @Override SortedMap<String, Configuration> loadConfigurations(NetworkSnapshot snapshot); @Override ConvertConfigurationAnswerElement loadConvertConfigurationAnswerElementOrReparse(
      NetworkSnapshot snapshot); @Override DataPlane loadDataPlane(NetworkSnapshot snapshot); @Override SortedMap<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables(
      NetworkSnapshot snapshot); ParseEnvironmentBgpTablesAnswerElement loadParseEnvironmentBgpTablesAnswerElement(
      NetworkSnapshot snapshot); @Override ParseVendorConfigurationAnswerElement loadParseVendorConfigurationAnswerElement(
      NetworkSnapshot snapshot); @Override Map<String, VendorConfiguration> loadVendorConfigurations(NetworkSnapshot snapshot); @Override AtomicInteger newBatch(String description, int jobs); @VisibleForTesting @Nonnull static AwsConfiguration parseAwsConfigurations(
      Map<String, String> configurationData, ParseVendorConfigurationAnswerElement pvcae); @Override Set<BgpAdvertisement> loadExternalBgpAnnouncements(
      NetworkSnapshot snapshot, Map<String, Configuration> configurations); @Override SortedMap<Flow, List<Trace>> buildFlows(
      NetworkSnapshot snapshot, Set<Flow> flows, boolean ignoreFilters); @Override TracerouteEngine getTracerouteEngine(NetworkSnapshot snapshot); @Override @Nullable String readExternalBgpAnnouncementsFile(NetworkSnapshot snapshot); @Override void registerAnswerer(
      String questionName,
      String questionClassName,
      BiFunction<Question, IBatfish, Answerer> answererCreator); @Override void registerBgpTablePlugin(BgpTableFormat format, BgpTablePlugin bgpTablePlugin); @Override void registerExternalBgpAdvertisementPlugin(
      ExternalBgpAdvertisementPlugin externalBgpAdvertisementPlugin); @MustBeClosed @Nonnull @Override InputStream getNetworkObject(NetworkId networkId, String key); @MustBeClosed @Nonnull @Override InputStream getSnapshotInputObject(NetworkSnapshot snapshot, String key); Answer run(NetworkSnapshot snapshot); @Override void registerDataPlanePlugin(DataPlanePlugin plugin, String name); void setTerminatingExceptionMessage(String terminatingExceptionMessage); @Override SpecifierContext specifierContext(NetworkSnapshot networkSnapshot); @Override BidirectionalReachabilityResult bidirectionalReachability(
      NetworkSnapshot snapshot, BDDPacket bddPacket, ReachabilityParameters parameters); @Override AnswerElement standard(
      NetworkSnapshot snapshot, ReachabilityParameters reachabilityParameters); AnswerElement bddSingleReachability(
      NetworkSnapshot snapshot, ReachabilityParameters parameters); @Override Set<Flow> bddLoopDetection(NetworkSnapshot snapshot); @Override Set<Flow> bddMultipathConsistency(
      NetworkSnapshot snapshot, MultipathConsistencyParameters parameters); @Nonnull IpSpaceAssignment getAllSourcesInferFromLocationIpSpaceAssignment(
      NetworkSnapshot snapshot); BDDReachabilityAnalysis getBddReachabilityAnalysis(
      NetworkSnapshot snapshot,
      BDDPacket pkt,
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions,
      boolean ignoreFilters,
      boolean useInterfaceRoots); @Override DifferentialReachabilityResult bddDifferentialReachability(
      NetworkSnapshot snapshot,
      NetworkSnapshot reference,
      DifferentialReachabilityParameters parameters); @Override @Nullable Answerer createAnswerer(@Nonnull Question question); }
Batfish extends PluginConsumer implements IBatfish { static void checkTopology(Map<String, Configuration> configurations, Topology topology) { for (Edge edge : topology.getEdges()) { if (!configurations.containsKey(edge.getNode1())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode1())); } if (!configurations.containsKey(edge.getNode2())) { throw new BatfishException( String.format("Topology contains a non-existent node '%s'", edge.getNode2())); } Configuration config1 = configurations.get(edge.getNode1()); Configuration config2 = configurations.get(edge.getNode2()); if (!config1.getAllInterfaces().containsKey(edge.getInt1())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt1(), edge.getNode1())); } if (!config2.getAllInterfaces().containsKey(edge.getInt2())) { throw new BatfishException( String.format( "Topology contains a non-existent interface '%s' on node '%s'", edge.getInt2(), edge.getNode2())); } } } Batfish(
      Settings settings,
      Cache<NetworkSnapshot, SortedMap<String, Configuration>> cachedConfigurations,
      Cache<NetworkSnapshot, DataPlane> cachedDataPlanes,
      Map<NetworkSnapshot, SortedMap<String, BgpAdvertisementsByVrf>> cachedEnvironmentBgpTables,
      Cache<NetworkSnapshot, Map<String, VendorConfiguration>> cachedVendorConfigurations,
      @Nullable StorageProvider alternateStorageProvider,
      @Nullable IdResolver alternateIdResolver); static Flattener flatten(
      String input,
      BatfishLogger logger,
      Settings settings,
      Warnings warnings,
      ConfigurationFormat format,
      String header); static void logWarnings(BatfishLogger logger, Warnings warnings); static ParserRuleContext parse(
      BatfishCombinedParser<?, ?> parser, BatfishLogger logger, GrammarSettings settings); Answer answer(); static Warnings buildWarnings(Settings settings); @Override DataPlaneAnswerElement computeDataPlane(NetworkSnapshot snapshot); @Override boolean debugFlagEnabled(String flag); @Override Map<Location, LocationInfo> getLocationInfo(NetworkSnapshot snapshot); Map<String, Configuration> getConfigurations(
      Map<String, VendorConfiguration> vendorConfigurations,
      SnapshotRuntimeData runtimeData,
      ConvertConfigurationAnswerElement answerElement); @Override NetworkId getContainerName(); @Override DataPlanePlugin getDataPlanePlugin(); @Override Environment getEnvironment(); @Override BatfishLogger getLogger(); @Override NodeRolesData getNodeRolesData(); @Override Optional<NodeRoleDimension> getNodeRoleDimension(@Nullable String dimension); @Override Map<String, String> getQuestionTemplates(boolean verbose); @Override @Nullable ReferenceLibrary getReferenceLibraryData(); Settings getSettings(); @Override ImmutableConfiguration getSettingsConfiguration(); @Override NetworkSnapshot getSnapshot(); @Override NetworkSnapshot getReferenceSnapshot(); @Override String getTaskId(); String getTerminatingExceptionMessage(); @Nonnull @Override TopologyProvider getTopologyProvider(); @Override PluginClientType getType(); @Override InitInfoAnswerElement initInfo(
      NetworkSnapshot snapshot, boolean summary, boolean verboseError); @Override InitInfoAnswerElement initInfoBgpAdvertisements(
      NetworkSnapshot snapshot, boolean summary, boolean verboseError); @Override SortedMap<String, Configuration> loadConfigurations(NetworkSnapshot snapshot); @Override ConvertConfigurationAnswerElement loadConvertConfigurationAnswerElementOrReparse(
      NetworkSnapshot snapshot); @Override DataPlane loadDataPlane(NetworkSnapshot snapshot); @Override SortedMap<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables(
      NetworkSnapshot snapshot); ParseEnvironmentBgpTablesAnswerElement loadParseEnvironmentBgpTablesAnswerElement(
      NetworkSnapshot snapshot); @Override ParseVendorConfigurationAnswerElement loadParseVendorConfigurationAnswerElement(
      NetworkSnapshot snapshot); @Override Map<String, VendorConfiguration> loadVendorConfigurations(NetworkSnapshot snapshot); @Override AtomicInteger newBatch(String description, int jobs); @VisibleForTesting @Nonnull static AwsConfiguration parseAwsConfigurations(
      Map<String, String> configurationData, ParseVendorConfigurationAnswerElement pvcae); @Override Set<BgpAdvertisement> loadExternalBgpAnnouncements(
      NetworkSnapshot snapshot, Map<String, Configuration> configurations); @Override SortedMap<Flow, List<Trace>> buildFlows(
      NetworkSnapshot snapshot, Set<Flow> flows, boolean ignoreFilters); @Override TracerouteEngine getTracerouteEngine(NetworkSnapshot snapshot); @Override @Nullable String readExternalBgpAnnouncementsFile(NetworkSnapshot snapshot); @Override void registerAnswerer(
      String questionName,
      String questionClassName,
      BiFunction<Question, IBatfish, Answerer> answererCreator); @Override void registerBgpTablePlugin(BgpTableFormat format, BgpTablePlugin bgpTablePlugin); @Override void registerExternalBgpAdvertisementPlugin(
      ExternalBgpAdvertisementPlugin externalBgpAdvertisementPlugin); @MustBeClosed @Nonnull @Override InputStream getNetworkObject(NetworkId networkId, String key); @MustBeClosed @Nonnull @Override InputStream getSnapshotInputObject(NetworkSnapshot snapshot, String key); Answer run(NetworkSnapshot snapshot); @Override void registerDataPlanePlugin(DataPlanePlugin plugin, String name); void setTerminatingExceptionMessage(String terminatingExceptionMessage); @Override SpecifierContext specifierContext(NetworkSnapshot networkSnapshot); @Override BidirectionalReachabilityResult bidirectionalReachability(
      NetworkSnapshot snapshot, BDDPacket bddPacket, ReachabilityParameters parameters); @Override AnswerElement standard(
      NetworkSnapshot snapshot, ReachabilityParameters reachabilityParameters); AnswerElement bddSingleReachability(
      NetworkSnapshot snapshot, ReachabilityParameters parameters); @Override Set<Flow> bddLoopDetection(NetworkSnapshot snapshot); @Override Set<Flow> bddMultipathConsistency(
      NetworkSnapshot snapshot, MultipathConsistencyParameters parameters); @Nonnull IpSpaceAssignment getAllSourcesInferFromLocationIpSpaceAssignment(
      NetworkSnapshot snapshot); BDDReachabilityAnalysis getBddReachabilityAnalysis(
      NetworkSnapshot snapshot,
      BDDPacket pkt,
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions,
      boolean ignoreFilters,
      boolean useInterfaceRoots); @Override DifferentialReachabilityResult bddDifferentialReachability(
      NetworkSnapshot snapshot,
      NetworkSnapshot reference,
      DifferentialReachabilityParameters parameters); @Override @Nullable Answerer createAnswerer(@Nonnull Question question);  }