Search in sources :

Example 6 with ParseVendorConfigurationAnswerElement

use of org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement in project batfish by batfish.

the class Batfish method histogram.

private void histogram(Path testRigPath) {
    Map<Path, String> configurationData = readConfigurationFiles(testRigPath, BfConsts.RELPATH_CONFIGURATIONS_DIR);
    // todo: either remove histogram function or do something userful with
    // answer
    Map<String, VendorConfiguration> vendorConfigurations = parseVendorConfigurations(configurationData, new ParseVendorConfigurationAnswerElement(), ConfigurationFormat.UNKNOWN);
    _logger.info("Building feature histogram...");
    MultiSet<String> histogram = new TreeMultiSet<>();
    for (VendorConfiguration vc : vendorConfigurations.values()) {
        Set<String> unimplementedFeatures = vc.getUnimplementedFeatures();
        histogram.add(unimplementedFeatures);
    }
    _logger.info("OK\n");
    for (String feature : histogram.elements()) {
        int count = histogram.count(feature);
        _logger.outputf("%s: %s\n", feature, count);
    }
}
Also used : Path(java.nio.file.Path) IptablesVendorConfiguration(org.batfish.representation.iptables.IptablesVendorConfiguration) VendorConfiguration(org.batfish.vendor.VendorConfiguration) ParseVendorConfigurationAnswerElement(org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement) TreeMultiSet(org.batfish.datamodel.collections.TreeMultiSet)

Example 7 with ParseVendorConfigurationAnswerElement

use of org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement in project batfish by batfish.

the class Batfish method repairConfigurations.

private void repairConfigurations() {
    ParseVendorConfigurationAnswerElement pvcae = loadParseVendorConfigurationAnswerElement();
    if (!Version.isCompatibleVersion("Service", "Old parsed configurations", pvcae.getVersion())) {
        repairVendorConfigurations();
    }
    Path inputPath = _testrigSettings.getSerializeVendorPath();
    serializeIndependentConfigs(inputPath);
}
Also used : Path(java.nio.file.Path) ParseVendorConfigurationAnswerElement(org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement)

Example 8 with ParseVendorConfigurationAnswerElement

use of org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement in project batfish by batfish.

the class WorkMgr method getParsingResults.

public JSONObject getParsingResults(String containerName, String testrigName) throws JsonProcessingException, JSONException {
    ParseVendorConfigurationAnswerElement pvcae = deserializeObject(getdirTestrig(containerName, testrigName).resolve(BfConsts.RELPATH_PARSE_ANSWER_PATH), ParseVendorConfigurationAnswerElement.class);
    JSONObject warnings = new JSONObject();
    SortedMap<String, Warnings> warningsMap = pvcae.getWarnings();
    ObjectWriter writer = BatfishObjectMapper.prettyWriter();
    for (String s : warningsMap.keySet()) {
        warnings.put(s, writer.writeValueAsString(warningsMap.get(s)));
    }
    return warnings;
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) ParseVendorConfigurationAnswerElement(org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) Warnings(org.batfish.common.Warnings)

Aggregations

ParseVendorConfigurationAnswerElement (org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement)8 Path (java.nio.file.Path)6 VendorConfiguration (org.batfish.vendor.VendorConfiguration)5 TreeMap (java.util.TreeMap)4 BatfishException (org.batfish.common.BatfishException)3 HostConfiguration (org.batfish.representation.host.HostConfiguration)3 File (java.io.File)2 InitInfoAnswerElement (org.batfish.datamodel.answers.InitInfoAnswerElement)2 IptablesVendorConfiguration (org.batfish.representation.iptables.IptablesVendorConfiguration)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 Verify (com.google.common.base.Verify)1 Cache (com.google.common.cache.Cache)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1