use of org.onosproject.net.optical.impl.DefaultOchPort in project onos by opennetworkinglab.
the class OchPortHelper method asOchPort.
public static Optional<OchPort> asOchPort(Port port) {
if (port instanceof OchPort) {
return Optional.of((OchPort) port);
}
try {
Annotations an = port.annotations();
OduSignalType signalType = Enum.valueOf(OduSignalType.class, an.value(SIGNAL_TYPE));
boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
OchSignal lambda = OchSignalCodec.decode(obj);
// DefaultOchPort should filter them, if necessary.
return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
// TODO: it'll be better to verify each inputs properly
// instead of catching all these Exceptions.
} catch (IOException | NullPointerException | IllegalArgumentException | ClassCastException e) {
log.warn("{} was not well-formed OCh port.", port, e);
return Optional.empty();
}
}
Aggregations