Search in sources :

Example 1 with BdpDataPlanePlugin

use of org.batfish.bdp.BdpDataPlanePlugin in project batfish by batfish.

the class NodJobChunkingTest method setupDataPlane.

private void setupDataPlane() throws IOException {
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(_configs, tmp);
    BdpDataPlanePlugin bdpDataPlanePlugin = new BdpDataPlanePlugin();
    bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    _dataPlane = batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish)

Example 2 with BdpDataPlanePlugin

use of org.batfish.bdp.BdpDataPlanePlugin in project batfish by batfish.

the class CiscoGrammarTest method testBgpRemovePrivateAs.

@Test
public void testBgpRemovePrivateAs() throws IOException {
    String testrigName = "bgp-remove-private-as";
    List<String> configurationNames = ImmutableList.of("r1", "r2", "r3");
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    Map<Ip, Set<String>> ipOwners = CommonUtil.computeIpOwners(configurations, true);
    CommonUtil.initRemoteBgpNeighbors(configurations, ipOwners);
    BdpDataPlanePlugin dataPlanePlugin = new BdpDataPlanePlugin();
    dataPlanePlugin.initialize(batfish);
    // compute and cache the dataPlane
    batfish.computeDataPlane(false);
    // Check that 1.1.1.1/32 appears on r3
    SortedMap<String, SortedMap<String, SortedSet<AbstractRoute>>> routes = dataPlanePlugin.getRoutes(batfish.loadDataPlane());
    SortedSet<AbstractRoute> r3Routes = routes.get("r3").get(Configuration.DEFAULT_VRF_NAME);
    Set<Prefix> r3Prefixes = r3Routes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
    Prefix r1Loopback = Prefix.parse("1.1.1.1/32");
    assertTrue(r3Prefixes.contains(r1Loopback));
    // check that private AS is present in path in received 1.1.1.1/32 advert on r2
    batfish.initBgpAdvertisements(configurations);
    Configuration r2 = configurations.get("r2");
    boolean r2HasPrivate = r2.getReceivedEbgpAdvertisements().stream().filter(a -> a.getNetwork().equals(r1Loopback)).toArray(BgpAdvertisement[]::new)[0].getAsPath().getAsSets().stream().flatMap(Collection::stream).anyMatch(AsPath::isPrivateAs);
    assertTrue(r2HasPrivate);
    // check that private AS is absent from path in received 1.1.1.1/32 advert on r3
    Configuration r3 = configurations.get("r3");
    boolean r3HasPrivate = r3.getReceivedEbgpAdvertisements().stream().filter(a -> a.getNetwork().equals(r1Loopback)).toArray(BgpAdvertisement[]::new)[0].getAsPath().getAsSets().stream().flatMap(Collection::stream).anyMatch(AsPath::isPrivateAs);
    assertFalse(r3HasPrivate);
}
Also used : AbstractRoute(org.batfish.datamodel.AbstractRoute) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) InterfaceAddress(org.batfish.datamodel.InterfaceAddress) OspfAreaSummaryMatchers.isAdvertised(org.batfish.datamodel.matchers.OspfAreaSummaryMatchers.isAdvertised) Matchers.hasKey(org.hamcrest.Matchers.hasKey) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Interface(org.batfish.datamodel.Interface) Assert.assertThat(org.junit.Assert.assertThat) InterfaceMatchers.hasMtu(org.batfish.datamodel.matchers.InterfaceMatchers.hasMtu) OspfProcess(org.batfish.datamodel.OspfProcess) OspfProcessMatchers.hasAreas(org.batfish.datamodel.matchers.OspfProcessMatchers.hasAreas) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) WellKnownCommunity(org.batfish.common.WellKnownCommunity) OspfProcess.getReferenceOspfBandwidth(org.batfish.representation.cisco.OspfProcess.getReferenceOspfBandwidth) InterfaceMatchers.hasVrf(org.batfish.datamodel.matchers.InterfaceMatchers.hasVrf) Vrf(org.batfish.datamodel.Vrf) OspfArea(org.batfish.datamodel.OspfArea) InterfaceMatchers.hasDeclaredNames(org.batfish.datamodel.matchers.InterfaceMatchers.hasDeclaredNames) ConfigurationFormat(org.batfish.datamodel.ConfigurationFormat) InterfaceMatchers.isProxyArp(org.batfish.datamodel.matchers.InterfaceMatchers.isProxyArp) Collection(java.util.Collection) InterfaceMatchers.isOspfPointToPoint(org.batfish.datamodel.matchers.InterfaceMatchers.isOspfPointToPoint) Set(java.util.Set) LoggingMatchers.isOn(org.batfish.datamodel.vendor_family.cisco.LoggingMatchers.isOn) OspfAreaMatchers.hasSummary(org.batfish.datamodel.matchers.OspfAreaMatchers.hasSummary) Collectors(java.util.stream.Collectors) AsPath(org.batfish.datamodel.AsPath) OspfProcessMatchers.hasArea(org.batfish.datamodel.matchers.OspfProcessMatchers.hasArea) List(java.util.List) MultipathEquivalentAsPathMatchMode(org.batfish.datamodel.MultipathEquivalentAsPathMatchMode) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ConfigurationMatchers.hasVendorFamily(org.batfish.datamodel.matchers.ConfigurationMatchers.hasVendorFamily) OspfAreaSummaryMatchers.hasMetric(org.batfish.datamodel.matchers.OspfAreaSummaryMatchers.hasMetric) SortedMap(java.util.SortedMap) Ip(org.batfish.datamodel.Ip) BatfishTestUtils(org.batfish.main.BatfishTestUtils) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) InterfaceMatchers.isOspfPassive(org.batfish.datamodel.matchers.InterfaceMatchers.isOspfPassive) CommonUtil(org.batfish.common.util.CommonUtil) CoreMatchers.not(org.hamcrest.CoreMatchers.not) InterfaceMatchers.hasOspfArea(org.batfish.datamodel.matchers.InterfaceMatchers.hasOspfArea) BgpAdvertisement(org.batfish.datamodel.BgpAdvertisement) CommunityList(org.batfish.datamodel.CommunityList) ImmutableList(com.google.common.collect.ImmutableList) AbstractRoute(org.batfish.datamodel.AbstractRoute) CiscoFamilyMatchers.hasLogging(org.batfish.datamodel.vendor_family.cisco.CiscoFamilyMatchers.hasLogging) Configuration(org.batfish.datamodel.Configuration) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Batfish(org.batfish.main.Batfish) Matchers.isIn(org.hamcrest.Matchers.isIn) TestrigText(org.batfish.main.TestrigText) ExpectedException(org.junit.rules.ExpectedException) VrfMatchers.hasOspfProcess(org.batfish.datamodel.matchers.VrfMatchers.hasOspfProcess) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) Assert.assertTrue(org.junit.Assert.assertTrue) OspfAreaMatchers(org.batfish.datamodel.matchers.OspfAreaMatchers) IOException(java.io.IOException) InterfaceType(org.batfish.datamodel.InterfaceType) Test(org.junit.Test) ConfigurationMatchers.hasDefaultVrf(org.batfish.datamodel.matchers.ConfigurationMatchers.hasDefaultVrf) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Rule(org.junit.Rule) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) ConfigurationMatchers.hasInterfaces(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterfaces) VendorFamilyMatchers.hasCisco(org.batfish.datamodel.vendor_family.VendorFamilyMatchers.hasCisco) ConfigurationMatchers.hasInterface(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterface) ConfigurationMatchers.hasVrfs(org.batfish.datamodel.matchers.ConfigurationMatchers.hasVrfs) TemporaryFolder(org.junit.rules.TemporaryFolder) Prefix(org.batfish.datamodel.Prefix) SortedSet(java.util.SortedSet) Set(java.util.Set) Configuration(org.batfish.datamodel.Configuration) Ip(org.batfish.datamodel.Ip) Prefix(org.batfish.datamodel.Prefix) AsPath(org.batfish.datamodel.AsPath) SortedMap(java.util.SortedMap) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Example 3 with BdpDataPlanePlugin

use of org.batfish.bdp.BdpDataPlanePlugin in project batfish by batfish.

the class NodJobTest method setupDataPlane.

private void setupDataPlane() throws IOException {
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(_configs, tmp);
    _bdpDataPlanePlugin = new BdpDataPlanePlugin();
    _bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(_bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    _dataPlane = batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish)

Example 4 with BdpDataPlanePlugin

use of org.batfish.bdp.BdpDataPlanePlugin in project batfish by batfish.

the class BatfishCompressionTest method getDataPlane.

private DataPlane getDataPlane(SortedMap<String, Configuration> configs) throws IOException {
    // make sure to reconstruct the network, since compression mutates it
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(configs, tmp);
    BdpDataPlanePlugin bdpDataPlanePlugin = new BdpDataPlanePlugin();
    bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    return batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish) IBatfish(org.batfish.common.plugin.IBatfish)

Aggregations

BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)4 Batfish (org.batfish.main.Batfish)4 TemporaryFolder (org.junit.rules.TemporaryFolder)4 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 SortedSet (java.util.SortedSet)1 Collectors (java.util.stream.Collectors)1 WellKnownCommunity (org.batfish.common.WellKnownCommunity)1 IBatfish (org.batfish.common.plugin.IBatfish)1 CommonUtil (org.batfish.common.util.CommonUtil)1 AbstractRoute (org.batfish.datamodel.AbstractRoute)1 AsPath (org.batfish.datamodel.AsPath)1 BgpAdvertisement (org.batfish.datamodel.BgpAdvertisement)1 CommunityList (org.batfish.datamodel.CommunityList)1