use of org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement in project batfish by batfish.
the class Batfish method loadEnvironmentRoutingTables.
@Override
public SortedMap<String, RoutesByVrf> loadEnvironmentRoutingTables() {
EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
SortedMap<String, RoutesByVrf> environmentRoutingTables = _cachedEnvironmentRoutingTables.get(envSettings);
if (environmentRoutingTables == null) {
ParseEnvironmentRoutingTablesAnswerElement pertae = loadParseEnvironmentRoutingTablesAnswerElement();
if (!Version.isCompatibleVersion("Service", "Old processed environment routing tables", pertae.getVersion())) {
repairEnvironmentRoutingTables();
}
environmentRoutingTables = deserializeEnvironmentRoutingTables(envSettings.getSerializeEnvironmentRoutingTablesPath());
_cachedEnvironmentRoutingTables.put(envSettings, environmentRoutingTables);
}
return environmentRoutingTables;
}
use of org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement in project batfish by batfish.
the class Batfish method serializeEnvironmentRoutingTables.
private Answer serializeEnvironmentRoutingTables(Path inputPath, Path outputPath) {
Answer answer = new Answer();
ParseEnvironmentRoutingTablesAnswerElement answerElement = new ParseEnvironmentRoutingTablesAnswerElement();
answerElement.setVersion(Version.getVersion());
answer.addAnswerElement(answerElement);
SortedMap<String, RoutesByVrf> routingTables = getEnvironmentRoutingTables(inputPath, answerElement);
serializeEnvironmentRoutingTables(routingTables, outputPath);
serializeObject(answerElement, _testrigSettings.getEnvironmentSettings().getParseEnvironmentRoutingTablesAnswerPath());
return answer;
}
use of org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement in project batfish by batfish.
the class Batfish method loadParseEnvironmentRoutingTablesAnswerElement.
private ParseEnvironmentRoutingTablesAnswerElement loadParseEnvironmentRoutingTablesAnswerElement(boolean firstAttempt) {
Path answerPath = _testrigSettings.getEnvironmentSettings().getParseEnvironmentRoutingTablesAnswerPath();
if (!Files.exists(answerPath)) {
repairEnvironmentRoutingTables();
}
ParseEnvironmentRoutingTablesAnswerElement pertae = deserializeObject(answerPath, ParseEnvironmentRoutingTablesAnswerElement.class);
if (!Version.isCompatibleVersion("Service", "Old processed environment routing tables", pertae.getVersion())) {
if (firstAttempt) {
repairEnvironmentRoutingTables();
return loadParseEnvironmentRoutingTablesAnswerElement(false);
} else {
throw new BatfishException("Version error repairing environment routing tables for parse environment routing " + "tables answer element");
}
} else {
return pertae;
}
}
use of org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement in project batfish by batfish.
the class Batfish method initInfoRoutes.
@Override
public InitInfoAnswerElement initInfoRoutes(boolean summary, boolean verboseError) {
ParseEnvironmentRoutingTablesAnswerElement parseAnswer = loadParseEnvironmentRoutingTablesAnswerElement();
InitInfoAnswerElement answerElement = mergeParseAnswer(summary, verboseError, parseAnswer);
_logger.info(answerElement.prettyPrint());
return answerElement;
}
Aggregations