Search in sources :

Example 6 with LinkDescription

use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.

the class LinkDiscoveryAristaImpl method buildLinkPair.

private static Set<LinkDescription> buildLinkPair(DeviceId localDevId, Port localPort, DeviceId remoteDevId, Port remotePort) {
    Set<LinkDescription> linkDescriptions = Sets.newHashSet();
    ConnectPoint local = new ConnectPoint(localDevId, localPort.number());
    ConnectPoint remote = new ConnectPoint(remoteDevId, remotePort.number());
    DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.LAYER, "ETHERNET").build();
    linkDescriptions.add(new DefaultLinkDescription(remote, local, Link.Type.DIRECT, true, annotations));
    return linkDescriptions;
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 7 with LinkDescription

use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStore method composeLink.

// Guarded by linkDescs value (=locking each Link)
private Link composeLink(Map<ProviderId, LinkDescription> descs) {
    ProviderId primary = getBaseProviderId(descs);
    LinkDescription base = descs.get(verifyNotNull(primary));
    ConnectPoint src = base.src();
    ConnectPoint dst = base.dst();
    Type type = base.type();
    DefaultAnnotations annotations = DefaultAnnotations.builder().build();
    annotations = merge(annotations, base.annotations());
    for (Entry<ProviderId, LinkDescription> e : descs.entrySet()) {
        if (primary.equals(e.getKey())) {
            continue;
        }
        // TODO: should keep track of Description timestamp
        // and only merge conflicting keys when timestamp is newer
        // Currently assuming there will never be a key conflict between
        // providers
        // annotation merging. not so efficient, should revisit later
        annotations = merge(annotations, e.getValue().annotations());
    }
    boolean isDurable = Objects.equals(annotations.value(AnnotationKeys.DURABLE), "true");
    return DefaultLink.builder().providerId(primary).src(src).dst(dst).type(type).state(ACTIVE).isExpected(isDurable).annotations(annotations).build();
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) Type(org.onosproject.net.Link.Type) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 8 with LinkDescription

use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStore method removeLink.

@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
    final LinkKey key = linkKey(src, dst);
    Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key);
    synchronized (descs) {
        Link link = links.remove(key);
        descs.clear();
        if (link != null) {
            srcLinks.remove(link.src().deviceId(), key);
            dstLinks.remove(link.dst().deviceId(), key);
            return new LinkEvent(LINK_REMOVED, link);
        }
        return null;
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) LinkEvent(org.onosproject.net.link.LinkEvent) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Example 9 with LinkDescription

use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.

the class BasicLinkOperatorTest method testDescOps.

@Test
public void testDescOps() {
    LinkDescription desc = BasicLinkOperator.combine(BLC, LD);
    assertEquals(String.valueOf(NTIME), desc.annotations().value(AnnotationKeys.LATENCY));
    assertEquals("true", desc.annotations().value(AnnotationKeys.DURABLE));
}
Also used : LinkDescription(org.onosproject.net.link.LinkDescription) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 10 with LinkDescription

use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.

the class ECLinkStore method removeLink.

@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
    final LinkKey linkKey = LinkKey.linkKey(src, dst);
    ProviderId primaryProviderId = getBaseProviderId(linkKey);
    // Stop if there is no base provider.
    if (primaryProviderId == null) {
        return null;
    }
    LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId));
    if (removedLinkDescription != null) {
        return purgeLinkCache(linkKey);
    }
    return null;
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription)

Aggregations

LinkDescription (org.onosproject.net.link.LinkDescription)29 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)24 DeviceId (org.onosproject.net.DeviceId)17 ConnectPoint (org.onosproject.net.ConnectPoint)11 Device (org.onosproject.net.Device)9 DeviceService (org.onosproject.net.device.DeviceService)9 ProviderId (org.onosproject.net.provider.ProviderId)7 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)6 Type (org.onosproject.net.Link.Type)6 LinkKey (org.onosproject.net.LinkKey)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 Port (org.onosproject.net.Port)5 NetconfController (org.onosproject.netconf.NetconfController)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 NetconfException (org.onosproject.netconf.NetconfException)3 NetconfSession (org.onosproject.netconf.NetconfSession)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2