Search in sources :

Example 1 with CustomTopologySimulator

use of org.onosproject.provider.nil.CustomTopologySimulator in project onos by opennetworkinglab.

the class CreateNullHosts method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    NetworkConfigService cfgService = get(NetworkConfigService.class);
    TopologySimulator simulator = service.currentSimulator();
    if (!validateSimulator(simulator)) {
        return;
    }
    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    List<ConnectPoint> points = findAvailablePorts(sim.deviceId(deviceName));
    String pattern = hostIpPattern.replace("*", "%d");
    double yStep = rowGap / hostsPerRow;
    double y = gridY;
    double x = gridX - (colGap * (hostsPerRow - 1)) / 2;
    for (int h = 0; h < hostCount; h++) {
        HostLocation location = new HostLocation(points.get(h), System.currentTimeMillis());
        IpAddress ip = IpAddress.valueOf(String.format(pattern, h));
        HostId id = sim.nextHostId();
        if (gridY != NONE) {
            BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class);
            setUiCoordinates(cfg, GRID, y, x);
            if (((h + 1) % hostsPerRow) == 0) {
                x = gridX - (colGap * (hostsPerRow - 1)) / 2;
            } else {
                x += colGap;
                y += yStep;
            }
        }
        Tools.delay(10);
        sim.createHost(id, location, ip);
    }
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) HostId(org.onosproject.net.HostId) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) BasicHostConfig(org.onosproject.net.config.basics.BasicHostConfig) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) HostLocation(org.onosproject.net.HostLocation) NullProviders(org.onosproject.provider.nil.NullProviders) IpAddress(org.onlab.packet.IpAddress)

Example 2 with CustomTopologySimulator

use of org.onosproject.provider.nil.CustomTopologySimulator in project onos by opennetworkinglab.

the class CreateNullHost method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    NetworkConfigService cfgService = get(NetworkConfigService.class);
    TopologySimulator simulator = service.currentSimulator();
    if (!validateSimulator(simulator) || !validateLocType(locType)) {
        return;
    }
    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    HostId id = sim.nextHostId();
    Set<HostLocation> locations;
    try {
        locations = getLocations(sim, deviceNames);
    } catch (NoLocationException e) {
        error("\u001B[1;31mHost not created - no location (free port) available on %s\u001B[0m", e.getMessage());
        return;
    }
    Set<IpAddress> ips = getIps(hostIps);
    BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class);
    setUiCoordinates(cfg, locType, latOrY, longOrX);
    Tools.delay(10);
    sim.createHost(id, locations, ips);
}
Also used : TopologySimulator(org.onosproject.provider.nil.TopologySimulator) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) HostLocation(org.onosproject.net.HostLocation) NullProviders(org.onosproject.provider.nil.NullProviders) IpAddress(org.onlab.packet.IpAddress) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) HostId(org.onosproject.net.HostId) BasicHostConfig(org.onosproject.net.config.basics.BasicHostConfig)

Example 3 with CustomTopologySimulator

use of org.onosproject.provider.nil.CustomTopologySimulator in project onos by opennetworkinglab.

the class CreateNullDevice method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    NetworkConfigService cfgService = get(NetworkConfigService.class);
    TopologySimulator simulator = service.currentSimulator();
    if (!validateSimulator(simulator) || !validateLocType(locType)) {
        return;
    }
    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    DeviceId deviceId = id == null ? sim.nextDeviceId() : DeviceId.deviceId(id);
    BasicDeviceConfig cfg = cfgService.addConfig(deviceId, BasicDeviceConfig.class);
    cfg.name(name);
    setUiCoordinates(cfg, locType, latOrY, longOrX);
    Tools.delay(10);
    sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()), hw, sw, portCount);
}
Also used : CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId) NullProviders(org.onosproject.provider.nil.NullProviders) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 4 with CustomTopologySimulator

use of org.onosproject.provider.nil.CustomTopologySimulator in project onos by opennetworkinglab.

the class CreateNullLink method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    TopologySimulator simulator = service.currentSimulator();
    if (!(simulator instanceof CustomTopologySimulator)) {
        error("Custom topology simulator is not active.");
        return;
    }
    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    ConnectPoint one = findAvailablePort(sim.deviceId(src), null);
    ConnectPoint two = findAvailablePort(sim.deviceId(dst), one);
    if (one == null) {
        error("\u001B[1;31mLink not created - no location (free port) available on src %s\u001B[0m", src);
        return;
    } else if (two == null) {
        error("\u001B[1;31mLink not created - no location (free port) available on dst %s\u001B[0m", dst);
        return;
    }
    sim.createLink(one, two, Link.Type.valueOf(type.toUpperCase()), !unidirectional);
}
Also used : CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) NullProviders(org.onosproject.provider.nil.NullProviders) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

CustomTopologySimulator (org.onosproject.provider.nil.CustomTopologySimulator)4 NullProviders (org.onosproject.provider.nil.NullProviders)4 TopologySimulator (org.onosproject.provider.nil.TopologySimulator)4 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)3 IpAddress (org.onlab.packet.IpAddress)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 HostId (org.onosproject.net.HostId)2 HostLocation (org.onosproject.net.HostLocation)2 BasicHostConfig (org.onosproject.net.config.basics.BasicHostConfig)2 DeviceId (org.onosproject.net.DeviceId)1 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)1