Search in sources :

Example 1 with ParseEnvironmentRoutingTablesAnswerElement

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;
}
Also used : EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings) ParseEnvironmentRoutingTablesAnswerElement(org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement) RoutesByVrf(org.batfish.datamodel.collections.RoutesByVrf)

Example 2 with ParseEnvironmentRoutingTablesAnswerElement

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;
}
Also used : Answer(org.batfish.datamodel.answers.Answer) ParseEnvironmentRoutingTablesAnswerElement(org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement) RoutesByVrf(org.batfish.datamodel.collections.RoutesByVrf)

Example 3 with ParseEnvironmentRoutingTablesAnswerElement

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;
    }
}
Also used : Path(java.nio.file.Path) CleanBatfishException(org.batfish.common.CleanBatfishException) BatfishException(org.batfish.common.BatfishException) ParseEnvironmentRoutingTablesAnswerElement(org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement)

Example 4 with ParseEnvironmentRoutingTablesAnswerElement

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;
}
Also used : InitInfoAnswerElement(org.batfish.datamodel.answers.InitInfoAnswerElement) ParseEnvironmentRoutingTablesAnswerElement(org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement)

Aggregations

ParseEnvironmentRoutingTablesAnswerElement (org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement)4 RoutesByVrf (org.batfish.datamodel.collections.RoutesByVrf)2 Path (java.nio.file.Path)1 BatfishException (org.batfish.common.BatfishException)1 CleanBatfishException (org.batfish.common.CleanBatfishException)1 EnvironmentSettings (org.batfish.config.Settings.EnvironmentSettings)1 Answer (org.batfish.datamodel.answers.Answer)1 InitInfoAnswerElement (org.batfish.datamodel.answers.InitInfoAnswerElement)1