Search in sources :

Example 1 with GenericConfigObject

use of org.batfish.datamodel.GenericConfigObject in project batfish by batfish.

the class Batfish method convertConfigurations.

private Map<String, Configuration> convertConfigurations(Map<String, GenericConfigObject> vendorConfigurations, ConvertConfigurationAnswerElement answerElement) {
    _logger.info("\n*** CONVERTING VENDOR CONFIGURATIONS TO INDEPENDENT FORMAT ***\n");
    _logger.resetTimer();
    Map<String, Configuration> configurations = new TreeMap<>();
    List<ConvertConfigurationJob> jobs = new ArrayList<>();
    for (Entry<String, GenericConfigObject> config : vendorConfigurations.entrySet()) {
        GenericConfigObject vc = config.getValue();
        ConvertConfigurationJob job = new ConvertConfigurationJob(_settings, vc, config.getKey());
        jobs.add(job);
    }
    BatfishJobExecutor.runJobsInExecutor(_settings, _logger, jobs, configurations, answerElement, _settings.getHaltOnConvertError(), "Convert configurations to vendor-independent format");
    _logger.printElapsedTime();
    return configurations;
}
Also used : HostConfiguration(org.batfish.representation.host.HostConfiguration) Configuration(org.batfish.datamodel.Configuration) ImmutableConfiguration(org.apache.commons.configuration2.ImmutableConfiguration) AwsConfiguration(org.batfish.representation.aws.AwsConfiguration) IptablesVendorConfiguration(org.batfish.representation.iptables.IptablesVendorConfiguration) VendorConfiguration(org.batfish.vendor.VendorConfiguration) ConvertConfigurationJob(org.batfish.job.ConvertConfigurationJob) GenericConfigObject(org.batfish.datamodel.GenericConfigObject) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Example 2 with GenericConfigObject

use of org.batfish.datamodel.GenericConfigObject in project batfish by batfish.

the class Batfish method deserializeVendorConfigurations.

public Map<String, GenericConfigObject> deserializeVendorConfigurations(Path serializedVendorConfigPath) {
    _logger.info("\n*** DESERIALIZING VENDOR CONFIGURATION STRUCTURES ***\n");
    _logger.resetTimer();
    Map<Path, String> namesByPath = new TreeMap<>();
    try (DirectoryStream<Path> serializedConfigs = Files.newDirectoryStream(serializedVendorConfigPath)) {
        for (Path serializedConfig : serializedConfigs) {
            String name = serializedConfig.getFileName().toString();
            namesByPath.put(serializedConfig, name);
        }
    } catch (IOException e) {
        throw new BatfishException("Error reading vendor configs directory", e);
    }
    Map<String, GenericConfigObject> vendorConfigurations = deserializeObjects(namesByPath, GenericConfigObject.class);
    _logger.printElapsedTime();
    return vendorConfigurations;
}
Also used : Path(java.nio.file.Path) CleanBatfishException(org.batfish.common.CleanBatfishException) BatfishException(org.batfish.common.BatfishException) GenericConfigObject(org.batfish.datamodel.GenericConfigObject) IOException(java.io.IOException) TreeMap(java.util.TreeMap)

Aggregations

TreeMap (java.util.TreeMap)2 GenericConfigObject (org.batfish.datamodel.GenericConfigObject)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ImmutableConfiguration (org.apache.commons.configuration2.ImmutableConfiguration)1 BatfishException (org.batfish.common.BatfishException)1 CleanBatfishException (org.batfish.common.CleanBatfishException)1 Configuration (org.batfish.datamodel.Configuration)1 ConvertConfigurationJob (org.batfish.job.ConvertConfigurationJob)1 AwsConfiguration (org.batfish.representation.aws.AwsConfiguration)1 HostConfiguration (org.batfish.representation.host.HostConfiguration)1 IptablesVendorConfiguration (org.batfish.representation.iptables.IptablesVendorConfiguration)1 VendorConfiguration (org.batfish.vendor.VendorConfiguration)1