use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.
the class Batfish method compileEnvironmentConfigurations.
private Answer compileEnvironmentConfigurations(TestrigSettings testrigSettings) {
Answer answer = new Answer();
EnvironmentSettings envSettings = testrigSettings.getEnvironmentSettings();
Path deltaConfigurationsDir = envSettings.getDeltaConfigurationsDir();
Path vendorConfigsDir = envSettings.getDeltaVendorConfigurationsDir();
if (deltaConfigurationsDir != null) {
if (Files.exists(deltaConfigurationsDir)) {
answer.append(serializeVendorConfigs(envSettings.getEnvPath(), vendorConfigsDir));
answer.append(serializeIndependentConfigs(vendorConfigsDir));
}
return answer;
} else {
throw new BatfishException("Delta configurations directory cannot be null");
}
}
use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.
the class Batfish method computeEnvironmentRoutingTables.
private void computeEnvironmentRoutingTables() {
EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
Path outputPath = envSettings.getSerializeEnvironmentRoutingTablesPath();
Path inputPath = envSettings.getEnvironmentRoutingTablesPath();
serializeEnvironmentRoutingTables(inputPath, outputPath);
}
use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.
the class Batfish method repairEnvironmentBgpTables.
private void repairEnvironmentBgpTables() {
EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
Path answerPath = envSettings.getParseEnvironmentBgpTablesAnswerPath();
Path bgpTablesOutputPath = envSettings.getSerializeEnvironmentBgpTablesPath();
CommonUtil.deleteIfExists(answerPath);
CommonUtil.deleteDirectory(bgpTablesOutputPath);
computeEnvironmentBgpTables();
}
use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.
the class Batfish method loadEnvironmentBgpTables.
@Override
public SortedMap<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables() {
EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
SortedMap<String, BgpAdvertisementsByVrf> environmentBgpTables = _cachedEnvironmentBgpTables.get(envSettings);
if (environmentBgpTables == null) {
ParseEnvironmentBgpTablesAnswerElement ae = loadParseEnvironmentBgpTablesAnswerElement();
if (!Version.isCompatibleVersion("Service", "Old processed environment BGP tables", ae.getVersion())) {
repairEnvironmentBgpTables();
}
environmentBgpTables = deserializeEnvironmentBgpTables(envSettings.getSerializeEnvironmentBgpTablesPath());
_cachedEnvironmentBgpTables.put(envSettings, environmentBgpTables);
}
return environmentBgpTables;
}
use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.
the class BatfishTestUtils method getBatfishFromTestrigText.
/**
* Get a new Batfish instance with given configurations, tempFolder should be present for
* non-empty configurations
*
* @param testrigText Structure containing names and content of testrig input files
* @param tempFolder Temporary folder to be used to files required for Batfish
* @return Batfish instance pointing at new testrig comprising testrigText
*/
public static Batfish getBatfishFromTestrigText(TestrigText testrigText, TemporaryFolder tempFolder) throws IOException {
Map<String, String> awsText = testrigText.getAwsText();
Map<String, String> bgpTablesText = testrigText.getBgpTablesText();
Map<String, String> configurationText = testrigText.getConfigurationText();
Map<String, String> hostsText = testrigText.getHostsText();
Map<String, String> iptablesFilesText = testrigText.getIptablesFilesText();
Map<String, String> routingTablesText = testrigText.getRoutingTablesText();
Settings settings = new Settings(new String[] {});
settings.setLogger(new BatfishLogger("debug", false));
settings.setDisableUnrecognized(true);
settings.setHaltOnConvertError(true);
settings.setHaltOnParseError(true);
settings.setThrowOnLexerError(true);
settings.setThrowOnParserError(true);
settings.setVerboseParse(true);
Path containerDir = tempFolder.newFolder().toPath();
settings.setContainerDir(containerDir);
settings.setTestrig("tempTestrig");
settings.setEnvironmentName("tempEnvironment");
settings.setDataplaneEngineName(BdpDataPlanePlugin.PLUGIN_NAME);
Batfish.initTestrigSettings(settings);
Path testrigPath = settings.getBaseTestrigSettings().getTestRigPath();
settings.setActiveTestrigSettings(settings.getBaseTestrigSettings());
EnvironmentSettings envSettings = settings.getBaseTestrigSettings().getEnvironmentSettings();
envSettings.getEnvPath().toFile().mkdirs();
writeTemporaryTestrigFiles(configurationText, testrigPath.resolve(BfConsts.RELPATH_CONFIGURATIONS_DIR));
writeTemporaryTestrigFiles(awsText, testrigPath.resolve(BfConsts.RELPATH_AWS_CONFIGS_DIR));
writeTemporaryTestrigFiles(bgpTablesText, envSettings.getEnvironmentBgpTablesPath());
writeTemporaryTestrigFiles(hostsText, testrigPath.resolve(BfConsts.RELPATH_HOST_CONFIGS_DIR));
writeTemporaryTestrigFiles(iptablesFilesText, testrigPath.resolve("iptables"));
writeTemporaryTestrigFiles(routingTablesText, envSettings.getEnvironmentRoutingTablesPath());
Batfish batfish = new Batfish(settings, makeTestrigCache(), makeTestrigCache(), makeDataPlaneCache(), makeDataPlaneCache(), makeEnvBgpCache(), makeEnvRouteCache(), makeForwardingAnalysisCache());
return batfish;
}
Aggregations