package org.opendaylight.transportpce.renderer.provisiondevice;
import java.util.ArrayList;
+import java.util.Arrays;
+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 java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.atomic.AtomicBoolean;
-
+import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
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.transportpce.common.types.rev200128.node.interfaces.NodeInterface;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200128.node.interfaces.NodeInterfaceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200128.node.interfaces.NodeInterfaceKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200128.otn.renderer.input.Nodes;
+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.OtnServicePathOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutputBuilder;
+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.ZEndApiInfo;
+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.rev210930.link.tp.LinkTp;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.link.tp.LinkTpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.node.interfaces.NodeInterface;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.node.interfaces.NodeInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.node.interfaces.NodeInterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.otn.renderer.nodes.Nodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class OtnDeviceRendererServiceImpl implements OtnDeviceRendererService {
private static final Logger LOG = LoggerFactory.getLogger(OtnDeviceRendererServiceImpl.class);
+ private static final String PT_03 = "03";
+ private static final String PT_07 = "07";
private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
private final CrossConnect crossConnect;
private final OpenRoadmInterfaces openRoadmInterfaces;
private final DeviceTransactionManager deviceTransactionManager;
-
+ private final NetworkModelService networkModelService;
public OtnDeviceRendererServiceImpl(OpenRoadmInterfaceFactory openRoadmInterfaceFactory, CrossConnect crossConnect,
OpenRoadmInterfaces openRoadmInterfaces,
- DeviceTransactionManager deviceTransactionManager) {
+ DeviceTransactionManager deviceTransactionManager,
+ NetworkModelService networkModelService) {
this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
this.crossConnect = crossConnect;
this.openRoadmInterfaces = openRoadmInterfaces;
this.deviceTransactionManager = deviceTransactionManager;
+ this.networkModelService = networkModelService;
}
+//TODO Align log messages and returned results messages
@Override
- public OtnServicePathOutput setupOtnServicePath(OtnServicePathInput input) {
- LOG.info("Calling setup service path");
- boolean success = true;
+ public OtnServicePathOutput setupOtnServicePath(OtnServicePathInput input, String serviceType) {
+ LOG.info("Calling setup otn-service path");
+ if (input.getServiceFormat() == null || input.getServiceRate() == null) {
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(false)
+ .setResult("Error - service-type and service-rate must be present")
+ .build();
+ }
List<NodeInterface> nodeInterfaces = new ArrayList<>();
- List<String> results = new ArrayList<>();
- if (input.getServiceType().equals("Ethernet")) {
- try {
- LOG.info("Calling Node interfaces {} {} {} {} {} {} {}",
- input.getServiceRate(),input.getEthernetEncoding(),
- input.getServiceType(),input.getOperation(),input.getTribPortNumber(),
- input.getTribSlot(),input.getNodes());
- nodeInterfaces = createInterface(input);
- LOG.info("Node interfaces created just fine ");
+ CopyOnWriteArrayList<LinkTp> otnLinkTps = new CopyOnWriteArrayList<>();
+ try {
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_1GE:
+ case StringConstants.SERVICE_TYPE_10GE:
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ LOG.info("Calling Node interfaces {} {} {} {} {} {} {}",
+ input.getServiceRate(), input.getEthernetEncoding(),
+ input.getServiceFormat(), input.getOperation(), input.getTribPortNumber(),
+ input.getTribSlot(), input.getNodes());
+ if (input.getNodes() != null) {
+ createLowOrderInterfaces(input, nodeInterfaces, otnLinkTps);
+ LOG.info("Node interfaces created just fine ");
+ }
+ break;
+ case StringConstants.SERVICE_TYPE_ODU4:
+ createHighOrderInterfaces(input, nodeInterfaces, otnLinkTps);
+ break;
+ // For all the intermediate rates, device renderer is generalized as
+ // ODUCnTTPinterface method
+ case StringConstants.SERVICE_TYPE_ODUC2:
+ case StringConstants.SERVICE_TYPE_ODUC3:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ createOducnTtpInterface(input, nodeInterfaces, otnLinkTps);
+ break;
+ case StringConstants.SERVICE_TYPE_100GE_S:
+ LOG.info("Calling Node interface for service-type {}", serviceType);
+ if (input.getNodes() != null) {
+ createHighOrderInterfaces(input, nodeInterfaces, otnLinkTps);
+ LOG.info("Node interfaces created");
+ }
+ break;
+ default:
+ LOG.error("Service-type {} not managed yet", serviceType);
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(false)
+ .setResult("Service-type not managed")
+ .build();
}
- catch (OpenRoadmInterfaceException e) {
- //handle exception
- LOG.warn("Set up service path failed {}", e.toString());
- success = false;
+ } catch (OpenRoadmInterfaceException e) {
+ LOG.warn("Service path set-up failed", e);
+ Map<NodeInterfaceKey,NodeInterface> nodeInterfacesMap = new HashMap<>();
+ for (NodeInterface nodeInterface : nodeInterfaces) {
+ if (nodeInterface != null) {
+ nodeInterfacesMap.put(nodeInterface.key(), nodeInterface);
+ }
}
-
+ //TODO check if we need to set a NodeInterface Map in the result in that case
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(false)
+ .setNodeInterface(nodeInterfacesMap)
+ .setResult("Service path set-up failed")
+ .setLinkTp(otnLinkTps)
+ .build();
}
- if (success) {
- LOG.info("Result is success");
- for (NodeInterface nodeInterface: nodeInterfaces) {
+ LOG.info("Service path set-up succeed");
+ List<String> results = new ArrayList<>();
+ Map<NodeInterfaceKey,NodeInterface> nodeInterfacesMap = new HashMap<>();
+ for (NodeInterface nodeInterface : nodeInterfaces) {
+ if (nodeInterface != null) {
results.add("Otn Service path was set up successfully for node :" + nodeInterface.getNodeId());
+ nodeInterfacesMap.put(nodeInterface.key(), nodeInterface);
}
- //TODO Add otn topology links
}
- OtnServicePathOutputBuilder otnServicePathOutputBuilder = new OtnServicePathOutputBuilder()
- .setSuccess(success)
- .setNodeInterface(nodeInterfaces)
- .setResult(String.join("\n", results));
- return otnServicePathOutputBuilder.build();
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(true)
+ .setNodeInterface(nodeInterfacesMap)
+ .setResult(String.join("\n", results))
+ .setLinkTp(otnLinkTps)
+ .build();
}
- @Override
- public OtnServicePathOutput deleteOtnServicePath(OtnServicePathInput input) {
+ @SuppressWarnings("rawtypes")
+ // FIXME check if the ForkJoinTask raw type can be avoided
+ // Raw types use are discouraged since they lack type safety.
+ // Resulting Problems are observed at run time and not at compile time
+ public OtnServicePathOutput deleteOtnServicePath(OtnServicePathInput input, String serviceType) {
+ if (input.getNodes() == null) {
+ LOG.error("Unable to delete otn service path. input nodes = null");
+ return new OtnServicePathOutputBuilder()
+ .setResult("Unable to delete otn service path. input nodes = null")
+ .setSuccess(false)
+ .build();
+ }
List<Nodes> nodes = input.getNodes();
AtomicBoolean success = new AtomicBoolean(true);
ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
+ CopyOnWriteArrayList<LinkTp> otnLinkTps = new CopyOnWriteArrayList<>();
ForkJoinPool forkJoinPool = new ForkJoinPool();
ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
- List<String> interfacesToDelete = new LinkedList<>();
String nodeId = node.getNodeId();
LOG.info("Deleting service setup on node {}", nodeId);
- String srcTp = node.getClientTp();
- String destTp = node.getNetworkTp();
- if ((srcTp == null) || (destTp == null) || input.getServiceRate() == null) {
- LOG.error("Source ({}) or destination ({}) termination point is null.", srcTp, destTp);
+ String networkTp = node.getNetworkTp();
+ 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)) {
- switch (input.getServiceRate()) {
- case("10G"):
- interfacesToDelete.add(srcTp + "-ODU2e-" + input.getServiceName());
- interfacesToDelete.add(destTp + "-ODU2e-" + input.getServiceName());
- case("1G"):
- interfacesToDelete.add(srcTp + "-ODU0-" + input.getServiceName());
- interfacesToDelete.add(destTp + "-ODU0-" + input.getServiceName());
- }
- String connectionNumber = interfacesToDelete.get(0) + "-x-" + interfacesToDelete.get(1);
- List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber);
- if (intToDelete != null) {
- for (String interf : intToDelete) {
- if (!this.openRoadmInterfaceFactory.isUsedbyXc(nodeId, interf, connectionNumber,
- this.deviceTransactionManager)) {
- interfacesToDelete.add(interf);
- }
- }
- }
- } else {
+ if (!this.deviceTransactionManager.isDeviceMounted(nodeId)) {
String result = nodeId + " is not mounted on the controller";
results.add(result);
success.set(false);
LOG.warn(result);
forkJoinPool.shutdown();
return;
- //TODO should deletion end here?
+ // TODO should deletion end here?
}
+ // if the node is currently mounted then proceed.
+ List<String> interfacesToDelete = new LinkedList<>();
+ String connectionNumber = "";
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_100GE_S:
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
+ break;
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(networkTp)
+ .build());
+ break;
+ case StringConstants.SERVICE_TYPE_ODU4:
+ if (node.getClientTp() == null && node.getNetwork2Tp() == null) {
+ interfacesToDelete.add(networkTp + "-ODU4");
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(networkTp)
+ .build());
+ }
+ if (node.getClientTp() == null && node.getNetwork2Tp() != null) {
+ interfacesToDelete.add(networkTp + "-ODU4");
+ interfacesToDelete.add(node.getNetwork2Tp() + "-ODU4");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
+ }
+ break;
+ case StringConstants.SERVICE_TYPE_ODUC2:
+ case StringConstants.SERVICE_TYPE_ODUC3:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ if (node.getClientTp() == null && node.getNetwork2Tp() == null) {
+ // Service-type can be ODUC2, ODUC3, ODUC4
+ interfacesToDelete.add(networkTp + "-" + serviceType);
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(networkTp)
+ .build());
+ }
+ if (node.getClientTp() == null && node.getNetwork2Tp() != null) {
+ interfacesToDelete.add(networkTp + "-" + serviceType);
+ interfacesToDelete.add(node.getNetwork2Tp() + "-" + serviceType);
+ connectionNumber = getConnectionNumber(node, networkTp, serviceType);
+ }
+ break;
+ case StringConstants.SERVICE_TYPE_10GE:
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU2e");
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(networkTp)
+ .build());
+ break;
+ case StringConstants.SERVICE_TYPE_1GE:
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU0");
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(networkTp)
+ .build());
+ break;
+ default:
+ LOG.error("service-type {} not managed yet", serviceType);
+ String result = serviceType + " is not supported";
+ results.add(result);
+ success.set(false);
+ return;
+ }
+ List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, true);
+ for (String interf : intToDelete == null ? new ArrayList<String>() : intToDelete) {
+ if (!this.openRoadmInterfaceFactory.isUsedByOtnXc(nodeId, interf, connectionNumber,
+ this.deviceTransactionManager)) {
+ interfacesToDelete.add(interf);
+ String supportedInterface = this.openRoadmInterfaces.getSupportedInterface(nodeId, interf);
+ if (supportedInterface == null) {
+ continue;
+ }
+ // Here ODUC can be ODUC2, ODUC3, ODUC4
+ if ((input.getServiceRate().intValue() == 100 && !supportedInterface.contains("ODUC"))
+ || (input.getServiceRate().intValue() != 100 && !supportedInterface.contains("ODU4"))) {
+ interfacesToDelete.add(supportedInterface);
+ }
+ }
+ }
+
for (String interfaceId : interfacesToDelete) {
try {
this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
forkJoinTask.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error while deleting service paths!", e);
+ return new OtnServicePathOutputBuilder()
+ .setResult("Error while deleting service paths!")
+ .setSuccess(false)
+ .build();
}
forkJoinPool.shutdown();
- OtnServicePathOutputBuilder delServBldr = new OtnServicePathOutputBuilder();
- delServBldr.setSuccess(success.get());
- if (results.isEmpty()) {
- return delServBldr.setResult("Request processed").build();
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(success.get())
+ .setLinkTp(otnLinkTps)
+ .setResult(
+ results.isEmpty()
+ ? "Request processed"
+ : String.join("\n", results))
+ .build();
+ }
+
+ private String getConnectionNumber(Nodes node, String networkTp, String oduType) {
+ List<String> list1 = new ArrayList<>();
+ List<String> list2 = new ArrayList<>(Arrays.asList("x"));
+ if (node.getClientTp() != null) {
+ list1.addAll(Arrays.asList(node.getClientTp(), oduType));
+ list2.addAll(Arrays.asList(networkTp, oduType));
+ } else if (node.getNetwork2Tp() != null) {
+ list1.addAll(Arrays.asList(networkTp, oduType));
+ list2.addAll(Arrays.asList(node.getNetwork2Tp(), oduType));
} else {
- return delServBldr.setResult(String.join("\n", results)).build();
+ return "";
}
+ list1.addAll(list2);
+ return String.join("-", list1);
+ }
+ private Optional<String> postCrossConnect(List<String> createdOduInterfaces, Nodes node)
+ throws OpenRoadmInterfaceException {
+ return this.crossConnect.postOtnCrossConnect(createdOduInterfaces, node);
}
- 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().equals("1G")) {
- for (Nodes node: input.getNodes()) {
- LOG.info("Input service is 1G");
- //check if the node is mounted or not?
- List<String> createdConnections = new ArrayList<>();
- List<String> createdEthInterfaces = new ArrayList<>();
- List<String> createdOduInterfaces = new ArrayList<>();
- createdEthInterfaces.add(
- openRoadmInterfaceFactory.createOpenRoadmEth1GInterface(node.getNodeId(), node.getClientTp()));
- LOG.debug("created ethernet interface {}",createdEthInterfaces.get(0));
- createdOduInterfaces.add(
- //suppporting interface?, payload ?
- openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(), node.getClientTp(),
- input.getServiceName(), "07", false, input.getTribPortNumber(), input.getTribSlot()));
- LOG.debug("Created odu interface client side {}",createdOduInterfaces.get(0));
- createdOduInterfaces.add(
- openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(), node.getNetworkTp(),
- input.getServiceName(), "07", true, input.getTribPortNumber(), input.getTribSlot()));
- LOG.debug("created odu inteface network side {} {}",createdOduInterfaces.get(0),createdOduInterfaces.get(1));
-
- //implement cross connect
+ private void createLowOrderInterfaces(OtnServicePathInput input, List<NodeInterface> nodeInterfaces,
+ CopyOnWriteArrayList<LinkTp> linkTpList) throws OpenRoadmInterfaceException {
+ for (Nodes node : input.getNodes()) {
+ AEndApiInfo apiInfoA = null;
+ ZEndApiInfo apiInfoZ = null;
+ if (input.getAEndApiInfo() != null && input.getAEndApiInfo().getNodeId().contains(node.getNodeId())) {
+ apiInfoA = input.getAEndApiInfo();
+ }
+ if (input.getZEndApiInfo() != null && input.getZEndApiInfo().getNodeId().contains(node.getNodeId())) {
+ apiInfoZ = input.getZEndApiInfo();
+ }
+ // check if the node is mounted or not?
+ List<String> createdEthInterfaces = new ArrayList<>();
+ List<String> createdOduInterfaces = new ArrayList<>();
+ switch (input.getServiceRate().intValue()) {
+ case 1:
+ LOG.info("Input service is 1G");
+ if (node.getClientTp() != null) {
+ createdEthInterfaces.add(
+ openRoadmInterfaceFactory.createOpenRoadmEth1GInterface(node.getNodeId(),
+ node.getClientTp()));
+ createdOduInterfaces.add(
+ // suppporting interface?, payload ?
+ openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(), node.getClientTp(),
+ input.getServiceName(), false, input.getTribPortNumber(), input.getTribSlot(), apiInfoA,
+ apiInfoZ, PT_07));
+ }
+ createdOduInterfaces.add(
+ openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(), node.getNetworkTp(),
+ input.getServiceName(), true, input.getTribPortNumber(), input.getTribSlot(), null, null,
+ null));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ if (node.getNetwork2Tp() != null) {
+ createdOduInterfaces.add(
+ // supporting interface? payload ?
+ openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(),
+ node.getNetwork2Tp(), input.getServiceName(), true, input.getTribPortNumber(),
+ input.getTribSlot(), null, null, null));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ }
+ break;
+ case 10:
+ LOG.info("Input service is 10G");
+ if (node.getClientTp() != null) {
+ createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth10GInterface(
+ node.getNodeId(), node.getClientTp()));
+ createdOduInterfaces.add(
+ // suppporting interface?, payload ?
+ openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(),
+ node.getClientTp(), false, input.getTribPortNumber(),
+ input.getTribSlot(), apiInfoA, apiInfoZ, PT_03));
+ }
+ createdOduInterfaces.add(
+ // supporting interface? payload ?
+ openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(), node.getNetworkTp(),
+ true, input.getTribPortNumber(), input.getTribSlot(), null,
+ null, null));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ if (node.getNetwork2Tp() != null) {
+ createdOduInterfaces.add(
+ // supporting interface? payload ?
+ openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(),
+ node.getNetwork2Tp(), true, input.getTribPortNumber(),
+ input.getTribSlot(), null, null, null));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ }
+ 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));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ // 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));
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ }
+ break;
+ default:
+ LOG.error("service rate {} not managed yet", input.getServiceRate());
+ return;
+ }
+
+ // implement cross connect
+ List<String> createdConnections = new ArrayList<>();
+ if (!createdOduInterfaces.isEmpty()) {
Optional<String> connectionNameOpt = postCrossConnect(createdOduInterfaces, node);
createdConnections.add(connectionNameOpt.get());
LOG.info("Created cross connects");
- NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
- .withKey(new NodeInterfaceKey(input.getServiceName() + "-" + node.getNodeId()))
- .setNodeId(input.getServiceName() + "-" + node.getNodeId())
- .setConnectionId(createdConnections)
- .setEthInterfaceId(createdEthInterfaces)
- .setOduInterfaceId(createdOduInterfaces);
- nodeInterfaces.add(nodeInterfaceBuilder.build());
}
+ nodeInterfaces.add(new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setConnectionId(createdConnections)
+ .setEthInterfaceId(createdEthInterfaces)
+ .setOduInterfaceId(createdOduInterfaces)
+ .build());
}
- else if (input.getServiceRate().equals("10G")) {
- // implementing ODU2e for now
-
- for (Nodes node: input.getNodes()) {
- LOG.info("Input service is 10G");
- //check if the node is mounted or not?
- List<String> createdConnections = new ArrayList<>();
- List<String> createdEthInterfaces = new ArrayList<>();
- List<String> createdOduInterfaces = new ArrayList<>();
- createdEthInterfaces.add(
- openRoadmInterfaceFactory.createOpenRoadmEth10GInterface(node.getNodeId(), node.getClientTp()));
- createdOduInterfaces.add(
- //suppporting interface?, payload ?
- openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(), node.getClientTp(),
- input.getServiceName(),"03", false ,input.getTribPortNumber(),input.getTribSlot()));
- createdOduInterfaces.add(
- // supporting interface? payload ?
- openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(), node.getNetworkTp(),
- input.getServiceName(),"03" , true ,input.getTribPortNumber(),input.getTribSlot()));
- //implement cross connect
+ }
+
+ private void createHighOrderInterfaces(OtnServicePathInput input, List<NodeInterface> nodeInterfaces,
+ CopyOnWriteArrayList<LinkTp> linkTpList) throws OpenRoadmInterfaceException {
+ for (Nodes node : input.nonnullNodes()) {
+ AEndApiInfo apiInfoA = null;
+ ZEndApiInfo apiInfoZ = null;
+ if (input.getAEndApiInfo() != null && input.getAEndApiInfo().getNodeId().contains(node.getNodeId())) {
+ apiInfoA = input.getAEndApiInfo();
+ }
+ if (input.getZEndApiInfo() != null && input.getZEndApiInfo().getNodeId().contains(node.getNodeId())) {
+ apiInfoZ = input.getZEndApiInfo();
+ }
+ // check if the node is mounted or not?
+ List<String> createdEthInterfaces = new ArrayList<>();
+ List<String> createdOduInterfaces = new ArrayList<>();
+ switch (input.getServiceRate().intValue()) {
+ case 100:
+ LOG.info("Input service is 100G");
+ if (node.getClientTp() != null && node.getNetwork2Tp() == null) {
+ createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth100GInterface(
+ node.getNodeId(), node.getClientTp()));
+ createdOduInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
+ node.getNodeId(), node.getClientTp(), false, apiInfoA, apiInfoZ, "21"));
+ // supporting interface? payload ?
+ createdOduInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
+ node.getNodeId(), node.getNetworkTp(), true, null, null, null));
+ linkTpList.add(new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getClientTp())
+ .build());
+ }
+ if (node.getClientTp() == null && node.getNetwork2Tp() == null) {
+ createdOduInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
+ node.getNodeId(), node.getNetworkTp(), false, apiInfoA, apiInfoZ, "21"));
+ linkTpList.add(new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp())
+ .build());
+ }
+ if (node.getClientTp() == null && node.getNetwork2Tp() != null) {
+ // supporting interface? payload ?
+ createdOduInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
+ node.getNodeId(), node.getNetworkTp(), true, null, null, null));
+ createdOduInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
+ node.getNodeId(), node.getNetwork2Tp(), true, null, null, null));
+ }
+ break;
+ default:
+ LOG.error("service rate {} not managed yet", input.getServiceRate());
+ return;
+ }
+
+ // implement cross connect
+ List<String> createdConnections = new ArrayList<>();
+ if (createdOduInterfaces.size() == 2) {
Optional<String> connectionNameOpt = postCrossConnect(createdOduInterfaces, node);
createdConnections.add(connectionNameOpt.get());
LOG.info("Created cross connects");
- LOG.info("Now creating node interface builder");
- NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder();
- LOG.info("Now Created node interface builder");
- nodeInterfaceBuilder.withKey(new NodeInterfaceKey(input.getServiceName() + "-" + node.getNodeId()));
- nodeInterfaceBuilder.setNodeId(input.getServiceName() + "-" + node.getNodeId());
- LOG.info("Now Ids are set");
- nodeInterfaceBuilder.setConnectionId(createdConnections);
- LOG.info("Now connections are set");
- nodeInterfaceBuilder.setEthInterfaceId(createdEthInterfaces);
- nodeInterfaceBuilder.setOduInterfaceId(createdOduInterfaces);
- LOG.info("Now Interfaces are set");
- nodeInterfaces.add(nodeInterfaceBuilder.build());
- LOG.info("Everythiong is done and now returning ");
}
+ nodeInterfaces.add(new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setConnectionId(createdConnections)
+ .setEthInterfaceId(createdEthInterfaces)
+ .setOduInterfaceId(createdOduInterfaces)
+ .build());
}
- return nodeInterfaces;
}
- private Optional<String> postCrossConnect(List<String> createdOduInterfaces, Nodes node)
- throws OpenRoadmInterfaceException {
- return this.crossConnect.postOtnCrossConnect(createdOduInterfaces,node);
+ private void createOducnTtpInterface(OtnServicePathInput input, List<NodeInterface> nodeInterfaces,
+ CopyOnWriteArrayList<LinkTp> linkTpList) throws OpenRoadmInterfaceException {
+ if (input.getNodes() == null) {
+ return;
+ }
+ if (input.getServiceRate() == null) {
+ LOG.error("Missing service rate for ODUCn interface");
+ return;
+ }
+ LOG.info("Creation of ODUCn TTP interface in OTN service path {}", input);
+ for (int i = 0; i < input.getNodes().size(); i++) {
+ Nodes node = input.getNodes().get(i);
+ // Based on the service rate, we will know if it is a OTUC4, OTUC3 or OTUC2
+ String supportingOtuInterface = node.getNetworkTp();
+ boolean serviceRateNotSupp = false;
+
+ switch (input.getServiceRate().intValue()) {
+ case 200:
+ supportingOtuInterface += "-OTUC2";
+ break;
+ case 300:
+ supportingOtuInterface += "-OTUC3";
+ break;
+ case 400:
+ supportingOtuInterface += "-OTUC4";
+ break;
+ default:
+ serviceRateNotSupp = true;
+ break;
+ }
+ if (serviceRateNotSupp) {
+ LOG.error("Service rate {} is not supported", input.getServiceRate());
+ }
+
+ Nodes tgtNode =
+ i + 1 == input.getNodes().size()
+ // For the end node, tgtNode becomes the first node in the list
+ ? input.getNodes().get(0)
+ : input.getNodes().get(i + 1);
+
+ nodeInterfaces.add(new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setOduInterfaceId(List.of(
+ // though this is odu, actually it has ODUCn interfaces
+ openRoadmInterfaceFactory.createOpenRoadmOtnOducnInterface(node.getNodeId(),
+ node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp())))
+ .build());
+ linkTpList.add(new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
+ }
}
}