Search in sources :

Example 6 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class PortWaveLengthCommand method createOchSignalFromWavelength.

private OchSignal createOchSignalFromWavelength(DeviceService deviceService, ConnectPoint cp) {
    long wavelength = Long.parseLong(parameter);
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(cp);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        print("[ERROR] connect point %s is not OChPort", cp);
        return null;
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OchSignal(org.onosproject.net.OchSignal) OchPort(org.onosproject.net.optical.OchPort) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 7 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class PortWaveLengthCommand method createOchSignal.

private OchSignal createOchSignal() throws IllegalArgumentException {
    if (parameter == null) {
        return null;
    }
    try {
        String[] splitted = parameter.split("/");
        checkArgument(splitted.length == 4, "signal requires 4 parameters: " + SIGNAL_FORMAT);
        int slotGranularity = Integer.parseInt(splitted[0]);
        String chSpacing = splitted[1];
        ChannelSpacing channelSpacing = checkNotNull(CHANNEL_SPACING_MAP.get(chSpacing), String.format("invalid channel spacing: %s", chSpacing));
        int multiplier = Integer.parseInt(splitted[2]);
        String gdType = splitted[3].toUpperCase();
        GridType gridType = GridType.valueOf(gdType);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } catch (RuntimeException e) {
        /* catching RuntimeException as both NullPointerException (thrown by
             * checkNotNull) and IllegalArgumentException (thrown by checkArgument)
             * are subclasses of RuntimeException.
             */
        String msg = String.format("Invalid signal format: %s, expected format is %s.", parameter, SIGNAL_FORMAT);
        print(msg);
        throw new IllegalArgumentException(msg, e);
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 8 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class CienaWaveserverDeviceDescription method parseWaveServerCienaOchPorts.

public static PortDescription parseWaveServerCienaOchPorts(long portNumber, HierarchicalConfiguration config, SparseAnnotations annotations) {
    final List<String> tunableType = Lists.newArrayList("performance-optimized", "accelerated");
    final String flexGrid = "flex-grid";
    final String state = "properties.transmitter.state";
    final String tunable = "properties.modem.tx-tuning-mode";
    final String spacing = "properties.line-system.wavelength-spacing";
    final String frequency = "properties.transmitter.frequency.value";
    boolean isEnabled = config.getString(state).equals(ENABLED);
    boolean isTunable = tunableType.contains(config.getString(tunable));
    GridType gridType = config.getString(spacing).equals(flexGrid) ? GridType.FLEX : null;
    ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null;
    // Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier
    final int baseFrequency = 193100;
    long spacingFrequency = chSpacing == null ? baseFrequency : chSpacing.frequency().asHz();
    int spacingMult = ((int) (toGbps(((int) config.getDouble(frequency) - baseFrequency)) / // FIXME is there a better way ?
    toGbpsFromHz(spacingFrequency)));
    return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, OduSignalType.ODU4, isTunable, new OchSignal(gridType, chSpacing, spacingMult, 1), annotations);
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) GridType(org.onosproject.net.GridType)

Example 9 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class ConfigLambdaQuery method queryLambdas.

@Override
public Set<OchSignal> queryLambdas(PortNumber port) {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    ConnectPoint cp = new ConnectPoint(data().deviceId(), port);
    LambdaConfig cfg = netcfg.getConfig(cp, LambdaConfig.class);
    if (cfg == null) {
        return ImmutableSet.of();
    }
    GridType type = cfg.gridType();
    Optional<ChannelSpacing> dwdmSpacing = cfg.dwdmSpacing();
    int start = cfg.slotStart();
    int step = cfg.slotStep();
    int end = cfg.slotEnd();
    Set<OchSignal> lambdas = new LinkedHashSet<>();
    for (int i = start; i <= end; i += step) {
        switch(type) {
            case DWDM:
                lambdas.add(OchSignal.newDwdmSlot(dwdmSpacing.get(), i));
                break;
            case FLEX:
                lambdas.add(OchSignal.newFlexGridSlot(i));
                break;
            case CWDM:
            default:
                log.warn("Unsupported grid type: {}", type);
                break;
        }
    }
    return lambdas;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ChannelSpacing(org.onosproject.net.ChannelSpacing) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) OchSignal(org.onosproject.net.OchSignal) LambdaConfig(org.onosproject.driver.optical.config.LambdaConfig) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 10 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class AddOpticalIntentCommand method createOchSignal.

private OchSignal createOchSignal() throws IllegalArgumentException {
    if (signal == null) {
        return null;
    }
    try {
        String[] splitted = signal.split("/");
        checkArgument(splitted.length == 4, "signal requires 4 parameters: " + SIGNAL_FORMAT);
        int slotGranularity = Integer.parseInt(splitted[0]);
        String chSpacing = splitted[1];
        ChannelSpacing channelSpacing = checkNotNull(CHANNEL_SPACING_MAP.get(chSpacing), String.format("invalid channel spacing: %s", chSpacing));
        int multiplier = Integer.parseInt(splitted[2]);
        String gdType = splitted[3].toUpperCase();
        GridType gridType = GridType.valueOf(gdType);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } catch (RuntimeException e) {
        /* catching RuntimeException as both NullPointerException (thrown by
             * checkNotNull) and IllegalArgumentException (thrown by checkArgument)
             * are subclasses of RuntimeException.
             */
        String msg = String.format("Invalid signal format: %s, expected format is %s.", signal, SIGNAL_FORMAT);
        print(msg);
        throw new IllegalArgumentException(msg, e);
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Aggregations

ChannelSpacing (org.onosproject.net.ChannelSpacing)11 GridType (org.onosproject.net.GridType)11 OchSignal (org.onosproject.net.OchSignal)9 ConnectPoint (org.onosproject.net.ConnectPoint)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 LinkedHashSet (java.util.LinkedHashSet)2 Port (org.onosproject.net.Port)2 OchPort (org.onosproject.net.optical.OchPort)2 Frequency (org.onlab.util.Frequency)1 HexString (org.onlab.util.HexString)1 LambdaConfig (org.onosproject.driver.optical.config.LambdaConfig)1 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)1