Search in sources :

Example 6 with NullProviders

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

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

Example 8 with NullProviders

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

the class NullControlCommand method doExecute.

@Override
protected void doExecute() {
    ComponentConfigService service = get(ComponentConfigService.class);
    // If there is an existing topology; make sure it's stopped before restarting
    if (cmd.equals(START)) {
        NullProviders npService = get(NullProviders.class);
        TopologySimulator simulator = npService.currentSimulator();
        if (simulator != null) {
            simulator.tearDownTopology();
        }
    }
    if (topoShape != null) {
        service.setProperty(NullProviders.class.getName(), "topoShape", topoShape);
    }
    service.setProperty(NullProviders.class.getName(), "enabled", cmd.equals(START) ? "true" : "false");
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) 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