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