use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.
the class OpenRoadmDeviceDescription method buildSrgPortDesc.
/**
* Parses a component XML doc into a PortDescription.
* An Och port description is constructed from XML parsed data.
*
* @param nodeId The OpenRoadm nodeId of the current node.
* @param circuitPackName name of circuit pack containing the port.
* @param pNum the portNumber of the port.
* @param reversepNum the portNumber of the partner port.
* @param port the hierarchical configuration of the port to parse
* @param extLink Hierarchical configuration for the external links.
* @return PortDescription or null.
*/
private PortDescription buildSrgPortDesc(String nodeId, String circuitPackName, PortNumber pNum, PortNumber reversepNum, HierarchicalConfiguration port, HierarchicalConfiguration extLink) {
DefaultAnnotations annotations = createPortAnnotations(nodeId, circuitPackName, pNum, reversepNum, port, extLink);
OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 3);
return OchPortHelper.ochPortDescription(pNum, true, /* enabled */
OduSignalType.ODU4, true, /* tunable */
signalId, annotations);
}
use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.
the class DistributedHostStore method createOrUpdateHost.
// TODO No longer need to return HostEvent
@Override
public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, HostDescription hostDescription, boolean replaceIPs) {
hostsConsistentMap.computeIf(hostId, existingHost -> shouldUpdate(existingHost, providerId, hostDescription, replaceIPs), (id, existingHost) -> {
final Set<IpAddress> addresses;
if (existingHost == null || replaceIPs) {
addresses = ImmutableSet.copyOf(hostDescription.ipAddress());
} else {
addresses = Sets.newHashSet(existingHost.ipAddresses());
addresses.addAll(hostDescription.ipAddress());
}
final Annotations annotations;
if (existingHost != null) {
annotations = merge((DefaultAnnotations) existingHost.annotations(), hostDescription.annotations());
} else {
annotations = hostDescription.annotations();
}
return new DefaultHost(providerId, hostId, hostDescription.hwAddress(), hostDescription.vlan(), hostDescription.locations(), hostDescription.auxLocations(), addresses, hostDescription.innerVlan(), hostDescription.tpid(), hostDescription.configured(), false, annotations);
});
return null;
}
use of org.onosproject.net.DefaultAnnotations in project onos by opennetworkinglab.
the class OpenConfigGnmiDeviceDescriptionDiscovery method discoverPortDetails.
@Override
public List<PortDescription> discoverPortDetails() {
if (!setupBehaviour("discoverPortDetails()")) {
return Collections.emptyList();
}
log.debug("Discovering port details on device {}", handler().data().deviceId());
final GetResponse response = Futures.getUnchecked(client.get(buildPortStateRequest()));
final Map<String, DefaultPortDescription.Builder> ports = Maps.newHashMap();
final Map<String, DefaultAnnotations.Builder> annotations = Maps.newHashMap();
final Map<String, PortNumber> portIds = Maps.newHashMap();
// Creates port descriptions with port name and port number
response.getNotificationList().forEach(notification -> {
notification.getUpdateList().forEach(update -> {
// /interfaces/interface[name=ifName]/state/...
final String ifName = update.getPath().getElem(1).getKeyMap().get("name");
if (!ports.containsKey(ifName)) {
ports.put(ifName, DefaultPortDescription.builder());
annotations.put(ifName, DefaultAnnotations.builder());
}
final DefaultPortDescription.Builder builder = ports.get(ifName);
final DefaultAnnotations.Builder annotationsBuilder = annotations.get(ifName);
parseInterfaceInfo(update, ifName, builder, annotationsBuilder, portIds);
});
});
final List<PortDescription> portDescriptionList = Lists.newArrayList();
ports.forEach((key, value) -> {
// For devices not providing last-change, we set it to 0
final DefaultAnnotations.Builder annotationsBuilder = annotations.get(key);
if (!annotationsBuilder.build().keys().contains(LAST_CHANGE)) {
annotationsBuilder.set(LAST_CHANGE, String.valueOf(0));
}
/* Override port number if read port-id is enabled
and /interfaces/interface/state/id is available */
if (readPortId() && portIds.containsKey(key)) {
value.withPortNumber(portIds.get(key));
}
DefaultAnnotations annotation = annotations.get(key).build();
portDescriptionList.add(value.annotations(annotation).build());
});
return portDescriptionList;
}
use of org.onosproject.net.DefaultAnnotations 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.DefaultAnnotations in project onos by opennetworkinglab.
the class OchPortHelper method ochPortDescription.
/**
* Creates OCh port DefaultPortDescription based on the supplied information.
*
* @param number port number
* @param isEnabled port enabled state
* @param signalType ODU signal type
* @param isTunable tunable wavelength capability
* @param lambda OCh signal
* @param annotationsIn key/value annotations map
* @return OCh port DefaultPortDescription with OCh annotations
*/
public static PortDescription ochPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, boolean isTunable, OchSignal lambda, SparseAnnotations annotationsIn) {
Builder builder = DefaultAnnotations.builder();
builder.putAll(annotationsIn);
builder.set(TUNABLE, String.valueOf(isTunable));
builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
builder.set(SIGNAL_TYPE, signalType.toString());
DefaultAnnotations annotations = builder.build();
long portSpeed = signalType.bitRate();
return DefaultPortDescription.builder().withPortNumber(number).isEnabled(isEnabled).type(Port.Type.OCH).portSpeed(portSpeed).annotations(annotations).build();
}
Aggregations