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;
}
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));
}
}
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());
}
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);
}
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);
}
}
Aggregations