use of org.onosproject.net.ChannelSpacing 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;
}
}
use of org.onosproject.net.ChannelSpacing 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);
}
}
use of org.onosproject.net.ChannelSpacing 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);
}
use of org.onosproject.net.ChannelSpacing 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;
}
use of org.onosproject.net.ChannelSpacing 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);
}
}
Aggregations