@Override protected String featureValueOf(Configuration actual) { return actual.getHostname(); } }
/** Associate VRFs with hostnames of configs on which they sit */ @VisibleForTesting static Map<Vrf, String> initVrfHostnameMap(Map<String, Configuration> configurations) { Map<Vrf, String> vrfHostnames = new IdentityHashMap<>(); for (Configuration c : configurations.values()) { for (Vrf v : c.getVrfs().values()) { vrfHostnames.put(v, c.getHostname()); } } // Use unmodifiableMap to lock the implementation return Collections.unmodifiableMap(vrfHostnames); }
@Override public Set<Interface> resolve(Set<String> nodes, SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> nodes.contains(c.getHostname())) .map(c -> c.getAllInterfaces().values()) .flatMap(Collection::stream) .filter(_shorthandSpecifier::matches) .collect(Collectors.toSet()); } }
@Override Stream<Location> getNodeLocations(Configuration node) { return node.getAllInterfaces().values().stream() .map(iface -> new InterfaceLinkLocation(node.getHostname(), iface.getName())); } }
@Override protected Stream<Location> getNodeLocations(Configuration node) { return node.getAllInterfaces().values().stream() .map(iface -> new InterfaceLocation(node.getHostname(), iface.getName())); } }
static @Nullable NodeInterfacePair getInterface(Configuration config, Ip localIp) { return CommonUtil.getActiveInterfaceWithIp(localIp, config) .map(iface -> new NodeInterfacePair(config.getHostname(), iface.getName())) .orElse(null); }
@Override public SortedMap<String, Configuration> loadConfigurations(NetworkSnapshot snapshot) { return ImmutableSortedMap.of(_c1.getHostname(), _c1, _c2.getHostname(), _c2); } };
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .map(iface -> new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName())) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .map(iface -> new InterfaceLocation(iface.getOwner().getHostname(), iface.getName())) .collect(ImmutableSet.toImmutableSet()); } }
private Map<Prefix, Boolean> aggregateRoutes() { Map<Prefix, Boolean> acc = new HashMap<>(); String name = _conf.getHostname(); List<GeneratedRoute> aggregates = _enc.getOptimizations().getRelevantAggregates().get(name); Set<Prefix> suppressed = _enc.getOptimizations().getSuppressedAggregates().get(name); for (GeneratedRoute gr : aggregates) { Prefix p = gr.getNetwork(); acc.put(p, suppressed.contains(p)); } return acc; }
@Override protected Stream<Location> getVrfLocations(Vrf vrf) { return vrf.getInterfaces().values().stream() .map(iface -> new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName())); } }
@Override protected Location getLocation(Interface iface) { return new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName()); } }
public RipNeighborSummary(RipNeighbor ripNeighbor) { super(ripNeighbor.getOwner().getHostname() + ":" + ripNeighbor._key); _localIp = ripNeighbor._key.getFirst(); _remoteIp = ripNeighbor._key.getSecond(); _vrf = ripNeighbor._vrf; }
@Override protected Location getLocation(Interface iface) { return new InterfaceLocation(iface.getOwner().getHostname(), iface.getName()); } }
@Override protected Location getLocation(Interface iface) { return new InterfaceLocation(iface.getOwner().getHostname(), iface.getName()); } }
@Before public void setup() throws IOException { _batfish = TwoNodeNetworkWithTwoLinks.create(_temp); SortedMap<String, Configuration> configs = _batfish.loadConfigurations(); _dstNode = configs.get(TwoNodeNetworkWithTwoLinks.DST_NODE); _srcNode = configs.get(TwoNodeNetworkWithTwoLinks.SRC_NODE); _failureDesc = String.format("link(%s,%s)", _dstNode.getHostname(), _srcNode.getHostname()); }
@Before public void setup() throws IOException { _batfish = TwoNodeNetworkWithTwoLinks.create(_temp); Map<String, Configuration> configs = _batfish.loadConfigurations(); _dstNode = configs.get(TwoNodeNetworkWithTwoLinks.DST_NODE); _srcNode = configs.get(TwoNodeNetworkWithTwoLinks.SRC_NODE); _failureDesc = String.format("link(%s,%s)", _dstNode.getHostname(), _srcNode.getHostname()); }
private Batfish getBatfish(Configuration baseConfig, Configuration deltaConfig) throws IOException { return BatfishTestUtils.getBatfish( ImmutableSortedMap.of(baseConfig.getHostname(), baseConfig), ImmutableSortedMap.of(deltaConfig.getHostname(), deltaConfig), _tmp); }
@Test public void testConfigurationBuilder() { NetworkFactory nf = new NetworkFactory(); Configuration.Builder cb = nf.configurationBuilder().setConfigurationFormat(CONFIG_FORMAT); Configuration c1 = cb.build(); Configuration c2 = cb.build(); assertThat(c1.getHostname(), is(notNullValue())); assertThat(c2.getHostname(), is(notNullValue())); assertThat(c1.getHostname(), not(equalTo(c2.getHostname()))); }
@Test public void testTestFilter() { String hostname = _config.getHostname(); Flow flow = Flow.builder().setIngressNode(hostname).setDstIp(IP2).setTag("tag").build(); assertThat( TestFiltersAnswerer.getRow(ACL, flow, _config), allOf( hasColumn(COL_ACTION, equalTo("DENY"), Schema.STRING), hasColumn(COL_FILTER_NAME, equalTo(ACL.getName()), Schema.STRING))); }