public class CrossConnectImpl221 {
private static final Logger LOG = LoggerFactory.getLogger(CrossConnectImpl221.class);
+ private static final String DEV_TRANSACTION_NOT_FOUND = "Device transaction for device {} was not found!";
+ private static final String UNABLE_DEV_TRANSACTION = "Unable to obtain device transaction for device {}!";
private final DeviceTransactionManager deviceTransactionManager;
public CrossConnectImpl221(DeviceTransactionManager deviceTransactionManager) {
if (deviceTxOpt.isPresent()) {
deviceTx = deviceTxOpt.get();
} else {
- LOG.error("Device transaction for device {} was not found!", deviceId);
+ LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return Optional.empty();
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Unable to obtain device transaction for device {}!", deviceId, e);
+ LOG.error(UNABLE_DEV_TRANSACTION, deviceId, e);
return Optional.empty();
}
if (deviceTxOpt.isPresent()) {
deviceTx = deviceTxOpt.get();
} else {
- LOG.error("Device transaction for device {} was not found!", deviceId);
+ LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return null;
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Unable to obtain device transaction for device {}!", deviceId, e);
+ LOG.error(UNABLE_DEV_TRANSACTION, deviceId, e);
return null;
}
if (deviceTxOpt.isPresent()) {
deviceTx = deviceTxOpt.get();
} else {
- LOG.error("Device transaction for device {} was not found!", deviceId);
+ LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return Optional.empty();
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Unable to obtain device transaction for device {}!", deviceId, e);
+ LOG.error(UNABLE_DEV_TRANSACTION, deviceId, e);
return Optional.empty();
}
*/
boolean updatePortMappingWithOduSwitchingPools(String nodeId, InstanceIdentifier<OduSwitchingPools> ospIID,
Map<Uint16, List<InstanceIdentifier<PortList>>> nbliidMap);
+
+ /**
+ * This method check the presence or not of a given node inside the PortMapping
+ * datastore.
+ *
+ * @param nodeId
+ * Unique Identifier for the node of interest.
+ *
+ * @return Result true/false based on existance or not of a given node.
+ */
+ boolean isNodeExist(String nodeId);
+
}
return false;
}
}
+
+ @Override
+ public boolean isNodeExist(String nodeId) {
+ return this.getNode(nodeId) != null;
+ }
}
break;
case Rx:
case Tx:
- if (!checkPartnerPortNotNull(port)) {
- LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG
- + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
- nodeId, port.getPortName(), circuitPackName);
+ Ports port2 = getPartnerPort(port, circuitPackName, nodeId);
+ if (port2 == null) {
continue;
}
String lcp1 = createLogicalConnectionPort(port, srgCpEntry.getKey(), portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
- nodeId, port.getPortName(), circuitPackName, lcp1);
- InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class,
- new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
- .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
- Optional<Ports> port2Object = this.deviceTransactionManager
- .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
- Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue()
- != Port.PortQual.RoadmExternal.getIntValue()) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
- nodeId, port.getPartnerPort().getPortName(),
- port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkPartnerPort(circuitPackName, port, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
- nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- portIndex++;
- continue;
- }
+ nodeId, port.getPortName(), circuitPackName, lcp1);
String lcp2 = createLogicalConnectionPort(port2, srgCpEntry.getKey(),portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
nodeId, port2.getPortName(), circuitPackName, lcp2);
return true;
}
+ private Ports getPartnerPort(Ports port, String circuitPackName, String nodeId) {
+ if (!checkPartnerPortNotNull(port)) {
+ LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
+ nodeId, port.getPortName(), circuitPackName);
+ return null;
+ }
+ InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
+ .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
+ Optional<Ports> port2Object = this.deviceTransactionManager
+ .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (port2Object.isEmpty()
+ || port2Object.get().getPortQual().getIntValue() != Port.PortQual.RoadmExternal.getIntValue()) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
+ nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ return null;
+ }
+ Ports port2 = port2Object.get();
+ if (!checkPartnerPort(circuitPackName, port, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
+ nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ //portIndex++;
+ //TODO check if we really needed to increase portIndex
+ // if yes this block should not be in getPartnerPort
+ return null;
+ }
+ return port2;
+ }
+
private List<Ports> getPortList(String circuitPackName, String nodeId) {
InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(circuitPackName));
switch (cpMapValue.size()) {
case 1:
// port is bidirectional
- InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port = getTtpPort(cp1, cp1Name, nodeId);
+ if (port == null) {
return false;
}
- Ports port = portObject.get();
if (!checkTtpPort(port, cp1Name, nodeId, true)) {
continue;
}
-
String logicalConnectionPoint =
PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(), "TXRX");
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
break;
case 2:
// ports are unidirectionals
- 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(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(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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port1 = getTtpPort(cp1, cp1Name, nodeId);
+ if (port1 == null) {
return false;
}
- if (port2Object.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp2.getPortName(), cp2Name);
+ ConnectionPorts cp2 = cpMapValue.get(1);
+ String cp2Name = cp2.getCircuitPackName();
+ Ports port2 = getTtpPort(cp2, cp2Name, nodeId);
+ if (port2 == null) {
return false;
}
-
- Ports port1 = port1Object.get();
- if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
+ if (!checkTtpPortsUnidir(port1, port2, cp1Name, cp2Name, nodeId)) {
continue;
}
-
- if (!checkPartnerPort(cp1Name, port1, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
- continue;
- }
- // Directions checks are the same for cp1 and cp2, no need to check them twice.
- if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
- continue;
- }
-
String logicalConnectionPoint1 = PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(),
port1.getPortDirection().getName().toUpperCase(Locale.getDefault()));
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
default:
LOG.error(PortMappingUtils.NOT_CORRECT_CONPORT_LOGMSG, nodeId, cpMapEntry.getKey());
continue;
+ //TODO should it be continue or return false ?
}
}
return true;
}
+ private Ports getTtpPort(ConnectionPorts cp, String cpName, String nodeId) {
+ InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(cpName))
+ .child(Ports.class, new PortsKey(cp.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp.getPortName(), cpName);
+ Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
+ LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
+ Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (portObject.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
+ return null;
+ }
+ return portObject.get();
+ }
+
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
if (port.getPortQual() == null) {
return false;
return true;
}
- private NodeInfo createNodeInfo(Info deviceInfo) {
+ private boolean checkTtpPortsUnidir(Ports port1, Ports port2, String cp1Name, String cp2Name, String nodeId) {
+ if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkPartnerPort(cp1Name, port1, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
+ return false;
+ }
+ // Directions checks are the same for cp1 and cp2, no need to check them twice.
+ if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
+ return false;
+ }
+ return true;
+ }
+ private NodeInfo createNodeInfo(Info deviceInfo) {
if (deviceInfo.getNodeType() == null) {
// TODO make mandatory in yang
LOG.error(PortMappingUtils.NODE_TYPE_LOGMSG, deviceInfo.getNodeId(), "field missing");
return null;
}
-
NodeInfoBuilder nodeInfoBldr = new NodeInfoBuilder()
.setOpenroadmVersion(OpenroadmNodeVersion._121)
.setNodeClli(
if (deviceInfo.getIpAddress() != null) {
nodeInfoBldr.setNodeIpAddress(deviceInfo.getIpAddress());
}
-
return nodeInfoBldr.build();
}
private boolean createXpdrPortMapping(String nodeId, List<Mapping> portMapList) {
// Creating for Xponder Line and Client Ports
+ OrgOpenroadmDevice device = getXpdrDevice(nodeId);
+ if (device == null) {
+ return false;
+ }
+ Map<String, String> lcpMap = new HashMap<>();
+ Map<String, Mapping> mappingMap = new HashMap<>();
+ getXpdrMaps(device, nodeId, lcpMap, mappingMap);
+ if (device.getConnectionMap() == null) {
+ LOG.warn(PortMappingUtils.NO_CONMAP_LOGMSG, nodeId);
+ } else {
+ for (ConnectionMap cm : device.nonnullConnectionMap().values()) {
+ String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
+ Destination destination0 = cm.nonnullDestination().values().iterator().next();
+ String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
+ if (!lcpMap.containsKey(skey)) {
+ LOG.error(PortMappingUtils.CONMAP_ISSUE_LOGMSG, nodeId, skey, dkey);
+ continue;
+ }
+ String slcp = lcpMap.get(skey);
+ Mapping mapping = mappingMap.get(slcp);
+ mappingMap.remove(slcp);
+ portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping,
+ //dlcp
+ lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null,
+ null));
+ }
+ }
+ if (device.getOduSwitchingPools() != null) {
+ List<SwitchingPoolLcp> switchingPoolList = new ArrayList<>();
+ for (OduSwitchingPools odp : device.nonnullOduSwitchingPools().values()) {
+ Map<NonBlockingListKey,NonBlockingList> nbMap = new HashMap<>();
+ for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org
+ .openroadm.device.odu.switching.pools.NonBlockingList nbl : odp.nonnullNonBlockingList().values()) {
+ if (nbl.getPortList() == null) {
+ continue;
+ }
+ List<String> lcpList = new ArrayList<>();
+ for (PortList item : nbl.nonnullPortList().values()) {
+ String key = item.getCircuitPackName() + "+" + item.getPortName();
+ if (!lcpMap.containsKey(key)) {
+ LOG.error(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG,
+ nodeId, item.getPortName(), item.getCircuitPackName(), "to a logical connection point");
+ continue;
+ }
+ lcpList.add(lcpMap.get(key));
+ }
+ NonBlockingList nonBlockingList = new NonBlockingListBuilder()
+ .setNblNumber(nbl.getNblNumber())
+ .setInterconnectBandwidth(nbl.getInterconnectBandwidth())
+ .setInterconnectBandwidthUnit(nbl.getInterconnectBandwidthUnit())
+ .setLcpList(lcpList)
+ .build();
+ nbMap.put(nonBlockingList.key(), nonBlockingList);
+ }
+ switchingPoolList.add(
+ new SwitchingPoolLcpBuilder()
+ .setSwitchingPoolNumber(odp.getSwitchingPoolNumber())
+ .setSwitchingPoolType(SwitchingPoolTypes.forValue(odp.getSwitchingPoolType().getIntValue()))
+ .setNonBlockingList(nbMap)
+ .build());
+ }
+ postPortMapping(nodeId, null, null, null, switchingPoolList, null);
+ }
+ mappingMap.forEach((k,v) -> portMapList.add(v));
+ return true;
+ }
+
+ private OrgOpenroadmDevice getXpdrDevice(String nodeId) {
InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (deviceObject.isEmpty()) {
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
- return false;
+ return null;
}
OrgOpenroadmDevice device = deviceObject.get();
if (device.getCircuitPacks() == null) {
LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, PortMappingUtils.FOUND);
- return false;
+ return null;
}
+ return device;
+ }
- Map<String, String> lcpMap = new HashMap<>();
- Map<String, Mapping> mappingMap = new HashMap<>();
+ private void getXpdrMaps(OrgOpenroadmDevice device, String nodeId,
+ Map<String, String> lcpMap, Map<String, Mapping> mappingMap) {
List<CircuitPacks> circuitPackList = new ArrayList<>(device.nonnullCircuitPacks().values());
circuitPackList.sort(Comparator.comparing(CircuitPack::getCircuitPackName));
if (device.getXponder() == null) {
}
} else {
LOG.info(PortMappingUtils.XPDR_LIST_IN_CONF_LOGMSG, nodeId, PortMappingUtils.FOUND);
- for (Xponder xponder : deviceObject.get().nonnullXponder().values()) {
+ for (Xponder xponder : device.nonnullXponder().values()) {
// Variables to keep track of number of line ports and client ports
int line = 1;
int client = 1;
XpdrNodeTypes xponderType = xponder.getXpdrType();
for (XpdrPort xpdrPort : xponder.nonnullXpdrPort().values().stream()
.sorted((xp1, xp2) -> xp1.getIndex().compareTo(xp2.getIndex())).collect(Collectors.toList())) {
- String circuitPackName = xpdrPort.getCircuitPackName();
- String portName = xpdrPort.getPortName();
- // If there xponder-subtree has missing circuit-packs or ports,
- // This gives a null-pointer expection,
- Optional<CircuitPacks> cpList = device.nonnullCircuitPacks().values().stream()
- .filter(cp -> cp.getCircuitPackName().equals(circuitPackName)).findFirst();
- if (cpList.isEmpty()) {
- LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
- nodeId, circuitPackName);
- continue;
- }
- Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
- .filter(p -> p.getPortName().equals(portName)).findFirst();
- if (portsList.isEmpty()) {
- LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
- nodeId, portName, circuitPackName, "in the device");
+ Ports port = getXpdrPorts(device, xpdrPort, nodeId);
+ if (port == null) {
continue;
}
int[] counters = fillXpdrLcpsMaps(line, client, nodeId,
- xponderNb, xponderType, circuitPackName, portsList.get(),
+ xponderNb, xponderType, xpdrPort.getCircuitPackName(), port,
circuitPackList, lcpMap, mappingMap);
line = counters[0];
client = counters[1];
}
}
}
+ }
- if (device.getConnectionMap() == null) {
- LOG.warn(PortMappingUtils.NO_CONMAP_LOGMSG, nodeId);
- } else {
- for (ConnectionMap cm : deviceObject.get().nonnullConnectionMap().values()) {
- String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
- Destination destination0 = cm.nonnullDestination().values().iterator().next();
- String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
- if (!lcpMap.containsKey(skey)) {
- LOG.error(PortMappingUtils.CONMAP_ISSUE_LOGMSG, nodeId, skey, dkey);
- continue;
- }
- String slcp = lcpMap.get(skey);
- Mapping mapping = mappingMap.get(slcp);
- mappingMap.remove(slcp);
- portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping,
- //dlcp
- lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null,
- null));
- }
+ private Ports getXpdrPorts(OrgOpenroadmDevice device, XpdrPort xpdrPort, String nodeId) {
+ String circuitPackName = xpdrPort.getCircuitPackName();
+ String portName = xpdrPort.getPortName();
+ // If there xponder-subtree has missing circuit-packs or ports,
+ // This gives a null-pointer expection,
+ Optional<CircuitPacks> cpList = device.nonnullCircuitPacks().values().stream()
+ .filter(cp -> cp.getCircuitPackName().equals(circuitPackName)).findFirst();
+ if (cpList.isEmpty()) {
+ LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
+ nodeId, circuitPackName);
+ return null;
}
-
- if (device.getOduSwitchingPools() != null) {
- List<SwitchingPoolLcp> switchingPoolList = new ArrayList<>();
- for (OduSwitchingPools odp : device.nonnullOduSwitchingPools().values()) {
- Map<NonBlockingListKey,NonBlockingList> nbMap = new HashMap<>();
- for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org
- .openroadm.device.odu.switching.pools.NonBlockingList nbl : odp.nonnullNonBlockingList().values()) {
- if (nbl.getPortList() == null) {
- continue;
- }
- List<String> lcpList = new ArrayList<>();
- for (PortList item : nbl.nonnullPortList().values()) {
- String key = item.getCircuitPackName() + "+" + item.getPortName();
- if (!lcpMap.containsKey(key)) {
- LOG.error(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG,
- nodeId, item.getPortName(), item.getCircuitPackName(), "to a logical connection point");
- continue;
- }
- lcpList.add(lcpMap.get(key));
- }
- NonBlockingList nonBlockingList = new NonBlockingListBuilder()
- .setNblNumber(nbl.getNblNumber())
- .setInterconnectBandwidth(nbl.getInterconnectBandwidth())
- .setInterconnectBandwidthUnit(nbl.getInterconnectBandwidthUnit())
- .setLcpList(lcpList)
- .build();
- nbMap.put(nonBlockingList.key(), nonBlockingList);
- }
- SwitchingPoolLcp splBldr = new SwitchingPoolLcpBuilder()
- .setSwitchingPoolNumber(odp.getSwitchingPoolNumber())
- .setSwitchingPoolType(SwitchingPoolTypes.forValue(odp.getSwitchingPoolType().getIntValue()))
- .setNonBlockingList(nbMap)
- .build();
- switchingPoolList.add(splBldr);
- }
- postPortMapping(nodeId, null, null, null, switchingPoolList, null);
+ Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
+ .filter(p -> p.getPortName().equals(portName)).findFirst();
+ if (portsList.isEmpty()) {
+ LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
+ nodeId, portName, circuitPackName, "in the device");
+ return null;
}
-
- mappingMap.forEach((k,v) -> portMapList.add(v));
- return true;
+ return portsList.get();
}
private boolean checkPartnerPortNotNull(Ports port) {
break;
case Rx:
case Tx:
- if (!checkPartnerPortNotNull(port)) {
- LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG
- + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
- nodeId, port.getPortName(), circuitPackName);
+ Ports port2 = getPartnerPort(port, circuitPackName, nodeId);
+ if (port2 == null) {
continue;
}
String lcp1 = createLogicalConnectionPort(port, srgCpEntry.getKey(), portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
nodeId, port.getPortName(), circuitPackName, lcp1);
- InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class,
- new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
- .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
- Optional<Ports> port2Object = this.deviceTransactionManager
- .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
- Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue()
- != PortQual.RoadmExternal.getIntValue()) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
- nodeId, port.getPartnerPort().getPortName(),
- port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkPartnerPort(circuitPackName, port, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
- nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- portIndex++;
- continue;
- }
String lcp2 = createLogicalConnectionPort(port2, srgCpEntry.getKey(),portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
nodeId, port2.getPortName(), circuitPackName, lcp2);
return true;
}
+ private Ports getPartnerPort(Ports port, String circuitPackName, String nodeId) {
+ if (!checkPartnerPortNotNull(port)) {
+ LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
+ nodeId, port.getPortName(), circuitPackName);
+ return null;
+ }
+ InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
+ .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
+ Optional<Ports> port2Object = this.deviceTransactionManager
+ .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (port2Object.isEmpty()
+ || port2Object.get().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
+ nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ return null;
+ }
+ Ports port2 = port2Object.get();
+ if (!checkPartnerPort(circuitPackName, port, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
+ nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ //portIndex++;
+ //TODO check if we really needed to increase portIndex
+ // if yes this block should not be in getPartnerPort
+ return null;
+ }
+ return port2;
+ }
+
private List<Ports> getPortList(String circuitPackName, String nodeId) {
InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(circuitPackName));
switch (cpMapValue.size()) {
case 1:
// port is bidirectional
- InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port = getTtpPort(cp1, cp1Name, nodeId);
+ if (port == null) {
return false;
}
- Ports port = portObject.get();
if (!checkTtpPort(port, cp1Name, nodeId, true)) {
continue;
}
-
String logicalConnectionPoint =
PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(), "TXRX");
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
break;
case 2:
// ports are unidirectionals
- 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(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(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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port1 = getTtpPort(cp1, cp1Name, nodeId);
+ if (port1 == null) {
return false;
}
- if (port2Object.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp2.getPortName(), cp2Name);
+ ConnectionPorts cp2 = cpMapValue.get(1);
+ String cp2Name = cp2.getCircuitPackName();
+ Ports port2 = getTtpPort(cp2, cp2Name, nodeId);
+ if (port2 == null) {
return false;
}
-
- Ports port1 = port1Object.get();
- if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
+ if (!checkTtpPortsUnidir(port1, port2, cp1Name, cp2Name, nodeId)) {
continue;
}
-
- if (!checkPartnerPort(cp1Name, port1, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
- continue;
- }
- // Directions checks are the same for cp1 and cp2, no need to check them twice.
- if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
- continue;
- }
-
String logicalConnectionPoint1 = PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(),
port1.getPortDirection().getName().toUpperCase(Locale.getDefault()));
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
default:
LOG.error(PortMappingUtils.NOT_CORRECT_CONPORT_LOGMSG, nodeId, cpMapEntry.getKey());
continue;
+ //TODO should it be continue or return false ?
}
}
return true;
}
+ private Ports getTtpPort(ConnectionPorts cp, String cpName, String nodeId) {
+ InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(cpName))
+ .child(Ports.class, new PortsKey(cp.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp.getPortName(), cpName);
+ Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
+ LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
+ Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (portObject.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
+ return null;
+ }
+ return portObject.get();
+ }
+
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
if (port.getPortQual() == null) {
return false;
return true;
}
- private NodeInfo createNodeInfo(Info deviceInfo) {
+ private boolean checkTtpPortsUnidir(Ports port1, Ports port2, String cp1Name, String cp2Name, String nodeId) {
+ if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkPartnerPort(cp1Name, port1, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
+ return false;
+ }
+ // Directions checks are the same for cp1 and cp2, no need to check them twice.
+ if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
+ return false;
+ }
+ return true;
+ }
+ private NodeInfo createNodeInfo(Info deviceInfo) {
if (deviceInfo.getNodeType() == null) {
// TODO make mandatory in yang
LOG.error(PortMappingUtils.NODE_TYPE_LOGMSG, deviceInfo.getNodeId(), "field missing");
return null;
}
-
NodeInfoBuilder nodeInfoBldr = new NodeInfoBuilder()
.setOpenroadmVersion(OpenroadmNodeVersion._221)
.setNodeClli(
if (deviceInfo.getIpAddress() != null) {
nodeInfoBldr.setNodeIpAddress(deviceInfo.getIpAddress());
}
-
return nodeInfoBldr.build();
}
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;
private boolean createXpdrPortMapping(String nodeId, List<Mapping> portMapList) {
// Creating for Xponder Line and Client Ports
+ OrgOpenroadmDevice device = getXpdrDevice(nodeId);
+ if (device == null) {
+ return false;
+ }
+ Map<String, String> lcpMap = new HashMap<>();
+ Map<String, Mapping> mappingMap = new HashMap<>();
+ getXpdrMaps(device, nodeId, lcpMap, mappingMap);
+ if (device.getConnectionMap() == null) {
+ LOG.warn(PortMappingUtils.NO_CONMAP_LOGMSG, nodeId);
+ } else {
+ for (ConnectionMap cm : device.nonnullConnectionMap().values()) {
+ String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
+ Destination destination0 = cm.nonnullDestination().values().iterator().next();
+ String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
+ if (!lcpMap.containsKey(skey)) {
+ LOG.error(PortMappingUtils.CONMAP_ISSUE_LOGMSG, nodeId, skey, dkey);
+ continue;
+ }
+ String slcp = lcpMap.get(skey);
+ Mapping mapping = mappingMap.get(slcp);
+ mappingMap.remove(slcp);
+ portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping,
+ //dlcp
+ lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null,
+ null));
+ }
+ }
+ if (device.getOduSwitchingPools() != null) {
+ List<SwitchingPoolLcp> switchingPoolList = new ArrayList<>();
+ 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()) {
+ if (nbl.getPortList() == null) {
+ continue;
+ }
+ List<String> lcpList = new ArrayList<>();
+ for (PortList item : nbl.nonnullPortList().values()) {
+ String key = item.getCircuitPackName() + "+" + item.getPortName();
+ if (!lcpMap.containsKey(key)) {
+ LOG.error(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG,
+ nodeId, item.getPortName(), item.getCircuitPackName(), "to a logical connection point");
+ continue;
+ }
+ lcpList.add(lcpMap.get(key));
+ }
+ NonBlockingList nonBlockingList = new NonBlockingListBuilder()
+ .setNblNumber(nbl.getNblNumber())
+ .setInterconnectBandwidth(nbl.getInterconnectBandwidth())
+ .setInterconnectBandwidthUnit(nbl.getInterconnectBandwidthUnit())
+ .setLcpList(lcpList)
+ .build();
+ nbMap.put(nonBlockingList.key(), nonBlockingList);
+ }
+ switchingPoolList.add(
+ new SwitchingPoolLcpBuilder()
+ .setSwitchingPoolNumber(odp.getSwitchingPoolNumber())
+ .setSwitchingPoolType(odp.getSwitchingPoolType())
+ //TODO differs from 2.2.1 SwitchingPoolTypes.forValue(odp.getSwitchingPoolType().getIntValue())
+ .setNonBlockingList(nbMap)
+ .build());
+ }
+ postPortMapping(nodeId, null, null, null, switchingPoolList, null);
+ }
+ mappingMap.forEach((k,v) -> portMapList.add(v));
+ return true;
+ }
+
+ private OrgOpenroadmDevice getXpdrDevice(String nodeId) {
InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (deviceObject.isEmpty()) {
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
- return false;
+ return null;
}
OrgOpenroadmDevice device = deviceObject.get();
if (device.getCircuitPacks() == null) {
LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, PortMappingUtils.FOUND);
- return false;
+ return null;
}
+ return device;
+ }
- Map<String, String> lcpMap = new HashMap<>();
- Map<String, Mapping> mappingMap = new HashMap<>();
+ private void getXpdrMaps(OrgOpenroadmDevice device, String nodeId,
+ Map<String, String> lcpMap, Map<String, Mapping> mappingMap) {
List<CircuitPacks> circuitPackList = new ArrayList<>(device.nonnullCircuitPacks().values());
circuitPackList.sort(Comparator.comparing(CircuitPack::getCircuitPackName));
if (device.getXponder() == null) {
}
} else {
LOG.info(PortMappingUtils.XPDR_LIST_IN_CONF_LOGMSG, nodeId, PortMappingUtils.FOUND);
- for (Xponder xponder : deviceObject.get().nonnullXponder().values()) {
+ for (Xponder xponder : device.nonnullXponder().values()) {
// Variables to keep track of number of line ports and client ports
int line = 1;
int client = 1;
XpdrNodeTypes xponderType = xponder.getXpdrType();
for (XpdrPort xpdrPort : xponder.nonnullXpdrPort().values().stream()
.sorted((xp1, xp2) -> xp1.getIndex().compareTo(xp2.getIndex())).collect(Collectors.toList())) {
- String circuitPackName = xpdrPort.getCircuitPackName();
- String portName = xpdrPort.getPortName();
- // If there xponder-subtree has missing circuit-packs or ports,
- // This gives a null-pointer expection,
- Optional<CircuitPacks> cpList = device.nonnullCircuitPacks().values().stream()
- .filter(cp -> cp.getCircuitPackName().equals(circuitPackName)).findFirst();
- if (cpList.isEmpty()) {
- LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
- nodeId, circuitPackName);
- continue;
- }
- Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
- .filter(p -> p.getPortName().equals(portName)).findFirst();
- if (portsList.isEmpty()) {
- LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
- nodeId, portName, circuitPackName, "in the device");
+ Ports port = getXpdrPorts(device, xpdrPort, nodeId);
+ if (port == null) {
continue;
}
int[] counters = fillXpdrLcpsMaps(line, client, nodeId,
- xponderNb, xponderType, circuitPackName, portsList.get(),
+ xponderNb, xponderType, xpdrPort.getCircuitPackName(), port,
circuitPackList, lcpMap, mappingMap);
line = counters[0];
client = counters[1];
}
}
}
+ }
- if (device.getConnectionMap() == null) {
- LOG.warn(PortMappingUtils.NO_CONMAP_LOGMSG, nodeId);
- } else {
- for (ConnectionMap cm : deviceObject.get().nonnullConnectionMap().values()) {
- String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
- Destination destination0 = cm.nonnullDestination().values().iterator().next();
- String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
- if (!lcpMap.containsKey(skey)) {
- LOG.error(PortMappingUtils.CONMAP_ISSUE_LOGMSG, nodeId, skey, dkey);
- continue;
- }
- String slcp = lcpMap.get(skey);
- Mapping mapping = mappingMap.get(slcp);
- mappingMap.remove(slcp);
- portMapList.add(createXpdrMappingObject(nodeId, null, null, null, null, mapping,
- //dlcp
- lcpMap.containsKey(dkey) ? lcpMap.get(dkey) : null,
- null));
- }
+ private Ports getXpdrPorts(OrgOpenroadmDevice device, XpdrPort xpdrPort, String nodeId) {
+ String circuitPackName = xpdrPort.getCircuitPackName();
+ String portName = xpdrPort.getPortName();
+ // If there xponder-subtree has missing circuit-packs or ports,
+ // This gives a null-pointer expection,
+ Optional<CircuitPacks> cpList = device.nonnullCircuitPacks().values().stream()
+ .filter(cp -> cp.getCircuitPackName().equals(circuitPackName)).findFirst();
+ if (cpList.isEmpty()) {
+ LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
+ nodeId, circuitPackName);
+ return null;
}
-
- if (device.getOduSwitchingPools() != null) {
- List<SwitchingPoolLcp> switchingPoolList = new ArrayList<>();
- 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()) {
- if (nbl.getPortList() == null) {
- continue;
- }
- List<String> lcpList = new ArrayList<>();
- for (PortList item : nbl.nonnullPortList().values()) {
- String key = item.getCircuitPackName() + "+" + item.getPortName();
- if (!lcpMap.containsKey(key)) {
- LOG.error(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG,
- nodeId, item.getPortName(), item.getCircuitPackName(), "to a logical connection point");
- continue;
- }
- lcpList.add(lcpMap.get(key));
- }
- NonBlockingList nonBlockingList = new NonBlockingListBuilder()
- .setNblNumber(nbl.getNblNumber())
- .setInterconnectBandwidth(nbl.getInterconnectBandwidth())
- .setInterconnectBandwidthUnit(nbl.getInterconnectBandwidthUnit())
- .setLcpList(lcpList)
- .build();
- nbMap.put(nonBlockingList.key(), nonBlockingList);
- }
- SwitchingPoolLcp splBldr = new SwitchingPoolLcpBuilder()
- .setSwitchingPoolNumber(odp.getSwitchingPoolNumber())
- .setSwitchingPoolType(odp.getSwitchingPoolType())
- //TODO differs from 2.2.1 SwitchingPoolTypes.forValue(odp.getSwitchingPoolType().getIntValue()
- .setNonBlockingList(nbMap)
- .build();
- switchingPoolList.add(splBldr);
- }
- postPortMapping(nodeId, null, null, null, switchingPoolList, null);
+ Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
+ .filter(p -> p.getPortName().equals(portName)).findFirst();
+ if (portsList.isEmpty()) {
+ LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
+ nodeId, portName, circuitPackName, "in the device");
+ return null;
}
-
- mappingMap.forEach((k,v) -> portMapList.add(v));
- return true;
+ return portsList.get();
}
private boolean checkPartnerPortNotNull(Ports port) {
break;
case Rx:
case Tx:
- if (!checkPartnerPortNotNull(port)) {
- LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG
- + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
- nodeId, port.getPortName(), circuitPackName);
+ Ports port2 = getPartnerPort(port, circuitPackName, nodeId);
+ if (port2 == null) {
continue;
}
String lcp1 = createLogicalConnectionPort(port, srgCpEntry.getKey(), portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
nodeId, port.getPortName(), circuitPackName, lcp1);
- InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class,
- new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
- .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
- Optional<Ports> port2Object = this.deviceTransactionManager
- .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
- Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue()
- != PortQual.RoadmExternal.getIntValue()) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
- nodeId, port.getPartnerPort().getPortName(),
- port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkPartnerPort(circuitPackName, port, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG
- + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
- nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
- port.getPortName(), circuitPackName);
- portIndex++;
- continue;
- }
String lcp2 = createLogicalConnectionPort(port2, srgCpEntry.getKey(),portIndex);
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
nodeId, port2.getPortName(), circuitPackName, lcp2);
return true;
}
+ private Ports getPartnerPort(Ports port, String circuitPackName, String nodeId) {
+ if (!checkPartnerPortNotNull(port)) {
+ LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
+ nodeId, port.getPortName(), circuitPackName);
+ return null;
+ }
+ InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
+ .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()));
+ Optional<Ports> port2Object = this.deviceTransactionManager
+ .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (port2Object.isEmpty()
+ || port2Object.get().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
+ nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ return null;
+ }
+ Ports port2 = port2Object.get();
+ if (!checkPartnerPort(circuitPackName, port, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
+ nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ //portIndex++;
+ //TODO check if we really needed to increase portIndex
+ // if yes this block should not be in getPartnerPort
+ return null;
+ }
+ return port2;
+ }
+
private List<Ports> getPortList(String circuitPackName, String nodeId) {
InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(circuitPackName));
if (partnerLcp != null) {
mpBldr.setPartnerLcp(partnerLcp);
}
- if (port.augmentation(Ports1.class) != null && port.augmentation(Ports1.class).getPortCapabilities() != null) {
+ Collection<SupportedInterfaceCapability> supIntfCapaList = getSupIntfCapaList(port);
+ if (supIntfCapaList != null) {
List<Class<? extends org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327
.SupportedIfCapability>> supportedIntf = new ArrayList<>();
SupportedInterfaceCapability sic1 = null;
- for (SupportedInterfaceCapability sic : port.augmentation(Ports1.class).getPortCapabilities()
- .nonnullSupportedInterfaceCapability().values()) {
+ for (SupportedInterfaceCapability sic : supIntfCapaList) {
supportedIntf.add(sic.getIfCapType());
sic1 = sic;
}
return mpBldr.build();
}
+ private Collection<SupportedInterfaceCapability> getSupIntfCapaList(Ports port) {
+ return
+ port.augmentation(Ports1.class) == null || port.augmentation(Ports1.class).getPortCapabilities() == null
+ ? null
+ : port.augmentation(Ports1.class).getPortCapabilities().nonnullSupportedInterfaceCapability().values();
+ }
+
private ArrayList<OpucnTribSlotDef> getOpucnTribSlots(String deviceId, String mxpProfileName) {
ArrayList<OpucnTribSlotDef> minMaxOpucnTribSlots = new ArrayList<>(2);
switch (cpMapValue.size()) {
case 1:
// port is bidirectional
- InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port = getTtpPort(cp1, cp1Name, nodeId);
+ if (port == null) {
return false;
}
- Ports port = portObject.get();
if (!checkTtpPort(port, cp1Name, nodeId, true)) {
continue;
}
-
String logicalConnectionPoint =
PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(), "TXRX");
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
break;
case 2:
// ports are unidirectionals
- 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(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(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.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp1.getPortName(), cp1Name);
+ Ports port1 = getTtpPort(cp1, cp1Name, nodeId);
+ if (port1 == null) {
return false;
}
- if (port2Object.isEmpty()) {
- LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp2.getPortName(), cp2Name);
+ ConnectionPorts cp2 = cpMapValue.get(1);
+ String cp2Name = cp2.getCircuitPackName();
+ Ports port2 = getTtpPort(cp2, cp2Name, nodeId);
+ if (port2 == null) {
return false;
}
-
- Ports port1 = port1Object.get();
- if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
- continue;
- }
- Ports port2 = port2Object.get();
- if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
- continue;
- }
-
- if (!checkPartnerPort(cp1Name, port1, port2)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
- continue;
- }
- // Directions checks are the same for cp1 and cp2, no need to check them twice.
- if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
- LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
- nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
+ if (!checkTtpPortsUnidir(port1, port2, cp1Name, cp2Name, nodeId)) {
continue;
}
-
String logicalConnectionPoint1 = PortMappingUtils.degreeTtpNodeName(cpMapEntry.getKey().toString(),
port1.getPortDirection().getName().toUpperCase(Locale.getDefault()));
LOG.info(PortMappingUtils.ASSOCIATED_LCP_LOGMSG,
default:
LOG.error(PortMappingUtils.NOT_CORRECT_CONPORT_LOGMSG, nodeId, cpMapEntry.getKey());
continue;
+ //TODO should it be continue or return false ?
}
}
return true;
}
+ private Ports getTtpPort(ConnectionPorts cp, String cpName, String nodeId) {
+ InstanceIdentifier<Ports> portID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(cpName))
+ .child(Ports.class, new PortsKey(cp.getPortName()));
+ LOG.debug(PortMappingUtils.FETCH_CONNECTIONPORT_LOGMSG, nodeId, cp.getPortName(), cpName);
+ Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
+ LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
+ Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (portObject.isEmpty()) {
+ LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
+ return null;
+ }
+ return portObject.get();
+ }
+
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
if (port.getPortQual() == null) {
return false;
return true;
}
- private NodeInfo createNodeInfo(Info deviceInfo) {
+ private boolean checkTtpPortsUnidir(Ports port1, Ports port2, String cp1Name, String cp2Name, String nodeId) {
+ if (!checkTtpPort(port1, cp1Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkTtpPort(port2, cp2Name, nodeId, false)) {
+ return false;
+ }
+ if (!checkPartnerPort(cp1Name, port1, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port2.getPortName(), cp2Name, port1.getPortName(), cp1Name);
+ return false;
+ }
+ // Directions checks are the same for cp1 and cp2, no need to check them twice.
+ if (!checkPartnerPortNoDir(cp2Name, port2, port1)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
+ nodeId, port1.getPortName(), cp1Name, port2.getPortName(), cp2Name);
+ return false;
+ }
+ return true;
+ }
+ private NodeInfo createNodeInfo(Info deviceInfo) {
if (deviceInfo.getNodeType() == null) {
// TODO make mandatory in yang
LOG.error(PortMappingUtils.NODE_TYPE_LOGMSG, deviceInfo.getNodeId(), "field missing");
return null;
}
-
NodeInfoBuilder nodeInfoBldr = new NodeInfoBuilder()
.setOpenroadmVersion(OpenroadmNodeVersion._71)
.setNodeClli(
if (deviceInfo.getIpAddress() != null) {
nodeInfoBldr.setNodeIpAddress(deviceInfo.getIpAddress());
}
-
return nodeInfoBldr.build();
}
}
public boolean addNode(String deviceId, String openROADMversion) {
- boolean sqlResult = false;
+ //boolean sqlResult = false;
return inode121.addNode(deviceId);
}
} catch (SQLException e) {
LOG.error("Something wrong when fetching node in DB", e);
}
- return nodeExists == 0 ? false : true;
+ return nodeExists != 0;
}
public boolean dataExists(String tableName, String searchKeys) {
} catch (SQLException e) {
LOG.error("Something wrong when fetching data in DB", e);
}
- return dataExists == 0 ? false : true;
+ return dataExists != 0;
}
/* public void getRoadmShelves(String nodeId, String openRoadmVersion)
} catch (SQLException e) {
LOG.error("Something wrong when fetching node in DB", e);
}
- return nodeExists == 0 ? false : true;
+ return nodeExists != 0;
}
public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
} catch (SQLException e) {
LOG.error("Something wrong when fetching node in DB", e);
}
- return nodeExists == 0 ? false : true;
+ return nodeExists != 0;
}
public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
LOG.info("Serialized event {}", serialized);
return serialized.getBytes(StandardCharsets.UTF_8);
} catch (IOException e) {
+ LOG.error("exception raised during serialization", e);
return new byte[0];
}
}
LOG.info("Serialized event {}", serialized);
return serialized.getBytes(StandardCharsets.UTF_8);
} catch (IOException e) {
+ LOG.error("exception raised during serialization", e);
return new byte[0];
}
}
LOG.warn("Kafka property file '{}' is empty", propertyFileName);
}
} catch (IOException e) {
- LOG.warn("Kafka property file '{}' was not found in the classpath", propertyFileName);
+ LOG.error("Kafka property file '{}' was not found in the classpath", propertyFileName, e);
}
return props;
}
NetconfNode netconfNodeBefore = rootNode.getDataBefore().augmentation(NetconfNode.class);
switch (rootNode.getModificationType()) {
case DELETE:
- this.networkModelService.deleteOpenRoadmnode(nodeId);
- onDeviceDisConnected(nodeId);
- LOG.info("Device {} correctly disconnected from controller", nodeId);
+ if (this.networkModelService.deleteOpenRoadmnode(nodeId)) {
+ onDeviceDisConnected(nodeId);
+ LOG.info("Device {} correctly disconnected from controller", nodeId);
+ }
break;
case WRITE:
NetconfNode netconfNodeAfter = rootNode.getDataAfter().augmentation(NetconfNode.class);
void createOpenRoadmNode(String nodeId, String nodeVersion);
/**
- * Delete OpenROADM node mapping and topologies.
+ * Delete OpenROADM node from portmapping and topologies.
*
* @param nodeId
* unique node ID of OpenROADM node.
*
+ * @return result of node deletion from portmapping and topologies
*/
- void deleteOpenRoadmnode(String nodeId);
+ boolean deleteOpenRoadmnode(String nodeId);
/**
* Update termination point, and if need, be associated links, of
*/
@Override
- public void deleteOpenRoadmnode(String nodeId) {
+ public boolean deleteOpenRoadmnode(String nodeId) {
try {
+ if (!this.portMapping.isNodeExist(nodeId)) {
+ return false;
+ }
NodeKey nodeIdKey = new NodeKey(new NodeId(nodeId));
LOG.info("deleting node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
LOG.info("all nodes and links deleted ! ");
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Error when trying to delete node : {}", nodeId, e);
+ return false;
}
+ return true;
}
@Override
OPENROADM_DEVICE_VERSION_2_2_1);
when(node.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
when(node.getDataBefore()).thenReturn(netconfNode);
- when(registrations.remove(anyString())).thenReturn(nodeRegistration);
NetConfTopologyListener listener = new NetConfTopologyListener(networkModelService, dataBroker,
deviceTransactionManager, portMapping, registrations);
verify(node, times(1)).getModificationType();
verify(node, times(3)).getDataBefore();
verify(networkModelService, times(1)).deleteOpenRoadmnode(anyString());
- verify(nodeRegistration, times(1)).unregisterListeners();
+ verify(nodeRegistration, times(0)).unregisterListeners();
}
@Test
counter++;
}
} catch (IllegalArgumentException e) {
- LOG.debug(" in GnpyResult: the element {} is not a ipv4Address ", nodeIp);
+ LOG.error(" in GnpyResult: the element {} is not a ipv4Address ", nodeIp, e);
}
}
}
public class OpenRoadmInterface710 {
private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
"Unable to get mapping from PortMapping for node % and logical connection port %s";
+ private static final String ODUC4 = "-ODUC4";
private final PortMapping portMapping;
private final OpenRoadmInterfaces openRoadmInterfaces;
.setMaintTestsignal(maintTestsignal.build());
InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
- logicalConnPoint + "-ODUC4");
+ logicalConnPoint + ODUC4);
// Create a list
List<String> listSupportingOtucnInterface = new ArrayList<>();
.setMaintTestsignal(maintTestsignal.build());
InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
- alogicalConnPoint + "-ODUC4");
+ alogicalConnPoint + ODUC4);
// Create a list
List<String> listSupportingOtucnInterface = new ArrayList<>();
.setMaintTestsignal(maintTestsignal.build());
InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
- logicalConnPoint + "-ODUC4");
+ logicalConnPoint + ODUC4);
// Create a list
List<String> listSupportingOtucnInterface = new ArrayList<>();
.setMaintTestsignal(maintTestsignal.build());
InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
- alogicalConnPoint + "-ODUC4");
+ alogicalConnPoint + ODUC4);
// Create a list
List<String> listSupportingOtucnInterface = new ArrayList<>();
private static final Logger LOG = LoggerFactory.getLogger(TapiContext.class);
public static final String TAPI_CONTEXT = "T-API context";
+ public static final String NODE_NOT_PRESENT = "Node is not present in datastore";
private final NetworkTransactionService networkTransactionService;
public TapiContext(NetworkTransactionService networkTransactionService) {
Optional<Node> optNode = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID)
.get();
if (!optNode.isPresent()) {
- LOG.error("Node is not present in datastore");
+ LOG.error(NODE_NOT_PRESENT);
return null;
}
// TODO -> Need to remove CEPs from NEPs. If not error from get Topology details output
.read(LogicalDatastoreType.OPERATIONAL, nepIID)
.get();
if (!optNode.isPresent()) {
- LOG.error("Node is not present in datastore");
+ LOG.error(NODE_NOT_PRESENT);
return null;
}
return optNode.get();
Optional<Link> optLink = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, linkIID)
.get();
if (!optLink.isPresent()) {
- LOG.error("Node is not present in datastore");
+ LOG.error(NODE_NOT_PRESENT);
return null;
}
return optLink.get();
Optional<OwnedNodeEdgePoint> optNode = this.networkTransactionService
.read(LogicalDatastoreType.OPERATIONAL, nepIID).get();
if (!optNode.isPresent()) {
- LOG.error("Node is not present in datastore");
+ LOG.error(NODE_NOT_PRESENT);
return null;
}
if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) {
return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
.get(new ConnectionEndPointKey(cepUuid));
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Couldnt read node in topology");
+ LOG.error("Couldnt read node in topology", e);
return null;
}
}
--- /dev/null
+#!/bin/sh
+
+DOCKER_CMD=docker
+if [ `which podman` ]
+then DOCKER_CMD=podman
+else
+ if [ ! `which $DOCKER_CMD` ]
+ then echo "no docker command available" >&2
+ exit 1
+ fi
+ #if "docker ps" cannot be run without error, prepend sudo
+ if ( ! $DOCKER_CMD ps >/dev/null 2>&1 );then
+ echo "docker command only usable as root, using sudo" >&2
+ DOCKER_CMD="sudo docker"
+ fi
+fi
+
+$DOCKER_CMD $@
+++ /dev/null
-version: '2'
-services:
- zookeeper:
- image: wurstmeister/zookeeper
- container_name: nbinotifications_zookeeper
- ports:
- - "2181:2181"
- kafka:
- image: wurstmeister/kafka
- container_name: nbinotifications_kafka
- ports:
- - "9092:9092"
- environment:
- KAFKA_ADVERTISED_HOST_NAME: localhost
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
\ No newline at end of file
[testenv:gnpy]
depends = buildcontroller
-whitelist_externals = sh
- sudo
+whitelist_externals = launch_tests.sh
+ dockercmd.sh
passenv = LAUNCHER USE_LIGHTY
commands =
#sudo docker pull atriki/gnpyrest:v1.2
- sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
+ ./dockercmd.sh run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
./launch_tests.sh with_docker gnpy
- sudo docker container rm -f gnpy_tpce_rest1
+ ./dockercmd.sh container rm -f gnpy_tpce_rest1
[testenv:nbinotifications]
depends = buildcontroller,sims221
-whitelist_externals = sh
- sudo
+whitelist_externals = launch_tests.sh
+ dockercmd.sh
passenv = LAUNCHER USE_LIGHTY
commands =
- sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
+ ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
./launch_tests.sh with_docker nbinotifications
- sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
+ ./dockercmd.sh container rm -f tpce_kafka1
[testenv:docs]
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY