Java Code Examples for org.onosproject.net.Port#annotations()
The following examples show how to use
org.onosproject.net.Port#annotations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OtuPortHelper.java From onos with Apache License 2.0 | 6 votes |
public static Optional<OtuPort> asOtuPort(Port port) { if (port instanceof OtuPort) { return Optional.of((OtuPort) port); } try { Annotations an = port.annotations(); OtuSignalType signalType = Enum.valueOf(OtuSignalType.class, an.value(SIGNAL_TYPE)); // Note: OTU specific annotations is not filtered-out here. // DefaultOtuPort should filter them, if necessary. return Optional.of(new DefaultOtuPort(port, signalType)); } catch (NullPointerException | IllegalArgumentException e) { log.warn("{} was not well-formed Otu port.", port, e); return Optional.empty(); } }
Example 2
Source File: OduCltPortHelper.java From onos with Apache License 2.0 | 6 votes |
public static Optional<OduCltPort> asOduCltPort(Port port) { if (port instanceof OduCltPort) { return Optional.of((OduCltPort) port); } try { Annotations an = port.annotations(); CltSignalType signalType = Enum.valueOf(CltSignalType.class, an.value(SIGNAL_TYPE)); // Note: ODU specific annotations is not filtered-out here. // DefaultOduCltPort should filter them, if necessary. return Optional.of(new DefaultOduCltPort(port, signalType)); } catch (NullPointerException | IllegalArgumentException e) { log.warn("{} was not well-formed OduClt port.", port, e); return Optional.empty(); } }
Example 3
Source File: OmsPortHelper.java From onos with Apache License 2.0 | 6 votes |
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(); } }
Example 4
Source File: SuppressionRules.java From onos with Apache License 2.0 | 5 votes |
public boolean isSuppressed(Port port) { Element parent = port.element(); if (parent instanceof Device) { if (isSuppressed((Device) parent)) { return true; } } final Annotations annotations = port.annotations(); if (containsSuppressionAnnotation(annotations)) { return true; } return false; }
Example 5
Source File: OchPortHelper.java From onos with Apache License 2.0 | 5 votes |
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); // Note: OCh specific annotations is not filtered-out here. // 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(); } }
Example 6
Source File: DefaultK8sNode.java From onos with Apache License 2.0 | 4 votes |
private MacAddress macAddress(DeviceId deviceId, String portName) { Port port = port(deviceId, portName); Annotations annots = port.annotations(); return annots != null ? MacAddress.valueOf(annots.value(PORT_MAC)) : null; }