Search in sources :

Example 1 with NullProviders

use of org.onosproject.provider.nil.NullProviders 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 NullProviders

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

the class NullDeviceCommand method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    DeviceId deviceId = DeviceId.deviceId(id);
    if (cmd.equals(UP)) {
        service.repairDevice(deviceId);
    } else if (cmd.equals(DOWN)) {
        service.failDevice(deviceId);
    } else {
        error("Illegal command %s; must be up or down", cmd);
    }
}
Also used : DeviceId(org.onosproject.net.DeviceId) NullProviders(org.onosproject.provider.nil.NullProviders)

Example 3 with NullProviders

use of org.onosproject.provider.nil.NullProviders 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 4 with NullProviders

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

the class NullLinkCommand method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    try {
        ConnectPoint onePoint = ConnectPoint.deviceConnectPoint(one);
        ConnectPoint twoPoint = ConnectPoint.deviceConnectPoint(two);
        if (cmd.equals(UP)) {
            service.repairLink(onePoint, twoPoint);
        } else if (cmd.equals(DOWN)) {
            service.severLink(onePoint, twoPoint);
        } else {
            error("Illegal command %s; must be up or down", cmd);
        }
    } catch (NumberFormatException e) {
        error("Invalid port number specified", e);
    }
}
Also used : NullProviders(org.onosproject.provider.nil.NullProviders) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 5 with NullProviders

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

the class NullPortStatsControlCommand method doExecute.

@Override
protected void doExecute() {
    ComponentConfigService service = get(ComponentConfigService.class);
    NullProviders npService = get(NullProviders.class);
    npService.enablePortStats(cmd.equals(START));
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) NullProviders(org.onosproject.provider.nil.NullProviders)

Aggregations

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