From ab8dd162f2138c7c5c24d37c4340698ad836f6a2 Mon Sep 17 00:00:00 2001 From: Balagangadhar Bathula Date: Tue, 11 Oct 2022 15:54:56 -0400 Subject: [PATCH] Support create/delete interfaces for regen - For regen xpdr-type create OTSi, OTSi-group, OTUCn and ODUCn on source and destination TP - Add support to delete interfaces for regen xpdr-type JIRA: TRNSPRTPCE-633 Change-Id: Ia044ebe9f6c9d1746a1959b8980ba9ec0af7a8cb Signed-off-by: Balagangadhar (Bala) Bathula --- .../OpenRoadmInterfaceException.java | 5 + .../OpenRoadmInterface710.java | 233 +++++++++++------- .../OpenRoadmInterfaceFactory.java | 11 + .../DeviceRendererServiceImpl.java | 108 ++++---- 4 files changed, 225 insertions(+), 132 deletions(-) diff --git a/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfaceException.java b/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfaceException.java index 9f058a380..6f77b5654 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfaceException.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfaceException.java @@ -26,4 +26,9 @@ public class OpenRoadmInterfaceException extends Exception { return String.format( "Unable to get mapping from PortMapping for node %s and logical connection port %s", node, port); } + + public static final String mapping_xpdrtype_err(String node, String port) { + return String.format( + "Unable to get XpdrType from PortMapping for node % and logical connection port %s", node, port); + } } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface710.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface710.java index 1022d92b1..e730df4f5 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface710.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface710.java @@ -47,6 +47,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Rs import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Scfec; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.Interface1Builder; import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.ethernet.container.EthernetBuilder; @@ -61,6 +62,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interface import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.attributes.FlexoBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCTP; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTP; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTPCTP; @@ -521,50 +523,64 @@ public class OpenRoadmInterface710 { public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint) throws OpenRoadmInterfaceException { - Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint); - if (mapping == null) { + Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint); + if (portMap == null) { throw new OpenRoadmInterfaceException( OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } - if (mapping.getSupportingOtucn() == null) { + // Used to find if the port is regen-type + if (portMap.getXpdrType() == null) { + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_xpdrtype_err(nodeId, logicalConnPoint)); + } + if (portMap.getSupportingOtucn() == null) { throw new OpenRoadmInterfaceException("Missing supporting OTUCn interface on port-mapping"); } - String supportingOtucn = mapping.getSupportingOtucn(); + String supportingOtucn = portMap.getSupportingOtucn(); // Set the ODUCn rate from OTUCn interface naming convention String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1); // check if the oducnrate is a valid value and if it is invalid, then throw error if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) { throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE); } + // set the common parameters + OduBuilder oduBuilder = new OduBuilder() + .setRate(ODUCn.VALUE) + .setOducnNRate(Uint16.valueOf(oducnrate)); + + if (portMap.getXpdrType() == XpdrNodeTypes.Regen) { + LOG.info("Regen mode only supports not-terminated or monitored"); + oduBuilder.setMonitoringMode(MonitoringMode.NotTerminated) + .setOduFunction(ODUCTP.VALUE); + } else { + // if it is other than regen mode + oduBuilder.setMonitoringMode(MonitoringMode.Terminated) + .setTimActEnabled(false) + .setOduFunction(ODUTTP.VALUE) + .setTimDetectMode(TimDetectMode.Disabled) + .setDegmIntervals(Uint8.valueOf(2)) + .setDegthrPercentage(Uint16.valueOf(100)) + .setOducnNRate(Uint16.valueOf(oducnrate)) + .setOpu( + // OPU payload + new OpuBuilder() + .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .build()); + } + InterfaceBuilder oduInterfaceBuilder = - createGenericInterfaceBuilder(mapping, OtnOdu.VALUE, logicalConnPoint + "-ODUC" + oducnrate) + createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + "-ODUC" + oducnrate) .setSupportingInterfaceList(new HashSet<>(Set.of(supportingOtucn))) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder() - .setOdu( - // Create an ODUCn object - new OduBuilder() - .setRate(ODUCn.VALUE) - .setOduFunction(ODUTTP.VALUE) - .setMonitoringMode(MonitoringMode.Terminated) - .setTimActEnabled(false) - .setTimDetectMode(TimDetectMode.Disabled) - .setDegmIntervals(Uint8.valueOf(2)) - .setDegthrPercentage(Uint16.valueOf(100)) - .setOducnNRate(Uint16.valueOf(oducnrate)) - .setOpu( - // OPU payload - new OpuBuilder() - .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .build()) - .build()) - .build()); + .setOdu(oduBuilder.build()) + .build()); // Post interface on the device openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder); // Post the equipment-state change on the device circuit-pack if xpdr node - if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) { - this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true); + if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) { + this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true); } return oduInterfaceBuilder.getName(); } @@ -585,38 +601,53 @@ public class OpenRoadmInterface710 { throw new OpenRoadmInterfaceException( OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint)); } + if (portMapA.getXpdrType() == null) { + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_xpdrtype_err(anodeId, alogicalConnPoint)); + } // On the Zside Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint); if (portMapZ == null) { throw new OpenRoadmInterfaceException( OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint)); } + // set the common parameters + OduBuilder oduBuilder = new OduBuilder() + .setRate(ODUCn.VALUE) + .setOducnNRate(Uint16.valueOf(oducnrate)); + + if (portMapA.getXpdrType() == XpdrNodeTypes.Regen) { + LOG.info("Regen mode only supports not-terminated or monitored"); + oduBuilder.setMonitoringMode(MonitoringMode.NotTerminated) + // For regen-mode ODU-function is set to CTP + .setOduFunction(ODUCTP.VALUE); + } else { + // if it is other than regen mode + oduBuilder.setMonitoringMode(MonitoringMode.Terminated) + .setTimActEnabled(false) + .setOduFunction(ODUTTP.VALUE) + .setTimDetectMode(TimDetectMode.Disabled) + .setDegmIntervals(Uint8.valueOf(2)) + .setDegthrPercentage(Uint16.valueOf(100)) + .setOducnNRate(Uint16.valueOf(oducnrate)) + .setOpu( + // OPU payload + new OpuBuilder() + .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .build()) + .setTxSapi(portMapA.getLcpHashVal()) + .setTxDapi(portMapZ.getLcpHashVal()) + .setExpectedSapi(portMapZ.getLcpHashVal()) + .setExpectedDapi(portMapZ.getLcpHashVal()); + } + InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint + ODUC + oducnrate) .setSupportingInterfaceList(new HashSet<>(Set.of(supportingOtucn))) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder() - .setOdu( - new OduBuilder() - .setRate(ODUCn.VALUE) - .setOducnNRate(Uint16.valueOf(oducnrate)) - .setOduFunction(ODUTTP.VALUE) - .setMonitoringMode(MonitoringMode.Terminated) - .setTimActEnabled(false) - .setTimDetectMode(TimDetectMode.Disabled) - .setDegmIntervals(Uint8.valueOf(2)) - .setDegthrPercentage(Uint16.valueOf(100)) - .setOpu( - // OPU payload - new OpuBuilder() - .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .build()) - .setTxSapi(portMapA.getLcpHashVal()) - .setTxDapi(portMapZ.getLcpHashVal()) - .setExpectedSapi(portMapZ.getLcpHashVal()) - .setExpectedDapi(portMapZ.getLcpHashVal()) - .build()) + .setOdu(oduBuilder.build()) .build()); // Post interface on the device openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder); @@ -815,35 +846,49 @@ public class OpenRoadmInterface710 { throw new OpenRoadmInterfaceException( OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } + // Used to find if the port is regen-type + if (portMap.getXpdrType() == null) { + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_xpdrtype_err(nodeId, logicalConnPoint)); + } // Set the ODUCn rate from OTUCn interface naming convention String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1); // check if the oducnrate is a valid value and if it is invalid, then throw error if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) { throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE); } + // set the common parameters + OduBuilder oduBuilder = new OduBuilder() + .setRate(ODUCn.VALUE) + .setOducnNRate(Uint16.valueOf(oducnrate)); + + if (portMap.getXpdrType() == XpdrNodeTypes.Regen) { + LOG.info("Regen mode only supports not-terminated or monitored"); + oduBuilder.setMonitoringMode(MonitoringMode.NotTerminated) + .setOduFunction(ODUCTP.VALUE); + } else { + // if it is other than regen mode + oduBuilder.setMonitoringMode(MonitoringMode.Terminated) + .setTimActEnabled(false) + .setOduFunction(ODUTTP.VALUE) + .setTimDetectMode(TimDetectMode.Disabled) + .setDegmIntervals(Uint8.valueOf(2)) + .setDegthrPercentage(Uint16.valueOf(100)) + .setOducnNRate(Uint16.valueOf(oducnrate)) + .setOpu( + // OPU payload + new OpuBuilder() + .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .build()); + } + InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + ODUC + oducnrate) .setSupportingInterfaceList(new HashSet<>(Set.of(supportingOtucn))) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder() - .setOdu( - // Create an ODUC4 object - new OduBuilder() - .setRate(ODUCn.VALUE) - .setOducnNRate(Uint16.valueOf(oducnrate)) - .setOduFunction(ODUTTP.VALUE) - .setMonitoringMode(MonitoringMode.Terminated) - .setTimActEnabled(false) - .setTimDetectMode(TimDetectMode.Disabled) - .setDegmIntervals(Uint8.valueOf(2)) - .setDegthrPercentage(Uint16.valueOf(100)) - .setOpu( - // OPU payload - new OpuBuilder() - .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .build()) - .build()) + .setOdu(oduBuilder.build()) .build()); // Post interface on the device openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder); @@ -866,6 +911,10 @@ public class OpenRoadmInterface710 { throw new OpenRoadmInterfaceException( OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint)); } + if (portMapA.getXpdrType() == null) { + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_xpdrtype_err(anodeId, alogicalConnPoint)); + } // On the Zside Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint); if (portMapZ == null) { @@ -879,33 +928,43 @@ public class OpenRoadmInterface710 { throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE); } + // set the common parameters + OduBuilder oduBuilder = new OduBuilder() + .setRate(ODUCn.VALUE) + .setOducnNRate(Uint16.valueOf(oducnrate)); + + if (portMapA.getXpdrType() == XpdrNodeTypes.Regen) { + LOG.info("Regen mode only supports not-terminated or monitored"); + oduBuilder.setMonitoringMode(MonitoringMode.NotTerminated) + // For regen-mode ODU-function is set to CTP + .setOduFunction(ODUCTP.VALUE); + } else { + // if it is other than regen mode + oduBuilder.setMonitoringMode(MonitoringMode.Terminated) + .setTimActEnabled(false) + .setOduFunction(ODUTTP.VALUE) + .setTimDetectMode(TimDetectMode.Disabled) + .setDegmIntervals(Uint8.valueOf(2)) + .setDegthrPercentage(Uint16.valueOf(100)) + .setOducnNRate(Uint16.valueOf(oducnrate)) + .setOpu( + // OPU payload + new OpuBuilder() + .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) + .build()) + .setTxSapi(portMapA.getLcpHashVal()) + .setTxDapi(portMapZ.getLcpHashVal()) + .setExpectedSapi(portMapZ.getLcpHashVal()) + .setExpectedDapi(portMapZ.getLcpHashVal()); + } + InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint + ODUC + oducnrate) .setSupportingInterfaceList(new HashSet<>(Set.of(supportingOtucn))) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder() - .setOdu( - // Create an ODUCn object - new OduBuilder() - .setRate(ODUCn.VALUE) - .setOducnNRate(Uint16.valueOf(oducnrate)) - .setOduFunction(ODUTTP.VALUE) - .setMonitoringMode(MonitoringMode.Terminated) - .setTimActEnabled(false) - .setTimDetectMode(TimDetectMode.Disabled) - .setDegmIntervals(Uint8.valueOf(2)) - .setDegthrPercentage(Uint16.valueOf(100)) - .setOpu( - // OPU payload - new OpuBuilder() - .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .setPayloadType(PayloadTypeDef.getDefaultInstance("22")) - .build()) - .setTxSapi(portMapA.getLcpHashVal()) - .setTxDapi(portMapZ.getLcpHashVal()) - .setExpectedSapi(portMapZ.getLcpHashVal()) - .setExpectedDapi(portMapZ.getLcpHashVal()) - .build()) + .setOdu(oduBuilder.build()) .build()); // Post interface on the device openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder); diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java index e9597a99f..cc16c6904 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java @@ -135,6 +135,17 @@ public class OpenRoadmInterfaceFactory { } } + public String createOpenRoadmOducn(String nodeId, String logicalConnPoint) + throws OpenRoadmInterfaceException { + + switch (mappingUtils.getOpenRoadmVersion(nodeId)) { + case StringConstants.OPENROADM_DEVICE_VERSION_7_1: + return openRoadmInterface710.createOpenRoadmOducnInterface(nodeId, logicalConnPoint); + default: + return null; + } + } + /** * This methods creates an OTU interface on the given termination point. * diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java index 39be93c61..2f807ed3c 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java @@ -158,14 +158,25 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { // Split the string based on # pass the last element as the supported Interface // This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH String[] listOfSuppOchInf = supportingOchInterface.split("#"); - createdOchInterfaces = Set.of(listOfSuppOchInf); + List createdOchInf = Arrays.asList(listOfSuppOchInf); + createdOchInterfaces.addAll(createdOchInf); + LOG.info("DEST all otsi interfaces {}", createdOchInterfaces); // Taking the last element - supportingOchInterface = listOfSuppOchInf[createdOchInterfaces.size() - 1]; - String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface( - nodeId, destTp, supportingOchInterface, apiInfoA, apiInfoZ); + supportingOchInterface = listOfSuppOchInf[createdOchInf.size() - 1]; + String supportingOtuInterface = this.openRoadmInterfaceFactory + .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface, apiInfoA, + apiInfoZ); createdOtuInterfaces.add(supportingOtuInterface); + LOG.info("all dest otu interfaces {}", createdOtuInterfaces); if (srcTp == null) { otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(destTp).build()); + } else if (srcTp.contains(StringConstants.NETWORK_TOKEN)) { + // If src and dest tp contains the network token, then it is regenerator + LOG.info("Create the ODUCn for regen on the dest-tp"); + // Here we first create ODUCn interface for the Regen + createdOduInterfaces.add(this.openRoadmInterfaceFactory + .createOpenRoadmOducn(nodeId, destTp)); + LOG.info("all dest odu interfaces {}", createdOduInterfaces); } else { // This is needed for 7.1 device models for 400GE, since we have ODUC4 and ODUflex // are combined @@ -188,7 +199,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { // create OpenRoadm Xponder Line Interfaces String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface( nodeId, srcTp, spectrumInformation); - createdOchInterfaces.add(supportingOchInterface); + // createdOchInterfaces.add(supportingOchInterface); // Split the string based on # pass the last element as the supported Interface // This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH String[] listOfSuppOchInf = supportingOchInterface.split("#"); @@ -201,6 +212,13 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { createdOtuInterfaces.add(supportingOtuInterface); if (destTp == null) { otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(srcTp).build()); + } else if (destTp.contains(StringConstants.NETWORK_TOKEN)) { + // If the src and dest tp have network-token, then it is a regen + LOG.info("Create the regen-interfaces on the src-tp"); + // Here we first create ODUCn interface for the Regen + createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOducn(nodeId, + srcTp)); + LOG.info("all src odu interfaces {}", createdOduInterfaces); } else { createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface( nodeId, srcTp, false, apiInfoA, apiInfoZ, PT_07)); @@ -277,7 +295,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e); } if (!alarmSuppressionNodeRemoval(input.getServiceName())) { - LOG.error("Alarm suppresion node removal failed!!!!"); + LOG.error("Alarm suppression node removal failed!!!!"); } return new ServicePathOutputBuilder() .setNodeInterface(nodeInterfaces) @@ -421,57 +439,57 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { // common GridConstant that states NAME_PARAMETERS_SEPARATOR = "-" if (destTp.contains(StringConstants.NETWORK_TOKEN)) { - try { - for (String suffix : suffixListMap.get("ODU")) { - if (this.openRoadmInterfaces.getInterface( - nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)).isPresent()) { - interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)); - } - } - } - catch (OpenRoadmInterfaceException e) { - LOG.error("impossible to get one of the interfaces {}", - destTp + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join( - " or " + destTp + GridConstant.NAME_PARAMETERS_SEPARATOR, - suffixListMap.get("ODU")), - e); - } - try { - for (String suffix : suffixListMap.get("other")) { - if (this.openRoadmInterfaces.getInterface( - nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)).isPresent()) { - LOG.info("Deleting the interface {}", - String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)); - interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)); - } - } - } - catch (OpenRoadmInterfaceException e) { - LOG.error("impossible to get one of the interfaces {}", - destTp + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join( - " or " + destTp + GridConstant.NAME_PARAMETERS_SEPARATOR, - suffixListMap.get("ODU")), - e); - } + interfacesToDelete.addAll(inf2Del(destTp, suffixListMap, nodeId)); } if (srcTp.contains(StringConstants.NETWORK_TOKEN)) { - interfacesToDelete.add( - String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, suffixListMap.get("ODU").get(0))); - for (String suffix : suffixListMap.get("other")) { - interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, suffix)); - } + // For a regen case, the srcTp can also contain the network-token + interfacesToDelete.addAll(inf2Del(srcTp, suffixListMap, nodeId)); } - if (srcTp.contains(StringConstants.CLIENT_TOKEN)) { interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, "ETHERNET")); } if (destTp.contains(StringConstants.CLIENT_TOKEN)) { - interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, "ETHERNET")); } return interfacesToDelete; } + private List inf2Del(String termPoint, Map> suffixListMap, String nodeId) { + List inf2Del = new LinkedList<>(); + try { + for (String suffix : suffixListMap.get("ODU")) { + if (this.openRoadmInterfaces.getInterface( + nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, termPoint, suffix)).isPresent()) { + inf2Del.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, termPoint, suffix)); + } + } + } + catch (OpenRoadmInterfaceException e) { + LOG.error("impossible to get one of the interfaces {}", + termPoint + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join( + " or " + termPoint + GridConstant.NAME_PARAMETERS_SEPARATOR, + suffixListMap.get("ODU")), + e); + } + try { + for (String suffix : suffixListMap.get("other")) { + if (this.openRoadmInterfaces.getInterface( + nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, termPoint, suffix)).isPresent()) { + LOG.info("Deleting the interface {}", + String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, termPoint, suffix)); + inf2Del.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, termPoint, suffix)); + } + } + } + catch (OpenRoadmInterfaceException e) { + LOG.error("impossible to get one of the interfaces {}", + termPoint + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join( + " or " + termPoint + GridConstant.NAME_PARAMETERS_SEPARATOR, + suffixListMap.get("ODU")), + e); + } + return inf2Del; + } @Override -- 2.36.6