use of org.batfish.datamodel.answers.ValidateEnvironmentAnswerElement in project batfish by batfish.
the class Batfish method blacklistInterface.
/**
* Helper function to disable a blacklisted interface and update the given {@link
* ValidateEnvironmentAnswerElement} if the interface does not actually exist.
*/
private static void blacklistInterface(Map<String, Configuration> configurations, ValidateEnvironmentAnswerElement veae, NodeInterfacePair iface) {
String hostname = iface.getHostname();
String ifaceName = iface.getInterface();
@Nullable Configuration node = configurations.get(hostname);
if (node == null) {
veae.setValid(false);
veae.getUndefinedInterfaceBlacklistNodes().add(hostname);
return;
}
@Nullable Interface nodeIface = node.getInterfaces().get(ifaceName);
if (nodeIface == null) {
veae.setValid(false);
veae.getUndefinedInterfaceBlacklistInterfaces().computeIfAbsent(hostname, k -> new TreeSet<>()).add(ifaceName);
return;
}
nodeIface.setActive(false);
nodeIface.setBlacklisted(true);
}
use of org.batfish.datamodel.answers.ValidateEnvironmentAnswerElement in project batfish by batfish.
the class Batfish method validateEnvironment.
private Answer validateEnvironment() {
Answer answer = new Answer();
ValidateEnvironmentAnswerElement ae = loadValidateEnvironmentAnswerElement();
answer.addAnswerElement(ae);
Topology envTopology = computeEnvironmentTopology(loadConfigurations());
serializeAsJson(_testrigSettings.getEnvironmentSettings().getSerializedTopologyPath(), envTopology, "environment topology");
return answer;
}
use of org.batfish.datamodel.answers.ValidateEnvironmentAnswerElement in project batfish by batfish.
the class Batfish method applyEnvironment.
/**
* Ensures that the current configurations for the current testrig+environment are up to date.
* Among other things, this includes:
*
* <ul>
* <li>Invalidating cached configs if the in-memory copy has been changed by question
* processing.
* <li>Re-loading configurations from disk, including re-parsing if the configs were parsed on a
* previous version of Batfish.
* <li>Re-applying the environment to the configs, to ensure that blacklists are honored.
* </ul>
*/
private void applyEnvironment(Map<String, Configuration> configurationsWithoutEnvironment) {
ValidateEnvironmentAnswerElement veae = new ValidateEnvironmentAnswerElement();
updateBlacklistedAndInactiveConfigs(configurationsWithoutEnvironment, veae);
processNodeRoles(configurationsWithoutEnvironment, veae);
serializeObject(veae, _testrigSettings.getEnvironmentSettings().getValidateEnvironmentAnswerPath());
}
Aggregations