Search in sources :

Example 11 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)

Example 12 with Annotations

use of org.onosproject.net.Annotations in project onos by opennetworkinglab.

the class SimpleHostStore method updateHost.

// checks for type of update to host, sends appropriate event
private HostEvent updateHost(ProviderId providerId, StoredHost host, HostDescription descr, boolean replaceIps) {
    HostEvent event;
    if (!host.location().equals(descr.location())) {
        host.setLocation(descr.location());
        return new HostEvent(HOST_MOVED, host);
    }
    if (host.ipAddresses().containsAll(descr.ipAddress()) && descr.annotations().keys().isEmpty()) {
        return null;
    }
    final Set<IpAddress> addresses;
    if (replaceIps) {
        addresses = ImmutableSet.copyOf(descr.ipAddress());
    } else {
        addresses = new HashSet<>(host.ipAddresses());
        addresses.addAll(descr.ipAddress());
    }
    Annotations annotations = merge((DefaultAnnotations) host.annotations(), descr.annotations());
    StoredHost updated = new StoredHost(providerId, host.id(), host.mac(), host.vlan(), descr.location(), addresses, descr.configured(), annotations);
    event = new HostEvent(HOST_UPDATED, updated);
    synchronized (this) {
        hosts.put(host.id(), updated);
        locations.remove(host.location(), host);
        locations.put(updated.location(), updated);
    }
    return event;
}
Also used : HostEvent(org.onosproject.net.host.HostEvent) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) IpAddress(org.onlab.packet.IpAddress)

Example 13 with Annotations

use of org.onosproject.net.Annotations in project onos by opennetworkinglab.

the class Topo2Jsonifier method addProps.

private void addProps(ObjectNode node, Annotated a) {
    Annotations annot = a.annotations();
    ObjectNode props = objectNode();
    if (annot != null) {
        annot.keys().forEach(k -> props.put(k, annot.value(k)));
    }
    node.set("props", props);
}
Also used : Annotations(org.onosproject.net.Annotations) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 14 with Annotations

use of org.onosproject.net.Annotations in project onos by opennetworkinglab.

the class TopologyViewMessageHandlerBase method hostDetails.

// Generates a property panel model for a host details response
protected PropertyPanel hostDetails(HostId hostId) {
    log.debug("generate prop panel data for host {}", hostId);
    Host host = services.host().getHost(hostId);
    Annotations annot = host.annotations();
    String glyphId = glyphForHost(annot);
    LionBundle lion = getLionBundle(LION_TOPO);
    PropertyPanel pp = new PropertyPanel(nameForHost(host), glyphId).navPath(HOST_NAV_PATH).id(hostId.toString());
    addHostBasicProps(pp, host, lion);
    addLocationProps(pp, annot, lion);
    return pp;
}
Also used : Annotations(org.onosproject.net.Annotations) Host(org.onosproject.net.Host) TopoUtils.compactLinkString(org.onosproject.ui.topo.TopoUtils.compactLinkString) LionBundle(org.onosproject.ui.lion.LionBundle) PropertyPanel(org.onosproject.ui.topo.PropertyPanel)

Example 15 with Annotations

use of org.onosproject.net.Annotations in project onos by opennetworkinglab.

the class TopologyViewMessageHandlerBase method friendlyDevice.

private String friendlyDevice(DeviceId deviceId) {
    Device device = services.device().getDevice(deviceId);
    Annotations annot = device.annotations();
    String name = annot.value(AnnotationKeys.NAME);
    return isNullOrEmpty(name) ? deviceId.toString() : name;
}
Also used : Annotations(org.onosproject.net.Annotations) Device(org.onosproject.net.Device) TopoUtils.compactLinkString(org.onosproject.ui.topo.TopoUtils.compactLinkString)

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