Search in sources :

Example 1 with ParseEnvironmentBgpTableJob

use of org.batfish.job.ParseEnvironmentBgpTableJob in project batfish by batfish.

the class Batfish method parseEnvironmentBgpTables.

private SortedMap<String, BgpAdvertisementsByVrf> parseEnvironmentBgpTables(SortedMap<Path, String> inputData, ParseEnvironmentBgpTablesAnswerElement answerElement) {
    _logger.info("\n*** PARSING ENVIRONMENT BGP TABLES ***\n");
    _logger.resetTimer();
    SortedMap<String, BgpAdvertisementsByVrf> bgpTables = new TreeMap<>();
    List<ParseEnvironmentBgpTableJob> jobs = new ArrayList<>();
    SortedMap<String, Configuration> configurations = loadConfigurations();
    for (Entry<Path, String> bgpFile : inputData.entrySet()) {
        Path currentFile = bgpFile.getKey();
        String fileText = bgpFile.getValue();
        String hostname = currentFile.getFileName().toString();
        String optionalSuffix = ".bgp";
        if (hostname.endsWith(optionalSuffix)) {
            hostname = hostname.substring(0, hostname.length() - optionalSuffix.length());
        }
        if (!configurations.containsKey(hostname)) {
            continue;
        }
        Warnings warnings = buildWarnings(_settings);
        ParseEnvironmentBgpTableJob job = new ParseEnvironmentBgpTableJob(_settings, fileText, hostname, currentFile, warnings, _bgpTablePlugins);
        jobs.add(job);
    }
    BatfishJobExecutor.runJobsInExecutor(_settings, _logger, jobs, bgpTables, answerElement, _settings.getHaltOnParseError(), "Parse environment BGP tables");
    _logger.printElapsedTime();
    return bgpTables;
}
Also used : Path(java.nio.file.Path) 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) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ParseEnvironmentBgpTableJob(org.batfish.job.ParseEnvironmentBgpTableJob) Warnings(org.batfish.common.Warnings) BgpAdvertisementsByVrf(org.batfish.datamodel.collections.BgpAdvertisementsByVrf)

Aggregations

Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 ImmutableConfiguration (org.apache.commons.configuration2.ImmutableConfiguration)1 Warnings (org.batfish.common.Warnings)1 Configuration (org.batfish.datamodel.Configuration)1 BgpAdvertisementsByVrf (org.batfish.datamodel.collections.BgpAdvertisementsByVrf)1 ParseEnvironmentBgpTableJob (org.batfish.job.ParseEnvironmentBgpTableJob)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