Logger.debug("Unable to find opposite", e);
}
if (aSwitch == null) { // create a switch if necessary
aSwitch = new Host(Type.Switch);
map.addVertex(aSwitch);
aSwitch.addInterface(new TransparentIF(aSwitch, gToS, gatewayIF));
map.addEdge(gToS, gateway, aSwitch);
}
final Device gw = gateway, sw = aSwitch;
final NetworkIF gif = gatewayIF;
for (final InetAddress address : hosts.keySet()) {
Scheduler.execute(new Runnable() {
@Override
public void run() {
try {
if (!address.equals(gif.getAddress())) {
if (tryFindIP(map, address) != null) return;
Logger.debug("Adding Interface "+address);
Connection c = new Connection();
Device d = new Host();
d.setName(address.getHostName());
PhysicalIF pif = new PhysicalIF(d, c, address.getHostAddress());
pif.setPingMethod(hosts.get(address));
pif.setSubnet(subnet.getInfo().getNetmask());
pif.setGateway(subnet.getInfo().getLowAddress());
d.addInterface(pif);
SNMP.inferProperties(d);
sw.addInterface(new TransparentIF(sw, c, pif));
map.addVertex(d);
map.addEdge(c, d, sw);
} else {
if (gif instanceof PhysicalIF) ((PhysicalIF) gif).setPingMethod(hosts.get(address));
gw.setName(address.getHostName());