Search in sources :

Example 11 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations 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 12 with DefaultAnnotations

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

the class LinkDiscoveryCiscoImpl 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("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 13 with DefaultAnnotations

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

the class CienaWaveserverAiDeviceDescriptionTest method getExpectedPorts.

private List getExpectedPorts() {
    List<PortDescription> result = new ArrayList<>();
    DefaultAnnotations port101 = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "1-1").set(AnnotationKeys.PROTOCOL, "otn").build();
    DefaultAnnotations port102 = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "1-2").set(AnnotationKeys.PROTOCOL, "otn").build();
    DefaultAnnotations port103 = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "1-3").set(AnnotationKeys.PROTOCOL, "ethernet").build();
    DefaultAnnotations port107 = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "1-7").set(AnnotationKeys.PROTOCOL, "ethernet").build();
    result.add(DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(10101)).isEnabled(false).portSpeed(421033).type(Port.Type.PACKET).annotations(port101).build());
    result.add(DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(10102)).isEnabled(true).portSpeed(421033).type(Port.Type.PACKET).annotations(port102).build());
    result.add(DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(10103)).isEnabled(true).portSpeed(103125).type(Port.Type.PACKET).annotations(port103).build());
    result.add(DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(10107)).isEnabled(true).portSpeed(103125).type(Port.Type.PACKET).annotations(port107).build());
    return result;
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) ArrayList(java.util.ArrayList) PortDescription(org.onosproject.net.device.PortDescription) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription)

Example 14 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations 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 15 with DefaultAnnotations

use of org.onosproject.net.DefaultAnnotations 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)

Aggregations

DefaultAnnotations (org.onosproject.net.DefaultAnnotations)33 ConnectPoint (org.onosproject.net.ConnectPoint)9 PortDescription (org.onosproject.net.device.PortDescription)9 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)8 DeviceId (org.onosproject.net.DeviceId)7 PortNumber (org.onosproject.net.PortNumber)7 ProviderId (org.onosproject.net.provider.ProviderId)7 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)6 LinkDescription (org.onosproject.net.link.LinkDescription)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 Device (org.onosproject.net.Device)4 DeviceDescription (org.onosproject.net.device.DeviceDescription)4 ArrayList (java.util.ArrayList)3 ChassisId (org.onlab.packet.ChassisId)3 DefaultDevice (org.onosproject.net.DefaultDevice)3 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)3 DeviceService (org.onosproject.net.device.DeviceService)3 XPath (javax.xml.xpath.XPath)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2 Test (org.junit.Test)2