package org.opendaylight.transportpce.renderer.provisiondevice;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterface;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.otn.renderer.input.Nodes;
-import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
+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.OtnServicePathOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.OtnServicePathOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.node.interfaces.NodeInterface;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.node.interfaces.NodeInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.node.interfaces.NodeInterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.otn.renderer.nodes.Nodes;
+import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public OtnServicePathOutput setupOtnServicePath(OtnServicePathInput input) {
- LOG.info("Calling setup service path");
+ LOG.info("Calling setup otn-service path");
boolean success = true;
List<NodeInterface> nodeInterfaces = new ArrayList<>();
List<String> results = new ArrayList<>();
- if (input.getServiceType() == null || input.getServiceRate() == null) {
+ if (input.getServiceFormat() == null || input.getServiceRate() == null) {
OtnServicePathOutputBuilder otnServicePathOutputBuilder = new OtnServicePathOutputBuilder()
.setSuccess(false)
.setResult("Error - service-type and service-rate must be presents");
return otnServicePathOutputBuilder.build();
}
CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
- switch (input.getServiceType()) {
+ switch (input.getServiceFormat()) {
case "Ethernet":
- if ("10G".equals(input.getServiceRate()) || "1G".equals(input.getServiceRate())) {
+ if (input.getServiceRate().intValue() == 1 || input.getServiceRate().intValue() == 10) {
try {
LOG.info("Calling Node interfaces {} {} {} {} {} {} {}",
input.getServiceRate(), input.getEthernetEncoding(),
- input.getServiceType(), input.getOperation(), input.getTribPortNumber(),
+ input.getServiceFormat(), input.getOperation(), input.getTribPortNumber(),
input.getTribSlot(), input.getNodes());
nodeInterfaces = createInterface(input);
LOG.info("Node interfaces created just fine ");
- List<String> nodesToUpdate = new ArrayList<>();
- if (!nodeInterfaces.isEmpty()) {
- for (NodeInterface nodeInterf : nodeInterfaces) {
- if (nodeInterf.getOduInterfaceId() != null) {
- List<String> interList = nodeInterf.getOduInterfaceId().stream()
- .filter(id -> id.contains("NETWORK")).collect(Collectors.toList());
- if (!interList.isEmpty()) {
- for (String inter : interList) {
- String tp = inter.split("-ODU")[0];
- String nodeTopo = nodeInterf.getNodeId() + "-" + tp.split("-")[0];
- nodesToUpdate.add(nodeTopo + "--" + tp);
- }
- }
- }
- }
- }
+ List<String> nodesToUpdate = updateOduNodes(nodeInterfaces, "ODU");
updateOtnTopology(null, nodesToUpdate, input.getServiceRate(), input.getTribPortNumber(),
input.getTribSlot(), false);
} catch (OpenRoadmInterfaceException e) {
LOG.warn("Set up service path failed", e);
success = false;
}
+ } else if (input.getServiceRate().intValue() == 100) {
+ try {
+ LOG.info("Calling Node interfaces {} {} {} {} {} {}",
+ input.getServiceRate(), input.getEthernetEncoding(),
+ input.getServiceFormat(), input.getOperation(), input.getOpucnTribSlots(),
+ input.getNodes());
+ nodeInterfaces = createInterface(input);
+ LOG.info("Node interfaces created just fine for 100G OTN ");
+ // TODO: Update the OTN topology accordingly with Opucn-Trib-slots
+ // List<String> nodesToUpdate = updateOduNodes(nodeInterfaces, "ODUC4");
+ // updateOtnTopology(null, nodesToUpdate, input.getServiceRate(), input.getTribPortNumber(),
+ // input.getTribSlot(), false);
+ } catch (OpenRoadmInterfaceException e) {
+ LOG.warn("Set up service path failed", e);
+ success = false;
+ }
} else {
LOG.warn("Unsupported service-rate for service-type Ethernet");
}
break;
case "ODU":
- if ("100G".equals(input.getServiceRate())) {
+ if (input.getServiceRate().intValue() == 100) {
try {
createODU4TtpInterface(input, nodeInterfaces, otnNodesProvisioned);
updateOtnTopology(otnNodesProvisioned, null, null, null, null, false);
LOG.warn("Set up service path failed", e);
success = false;
}
+ } else if (input.getServiceRate().intValue() == 400) {
+ try {
+ createOduc4TtpInterface(input, nodeInterfaces, otnNodesProvisioned);
+ updateOtnTopology(otnNodesProvisioned, null, null, null, null, false);
+ } catch (OpenRoadmInterfaceException e) {
+ LOG.warn("Set up service path failed", e);
+ success = false;
+ }
} else {
LOG.warn("Unsupported service-rate for service-type ODU");
}
break;
default:
- LOG.error("service-type {} not managed yet", input.getServiceType());
+ LOG.error("service-type {} not managed yet", input.getServiceFormat());
break;
}
if (success) {
results.add("Otn Service path was set up successfully for node :" + nodeInterface.getNodeId());
}
}
+ Map<NodeInterfaceKey,NodeInterface> nodeInterfacesMap = new HashMap<>();
+ for (NodeInterface nodeInterface : nodeInterfaces) {
+ if (nodeInterface != null) {
+ nodeInterfacesMap.put(nodeInterface.key(), nodeInterface);
+ }
+ }
OtnServicePathOutputBuilder otnServicePathOutputBuilder = new OtnServicePathOutputBuilder()
.setSuccess(success)
- .setNodeInterface(nodeInterfaces)
+ .setNodeInterface(nodeInterfacesMap)
.setResult(String.join("\n", results));
return otnServicePathOutputBuilder.build();
}
public OtnServicePathOutput deleteOtnServicePath(OtnServicePathInput input) {
+ if (input == null) {
+ LOG.error("Unable to delete otn service path. input = null");
+ return new OtnServicePathOutputBuilder().setResult("Unable to delete otn service path. input = null")
+ .setSuccess(false).build();
+ }
List<Nodes> nodes = input.getNodes();
AtomicBoolean success = new AtomicBoolean(true);
ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
String nodeId = node.getNodeId();
LOG.info("Deleting service setup on node {}", nodeId);
String networkTp = node.getNetworkTp();
- if (networkTp == null || input.getServiceRate() == null || input.getServiceType() == null) {
- LOG.error("destination ({}) or service rate ({}) or service type ({}) is null.", networkTp,
- input.getServiceRate(), input.getServiceType());
+ if (networkTp == null || input.getServiceRate() == null || input.getServiceFormat() == null) {
+ LOG.error("destination ({}) or service-rate ({}) or service-format ({}) is null.", networkTp,
+ input.getServiceRate(), input.getServiceFormat());
return;
}
// if the node is currently mounted then proceed.
if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
String connectionNumber = "";
- switch (input.getServiceRate()) {
- case ("100G"):
- if ("ODU".equals(input.getServiceType())) {
+ switch (input.getServiceRate().intValue()) {
+ case 100:
+ if ("ODU".equals(input.getServiceFormat())) {
interfacesToDelete.add(networkTp + "-ODU4");
otnNodesProvisioned.add(node);
if (node.getNetwork2Tp() != null) {
interfacesToDelete.add(node.getNetwork2Tp() + "-ODU4");
}
+ } else if ("Ethernet".equals(input.getServiceFormat())) {
+ connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU4");
+ }
+ break;
+ case 400:
+ if ("ODU".equals(input.getServiceFormat())) {
+ interfacesToDelete.add(networkTp + "-ODUC4");
+ otnNodesProvisioned.add(node);
+ if (node.getNetwork2Tp() != null) {
+ interfacesToDelete.add(node.getNetwork2Tp() + "-ODUC4");
+ }
}
break;
- case ("10G"):
+ case 10:
connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU2e");
break;
- case ("1G"):
+ case 1:
connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU0");
break;
default:
for (String interf : intToDelete) {
if (!this.openRoadmInterfaceFactory.isUsedByOtnXc(nodeId, interf, connectionNumber,
this.deviceTransactionManager)) {
+
interfacesToDelete.add(interf);
- if (!getSupportedInterface(nodeId, interf).contains("ODU4")) {
- interfacesToDelete.add(getSupportedInterface(nodeId, interf));
+ String supportedInterface = this.openRoadmInterfaces.getSupportedInterface(nodeId, interf);
+ if (input.getServiceRate().intValue() == 100) {
+ if (!supportedInterface.contains("ODUC4")) {
+ interfacesToDelete.add(supportedInterface);
+ }
+ } else {
+ if (!supportedInterface.contains("ODU4")) {
+ interfacesToDelete.add(supportedInterface);
+ }
}
}
}
}
forkJoinPool.shutdown();
LOG.info("requesting otn-topology update...");
- if (!nodesTpToUpdate.isEmpty() && !"ODU".equals(input.getServiceType())) {
+ if (!nodesTpToUpdate.isEmpty() && !"ODU".equals(input.getServiceFormat())) {
updateOtnTopology(null, nodesTpToUpdate, input.getServiceRate(), input.getTribPortNumber(),
input.getTribSlot(), true);
} else if (!otnNodesProvisioned.isEmpty()) {
}
}
- private String getSupportedInterface(String nodeId, String interf) {
- Optional<Interface> supInterfOpt;
- try {
- supInterfOpt = this.openRoadmInterfaces.getInterface(nodeId, interf);
- if (supInterfOpt.isPresent()) {
- return supInterfOpt.get().getSupportingInterface();
- } else {
- return null;
+ private List<String> updateOduNodes(List<NodeInterface> nodeInterfaceList, String deLimiter) {
+ List<String> nodesToUpdate = new ArrayList<>();
+ if (!(deLimiter.equals("ODU")) || !(deLimiter.equals("ODUC4"))) {
+ LOG.error("ODU node list update will be incorrect");
+ }
+
+ if (!nodeInterfaceList.isEmpty()) {
+ for (NodeInterface nodeInterf : nodeInterfaceList) {
+ if (nodeInterf.getOduInterfaceId() != null) {
+ List<String> interList = nodeInterf.getOduInterfaceId().stream()
+ .filter(id -> id.contains("NETWORK")).collect(Collectors.toList());
+ if (!interList.isEmpty()) {
+ for (String inter : interList) {
+ String tp = inter.split("-" + deLimiter)[0];
+ String nodeTopo = nodeInterf.getNodeId() + "-" + tp.split("-")[0];
+ nodesToUpdate.add(nodeTopo + "--" + tp);
+ }
+ }
+ }
}
- } catch (OpenRoadmInterfaceException e) {
- LOG.error("error getting Supported Interface of {} - {}", interf, nodeId, e);
- return null;
}
+
+ return nodesToUpdate;
}
private List<NodeInterface> createInterface(OtnServicePathInput input) throws OpenRoadmInterfaceException {
List<NodeInterface> nodeInterfaces = new ArrayList<>();
LOG.info("Calling Create Interface entry for OTN service path");
if (input.getServiceRate() == null
- || !("1G".equals(input.getServiceRate()) || "10G".equals(input.getServiceRate()))) {
+ || !(input.getServiceRate().intValue() == 1 || input.getServiceRate().intValue() == 10
+ || input.getServiceRate().intValue() == 100)) {
LOG.error("Service rate {} not managed yet", input.getServiceRate());
} else {
createLowOrderInterfaces(input, nodeInterfaces);
// check if the node is mounted or not?
List<String> createdEthInterfaces = new ArrayList<>();
List<String> createdOduInterfaces = new ArrayList<>();
- switch (input.getServiceRate()) {
- case ("1G"):
+ switch (input.getServiceRate().intValue()) {
+ case 1:
LOG.info("Input service is 1G");
if (node.getClientTp() != null) {
createdEthInterfaces.add(
input.getTribSlot()));
}
break;
- case ("10G"):
+ case 10:
LOG.info("Input service is 10G");
if (node.getClientTp() != null) {
createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth10GInterface(
input.getTribSlot()));
}
break;
+ case 100:
+ LOG.info("Input service is 100G");
+ // Take the first and last value in the list of OpucnTribSlot (assuming SH would provide
+ // min and max value only, size two)
+ OpucnTribSlotDef minOpucnTs = OpucnTribSlotDef.getDefaultInstance(
+ input.getOpucnTribSlots().get(0).getValue());
+ OpucnTribSlotDef maxOpucnTs = OpucnTribSlotDef.getDefaultInstance(
+ input.getOpucnTribSlots().get(1).getValue());
+ if (node.getClientTp() != null) {
+ createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth100GInterface(
+ node.getNodeId(), node.getClientTp()));
+ // OPUCn trib information is optional when creating ODU4 ethernet (client) interface
+ createdOduInterfaces.add(
+ openRoadmInterfaceFactory.createOpenRoadmOtnOdu4LoInterface(node.getNodeId(),
+ node.getClientTp(), input.getServiceName(), PT_07, false, minOpucnTs,
+ maxOpucnTs));
+ }
+ // Here payload-type is optional and is not used for interface creation (especially for network)
+ createdOduInterfaces.add(
+ openRoadmInterfaceFactory.createOpenRoadmOtnOdu4LoInterface(node.getNodeId(),
+ node.getNetworkTp(), input.getServiceName(), PT_07, true, minOpucnTs,
+ maxOpucnTs));
+ // Here payload-type is optional and is not used for service creation
+ // This is needed if there is an intermediate node
+ if (node.getNetwork2Tp() != null) {
+ createdOduInterfaces.add(
+ openRoadmInterfaceFactory.createOpenRoadmOtnOdu4LoInterface(node.getNodeId(),
+ node.getNetwork2Tp(), input.getServiceName(), PT_07, true, minOpucnTs,
+ maxOpucnTs));
+ }
+ break;
default:
LOG.error("service rate {} not managed yet", input.getServiceRate());
return;
}
}
+ private void createOduc4TtpInterface(OtnServicePathInput input, List<NodeInterface> nodeInterfaces,
+ CopyOnWriteArrayList<Nodes> otnNodesProvisioned) throws OpenRoadmInterfaceException {
+ if (input.getNodes() == null) {
+ return;
+ }
+ LOG.info("Creation of ODUC4 TTP interface in OTN service path {}", input);
+ for (int i = 0; i < input.getNodes().size(); i++) {
+ Nodes node = input.getNodes().get(i);
+ String supportingOtuInterface = node.getNetworkTp() + "-OTUC4";
+ List<String> createdOduc4Interfaces = new ArrayList<>();
+ // Adding SAPI/DAPI information to the
+ Nodes tgtNode = null;
+ if (i + 1 == input.getNodes().size()) {
+ // For the end node, tgtNode becomes the first node in the list
+ tgtNode = input.getNodes().get(0);
+ } else {
+ tgtNode = input.getNodes().get(i + 1);
+ }
+ createdOduc4Interfaces.add(openRoadmInterfaceFactory.createOpenRoadmOtnOduc4Interface(node.getNodeId(),
+ node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp()));
+
+ NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setOduInterfaceId(createdOduc4Interfaces); // though this is odu, actually it has ODUC4 interfaces
+ nodeInterfaces.add(nodeInterfaceBuilder.build());
+ otnNodesProvisioned.add(node);
+ }
+ }
+
private void createODU4TtpInterface(OtnServicePathInput input, List<NodeInterface> nodeInterfaces,
CopyOnWriteArrayList<Nodes> otnNodesProvisioned) throws OpenRoadmInterfaceException {
- for (Nodes node : input.getNodes()) {
+ if (input.getNodes() == null) {
+ return;
+ }
+ LOG.info("Creation of ODU4 tp interface {}", input);
+ for (int i = 0; i < input.getNodes().size(); i++) {
+ Nodes node = input.getNodes().get(i);
String supportingOtuInterface = node.getNetworkTp() + "-OTU";
List<String> createdOdu4Interfaces = new ArrayList<>();
+ // Adding SAPI/DAPI information to the
+ Nodes tgtNode = null;
+ if (i + 1 == input.getNodes().size()) {
+ // For the end node, tgtNode becomes the first node in the list
+ tgtNode = input.getNodes().get(0);
+ } else {
+ tgtNode = input.getNodes().get(i + 1);
+ }
createdOdu4Interfaces.add(openRoadmInterfaceFactory.createOpenRoadmOtnOdu4Interface(node.getNodeId(),
- node.getNetworkTp(), supportingOtuInterface));
+ node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp()));
NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
.withKey(new NodeInterfaceKey(node.getNodeId()))
.setNodeId(node.getNodeId())
}
}
- private void updateOtnTopology(CopyOnWriteArrayList<Nodes> nodes, List<String> nodesTps, String serviceRate,
+ private void updateOtnTopology(CopyOnWriteArrayList<Nodes> nodes, List<String> nodesTps, Uint32 serviceRate,
Short tribPortNb, Short tribSlotNb, boolean isDeletion) {
if (nodes != null && nodes.size() == 2) {
if (isDeletion) {