Search in sources :

Example 1 with ParseEnvironmentBgpTablesAnswerElement

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

Example 2 with ParseEnvironmentBgpTablesAnswerElement

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

Example 3 with ParseEnvironmentBgpTablesAnswerElement

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

Example 4 with ParseEnvironmentBgpTablesAnswerElement

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

Aggregations

ParseEnvironmentBgpTablesAnswerElement (org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement)4 BgpAdvertisementsByVrf (org.batfish.datamodel.collections.BgpAdvertisementsByVrf)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