Package ch.rakudave.jnetmap.model.device

Examples of ch.rakudave.jnetmap.model.device.Host


public class DeviceFactory implements Factory<Device> {
  private static Type type = Type.Workstation;

  @Override
  public Device create() {
    return new Host(type);
  }
View Full Code Here


      gatewayIF = tryFindIP(map, InetAddress.getByName(subnet.getInfo().getLowAddress()));
    } catch (UnknownHostException ex) {
      Logger.debug("Unable to find gateway-interface", ex);
    }
    if (gatewayIF == null) { // create a gateway if none was found
      gateway = new Host(Type.Router);
      gatewayIF = new PhysicalIF(gateway, gToS, subnet.getInfo().getLowAddress());
      map.addVertex(gateway);
      gateway.addInterface(gatewayIF);
    } else {
      gateway = gatewayIF.getDevice();
    }
    try { // try to find the switch attached to the gateway
      aSwitch = map.getOpposite(gateway, gatewayIF.getConnection());
      // if the opposite is not a switch, reset
      if (aSwitch != null && !aSwitch.getType().toString().toLowerCase().contains("switch")) aSwitch = null;
    } catch (Exception e) {
      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 {
View Full Code Here

  public void setUp() {
    status = Status.UP;
    lastSeen = new Date();
    Connection c = new Connection();
    c.setBandwidth(100);
    Host host = new Host();
    pif = new PhysicalIF(host, c, address1);
    pif2 = new PhysicalIF(host, c, address2);
  }
View Full Code Here

  @Before
  public void setUp() {
    Connection c = new Connection();
    c.setBandwidth(100);
    Host host = new Host();
    pif = new PhysicalIF(host, c, address1);
    pif2 = new PhysicalIF(host, c, address2);
    tif = new TransparentIF(host, c, pif);
    tif2 = new TransparentIF(host, c, pif2);
  }
View Full Code Here

  private String address2;
  private String failaddress;

  @Before
  public void setUP() {
    Host parent = new Host();
    address = "192.168.0.16";
    address2 = "170.234.120.11";
    failaddress = "Ringo";
    LIF = new LogicalIF(parent, new Connection(), address);
    LIF2 = new LogicalIF(parent, new Connection(), address);
View Full Code Here

TOP

Related Classes of ch.rakudave.jnetmap.model.device.Host

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.