use of org.onosproject.net.Annotations in project onos by opennetworkinglab.
the class DefaultK8sNode method macAddress.
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;
}
use of org.onosproject.net.Annotations 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();
}
}
use of org.onosproject.net.Annotations in project onos by opennetworkinglab.
the class OduCltPortHelper method asOduCltPort.
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));
// 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();
}
}
use of org.onosproject.net.Annotations in project onos by opennetworkinglab.
the class DeviceSetControllersCommand method parseCInfoString.
private ControllerInfo parseCInfoString(String cInfoString) {
Annotations annotation;
String[] config = cInfoString.split(",");
if (config.length == 2) {
String[] pair = config[1].split("=");
if (pair.length == 2) {
annotation = DefaultAnnotations.builder().set(pair[0], pair[1]).build();
} else {
print("Wrong format {}", config[1]);
return null;
}
return getControllerInfo(annotation, config[0]);
} else {
return getControllerInfo(null, config[0]);
}
}
use of org.onosproject.net.Annotations in project onos by opennetworkinglab.
the class LatencyConstraintTest method setUp.
@Before
public void setUp() {
resourceContext = createMock(ResourceContext.class);
Annotations annotations1 = DefaultAnnotations.builder().set(LATENCY, LATENCY1).build();
Annotations annotations2 = DefaultAnnotations.builder().set(LATENCY, LATENCY2).build();
link1 = DefaultLink.builder().providerId(PROVIDER_ID).src(cp(DID1, PN1)).dst(cp(DID2, PN2)).type(DIRECT).annotations(annotations1).build();
link2 = DefaultLink.builder().providerId(PROVIDER_ID).src(cp(DID2, PN3)).dst(cp(DID3, PN4)).type(DIRECT).annotations(annotations2).build();
path = new DefaultPath(PROVIDER_ID, Arrays.asList(link1, link2), ScalarWeight.toWeight(10));
}
Aggregations