import com.google.common.util.concurrent.FluentFuture;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!deviceObject.isPresent()) {
+ if (deviceObject.isEmpty()) {
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
return false;
}
if (device.getConnectionMap() == null) {
LOG.warn(PortMappingUtils.NO_CONMAP_LOGMSG, nodeId);
} else {
- Collection<ConnectionMap> connectionMap = deviceObject.get().nonnullConnectionMap().values();
- for (ConnectionMap cm : connectionMap) {
+ for (ConnectionMap cm : deviceObject.get().nonnullConnectionMap().values()) {
String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
- String slcp = lcpMap.containsKey(skey) ? lcpMap.get(skey) : null;
Destination destination0 = cm.nonnullDestination().values().iterator().next();
String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
- if (slcp == null) {
+ if (!lcpMap.containsKey(skey)) {
LOG.error(PortMappingUtils.CONMAP_ISSUE_LOGMSG, nodeId, skey, dkey);
continue;
}
- String dlcp = lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null;
+ String slcp = lcpMap.get(skey);
Mapping mapping = mappingMap.get(slcp);
mappingMap.remove(slcp);
- portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping, dlcp, null));
+ portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping,
+ //dlcp
+ lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null,
+ null));
}
}
if (device.getOduSwitchingPools() != null) {
- Collection<OduSwitchingPools> oduSwithcingPools = device.nonnullOduSwitchingPools().values();
List<SwitchingPoolLcp> switchingPoolList = new ArrayList<>();
- for (OduSwitchingPools odp : oduSwithcingPools) {
+ for (OduSwitchingPools odp : device.nonnullOduSwitchingPools().values()) {
Map<NonBlockingListKey,NonBlockingList> nbMap = new HashMap<>();
for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org
.openroadm.device.odu.switching.pools.NonBlockingList nbl : odp.nonnullNonBlockingList().values()) {
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
OrgOpenroadmDevice device = null;
- if (!deviceObject.isPresent()) {
+ if (deviceObject.isEmpty()) {
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, deviceId);
LOG.warn("MC-capabilities profile will be empty for node {}", deviceId);
return mcCapabilityProfiles;
Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, protocoliid, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class).getLldp() == null) {
+ if (protocolObject.isEmpty() || protocolObject.get().augmentation(Protocols1.class).getLldp() == null) {
LOG.warn(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, PortMappingUtils.CANNOT_GET_LLDP_CONF_LOGMSG);
return new HashMap<>();
}
Optional<Interface> interfaceObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, interfaceIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!interfaceObject.isPresent() || (interfaceObject.get().getSupportingCircuitPackName() == null)) {
+ if (interfaceObject.isEmpty() || interfaceObject.get().getSupportingCircuitPackName() == null) {
continue;
}
String supportingCircuitPackName = interfaceObject.get().getSupportingCircuitPackName();
Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(
nodeId, LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!circuitPackObject.isPresent() || (circuitPackObject.get().getParentCircuitPack() == null)) {
+ if (circuitPackObject.isEmpty() || circuitPackObject.get().getParentCircuitPack() == null) {
continue;
}
cpToInterfaceMap.put(circuitPackObject.get().getParentCircuitPack().getCircuitPackName(),
LOG.info(PortMappingUtils.MAP_LOOKS_LOGMSG, nodeId, interfaceList);
postPortMapping(nodeId, null, null, cpToDegreeList, null, null);
- Map<Integer, List<ConnectionPorts>> connectionPortMap = getPerDegreePorts(nodeId, deviceInfo);
- for (Entry<Integer, List<ConnectionPorts>> cpMapEntry : connectionPortMap.entrySet()) {
- switch (connectionPortMap.get(cpMapEntry.getKey()).size()) {
+ for (Entry<Integer, List<ConnectionPorts>> cpMapEntry : getPerDegreePorts(nodeId, deviceInfo).entrySet()) {
+ List<ConnectionPorts> cpMapValue = cpMapEntry.getValue();
+ ConnectionPorts cp1 = cpMapValue.get(0);
+ String cp1Name = cp1.getCircuitPackName();
+ switch (cpMapValue.size()) {
case 1:
// port is bidirectional
- String cpName = connectionPortMap.get(cpMapEntry.getKey()).get(0).getCircuitPackName();
InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey(cpName))
- .child(Ports.class,
- new PortsKey(connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName()));
- LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName(), cpName);
+ .child(CircuitPacks.class, new CircuitPacksKey(cp1Name))
+ .child(Ports.class, new PortsKey(cp1.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!portObject.isPresent()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName(), cpName);
+ if (portObject.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
return false;
}
Ports port = portObject.get();
}
if (PortQual.RoadmExternal.getIntValue() != port.getPortQual().getIntValue()) {
LOG.error(PortMappingUtils.CANNOT_CREATE_LCP_LOGMSG + PortMappingUtils.PORTQUAL_ERROR_LOGMSG,
- nodeId, port.getPortName(), cpName);
+ nodeId, port.getPortName(), cp1Name);
continue;
}
if (Direction.Bidirectional.getIntValue() != port.getPortDirection().getIntValue()) {
LOG.error(PortMappingUtils.CANNOT_CREATE_LCP_LOGMSG + PortMappingUtils.PORTDIR_ERROR_LOGMSG,
- nodeId, port.getPortName(), cpName);
+ nodeId, port.getPortName(), cp1Name);
continue;
}
String logicalConnectionPoint =
PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(), "TXRX");
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
- nodeId, port.getPortName(), cpName, logicalConnectionPoint);
- portMapList.add(createMappingObject(nodeId, port, cpName, logicalConnectionPoint));
+ nodeId, port.getPortName(), cp1Name, logicalConnectionPoint);
+ portMapList.add(createMappingObject(nodeId, port, cp1Name, logicalConnectionPoint));
break;
case 2:
// ports are unidirectionals
- String cp1Name = connectionPortMap.get(cpMapEntry.getKey()).get(0).getCircuitPackName();
- String cp2Name = connectionPortMap.get(cpMapEntry.getKey()).get(1).getCircuitPackName();
+ ConnectionPorts cp2 = cpMapValue.get(1);
+ String cp2Name = cp2.getCircuitPackName();
InstanceIdentifier<Ports> port1ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(cp1Name))
- .child(Ports.class,
- new PortsKey(connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName()));
- LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName(), cp1Name);
+ .child(Ports.class, new PortsKey(cp1.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
Optional<Ports> port1Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port1ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(cp2Name))
- .child(Ports.class,
- new PortsKey(connectionPortMap.get(cpMapEntry.getKey()).get(1).getPortName()));
- LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(1).getPortName(), cp2Name);
+ .child(Ports.class, new PortsKey(cp2.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp2.getPortName(), cp2Name);
Optional<Ports> port2Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port2ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!port1Object.isPresent() || !port2Object.isPresent()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName(), cp1Name);
+ if (port1Object.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
return false;
}
- if (!port2Object.isPresent()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG,
- nodeId, connectionPortMap.get(cpMapEntry.getKey()).get(1).getPortName(), cp2Name);
+ if (port2Object.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp2.getPortName(), cp2Name);
return false;
}
NodeInfoBuilder nodeInfoBldr = new NodeInfoBuilder()
.setOpenroadmVersion(OpenroadmNodeVersion._71)
+ .setNodeClli(
+ deviceInfo.getClli() == null || deviceInfo.getClli().isEmpty()
+ ? "defaultCLLI"
+ : deviceInfo.getClli())
.setNodeType(deviceInfo.getNodeType());
// TODO: 221 versions expects an int value - need to check whether it is bug or an evolution here
- if (deviceInfo.getClli() != null && !deviceInfo.getClli().isEmpty()) {
- nodeInfoBldr.setNodeClli(deviceInfo.getClli());
- } else {
- nodeInfoBldr.setNodeClli("defaultCLLI");
- }
if (deviceInfo.getModel() != null) {
nodeInfoBldr.setNodeModel(deviceInfo.getModel());
}