use of org.batfish.datamodel.answers.InitInfoAnswerElement in project batfish by batfish.
the class Batfish method run.
public Answer run() {
newBatch("Begin job", 0);
loadPlugins();
boolean action = false;
Answer answer = new Answer();
if (_settings.getPrintSymmetricEdgePairs()) {
printSymmetricEdgePairs();
return answer;
}
if (_settings.getReport()) {
answer.addAnswerElement(report());
return answer;
}
if (_settings.getSynthesizeJsonTopology()) {
writeJsonTopology();
return answer;
}
if (_settings.getHistogram()) {
histogram(_testrigSettings.getTestRigPath());
return answer;
}
if (_settings.getFlatten()) {
Path flattenSource = _testrigSettings.getTestRigPath();
Path flattenDestination = _settings.getFlattenDestination();
flatten(flattenSource, flattenDestination);
return answer;
}
if (_settings.getGenerateStubs()) {
String inputRole = _settings.getGenerateStubsInputRole();
String interfaceDescriptionRegex = _settings.getGenerateStubsInterfaceDescriptionRegex();
int stubAs = _settings.getGenerateStubsRemoteAs();
generateStubs(inputRole, stubAs, interfaceDescriptionRegex);
return answer;
}
if (_settings.getSerializeVendor()) {
Path testRigPath = _testrigSettings.getTestRigPath();
Path outputPath = _testrigSettings.getSerializeVendorPath();
answer.append(serializeVendorConfigs(testRigPath, outputPath));
action = true;
}
if (_settings.getSerializeIndependent()) {
Path inputPath = _testrigSettings.getSerializeVendorPath();
answer.append(serializeIndependentConfigs(inputPath));
action = true;
}
if (_settings.getInitInfo()) {
InitInfoAnswerElement initInfoAnswerElement = initInfo(true, false);
// In this context we can remove parse trees because they will be returned in preceding answer
// element. Note that parse trees are not removed when asking initInfo as its own question.
initInfoAnswerElement.setParseTrees(Collections.emptySortedMap());
answer.addAnswerElement(initInfoAnswerElement);
action = true;
}
if (_settings.getCompileEnvironment()) {
answer.append(compileEnvironmentConfigurations(_testrigSettings));
action = true;
}
if (_settings.getAnswer()) {
answer.append(answer());
action = true;
}
if (_settings.getAnalyze()) {
answer.append(analyze());
action = true;
}
if (_settings.getDataPlane()) {
answer.addAnswerElement(computeDataPlane(_settings.getDiffActive()));
action = true;
}
if (_settings.getValidateEnvironment()) {
answer.append(validateEnvironment());
action = true;
}
if (!action) {
throw new CleanBatfishException("No task performed! Run with -help flag to see usage\n");
}
return answer;
}
use of org.batfish.datamodel.answers.InitInfoAnswerElement in project batfish by batfish.
the class Batfish method mergeParseAnswer.
private InitInfoAnswerElement mergeParseAnswer(boolean summary, boolean verboseError, ParseAnswerElement parseAnswer) {
InitInfoAnswerElement answerElement = new InitInfoAnswerElement();
mergeInitStepAnswer(answerElement, parseAnswer, summary, verboseError);
answerElement.setParseStatus(parseAnswer.getParseStatus());
answerElement.setParseTrees(parseAnswer.getParseTrees());
return answerElement;
}
use of org.batfish.datamodel.answers.InitInfoAnswerElement in project batfish by batfish.
the class Batfish method initInfo.
@Override
public InitInfoAnswerElement initInfo(boolean summary, boolean verboseError) {
ParseVendorConfigurationAnswerElement parseAnswer = loadParseVendorConfigurationAnswerElement();
InitInfoAnswerElement answerElement = mergeParseAnswer(summary, verboseError, parseAnswer);
mergeConvertAnswer(summary, verboseError, answerElement);
_logger.info(answerElement.prettyPrint());
return answerElement;
}
use of org.batfish.datamodel.answers.InitInfoAnswerElement 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.InitInfoAnswerElement in project batfish by batfish.
the class Batfish method mergeInitStepAnswer.
private void mergeInitStepAnswer(InitInfoAnswerElement initInfoAnswerElement, InitStepAnswerElement initStepAnswerElement, boolean summary, boolean verboseError) {
if (!summary) {
if (verboseError) {
SortedMap<String, List<BatfishStackTrace>> errors = initInfoAnswerElement.getErrors();
initStepAnswerElement.getErrors().forEach((hostname, initStepErrors) -> {
errors.computeIfAbsent(hostname, k -> new ArrayList<>()).add(initStepErrors);
});
}
SortedMap<String, Warnings> warnings = initInfoAnswerElement.getWarnings();
initStepAnswerElement.getWarnings().forEach((hostname, initStepWarnings) -> {
Warnings combined = warnings.computeIfAbsent(hostname, h -> buildWarnings(_settings));
combined.getPedanticWarnings().addAll(initStepWarnings.getPedanticWarnings());
combined.getRedFlagWarnings().addAll(initStepWarnings.getRedFlagWarnings());
combined.getUnimplementedWarnings().addAll(initStepWarnings.getUnimplementedWarnings());
});
}
}
Aggregations