Search in sources :

Example 1 with EnvironmentSettings

use of org.batfish.config.Settings.EnvironmentSettings 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 EnvironmentSettings

use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.

the class Batfish method initQuestionEnvironment.

private void initQuestionEnvironment(Question question, boolean dp, boolean differentialContext) {
    EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
    if (!environmentExists(_testrigSettings)) {
        Path envPath = envSettings.getEnvPath();
        // create environment required folders
        CommonUtil.createDirectories(envPath);
    }
    if (!environmentBgpTablesExist(envSettings)) {
        computeEnvironmentBgpTables();
    }
    if (!environmentRoutingTablesExist(envSettings)) {
        computeEnvironmentRoutingTables();
    }
    if (dp) {
        if (!dataPlaneDependenciesExist(_testrigSettings)) {
            computeDataPlane(differentialContext);
        }
        if (!compressedDataPlaneDependenciesExist(_testrigSettings)) {
            computeCompressedDataPlane();
        }
    }
}
Also used : Path(java.nio.file.Path) EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings)

Example 3 with EnvironmentSettings

use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.

the class Batfish method computeEnvironmentBgpTables.

private void computeEnvironmentBgpTables() {
    EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
    Path outputPath = envSettings.getSerializeEnvironmentBgpTablesPath();
    Path inputPath = envSettings.getEnvironmentBgpTablesPath();
    serializeEnvironmentBgpTables(inputPath, outputPath);
}
Also used : Path(java.nio.file.Path) EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings)

Example 4 with EnvironmentSettings

use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.

the class Batfish method repairEnvironmentRoutingTables.

private void repairEnvironmentRoutingTables() {
    EnvironmentSettings envSettings = _testrigSettings.getEnvironmentSettings();
    Path answerPath = envSettings.getParseEnvironmentRoutingTablesAnswerPath();
    Path rtOutputPath = envSettings.getSerializeEnvironmentRoutingTablesPath();
    CommonUtil.deleteIfExists(answerPath);
    CommonUtil.deleteDirectory(rtOutputPath);
    computeEnvironmentRoutingTables();
}
Also used : Path(java.nio.file.Path) EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings)

Example 5 with EnvironmentSettings

use of org.batfish.config.Settings.EnvironmentSettings in project batfish by batfish.

the class Batfish method applyBaseDir.

public static void applyBaseDir(TestrigSettings settings, Path containerDir, String testrig, String envName) {
    Path testrigDir = containerDir.resolve(Paths.get(BfConsts.RELPATH_TESTRIGS_DIR, testrig));
    settings.setName(testrig);
    settings.setBasePath(testrigDir);
    EnvironmentSettings envSettings = settings.getEnvironmentSettings();
    settings.setSerializeVendorPath(testrigDir.resolve(BfConsts.RELPATH_VENDOR_SPECIFIC_CONFIG_DIR));
    settings.setTestRigPath(testrigDir.resolve(BfConsts.RELPATH_TEST_RIG_DIR));
    settings.setParseAnswerPath(testrigDir.resolve(BfConsts.RELPATH_PARSE_ANSWER_PATH));
    settings.setNodeRolesPath(testrigDir.resolve(Paths.get(BfConsts.RELPATH_TEST_RIG_DIR, BfConsts.RELPATH_NODE_ROLES_PATH)));
    settings.setInferredNodeRolesPath(testrigDir.resolve(Paths.get(BfConsts.RELPATH_TEST_RIG_DIR, BfConsts.RELPATH_INFERRED_NODE_ROLES_PATH)));
    settings.setTopologyPath(testrigDir.resolve(BfConsts.RELPATH_TESTRIG_TOPOLOGY_PATH));
    settings.setPojoTopologyPath(testrigDir.resolve(BfConsts.RELPATH_TESTRIG_POJO_TOPOLOGY_PATH));
    if (envName != null) {
        envSettings.setName(envName);
        Path envPath = testrigDir.resolve(BfConsts.RELPATH_ENVIRONMENTS_DIR).resolve(envName);
        envSettings.setEnvironmentBasePath(envPath);
        envSettings.setCompressedDataPlanePath(envPath.resolve(BfConsts.RELPATH_COMPRESSED_DATA_PLANE));
        envSettings.setCompressedDataPlaneAnswerPath(envPath.resolve(BfConsts.RELPATH_COMPRESSED_DATA_PLANE_ANSWER));
        envSettings.setDataPlanePath(envPath.resolve(BfConsts.RELPATH_DATA_PLANE));
        envSettings.setDataPlaneAnswerPath(envPath.resolve(BfConsts.RELPATH_DATA_PLANE_ANSWER_PATH));
        envSettings.setParseEnvironmentBgpTablesAnswerPath(envPath.resolve(BfConsts.RELPATH_ENVIRONMENT_BGP_TABLES_ANSWER));
        envSettings.setParseEnvironmentRoutingTablesAnswerPath(envPath.resolve(BfConsts.RELPATH_ENVIRONMENT_ROUTING_TABLES_ANSWER));
        envSettings.setSerializeEnvironmentBgpTablesPath(envPath.resolve(BfConsts.RELPATH_SERIALIZED_ENVIRONMENT_BGP_TABLES));
        envSettings.setSerializeEnvironmentRoutingTablesPath(envPath.resolve(BfConsts.RELPATH_SERIALIZED_ENVIRONMENT_ROUTING_TABLES));
        envSettings.setValidateEnvironmentAnswerPath(envPath.resolve(BfConsts.RELPATH_VALIDATE_ENVIRONMENT_ANSWER));
        Path envDirPath = envPath.resolve(BfConsts.RELPATH_ENV_DIR);
        envSettings.setEnvPath(envDirPath);
        envSettings.setNodeBlacklistPath(envDirPath.resolve(BfConsts.RELPATH_NODE_BLACKLIST_FILE));
        envSettings.setInterfaceBlacklistPath(envDirPath.resolve(BfConsts.RELPATH_INTERFACE_BLACKLIST_FILE));
        envSettings.setEdgeBlacklistPath(envDirPath.resolve(BfConsts.RELPATH_EDGE_BLACKLIST_FILE));
        envSettings.setSerializedTopologyPath(envDirPath.resolve(BfConsts.RELPATH_ENV_TOPOLOGY_FILE));
        envSettings.setDeltaConfigurationsDir(envDirPath.resolve(BfConsts.RELPATH_CONFIGURATIONS_DIR));
        envSettings.setExternalBgpAnnouncementsPath(envDirPath.resolve(BfConsts.RELPATH_EXTERNAL_BGP_ANNOUNCEMENTS));
        envSettings.setEnvironmentBgpTablesPath(envDirPath.resolve(BfConsts.RELPATH_ENVIRONMENT_BGP_TABLES));
        envSettings.setEnvironmentRoutingTablesPath(envDirPath.resolve(BfConsts.RELPATH_ENVIRONMENT_ROUTING_TABLES));
        envSettings.setPrecomputedRoutesPath(envPath.resolve(BfConsts.RELPATH_PRECOMPUTED_ROUTES));
        envSettings.setDeltaCompiledConfigurationsDir(envPath.resolve(BfConsts.RELPATH_VENDOR_INDEPENDENT_CONFIG_DIR));
        envSettings.setDeltaVendorConfigurationsDir(envPath.resolve(BfConsts.RELPATH_VENDOR_SPECIFIC_CONFIG_DIR));
    }
}
Also used : Path(java.nio.file.Path) EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings)

Aggregations

EnvironmentSettings (org.batfish.config.Settings.EnvironmentSettings)10 Path (java.nio.file.Path)8 BatfishException (org.batfish.common.BatfishException)1 BatfishLogger (org.batfish.common.BatfishLogger)1 CleanBatfishException (org.batfish.common.CleanBatfishException)1 Settings (org.batfish.config.Settings)1 TestrigSettings (org.batfish.config.Settings.TestrigSettings)1 Answer (org.batfish.datamodel.answers.Answer)1 ParseEnvironmentBgpTablesAnswerElement (org.batfish.datamodel.answers.ParseEnvironmentBgpTablesAnswerElement)1 ParseEnvironmentRoutingTablesAnswerElement (org.batfish.datamodel.answers.ParseEnvironmentRoutingTablesAnswerElement)1 BgpAdvertisementsByVrf (org.batfish.datamodel.collections.BgpAdvertisementsByVrf)1 RoutesByVrf (org.batfish.datamodel.collections.RoutesByVrf)1