Search in sources :

Example 6 with SparseAnnotations

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

the class DistributedOpenstackVtapStore method createOrUpdateVtap.

private OpenstackVtap createOrUpdateVtap(boolean update, OpenstackVtap description, boolean replaceDevices) {
    DefaultOpenstackVtap result = vtapMap.compute(description.id(), (id, existing) -> {
        // Check create or update validity
        if (update && existing == null) {
            return null;
        } else if (!update && existing != null) {
            return existing;
        }
        if (shouldUpdateVtap(existing, description, replaceDevices)) {
            // Replace or add devices
            final Set<DeviceId> txDeviceIds;
            if (existing == null || replaceDevices) {
                txDeviceIds = description.txDeviceIds();
            } else {
                txDeviceIds = Sets.newHashSet(existing.txDeviceIds());
                txDeviceIds.addAll(description.txDeviceIds());
            }
            final Set<DeviceId> rxDeviceIds;
            if (existing == null || replaceDevices) {
                rxDeviceIds = description.rxDeviceIds();
            } else {
                rxDeviceIds = Sets.newHashSet(existing.rxDeviceIds());
                rxDeviceIds.addAll(description.rxDeviceIds());
            }
            // Replace or add annotations
            final SparseAnnotations annotations;
            if (existing != null) {
                annotations = merge((DefaultAnnotations) existing.annotations(), (SparseAnnotations) description.annotations());
            } else {
                annotations = (SparseAnnotations) description.annotations();
            }
            return DefaultOpenstackVtap.builder(description).txDeviceIds(txDeviceIds).rxDeviceIds(rxDeviceIds).annotations(annotations).build();
        }
        return existing;
    });
    return result;
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DeviceId(org.onosproject.net.DeviceId)

Example 7 with SparseAnnotations

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

the class KryoSerializerTest method assertAnnotationsEquals.

// code clone
private static void assertAnnotationsEquals(Annotations actual, SparseAnnotations... annotations) {
    SparseAnnotations expected = DefaultAnnotations.builder().build();
    for (SparseAnnotations a : annotations) {
        expected = DefaultAnnotations.union(expected, a);
    }
    assertEquals(expected.keys(), actual.keys());
    for (String key : expected.keys()) {
        assertEquals(expected.value(key), actual.value(key));
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations)

Example 8 with SparseAnnotations

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

the class OvsdbTunnelProviderTest method testTunnelAdded.

@Test
public void testTunnelAdded() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel12"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelAdded(tunnel);
    assertEquals(1, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 9 with SparseAnnotations

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

the class LispDeviceProvider method connectDevice.

/**
 * Adds a LISP router into device store.
 */
private void connectDevice(LispRouterId routerId) {
    DeviceId deviceId = getDeviceId(routerId.id().toString());
    Preconditions.checkNotNull(deviceId, IS_NULL_MSG);
    // formulate LISP router object
    ChassisId cid = new ChassisId();
    String ipAddress = routerId.id().toString();
    SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase()).build();
    DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.ROUTER, MANUFACTURER, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, false, annotations);
    if (deviceService.getDevice(deviceId) == null) {
        providerService.deviceConnected(deviceId, deviceDescription);
    }
    checkAndUpdateDevice(deviceId, deviceDescription);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 10 with SparseAnnotations

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

the class Tl1DeviceProvider method connectDevice.

// Register a device in the core and in the TL1 controller.
private void connectDevice(Tl1Device device) {
    try {
        // Add device to TL1 controller
        DeviceId deviceId = DeviceId.deviceId(new URI(Tl1DeviceConfig.TL1, device.ip() + ":" + device.port(), null));
        if (controller.addDevice(deviceId, device)) {
            SparseAnnotations ann = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, Tl1DeviceConfig.TL1.toUpperCase()).build();
            // Register device in the core with default parameters and mark it as unavailable
            DeviceDescription dd = new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), false, ann);
            providerService.deviceConnected(deviceId, dd);
        }
    } catch (URISyntaxException e) {
        log.error("Skipping device {}", device, e);
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

SparseAnnotations (org.onosproject.net.SparseAnnotations)30 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)12 ChassisId (org.onlab.packet.ChassisId)10 DeviceId (org.onosproject.net.DeviceId)8 Device (org.onosproject.net.Device)6 Test (org.junit.Test)5 DefaultTunnelDescription (org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)4 TunnelDescription (org.onosproject.incubator.net.tunnel.TunnelDescription)4 DeviceDescription (org.onosproject.net.device.DeviceDescription)4 PortDescription (org.onosproject.net.device.PortDescription)4 NetconfException (org.onosproject.netconf.NetconfException)4 NetconfSession (org.onosproject.netconf.NetconfSession)4 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)3 GroupId (org.onosproject.core.GroupId)3 IpTunnelEndPoint (org.onosproject.incubator.net.tunnel.IpTunnelEndPoint)3 TunnelEndPoint (org.onosproject.incubator.net.tunnel.TunnelEndPoint)3 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)3 Link (org.onosproject.net.Link)3 PortNumber (org.onosproject.net.PortNumber)3 NetconfDevice (org.onosproject.netconf.NetconfDevice)3