@Nullable @Deprecated public Path getTestrigObject(String networkName, String testrigName, String objectName) { Path testrigDir = getdirSnapshot(networkName, testrigName); Path file = testrigDir.resolve(Paths.get(BfConsts.RELPATH_OUTPUT, objectName)); /* * Check if we got an object name outside of the testrig folder, perhaps because of ".." in the * name; disallow it */ if (!CommonUtil.getCanonicalPath(file).startsWith(CommonUtil.getCanonicalPath(testrigDir))) { throw new BatfishException("Illegal object name: '" + objectName + "'"); } // Check in output then input directories for backward compatibility // Since inputs and outputs used to be stored together, in the testrig dir if (!file.toFile().exists()) { file = testrigDir.resolve(Paths.get(BfConsts.RELPATH_INPUT, objectName)); } if (Files.isRegularFile(file)) { return file; } else if (Files.isDirectory(file)) { Path zipfile = Paths.get(file + ".zip"); if (Files.exists(zipfile)) { CommonUtil.deleteIfExists(zipfile); } ZipUtility.zipFiles(file, zipfile); // TODO: delete the zipfile return zipfile; } return null; }
private void repairDataPlane(boolean compressed) { Path dataPlanePath = compressed ? _testrigSettings.getCompressedDataPlanePath() : _testrigSettings.getDataPlanePath(); Path dataPlaneAnswerPath = compressed ? _testrigSettings.getCompressedDataPlaneAnswerPath() : _testrigSettings.getDataPlaneAnswerPath(); CommonUtil.deleteIfExists(dataPlanePath); CommonUtil.deleteIfExists(dataPlaneAnswerPath); if (compressed) { computeCompressedDataPlane(); } else { computeDataPlane(); } }
private void repairEnvironmentBgpTables() { Path answerPath = _testrigSettings.getParseEnvironmentBgpTablesAnswerPath(); Path bgpTablesOutputPath = _testrigSettings.getSerializeEnvironmentBgpTablesPath(); CommonUtil.deleteIfExists(answerPath); CommonUtil.deleteDirectory(bgpTablesOutputPath); computeEnvironmentBgpTables(); }
private void repairEnvironmentRoutingTables() { Path answerPath = _testrigSettings.getParseEnvironmentRoutingTablesAnswerPath(); Path rtOutputPath = _testrigSettings.getSerializeEnvironmentRoutingTablesPath(); CommonUtil.deleteIfExists(answerPath); CommonUtil.deleteDirectory(rtOutputPath); computeEnvironmentRoutingTables(); }
CommonUtil.deleteIfExists(failedTestoutPath);
CommonUtil.deleteIfExists(questionFile);
/** * Stores the configuration information into the given testrig. Will replace any previously-stored * configurations. */ @Override public void storeConfigurations( Map<String, Configuration> configurations, ConvertConfigurationAnswerElement convertAnswerElement, NetworkId network, SnapshotId snapshot) { mkdirs(_d.getSnapshotDir(network, snapshot)); // Save the convert configuration answer element. Path ccaePath = getConvertAnswerPath(network, snapshot); mkdirs(ccaePath); CommonUtil.deleteIfExists(ccaePath); serializeObject(convertAnswerElement, ccaePath); Path outputDir = _d.getVendorIndependentConfigDir(network, snapshot); String batchName = String.format( "Serializing %s vendor-independent configuration structures for snapshot %s", configurations.size(), snapshot); storeConfigurations(outputDir, batchName, configurations); }
answerFile(questionFile, modifiedQuestion.getDifferential(), isDelta, outWriter); if (questionFile != null) { CommonUtil.deleteIfExists(questionFile);
CommonUtil.deleteIfExists(analysisFile);