Search in sources :

Example 1 with DefaultOmsPort

use of org.onosproject.net.optical.impl.DefaultOmsPort in project onos by opennetworkinglab.

the class OmsPortHelper method asOmsPort.

public static Optional<OmsPort> asOmsPort(Port port) {
    if (port instanceof OmsPort) {
        return Optional.of((OmsPort) port);
    }
    try {
        Annotations an = port.annotations();
        Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MIN_FREQ_HZ)));
        Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MAX_FREQ_HZ)));
        Frequency grid = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.GRID_HZ)));
        return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
    } catch (NumberFormatException e) {
        log.warn("{} was not well-formed OMS port.", port, e);
        return Optional.empty();
    }
}
Also used : DefaultOmsPort(org.onosproject.net.optical.impl.DefaultOmsPort) OmsPort(org.onosproject.net.optical.OmsPort) OpticalAnnotations(org.onosproject.net.optical.OpticalAnnotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) Frequency(org.onlab.util.Frequency) DefaultOmsPort(org.onosproject.net.optical.impl.DefaultOmsPort)

Aggregations

Frequency (org.onlab.util.Frequency)1 Annotations (org.onosproject.net.Annotations)1 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)1 SparseAnnotations (org.onosproject.net.SparseAnnotations)1 OmsPort (org.onosproject.net.optical.OmsPort)1 OpticalAnnotations (org.onosproject.net.optical.OpticalAnnotations)1 DefaultOmsPort (org.onosproject.net.optical.impl.DefaultOmsPort)1