Search in sources :

Example 1 with Annotations

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;
}
Also used : Annotations(org.onosproject.net.Annotations) Port(org.onosproject.net.Port)

Example 2 with Annotations

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();
    }
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) OduSignalType(org.onosproject.net.OduSignalType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) OchSignal(org.onosproject.net.OchSignal) DefaultOchPort(org.onosproject.net.optical.impl.DefaultOchPort) IOException(java.io.IOException) OchPort(org.onosproject.net.optical.OchPort) DefaultOchPort(org.onosproject.net.optical.impl.DefaultOchPort)

Example 3 with Annotations

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();
    }
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultOduCltPort(org.onosproject.net.optical.impl.DefaultOduCltPort) OduCltPort(org.onosproject.net.optical.OduCltPort) DefaultOduCltPort(org.onosproject.net.optical.impl.DefaultOduCltPort) CltSignalType(org.onosproject.net.CltSignalType)

Example 4 with Annotations

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]);
    }
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations)

Example 5 with Annotations

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));
}
Also used : ResourceContext(org.onosproject.net.intent.ResourceContext) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) DefaultPath(org.onosproject.net.DefaultPath) Before(org.junit.Before)

Aggregations

Annotations (org.onosproject.net.Annotations)39 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)25 Test (org.junit.Test)9 Device (org.onosproject.net.Device)9 Port (org.onosproject.net.Port)8 ArrayList (java.util.ArrayList)6 DefaultDevice (org.onosproject.net.DefaultDevice)6 DefaultPort (org.onosproject.net.DefaultPort)6 SparseAnnotations (org.onosproject.net.SparseAnnotations)5 IpAddress (org.onlab.packet.IpAddress)4 DefaultPath (org.onosproject.net.DefaultPath)4 PortNumber (org.onosproject.net.PortNumber)4 ProviderId (org.onosproject.net.provider.ProviderId)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Set (java.util.Set)3 Before (org.junit.Before)3 Frequency (org.onlab.util.Frequency)3 NodeId (org.onosproject.cluster.NodeId)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 DefaultHost (org.onosproject.net.DefaultHost)3