use of org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement in project batfish by batfish.
the class Batfish method loadParseEnvironmentBgpTablesAnswerElement.
private ParseEnvironmentBgpTablesAnswerElement loadParseEnvironmentBgpTablesAnswerElement(boolean firstAttempt) {
Path answerPath = _testrigSettings.getEnvironmentSettings().getParseEnvironmentBgpTablesAnswerPath();
if (!Files.exists(answerPath)) {
repairEnvironmentBgpTables();
}
ParseEnvironmentBgpTablesAnswerElement ae = deserializeObject(answerPath, ParseEnvironmentBgpTablesAnswerElement.class);
if (!Version.isCompatibleVersion("Service", "Old processed environment BGP tables", ae.getVersion())) {
if (firstAttempt) {
repairEnvironmentRoutingTables();
return loadParseEnvironmentBgpTablesAnswerElement(false);
} else {
throw new BatfishException("Version error repairing environment BGP tables for parse environment BGP tables " + "answer element");
}
} else {
return ae;
}
}
use of org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement in project batfish by batfish.
the class Batfish method serializeEnvironmentBgpTables.
private Answer serializeEnvironmentBgpTables(Path inputPath, Path outputPath) {
Answer answer = new Answer();
ParseEnvironmentBgpTablesAnswerElement answerElement = new ParseEnvironmentBgpTablesAnswerElement();
answerElement.setVersion(Version.getVersion());
answer.addAnswerElement(answerElement);
SortedMap<String, BgpAdvertisementsByVrf> bgpTables = getEnvironmentBgpTables(inputPath, answerElement);
serializeEnvironmentBgpTables(bgpTables, outputPath);
serializeObject(answerElement, _testrigSettings.getEnvironmentSettings().getParseEnvironmentBgpTablesAnswerPath());
return answer;
}
use of org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement in project batfish by batfish.
the class Batfish method initInfoBgpAdvertisements.
@Override
public InitInfoAnswerElement initInfoBgpAdvertisements(boolean summary, boolean verboseError) {
ParseEnvironmentBgpTablesAnswerElement parseAnswer = loadParseEnvironmentBgpTablesAnswerElement();
InitInfoAnswerElement answerElement = mergeParseAnswer(summary, verboseError, parseAnswer);
_logger.info(answerElement.prettyPrint());
return answerElement;
}
use of org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement 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;
}
Aggregations