private void identifyDeviceTypes(Collection<Configuration> configurations) { for (Configuration c : configurations) { if (c.getDeviceType() != null) { continue; } // Set device type to host iff the configuration format is HOST if (c.getConfigurationFormat() == ConfigurationFormat.HOST) { c.setDeviceType(DeviceType.HOST); } else if (c.getVrfs().values().stream() .anyMatch( vrf -> vrf.getBgpProcess() != null || !vrf.getEigrpProcesses().isEmpty() || vrf.getOspfProcess() != null || vrf.getRipProcess() != null)) { // If any vrf on device has BGP, EIGRP, OSPF, or RIP, set device type to router c.setDeviceType(DeviceType.ROUTER); } else { // If device was not a host or router, call it a switch c.setDeviceType(DeviceType.SWITCH); } } }
private void postProcessConfiguration(Configuration c) { // Set device type to host iff the configuration format is HOST if (c.getConfigurationFormat() == ConfigurationFormat.HOST) { c.setDeviceType(DeviceType.HOST); } for (Vrf vrf : c.getVrfs().values()) { // If vrf has BGP, OSPF, or RIP process and device isn't a host, set device type to router if (c.getDeviceType() == null && (vrf.getBgpProcess() != null || vrf.getOspfProcess() != null || vrf.getRipProcess() != null)) { c.setDeviceType(DeviceType.ROUTER); } // Compute OSPF interface costs where they are missing OspfProcess proc = vrf.getOspfProcess(); if (proc != null) { proc.initInterfaceCosts(c); } } // If device was not a host or router, call it a switch if (c.getDeviceType() == null) { c.setDeviceType(DeviceType.SWITCH); } } }
Configuration cfgNode = elasticsearchDomain.toConfigurationNode(awsConfiguration, this, warnings); cfgNode.setDeviceType(DeviceType.HOST); configurationNodes.put(cfgNode.getHostname(), cfgNode); awsConfiguration.getWarningsByHost().put(cfgNode.getHostname(), warnings); Warnings warnings = Batfish.buildWarnings(awsConfiguration.getSettings()); Configuration cfgNode = instance.toConfigurationNode(this, warnings); cfgNode.setDeviceType(DeviceType.HOST); configurationNodes.put(cfgNode.getHostname(), cfgNode); awsConfiguration.getWarningsByHost().put(cfgNode.getHostname(), warnings); Warnings warnings = Batfish.buildWarnings(awsConfiguration.getSettings()); Configuration cfgNode = rdsInstance.toConfigurationNode(awsConfiguration, this, warnings); cfgNode.setDeviceType(DeviceType.HOST); configurationNodes.put(cfgNode.getHostname(), cfgNode); awsConfiguration.getWarningsByHost().put(cfgNode.getHostname(), warnings);