package org.opendaylight.transportpce.renderer;
import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.opendaylight.transportpce.common.fixedflex.GridConstant;
import org.opendaylight.transportpce.common.fixedflex.GridUtils;
import org.opendaylight.transportpce.common.mapping.PortMappingUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.Action;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.OtnServicePathInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.OtnServicePathInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.ServicePathInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.ServicePathInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.otn.service.path.input.AEndApiInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.otn.service.path.input.AEndApiInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.otn.service.path.input.ZEndApiInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.otn.service.path.input.ZEndApiInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.Action;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.Resource;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Link;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.optical.renderer.nodes.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.optical.renderer.nodes.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.optical.renderer.nodes.NodesKey;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.common.Uint32;
olmSetupBldr.setWaveNumber(atoZDirection.getAToZWavelengthNumber());
if (atoZDirection.getAToZMinFrequency() != null) {
olmSetupBldr.setLowerSpectralSlotNumber(Uint32
- .valueOf(GridUtils
- .getLowerSpectralIndexFromFrequency(atoZDirection.getAToZMinFrequency().getValue())));
+ .valueOf(GridUtils
+ .getLowerSpectralIndexFromFrequency(atoZDirection.getAToZMinFrequency().getValue())));
}
if (atoZDirection.getAToZMaxFrequency() != null) {
olmSetupBldr.setHigherSpectralSlotNumber(Uint32
- .valueOf(GridUtils
- .getHigherSpectralIndexFromFrequency(atoZDirection.getAToZMaxFrequency().getValue())));
+ .valueOf(GridUtils
+ .getHigherSpectralIndexFromFrequency(atoZDirection.getAToZMaxFrequency().getValue())));
}
+ // Set the MC-width for the OLM
+ olmSetupBldr.setMcWidth(new FrequencyGHz(atoZDirection.getAToZMaxFrequency().getValue()
+ .subtract(atoZDirection.getAToZMinFrequency().getValue()).multiply(new BigDecimal(1000))));
}
return olmSetupBldr.build();
}
.setServiceName(serviceName)
.setOperation(operation)
.setNodes(nodeLists.getRendererNodeList())
- .setWidth(new FrequencyGHz(GridConstant.WIDTH_40));
+ .setNmcWidth(new FrequencyGHz(GridConstant.WIDTH_40))
+ .setMcWidth(new FrequencyGHz(pathDescription.getAToZDirection().getAToZMaxFrequency().getValue()
+ .subtract(pathDescription.getAToZDirection().getAToZMinFrequency().getValue())));
if (atoZDirection.getAToZWavelengthNumber() != null) {
servicePathInputBuilder
.setWaveNumber(atoZDirection.getAToZWavelengthNumber());
&& GridConstant.FREQUENCY_WIDTH_TABLE
.contains(atoZDirection.getRate(), optionalModulationFormat.get())) {
servicePathInputBuilder
- .setWidth(FrequencyGHz
+ .setNmcWidth(FrequencyGHz
.getDefaultInstance(GridConstant.FREQUENCY_WIDTH_TABLE.get(atoZDirection.getRate(),
optionalModulationFormat.get())));
}
}
- servicePathInputBuilder.setModulationFormat(atoZDirection.getModulationFormat());
+ servicePathInputBuilder.setModulationFormat(atoZDirection.getModulationFormat())
+ .setAEndApiInfo(createAendApiInfo(pathDescription, false))
+ .setZEndApiInfo(createZendApiInfo(pathDescription, false));
return new ServicePathInputData(servicePathInputBuilder.build(), nodeLists);
}
.setOperation(operation)
.setServiceName(serviceName)
.setNodes(nodeLists.getRendererNodeList())
- .setWidth(new FrequencyGHz(GridConstant.WIDTH_40));
+ .setNmcWidth(new FrequencyGHz(GridConstant.WIDTH_40))
+ .setMcWidth(new FrequencyGHz(pathDescription.getAToZDirection().getAToZMaxFrequency().getValue()
+ .subtract(pathDescription.getAToZDirection().getAToZMinFrequency().getValue())));
if (ztoADirection.getZToAWavelengthNumber() != null) {
servicePathInputBuilder
.setWaveNumber(ztoADirection.getZToAWavelengthNumber());
if (optionalModulationFormat.isPresent()
&& GridConstant.FREQUENCY_WIDTH_TABLE
.contains(ztoADirection.getRate(), optionalModulationFormat.get())) {
- servicePathInputBuilder.setWidth(FrequencyGHz
+ servicePathInputBuilder.setNmcWidth(FrequencyGHz
.getDefaultInstance(GridConstant.FREQUENCY_WIDTH_TABLE.get(ztoADirection.getRate(),
optionalModulationFormat.get())));
}
}
- servicePathInputBuilder.setModulationFormat(ztoADirection.getModulationFormat());
+ servicePathInputBuilder.setModulationFormat(ztoADirection.getModulationFormat())
+ .setAEndApiInfo(createAendApiInfo(pathDescription, false))
+ .setZEndApiInfo(createZendApiInfo(pathDescription, false));
return new ServicePathInputData(servicePathInputBuilder.build(), nodeLists);
}
public static OtnServicePathInput rendererCreateOtnServiceInput(String serviceName, Action operation,
String serviceFormat, Uint32 serviceRate, PathDescription pathDescription, boolean asideToZside) {
// If atoZ is set true use A-to-Z direction otherwise use Z-to-A
- List<org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.otn.renderer.nodes.Nodes> nodes =
+ List<org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.otn.renderer.nodes.Nodes> nodes =
new ArrayList<>();
NodeLists nodeLists =
(asideToZside)
: getNodesListZtoA(pathDescription.getZToADirection().nonnullZToA().values().iterator());
LOG.info("These are node-lists {}, {}", nodeLists.getRendererNodeList(), nodeLists.getOlmNodeList());
for (Nodes node: nodeLists.getRendererNodeList()) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.otn.renderer.nodes.NodesBuilder nb
- = new org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.otn.renderer.nodes
+ org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.otn.renderer.nodes.NodesBuilder nb
+ = new org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.otn.renderer.nodes
.NodesBuilder().setNodeId(node.getNodeId()).setNetworkTp(node.getDestTp());
if (node.getSrcTp() != null && node.getSrcTp().contains("NETWORK")) {
nb.setNetwork2Tp(node.getSrcTp());
.setServiceFormat(serviceFormat)
.setServiceRate(serviceRate)
.setNodes(nodes)
- .setAEndApiInfo(createAendApiInfo(pathDescription))
- .setZEndApiInfo(createZendApiInfo(pathDescription));
+ .setAEndApiInfo(createAendApiInfo(pathDescription, true))
+ .setZEndApiInfo(createZendApiInfo(pathDescription, true));
// set the trib-slots and trib-ports for the lower oder odu
if (serviceRate.intValue() == 1 || (serviceRate.intValue() == 10)) {
}
}
- private static AEndApiInfo createAendApiInfo(PathDescription pathDescription) {
- String anodeId = extractAendFromPathDescription(pathDescription).get("nodeId");
- String sapi = PortMappingUtils.fnv1size64(
- String.join("-", anodeId, extractAendFromPathDescription(pathDescription).get("tpid")));
- String dapi = PortMappingUtils.fnv1size64(
- String.join("-", extractZendFromPathDescription(pathDescription).get("nodeId"),
- extractZendFromPathDescription(pathDescription).get("tpid")));
+ private static AEndApiInfo createAendApiInfo(PathDescription pathDescription, boolean isForOtn) {
+ String anodeId = null;
+ String sapi = null;
+ String dapi = null;
+ if (isForOtn) {
+ anodeId = extractAendFromPathDescriptionForOtn(pathDescription).get("nodeId");
+ sapi = PortMappingUtils.fnv1size64(
+ String.join("-", anodeId, extractAendFromPathDescriptionForOtn(pathDescription).get("tpid")));
+ dapi = PortMappingUtils.fnv1size64(
+ String.join("-", extractZendFromPathDescriptionForOtn(pathDescription).get("nodeId"),
+ extractZendFromPathDescriptionForOtn(pathDescription).get("tpid")));
+ } else {
+ anodeId = extractAendFromPathDescriptionForOptical(pathDescription).get("nodeId");
+ sapi = PortMappingUtils.fnv1size64(
+ String.join("-", anodeId, extractAendFromPathDescriptionForOptical(pathDescription).get("tpid")));
+ dapi = PortMappingUtils.fnv1size64(
+ String.join("-", extractZendFromPathDescriptionForOptical(pathDescription).get("nodeId"),
+ extractZendFromPathDescriptionForOptical(pathDescription).get("tpid")));
+ }
return new AEndApiInfoBuilder()
.setSapi(sapi)
.setExpectedDapi(sapi)
.build();
}
- private static ZEndApiInfo createZendApiInfo(PathDescription pathDescription) {
- String znodeId = extractZendFromPathDescription(pathDescription).get("nodeId");
- String sapi = PortMappingUtils.fnv1size64(
- String.join("-", znodeId, extractZendFromPathDescription(pathDescription).get("tpid")));
- String dapi = PortMappingUtils.fnv1size64(
- String.join("-", extractAendFromPathDescription(pathDescription).get("nodeId"),
- extractAendFromPathDescription(pathDescription).get("tpid")));
+ private static ZEndApiInfo createZendApiInfo(PathDescription pathDescription, boolean isForOtn) {
+ String znodeId = null;
+ String sapi = null;
+ String dapi = null;
+ if (isForOtn) {
+ znodeId = extractZendFromPathDescriptionForOtn(pathDescription).get("nodeId");
+ sapi = PortMappingUtils.fnv1size64(
+ String.join("-", znodeId, extractZendFromPathDescriptionForOtn(pathDescription).get("tpid")));
+ dapi = PortMappingUtils.fnv1size64(
+ String.join("-", extractAendFromPathDescriptionForOtn(pathDescription).get("nodeId"),
+ extractAendFromPathDescriptionForOtn(pathDescription).get("tpid")));
+ } else {
+ znodeId = extractZendFromPathDescriptionForOptical(pathDescription).get("nodeId");
+ sapi = PortMappingUtils.fnv1size64(
+ String.join("-", znodeId, extractZendFromPathDescriptionForOptical(pathDescription).get("tpid")));
+ dapi = PortMappingUtils.fnv1size64(
+ String.join("-", extractAendFromPathDescriptionForOptical(pathDescription).get("nodeId"),
+ extractAendFromPathDescriptionForOptical(pathDescription).get("tpid")));
+ }
return new ZEndApiInfoBuilder()
.setSapi(sapi)
.setExpectedDapi(sapi)
.build();
}
- private static Map<String, String> extractAendFromPathDescription(PathDescription pathDescription) {
+ private static Map<String, String> extractAendFromPathDescriptionForOtn(PathDescription pathDescription) {
List<AToZ> tpList = pathDescription.getAToZDirection().getAToZ().values().stream()
+ .sorted((az1, az2) -> Integer.compare(Integer.parseInt(az1.getId()), Integer.parseInt(az2.getId())))
.filter(az -> TERMINATION_POINT.equals(az.getResource().getResource().implementedInterface()
.getSimpleName()))
.collect(Collectors.toList());
return Map.of("nodeId", nodeId, "tpid", lcp);
}
}
- return null;
+ return Map.of();
}
- private static Map<String, String> extractZendFromPathDescription(PathDescription pathDescription) {
+ private static Map<String, String> extractZendFromPathDescriptionForOtn(PathDescription pathDescription) {
List<ZToA> tpList = pathDescription.getZToADirection().getZToA().values().stream()
+ .sorted((az1, az2) -> Integer.compare(Integer.parseInt(az1.getId()), Integer.parseInt(az2.getId())))
.filter(az -> TERMINATION_POINT.equals(az.getResource().getResource().implementedInterface()
.getSimpleName()))
.collect(Collectors.toList());
return Map.of("nodeId", nodeId, "tpid", lcp);
}
}
- return null;
+ return Map.of();
}
+ private static Map<String, String> extractAendFromPathDescriptionForOptical(PathDescription pathDescription) {
+ List<AToZ> tpList = pathDescription.getAToZDirection().getAToZ().values().stream()
+ .sorted((az1, az2) -> Integer.compare(Integer.parseInt(az1.getId()), Integer.parseInt(az2.getId())))
+ .filter(az -> TERMINATION_POINT.equals(az.getResource().getResource().implementedInterface()
+ .getSimpleName()))
+ .collect(Collectors.toList());
+ for (AToZ atoZ : tpList) {
+ TerminationPoint tp = (TerminationPoint) atoZ.getResource().getResource();
+ if (!tp.getTpId().contains("CLIENT") && !tp.getTpId().isEmpty() && !tp.getTpNodeId().isEmpty()) {
+// String nodeId = tp.getTpNodeId();
+// String lcp = tp.getTpId();
+ return Map.of("nodeId", tp.getTpNodeId(), "tpid", tp.getTpId());
+ }
+ }
+ return Map.of();
+ }
+
+ private static Map<String, String> extractZendFromPathDescriptionForOptical(PathDescription pathDescription) {
+ List<ZToA> tpList = pathDescription.getZToADirection().getZToA().values().stream()
+ .sorted((az1, az2) -> Integer.compare(Integer.parseInt(az1.getId()), Integer.parseInt(az2.getId())))
+ .filter(az -> TERMINATION_POINT.equals(az.getResource().getResource().implementedInterface()
+ .getSimpleName()))
+ .collect(Collectors.toList());
+ for (ZToA ztoA : tpList) {
+ TerminationPoint tp = (TerminationPoint) ztoA.getResource().getResource();
+ if (!tp.getTpId().contains("CLIENT") && !tp.getTpId().isEmpty() && !tp.getTpNodeId().isEmpty()) {
+// String nodeId = tp.getTpNodeId();
+// String lcp = tp.getTpId();
+ return Map.of("nodeId", tp.getTpNodeId(), "tpid", tp.getTpId());
+ }
+ }
+ return Map.of();
+ }
}