use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class CiscoGrammarTest method testIpsecVpnIos.
@Test
public void testIpsecVpnIos() throws IOException {
String testrigName = "ipsec-vpn-ios";
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();
assertThat(configurations.values().stream().mapToLong(c -> c.getIpsecVpns().values().size()).sum(), equalTo(6L));
configurations.values().stream().flatMap(c -> c.getIpsecVpns().values().stream()).forEach(iv -> assertThat(iv.getRemoteIpsecVpn(), not(nullValue())));
/* Two tunnels should not be established because of a password mismatch between r1 and r3 */
assertThat(configurations.values().stream().flatMap(c -> c.getInterfaces().values().stream()).filter(i -> i.getInterfaceType().equals(InterfaceType.TUNNEL) && i.getActive()).count(), equalTo(4L));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class CiscoGrammarTest method testParsingRecovery.
@Test
public void testParsingRecovery() throws IOException {
String testrigName = "parsing-recovery";
String hostname = "ios-recovery";
List<String> configurationNames = ImmutableList.of(hostname);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
batfish.getSettings().setDisableUnrecognized(false);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Configuration iosRecovery = configurations.get(hostname);
Map<String, Interface> iosRecoveryInterfaces = iosRecovery.getInterfaces();
Set<String> iosRecoveryInterfaceNames = iosRecoveryInterfaces.keySet();
Set<InterfaceAddress> l3Prefixes = iosRecoveryInterfaces.get("Loopback3").getAllAddresses();
Set<InterfaceAddress> l4Prefixes = iosRecoveryInterfaces.get("Loopback4").getAllAddresses();
assertThat("Loopback0", isIn(iosRecoveryInterfaceNames));
assertThat("Loopback1", isIn(iosRecoveryInterfaceNames));
assertThat("Loopback2", not(isIn(iosRecoveryInterfaceNames)));
assertThat("Loopback3", isIn(iosRecoveryInterfaceNames));
assertThat(new InterfaceAddress("10.0.0.1/32"), not(isIn(l3Prefixes)));
assertThat(new InterfaceAddress("10.0.0.2/32"), isIn(l3Prefixes));
assertThat("Loopback4", isIn(iosRecoveryInterfaceNames));
assertThat(new InterfaceAddress("10.0.0.3/32"), not(isIn(l4Prefixes)));
assertThat(new InterfaceAddress("10.0.0.4/32"), isIn(l4Prefixes));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class CiscoGrammarTest method testOspfMaxMetric.
@Test
public void testOspfMaxMetric() throws IOException {
String testrigName = "ospf-max-metric";
String iosMaxMetricName = "ios-max-metric";
String iosMaxMetricCustomName = "ios-max-metric-custom";
String iosMaxMetricOnStartupName = "ios-max-metric-on-startup";
List<String> configurationNames = ImmutableList.of(iosMaxMetricName, iosMaxMetricCustomName, iosMaxMetricOnStartupName);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Configuration iosMaxMetric = configurations.get(iosMaxMetricName);
Configuration iosMaxMetricCustom = configurations.get(iosMaxMetricCustomName);
Configuration iosMaxMetricOnStartup = configurations.get(iosMaxMetricOnStartupName);
OspfProcess proc = iosMaxMetric.getDefaultVrf().getOspfProcess();
OspfProcess procCustom = iosMaxMetricCustom.getDefaultVrf().getOspfProcess();
OspfProcess procOnStartup = iosMaxMetricOnStartup.getDefaultVrf().getOspfProcess();
long expectedMaxMetricRouterLsa = org.batfish.representation.cisco.OspfProcess.MAX_METRIC_ROUTER_LSA;
long expectedMaxMetricStub = org.batfish.representation.cisco.OspfProcess.MAX_METRIC_ROUTER_LSA;
long expectedMaxMetricExternal = org.batfish.representation.cisco.OspfProcess.DEFAULT_MAX_METRIC_EXTERNAL_LSA;
long expectedMaxMetricSummary = org.batfish.representation.cisco.OspfProcess.DEFAULT_MAX_METRIC_SUMMARY_LSA;
long expectedCustomMaxMetricExternal = 12345L;
long expectedCustomMaxMetricSummary = 23456L;
assertThat(proc.getMaxMetricTransitLinks(), equalTo(expectedMaxMetricRouterLsa));
assertThat(proc.getMaxMetricStubNetworks(), equalTo(expectedMaxMetricStub));
assertThat(proc.getMaxMetricExternalNetworks(), equalTo(expectedMaxMetricExternal));
assertThat(proc.getMaxMetricSummaryNetworks(), equalTo(expectedMaxMetricSummary));
assertThat(procCustom.getMaxMetricTransitLinks(), equalTo(expectedMaxMetricRouterLsa));
assertThat(procCustom.getMaxMetricStubNetworks(), equalTo(expectedMaxMetricStub));
assertThat(procCustom.getMaxMetricExternalNetworks(), equalTo(expectedCustomMaxMetricExternal));
assertThat(procCustom.getMaxMetricSummaryNetworks(), equalTo(expectedCustomMaxMetricSummary));
assertThat(procOnStartup.getMaxMetricTransitLinks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricStubNetworks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricExternalNetworks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricSummaryNetworks(), is(nullValue()));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class CiscoGrammarTest method testAristaOspfReferenceBandwidth.
@Test
public void testAristaOspfReferenceBandwidth() throws IOException {
Configuration manual = parseConfig("aristaOspfCost");
assertThat(manual.getDefaultVrf().getOspfProcess().getReferenceBandwidth(), equalTo(3e6d));
Configuration defaults = parseConfig("aristaOspfCostDefaults");
assertThat(defaults.getDefaultVrf().getOspfProcess().getReferenceBandwidth(), equalTo(getReferenceOspfBandwidth(ConfigurationFormat.ARISTA)));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class CiscoGrammarTest method testNxosOspfAreaParameters.
@Test
public void testNxosOspfAreaParameters() throws IOException {
String testrigName = "nxos-ospf";
String hostname = "nxos-ospf-area";
String ifaceName = "Ethernet1";
long areaNum = 1L;
List<String> configurationNames = ImmutableList.of(hostname);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
/* Ensure bidirectional references between OSPF area and interface */
assertThat(configurations, hasKey(hostname));
Configuration c = configurations.get(hostname);
assertThat(c, hasDefaultVrf(hasOspfProcess(hasAreas(hasKey(areaNum)))));
OspfArea area = c.getDefaultVrf().getOspfProcess().getAreas().get(areaNum);
assertThat(area, OspfAreaMatchers.hasInterfaces(hasItem(ifaceName)));
assertThat(c, hasInterface(ifaceName, hasOspfArea(sameInstance(area))));
assertThat(c, hasInterface(ifaceName, isOspfPassive(equalTo(false))));
assertThat(c, hasInterface(ifaceName, isOspfPointToPoint()));
}
Aggregations