X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fopenroadminterface%2FOpenRoadmInterface121.java;h=14bcabb0bf6e54482b8ab54d864508824bb59ea4;hb=4bb3743a3214fb481e4cc147914a314c9ff6d1c3;hp=805fa64d80ff3884108db532d4e08686f7bea3ac;hpb=3cb0866be6bc8b477849b6ad61e152e565254058;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java index 805fa64d8..14bcabb0b 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java @@ -8,7 +8,6 @@ package org.opendaylight.transportpce.renderer.openroadminterface; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -17,11 +16,13 @@ import org.opendaylight.transportpce.common.StringConstants; import org.opendaylight.transportpce.common.Timeouts; import org.opendaylight.transportpce.common.device.DeviceTransactionManager; import org.opendaylight.transportpce.common.fixedflex.GridConstant; +import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation; import org.opendaylight.transportpce.common.mapping.PortMapping; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.PowerDBm; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice; @@ -39,6 +40,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.Opti import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OtnOdu; import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OtnOtu; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.R100G; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.OtsAttributes; @@ -51,14 +53,13 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.OtuAttributes; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Decimal64; import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OpenRoadmInterface121 { - private static final String MAPPING_MSG_ERROR = - "Unable to get mapping from PortMapping for node % and logical connection port %s"; private final PortMapping portMapping; private final OpenRoadmInterfaces openRoadmInterfaces; private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface121.class); @@ -72,34 +73,32 @@ public class OpenRoadmInterface121 { throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } - - // Ethernet interface specific data - EthernetBuilder ethIfBuilder = new EthernetBuilder() - .setAutoNegotiation(EthAttributes.AutoNegotiation.Enabled) - .setDuplex(EthAttributes.Duplex.Full) - .setFec(EthAttributes.Fec.Off) - .setSpeed(Uint32.valueOf(100000)) - .setMtu(Uint32.valueOf(9000)); - - InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, - logicalConnPoint + "-ETHERNET"); - - // Create Interface1 type object required for adding as augmentation - Interface1Builder ethIf1Builder = new Interface1Builder(); - ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build()); - + InterfaceBuilder ethInterfaceBldr = + createGenericInterfaceBuilder(portMap, EthernetCsmacd.VALUE, logicalConnPoint + "-ETHERNET") + .addAugmentation( + // Create Interface1 type object required for adding as augmentation + new Interface1Builder() + .setEthernet( + // Ethernet interface specific data + new EthernetBuilder() + .setAutoNegotiation(EthAttributes.AutoNegotiation.Enabled) + .setDuplex(EthAttributes.Duplex.Full) + .setFec(EthAttributes.Fec.Off) + .setSpeed(Uint32.valueOf(100000)) + .setMtu(Uint32.valueOf(9000)) + .build()) + .build()); // Post interface on the device this.openRoadmInterfaces.postInterface(nodeId, ethInterfaceBldr); - // Post the equipment-state change on the device circuit-pack this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true); - return ethInterfaceBldr.getName(); } - private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class type, + private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, InterfaceType type, String key) { return new InterfaceBuilder() .setDescription(" TBD ") @@ -126,26 +125,25 @@ public class OpenRoadmInterface121 { throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } // Create generic interface - InterfaceBuilder otuInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOtu.class, logicalConnPoint - + "-OTU"); - otuInterfaceBldr.setSupportingInterface(supportOchInterface); - - // OTU interface specific data - OtuBuilder otuIfBuilder = new OtuBuilder() - .setFec(OtuAttributes.Fec.Scfec) - .setRate(OTU4.class); - - // Create Interface1 type object required for adding as augmentation - // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1Builder otuIf1Builder = - new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1Builder(); - otuInterfaceBldr.addAugmentation(otuIf1Builder.setOtu(otuIfBuilder.build()).build()); - + InterfaceBuilder otuInterfaceBldr = + createGenericInterfaceBuilder(portMap, OtnOtu.VALUE, logicalConnPoint + "-OTU") + .setSupportingInterface(supportOchInterface) + .addAugmentation( + new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1Builder() + .setOtu( + // OTU interface specific data + new OtuBuilder() + .setFec(OtuAttributes.Fec.Scfec) + .setRate(OTU4.VALUE) + .build()) + .build()); // Post interface on the device this.openRoadmInterfaces.postInterface(nodeId, otuInterfaceBldr); + this.portMapping.updateMapping(nodeId, portMap); return otuInterfaceBldr.getName(); } @@ -154,125 +152,116 @@ public class OpenRoadmInterface121 { * * @param nodeId node ID * @param logicalConnPoint logical Connection Point - * @param supportingOtuInterface supporting OTU Interface * * @return Name of the interface if successful, otherwise return null. * @throws OpenRoadmInterfaceException OpenRoadmInterfaceException */ - public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface) + public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } - InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint - + "-ODU"); - oduInterfaceBldr.setSupportingInterface(supportingOtuInterface); - - // ODU interface specific data - // Set Opu attributes - OpuBuilder opuBldr = new OpuBuilder() - .setPayloadType("07") - .setExpPayloadType("07"); - OduBuilder oduIfBuilder = new OduBuilder() - .setRate(ODU4.class) - .setMonitoringMode(OduAttributes.MonitoringMode.Terminated) - .setOpu(opuBldr.build()); - - // Create Interface1 type object required for adding as augmentation - // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1Builder oduIf1Builder = - new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1Builder(); - oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduIfBuilder.build()).build()); - + InterfaceBuilder oduInterfaceBldr = + createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + "-ODU"); + if (portMap.getSupportingOtu4() != null) { + oduInterfaceBldr.setSupportingInterface(portMap.getSupportingOtu4()); + } + oduInterfaceBldr.addAugmentation( + // Create Interface1 type object required for adding as augmentation + new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1Builder() + .setOdu( + // ODU interface specific data + new OduBuilder() + .setRate(ODU4.VALUE) + .setMonitoringMode(OduAttributes.MonitoringMode.Terminated) + .setOpu( + // Set Opu attributes + new OpuBuilder() + .setPayloadType("07") + .setExpPayloadType("07") + .build()) + .build()) + .build()); // Post interface on the device this.openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr); return oduInterfaceBldr.getName(); } /** - * This methods creates an OCH interface on the given termination point on + * This methods creates a list of OCH interface on the given termination point on * Roadm. * * @param nodeId node ID * @param logicalConnPoint logical connection point - * @param waveNumber wavelength number of the OCH interface. - * @param lowerSpectralSlotNumber int - * @param higherSpectralSlotNumber int - * @return Name of the interface if successful, otherwise return null. + * @param spectrumInformation SpectrumInformation + * @return List containing name of the interface if successful, otherwise return empty list. * * @throws OpenRoadmInterfaceException OpenRoadm interface exception */ - public List createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber, - int lowerSpectralSlotNumber, int higherSpectralSlotNumber) - throws OpenRoadmInterfaceException { + public List createOpenRoadmOchInterfaces(String nodeId, String logicalConnPoint, + SpectrumInformation spectrumInformation) + throws OpenRoadmInterfaceException { Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node %s and logical connection port %s", - nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); } - String spectralSlotName = String.join(GridConstant.SPECTRAL_SLOT_SEPARATOR, - String.valueOf(lowerSpectralSlotNumber), - String.valueOf(higherSpectralSlotNumber)); // Create generic interface - InterfaceBuilder ochInterfaceBldr = createGenericInterfaceBuilder(portMap, OpticalChannel.class, - createOpenRoadmOchInterfaceName(logicalConnPoint, spectralSlotName)); - - // OCH interface specific data - OchBuilder ocIfBuilder = new OchBuilder().setWavelengthNumber(Uint32.valueOf(waveNumber)); - + InterfaceBuilder ochInterfaceBldr = + createGenericInterfaceBuilder( + portMap, OpticalChannel.VALUE, + spectrumInformation.getIdentifierFromParams(logicalConnPoint)); // Add supporting OMS interface if (portMap.getSupportingOms() != null) { ochInterfaceBldr.setSupportingInterface(portMap.getSupportingOms()); } - // Create Interface1 type object required for adding as augmentation - // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.Interface1Builder - ochIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces - .rev161014.Interface1Builder(); - ochInterfaceBldr.addAugmentation(ochIf1Builder.setOch(ocIfBuilder.build()).build()); - - List interfacesCreated = new ArrayList<>(); + ochInterfaceBldr.addAugmentation( + // Create Interface1 type object required for adding as augmentation + new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.Interface1Builder() + .setOch( + // OCH interface specific data + new OchBuilder().setWavelengthNumber(spectrumInformation.getWaveLength()).build()) + .build()); // Post interface on the device openRoadmInterfaces.postInterface(nodeId, ochInterfaceBldr); - interfacesCreated.add(ochInterfaceBldr.getName()); - return interfacesCreated; + return new ArrayList(List.of(ochInterfaceBldr.getName())); } - public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber, - OchAttributes.ModulationFormat format, int lowerSpectralSlotNumber, int higherSpectralSlotNumber) - throws OpenRoadmInterfaceException { + public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, + SpectrumInformation spectrumInformation) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node %s and logical connection port %s", - nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException( + OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint)); + } + ModulationFormat modulationFormat = + OchAttributes.ModulationFormat.forName(spectrumInformation.getModulationFormat()); + if (modulationFormat == null) { + modulationFormat = OchAttributes.ModulationFormat.DpQpsk; } - String spectralSlotName = String.join(GridConstant.SPECTRAL_SLOT_SEPARATOR, - String.valueOf(lowerSpectralSlotNumber), - String.valueOf(higherSpectralSlotNumber)); - // OCH interface specific data - OchBuilder ocIfBuilder = new OchBuilder() - .setWavelengthNumber(Uint32.valueOf(waveNumber)) - .setModulationFormat(format) - .setRate(R100G.class) - .setTransmitPower(new PowerDBm(new BigDecimal("-5"))); - - // Create Interface1 type object required for adding as augmentation - // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014 - .Interface1Builder ochIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel - .interfaces.rev161014.Interface1Builder(); // Create generic interface - InterfaceBuilder ochInterfaceBldr = createGenericInterfaceBuilder(portMap, OpticalChannel.class, - createOpenRoadmOchInterfaceName(logicalConnPoint, spectralSlotName)); - ochInterfaceBldr.addAugmentation(ochIf1Builder.setOch(ocIfBuilder.build()).build()); - + InterfaceBuilder ochInterfaceBldr = + createGenericInterfaceBuilder( + portMap, OpticalChannel.VALUE, + spectrumInformation.getIdentifierFromParams(logicalConnPoint)) + .addAugmentation( + // Create Interface1 type object required for adding as augmentation + new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014 + .Interface1Builder() + .setOch( + // OCH interface specific data + new OchBuilder() + .setWavelengthNumber(spectrumInformation.getWaveLength()) + .setModulationFormat(modulationFormat) + .setRate(R100G.VALUE) + .setTransmitPower(new PowerDBm(Decimal64.valueOf("-5"))) + .build()) + .build()); // Post interface on the device this.openRoadmInterfaces.postInterface(nodeId, ochInterfaceBldr); - // Post the equipment-state change on the device circuit-pack if xpdr node if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) { this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true); @@ -285,64 +274,66 @@ public class OpenRoadmInterface121 { } public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException { - if (mapping.getSupportingOms() == null) { - // Create generic interface - InterfaceBuilder omsInterfaceBldr = createGenericInterfaceBuilder(mapping, OpenROADMOpticalMultiplex.class, - "OMS-" + mapping.getLogicalConnectionPoint()); - if (mapping.getSupportingOts() != null) { - omsInterfaceBldr.setSupportingInterface(mapping.getSupportingOts()); - } else { - LOG.error("Unable to get ots interface from mapping {} - {}", nodeId, - mapping.getLogicalConnectionPoint()); - return null; - } - this.openRoadmInterfaces.postInterface(nodeId, omsInterfaceBldr); - this.portMapping.updateMapping(nodeId, mapping); - return omsInterfaceBldr.build().getName(); - } else { + if (mapping.getSupportingOms() != null) { return mapping.getSupportingOms(); } + if (mapping.getSupportingOts() == null) { + LOG.error("Unable to get ots interface from mapping {} - {}", nodeId, mapping.getLogicalConnectionPoint()); + return null; + } + // Create generic interface + InterfaceBuilder omsInterfaceBldr = + createGenericInterfaceBuilder( + mapping, OpenROADMOpticalMultiplex.VALUE, + "OMS-" + mapping.getLogicalConnectionPoint()) + .setSupportingInterface(mapping.getSupportingOts()); + this.openRoadmInterfaces.postInterface(nodeId, omsInterfaceBldr); + this.portMapping.updateMapping(nodeId, mapping); + return omsInterfaceBldr.build().getName(); } public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException { - if (mapping.getSupportingOts() == null) { - // Create generic interface - InterfaceBuilder otsInterfaceBldr = createGenericInterfaceBuilder(mapping, OpticalTransport.class, "OTS-" - + mapping.getLogicalConnectionPoint()); - // OTS interface augmentation specific data - OtsBuilder otsIfBuilder = new OtsBuilder(); - otsIfBuilder.setFiberType(OtsAttributes.FiberType.Smf); - - // Create Interface1 type object required for adding as - // augmentation - org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014 - .Interface1Builder otsIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm - .optical.transport.interfaces.rev161014.Interface1Builder(); - otsInterfaceBldr.addAugmentation(otsIf1Builder.setOts(otsIfBuilder.build()).build()); - this.openRoadmInterfaces.postInterface(nodeId, otsInterfaceBldr); - this.portMapping.updateMapping(nodeId, mapping); - return otsInterfaceBldr.build().getName(); - } else { + if (mapping.getSupportingOts() != null) { return mapping.getSupportingOts(); } + // Create generic interface + InterfaceBuilder otsInterfaceBldr = + createGenericInterfaceBuilder(mapping, OpticalTransport.VALUE, "OTS-" + mapping.getLogicalConnectionPoint()) + .addAugmentation( + // Create Interface1 type object required for adding as + // augmentation + new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014 + .Interface1Builder() + .setOts( + // OTS interface augmentation specific data + new OtsBuilder().setFiberType(OtsAttributes.FiberType.Smf).build()) + .build()); + this.openRoadmInterfaces.postInterface(nodeId, otsInterfaceBldr); + this.portMapping.updateMapping(nodeId, mapping); + return otsInterfaceBldr.build().getName(); } public boolean isUsedByXc(String nodeId, String interfaceName, String xc, - DeviceTransactionManager deviceTransactionManager) { - InstanceIdentifier xciid = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(RoadmConnections.class, new RoadmConnectionsKey(xc)); + DeviceTransactionManager deviceTransactionManager) { LOG.info("reading xc {} in node {}", xc, nodeId); - Optional crossconnection = deviceTransactionManager.getDataFromDevice(nodeId, - LogicalDatastoreType.CONFIGURATION, xciid, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); - if (crossconnection.isPresent()) { - RoadmConnections rc = crossconnection.get(); - LOG.info("xd {} found", xc); - if (rc.getSource().getSrcIf().equals(interfaceName) - || rc.getDestination().getDstIf().equals(interfaceName)) { - return true; - } - } else { + Optional crossconnection = deviceTransactionManager.getDataFromDevice( + nodeId, + LogicalDatastoreType.CONFIGURATION, + InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(RoadmConnections.class, new RoadmConnectionsKey(xc)) + .build(), + Timeouts.DEVICE_READ_TIMEOUT, + Timeouts.DEVICE_READ_TIMEOUT_UNIT); + if (crossconnection.isEmpty()) { LOG.info("xd {} not found !", xc); + return false; + } + RoadmConnections rc = crossconnection.orElseThrow(); + LOG.info("xd {} found", xc); + if (rc.getSource().getSrcIf().equals(interfaceName) + || rc.getDestination().getDstIf().equals(interfaceName)) { + return true; } return false; }