}
public Optional<?> getCrossConnect(String nodeId, String connectionNumber) {
- String openRoadmVersion = mappingUtils.getOpenRoadmVersion(nodeId);
- if (OPENROADM_DEVICE_VERSION_1_2_1.equals(openRoadmVersion)) {
- return crossConnectImpl121.getCrossConnect(nodeId,connectionNumber);
- }
- else if (OPENROADM_DEVICE_VERSION_2_2_1.equals(openRoadmVersion)) {
- return crossConnectImpl221.getCrossConnect(nodeId,connectionNumber);
+ switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
+ case OPENROADM_DEVICE_VERSION_1_2_1:
+ return crossConnectImpl121.getCrossConnect(nodeId,connectionNumber);
+ case OPENROADM_DEVICE_VERSION_2_2_1:
+ return crossConnectImpl221.getCrossConnect(nodeId,connectionNumber);
+ default:
+ return Optional.empty();
}
- return Optional.empty();
}
public Optional<String> postCrossConnect(String nodeId, String srcTp, String destTp,
SpectrumInformation spectrumInformation) {
String openRoadmVersion = mappingUtils.getOpenRoadmVersion(nodeId);
- LOG.info("Cross Connect post request received for node {} with version {}",nodeId,openRoadmVersion);
- if (OPENROADM_DEVICE_VERSION_1_2_1.equals(openRoadmVersion)) {
- LOG.info("Device Version is 1.2.1");
- return crossConnectImpl121.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
- }
- else if (OPENROADM_DEVICE_VERSION_2_2_1.equals(openRoadmVersion)) {
- LOG.info("Device Version is 2.2");
- return crossConnectImpl221.postCrossConnect(nodeId, srcTp, destTp,
- spectrumInformation);
+ LOG.info("Cross Connect post request received for node {} with version {}", nodeId, openRoadmVersion);
+ switch (openRoadmVersion) {
+ case OPENROADM_DEVICE_VERSION_1_2_1:
+ LOG.info("Device Version is 1.2.1");
+ return crossConnectImpl121.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
+ case OPENROADM_DEVICE_VERSION_2_2_1:
+ LOG.info("Device Version is 2.2.1");
+ return crossConnectImpl221.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
+ default:
+ LOG.info("Device Version not found");
+ return Optional.empty();
}
- LOG.info("Device Version not found");
- return Optional.empty();
-
}
public List<String> deleteCrossConnect(String nodeId, String connectionNumber, Boolean isOtn) {
-
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case OPENROADM_DEVICE_VERSION_1_2_1:
return crossConnectImpl121.deleteCrossConnect(nodeId, connectionNumber);
public List<?> getConnectionPortTrail(String nodeId, String srcTp, String destTp, int lowerSpectralSlotNumber,
int higherSpectralSlotNumber)
throws OpenRoadmInterfaceException {
- String openRoadmVersion = mappingUtils.getOpenRoadmVersion(nodeId);
- if (OPENROADM_DEVICE_VERSION_1_2_1.equals(openRoadmVersion)) {
- return crossConnectImpl121.getConnectionPortTrail(nodeId, srcTp, destTp,
- lowerSpectralSlotNumber, higherSpectralSlotNumber);
- }
- else if (OPENROADM_DEVICE_VERSION_2_2_1.equals(openRoadmVersion)) {
- return crossConnectImpl221
+ switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
+ case OPENROADM_DEVICE_VERSION_1_2_1:
+ return crossConnectImpl121
.getConnectionPortTrail(nodeId, srcTp, destTp, lowerSpectralSlotNumber, higherSpectralSlotNumber);
+ case OPENROADM_DEVICE_VERSION_2_2_1:
+ return crossConnectImpl221
+ .getConnectionPortTrail(nodeId, srcTp, destTp, lowerSpectralSlotNumber, higherSpectralSlotNumber);
+ default:
+ return null;
}
- return null;
}
@Override
public boolean setPowerLevel(String nodeId, String mode, Decimal64 powerValue, String connectionNumber) {
- String openRoadmVersion = mappingUtils.getOpenRoadmVersion(nodeId);
- if (OPENROADM_DEVICE_VERSION_1_2_1.equals(openRoadmVersion) && OpticalControlMode.forName(mode) != null) {
- return crossConnectImpl121.setPowerLevel(nodeId,OpticalControlMode.forName(mode), powerValue,
- connectionNumber);
- }
- else if (OPENROADM_DEVICE_VERSION_2_2_1.equals(openRoadmVersion)
- && org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.OpticalControlMode
- .forName(mode) != null) {
- return crossConnectImpl221.setPowerLevel(nodeId,
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.OpticalControlMode.forName(mode),
- powerValue, connectionNumber);
+ switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
+ case OPENROADM_DEVICE_VERSION_1_2_1:
+ if (OpticalControlMode.forName(mode) == null) {
+ return false;
+ }
+ return crossConnectImpl121.setPowerLevel(nodeId,
+ OpticalControlMode.forName(mode),
+ powerValue, connectionNumber);
+ case OPENROADM_DEVICE_VERSION_2_2_1:
+ if (org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.OpticalControlMode
+ .forName(mode) == null) {
+ return false;
+ }
+ return crossConnectImpl221.setPowerLevel(nodeId,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.OpticalControlMode
+ .forName(mode),
+ powerValue, connectionNumber);
+ default:
+ return false;
}
- return false;
}
@Override
public Optional<String> postOtnCrossConnect(List<String> createdOduInterfaces, Nodes node)
throws OpenRoadmInterfaceException {
- String openRoadmVersion = mappingUtils.getOpenRoadmVersion(node.getNodeId());
-
- if (OPENROADM_DEVICE_VERSION_2_2_1.equals(openRoadmVersion)) {
- return crossConnectImpl221.postOtnCrossConnect(createdOduInterfaces, node);
- }
- else if (OPENROADM_DEVICE_VERSION_7_1.equals(openRoadmVersion)) {
- return crossConnectImpl710.postOtnCrossConnect(createdOduInterfaces, node);
+ switch (mappingUtils.getOpenRoadmVersion(node.getNodeId())) {
+ case OPENROADM_DEVICE_VERSION_2_2_1:
+ return crossConnectImpl221.postOtnCrossConnect(createdOduInterfaces, node);
+ case OPENROADM_DEVICE_VERSION_7_1:
+ return crossConnectImpl710.postOtnCrossConnect(createdOduInterfaces, node);
+ default:
+ return Optional.empty();
}
- return Optional.empty();
}
}
Direction.Bidirectional, "TXRX");
}
+
public PortMappingVersion121(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager) {
this.dataBroker = dataBroker;
this.deviceTransactionManager = deviceTransactionManager;
}
private MappingBuilder updateMappingInterfaces(String nodeId, MappingBuilder mpBldr, Ports port) {
- mpBldr.setSupportingOtu4(null)
- .setSupportingOdu4(null);
+ mpBldr.setSupportingOtu4(null).setSupportingOdu4(null);
for (Interfaces interfaces : port.getInterfaces()) {
Optional<Interface> openRoadmInterface = getInterfaceFromDevice(nodeId, interfaces.getInterfaceName());
if (openRoadmInterface.isEmpty()) {
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG,
- nodeId, openRoadmInterface.get().getName(), openRoadmInterface.get().getType());
InterfaceType interfaceType = openRoadmInterface.get().getType();
- // Check if interface type is OMS or OTS
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
+ // Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
mpBldr.setSupportingOms(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OpticalTransport.VALUE)) {
+ } else if (interfaceType.equals(OpticalTransport.VALUE)) {
mpBldr.setSupportingOts(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OtnOtu.VALUE)) {
+ } else if (interfaceType.equals(OtnOtu.VALUE)) {
mpBldr.setSupportingOtu4(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OtnOdu.VALUE)) {
+ } else if (interfaceType.equals(OtnOdu.VALUE)) {
mpBldr.setSupportingOdu4(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(EthernetCsmacd.VALUE)) {
+ } else if (interfaceType.equals(EthernetCsmacd.VALUE)) {
mpBldr.setSupportingEthernet(interfaces.getInterfaceName());
}
}
}
private MappingBuilder updateMappingInterfaces(String nodeId, MappingBuilder mpBldr, Ports port) {
- mpBldr.setSupportingOtu4(null)
- .setSupportingOdu4(null);
+ mpBldr.setSupportingOtu4(null).setSupportingOdu4(null);
for (Interfaces interfaces : port.getInterfaces()) {
Optional<Interface> openRoadmInterface = getInterfaceFromDevice(nodeId,
interfaces.getInterfaceName());
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG,
- nodeId, openRoadmInterface.get().getName(), openRoadmInterface.get().getType());
InterfaceType interfaceType = openRoadmInterface.get().getType();
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
// Check if interface type is OMS or OTS
+ // Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
mpBldr.setSupportingOms(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OpticalTransport.VALUE)) {
+ } else if (interfaceType.equals(OpticalTransport.VALUE)) {
mpBldr.setSupportingOts(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OtnOtu.VALUE)) {
+ } else if (interfaceType.equals(OtnOtu.VALUE)) {
mpBldr.setSupportingOtu4(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OtnOdu.VALUE)) {
+ } else if (interfaceType.equals(OtnOdu.VALUE)) {
mpBldr.setSupportingOdu4(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(EthernetCsmacd.VALUE)) {
+ } else if (interfaceType.equals(EthernetCsmacd.VALUE)) {
mpBldr.setSupportingEthernet(interfaces.getInterfaceName());
}
}
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG,
- nodeId, openRoadmInterface.get().getName(), openRoadmInterface.get().getType());
InterfaceType interfaceType = openRoadmInterface.get().getType();
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
// Check if interface type is OMS or OTS
+ // Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
mpBldr.setSupportingOms(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OpticalTransport.VALUE)) {
+ } else if (interfaceType.equals(OpticalTransport.VALUE)) {
mpBldr.setSupportingOts(interfaces.getInterfaceName());
- }
- String interfaceName = interfaces.getInterfaceName();
- if (interfaceType.equals(OtnOtu.VALUE)
- && (interfaceName.substring(interfaceName.lastIndexOf("-") + 1)
- .equals("OTU4"))) {
- mpBldr.setSupportingOtu4(interfaces.getInterfaceName());
- }
- if ((interfaceType.equals(OtnOtu.VALUE))
- && (interfaceName.substring(interfaceName.lastIndexOf("-") + 1)
- .contains("OTUC"))) {
- mpBldr.setSupportingOtucn(interfaces.getInterfaceName());
- }
- if (interfaceType.equals(OtnOdu.VALUE)
- && (interfaceName.substring(interfaceName.lastIndexOf("-") + 1)
- .equals("ODU4"))) {
- mpBldr.setSupportingOdu4(interfaces.getInterfaceName());
- }
- if ((interfaceType.equals(OtnOdu.VALUE))
- && (interfaceName.substring(interfaceName.lastIndexOf("-") + 1)
- .contains("ODUC"))) {
- mpBldr.setSupportingOducn(interfaces.getInterfaceName());
+ //TODO check if the following lines for Eth CSMACD present in 1.2.1 and 2.2.1 were not forgotten in 7.1
+ //} else if(interfaceType.equals(EthernetCsmacd.VALUE)) {
+ // mpBldr.setSupportingEthernet(interfaces.getInterfaceName());
+ } else if (interfaceType.equals(OtnOtu.VALUE)) {
+ String interfaceName = interfaces.getInterfaceName();
+ String suffix = interfaceName.substring(interfaceName.lastIndexOf("-") + 1);
+ if (suffix.equals("OTU4")) {
+ mpBldr.setSupportingOtu4(interfaces.getInterfaceName());
+ } else if (suffix.contains("OTUC")) {
+ mpBldr.setSupportingOtucn(interfaces.getInterfaceName());
+ }
+ } else if (interfaceType.equals(OtnOdu.VALUE)) {
+ String interfaceName = interfaces.getInterfaceName();
+ String suffix = interfaceName.substring(interfaceName.lastIndexOf("-") + 1);
+ if (suffix.equals("ODU4")) {
+ mpBldr.setSupportingOdu4(interfaces.getInterfaceName());
+ } else if (suffix.contains("ODUC")) {
+ mpBldr.setSupportingOducn(interfaces.getInterfaceName());
+ }
}
}
return mpBldr;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mc.capabilities.McCapabilities;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmLinkType;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
-//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
LOG.error("readMdSal: Error reading topology {}", nwInstanceIdentifier);
networkTransactionService.close();
returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
-// throw new RuntimeException(
-// "readMdSal: Error reading from operational store, topology : " + nwInstanceIdentifier + " :" + e);
}
return nw;
}
.build()));
if (serviceFormat.equals(ServiceFormat.ODU)) {
serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
- }
- if (serviceFormat.equals(ServiceFormat.OTU)) {
+ } else if (serviceFormat.equals(ServiceFormat.OTU)) {
serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
}
if (!serviceLayer.equals(LayerProtocolName.ETH)) {
}
return openroadmNodeTypeList.get(0);
}
-}
\ No newline at end of file
+}