package org.opendaylight.transportpce.common.service;
+import java.util.Map;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.PortQual;
}
public static String getServiceType(String serviceFormat, Uint32 serviceRate, Mapping mapping) {
- String serviceType = null;
- if ("Ethernet".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 1:
- serviceType = StringConstants.SERVICE_TYPE_1GE;
- break;
- case 10:
- serviceType = StringConstants.SERVICE_TYPE_10GE;
- break;
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_100GE_T;
- if (mapping != null && PortQual.SwitchClient.getName().equals(mapping.getPortQual())) {
- serviceType = StringConstants.SERVICE_TYPE_100GE_M;
- }
- break;
- case 400:
- serviceType = StringConstants.SERVICE_TYPE_400GE;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
- }
- if ("OC".equals(serviceFormat) && Uint32.valueOf(100).equals(serviceRate)) {
- serviceType = StringConstants.SERVICE_TYPE_100GE_T;
- }
- if ("OTU".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_OTU4;
- break;
- case 400:
- serviceType = StringConstants.SERVICE_TYPE_OTUC4;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
- }
- if ("ODU".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_ODU4;
- break;
- case 400:
- serviceType = StringConstants.SERVICE_TYPE_ODUC4;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
+
+ switch (serviceFormat) {
+ case "OC":
+ if (Uint32.valueOf(100).equals(serviceRate)) {
+ return StringConstants.SERVICE_TYPE_100GE_T;
+ }
+ LOG.warn("Invalid service-rate {}", serviceRate);
+ return null;
+
+ case "Ethernet":
+ if (Uint32.valueOf(400).equals(serviceRate)) {
+ return StringConstants.SERVICE_TYPE_400GE;
+ }
+ if (Uint32.valueOf(100).equals(serviceRate)
+ && (mapping == null || !PortQual.SwitchClient.getName().equals(mapping.getPortQual()))) {
+ return StringConstants.SERVICE_TYPE_100GE_T;
+ }
+ return getOtnServiceType(serviceFormat, serviceRate);
+
+ //case "ODU":
+ //case "OTU":
+ default:
+ return getOtnServiceType(serviceFormat, serviceRate);
}
- return serviceType;
}
public static String getOtnServiceType(String serviceFormat, Uint32 serviceRate) {
- String serviceType = null;
- if ("Ethernet".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 1:
- serviceType = StringConstants.SERVICE_TYPE_1GE;
- break;
- case 10:
- serviceType = StringConstants.SERVICE_TYPE_10GE;
- break;
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_100GE_M;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
- }
- if ("OTU".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_OTU4;
- break;
- case 400:
- serviceType = StringConstants.SERVICE_TYPE_OTUC4;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
+ Map<String, Map<Uint32, String>> otnMap = Map.of(
+ "Ethernet", Map.of(
+ Uint32.valueOf(1), StringConstants.SERVICE_TYPE_1GE,
+ Uint32.valueOf(10), StringConstants.SERVICE_TYPE_10GE,
+ Uint32.valueOf(100), StringConstants.SERVICE_TYPE_100GE_M),
+ "OTU", Map.of(
+ Uint32.valueOf(100), StringConstants.SERVICE_TYPE_OTU4,
+ Uint32.valueOf(400), StringConstants.SERVICE_TYPE_OTUC4),
+ "ODU", Map.of(
+ Uint32.valueOf(100), StringConstants.SERVICE_TYPE_ODU4,
+ Uint32.valueOf(400), StringConstants.SERVICE_TYPE_ODUC4));
+
+ if (!otnMap.containsKey(serviceFormat)) {
+ LOG.warn("Invalid service-format {}", serviceFormat);
+ return null;
}
- if ("ODU".equals(serviceFormat)) {
- switch (serviceRate.intValue()) {
- case 100:
- serviceType = StringConstants.SERVICE_TYPE_ODU4;
- break;
- case 400:
- serviceType = StringConstants.SERVICE_TYPE_ODUC4;
- break;
- default:
- LOG.warn("Invalid service-rate {}", serviceRate);
- break;
- }
+
+ if (!otnMap.get(serviceFormat).containsKey(serviceRate)) {
+ LOG.warn("Invalid service-rate {}", serviceRate);
+ return null;
}
- return serviceType;
+
+ return otnMap.get(serviceFormat).get(serviceRate);
+
}
}
pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
return pceResult;
}
- int tribSlotNb = 1;
int spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP
.getOrDefault(serviceType, GridConstant.NB_SLOTS_100G);
SpectrumAssignment spectrumAssignment = null;
case StringConstants.SERVICE_TYPE_100GE_M:
case StringConstants.SERVICE_TYPE_10GE:
case StringConstants.SERVICE_TYPE_1GE:
- if (StringConstants.SERVICE_TYPE_100GE_M.equals(serviceType)) {
- tribSlotNb = 20;
- } else if (StringConstants.SERVICE_TYPE_10GE.equals(serviceType)) {
- tribSlotNb = 8;
- } else if (StringConstants.SERVICE_TYPE_1GE.equals(serviceType)) {
- tribSlotNb = 1;
- } else {
- pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
- LOG.warn("In PostAlgoPathValidator checkPath: unsupported serviceType {} found {}",
- serviceType, path);
- break;
- }
+ Map<String, Integer> tribSlotNbMap = Map.of(
+ StringConstants.SERVICE_TYPE_100GE_M, 20,
+ StringConstants.SERVICE_TYPE_10GE, 8,
+ StringConstants.SERVICE_TYPE_1GE, 1);
+ int tribSlotNb = tribSlotNbMap.get(serviceType);
pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
pceResult.setServiceType(serviceType);
Map<String, List<Uint16>> tribSlot = chooseTribSlot(path, allPceNodes, tribSlotNb);
Collections.sort(commonEdgeTsPoolList);
List<Uint16> commonGoodStartEdgeTsPoolList = new ArrayList<>();
for (Uint16 startEdgeTsPool : commonEdgeTsPoolList) {
- if (Integer.valueOf(1).equals(startEdgeTsPool.toJava() % nbSlot)) {
- commonGoodStartEdgeTsPoolList.add(startEdgeTsPool);
- } else if (nbSlot == 1) {
+ if (Integer.valueOf(1).equals(startEdgeTsPool.toJava() % nbSlot)
+ || nbSlot == 1) {
commonGoodStartEdgeTsPoolList.add(startEdgeTsPool);
}
}
int goodStartIndex = commonEdgeTsPoolList.indexOf(Uint16.valueOf(goodStartTsPool.intValue()));
if (!goodTsList && commonEdgeTsPoolList.size() - goodStartIndex >= nbSlot) {
for (int i = 0; i < nbSlot; i++) {
- if (commonEdgeTsPoolList.get(goodStartIndex + i)
+ if (!commonEdgeTsPoolList.get(goodStartIndex + i)
.equals(Uint16.valueOf(goodStartTsPool.toJava() + i))) {
- tribSlotList.add(commonEdgeTsPoolList.get(goodStartIndex + i));
- goodTsList = true;
- } else {
goodTsList = false;
tribSlotList.clear();
break;
}
+ tribSlotList.add(commonEdgeTsPoolList.get(goodStartIndex + i));
+ goodTsList = true;
}
}
}
}
private double getOsnrDb(double osnrLu) {
- double osnrDb;
- osnrDb = 10 * Math.log10(osnrLu);
- return osnrDb;
+ return (10 * Math.log10(osnrLu));
}
private double getInverseOsnrLinkLu(double linkOsnrDb) {
// 1 over the link OSNR, in linear units
- double linkOsnrLu;
- linkOsnrLu = Math.pow(10, (linkOsnrDb / 10.0));
+ double linkOsnrLu = Math.pow(10, (linkOsnrDb / 10.0));
LOG.debug("In retrieveosnr: the inverse of link osnr is {} (Linear Unit)", linkOsnrLu);
return (CONST_OSNR / linkOsnrLu);
}
.setFlexGrid(isFlexGrid);
BitSet referenceBitSet = new BitSet(spectralWidthSlotNumber);
referenceBitSet.set(0, spectralWidthSlotNumber);
- int nbSteps = 1;
- if (isFlexGrid) {
- nbSteps = spectralWidthSlotNumber;
- }
+ int nbSteps = isFlexGrid ? spectralWidthSlotNumber : 1;
//higher is the frequency, smallest is the wavelength number
//in operational, the allocation is done through wavelength starting from the smallest
//so we have to loop from the last element of the spectrum occupation
}
return spectrumAssignmentBldr.build();
}
-}
\ No newline at end of file
+}
import org.opendaylight.transportpce.pce.PceComplianceCheck;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mc.capabilities.McCapabilities;
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;
serviceFormatA = input.getServiceAEnd().getServiceFormat().getName();
serviceFormatZ = input.getServiceZEnd().getServiceFormat().getName();
serviceRate = input.getServiceAEnd().getServiceRate();
- if (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId()).getNodeInfo().getNodeType())
+ serviceType = ServiceTypes.getServiceType(serviceFormatA, serviceRate,
+ (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId()).getNodeInfo().getNodeType())
&& input.getServiceAEnd().getTxDirection() != null
&& input.getServiceAEnd().getTxDirection().getPort() != null
- && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null) {
- Mapping mapping = portMapping.getMapping(input.getServiceAEnd().getNodeId(),
- input.getServiceAEnd().getTxDirection().getPort().getPortName());
- serviceType = ServiceTypes.getServiceType(serviceFormatA, serviceRate, mapping);
- } else {
- serviceType = ServiceTypes.getServiceType(serviceFormatA, serviceRate, null);
- }
+ && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null)
+ ? portMapping.getMapping(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getTxDirection().getPort().getPortName())
+ : null);
LOG.info("parseInput: A and Z :[{}] and [{}]", anodeId, znodeId);
}
private void getAZnodeId() {
- if (StringConstants.SERVICE_TYPE_ODU4.equals(serviceType)
- || StringConstants.SERVICE_TYPE_ODUC4.equals(serviceType)
- || StringConstants.SERVICE_TYPE_100GE_M.equals(serviceType)
- || StringConstants.SERVICE_TYPE_10GE.equals(serviceType)
- || StringConstants.SERVICE_TYPE_1GE.equals(serviceType)) {
- anodeId = input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName();
- znodeId = input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName();
- } else {
- anodeId = input.getServiceAEnd().getNodeId();
- znodeId = input.getServiceZEnd().getNodeId();
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_ODU4:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ case StringConstants.SERVICE_TYPE_10GE:
+ case StringConstants.SERVICE_TYPE_1GE:
+ anodeId = input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName();
+ znodeId = input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName();
+ break;
+ default:
+ anodeId = input.getServiceAEnd().getNodeId();
+ znodeId = input.getServiceZEnd().getNodeId();
+ break;
}
}
break;
}
- if (readTopology(nwInstanceIdentifier) != null) {
- allNodes = readTopology(nwInstanceIdentifier).nonnullNode().values().stream().sorted((n1, n2)
- -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())).collect(Collectors.toList());
- Network1 nw1 = readTopology(nwInstanceIdentifier).augmentation(Network1.class);
- if (nw1 != null) {
- allLinks = nw1.nonnullLink().values().stream().sorted((l1, l2)
- -> l1.getSource().getSourceTp().toString().compareTo(l2.getSource().getSourceTp().toString()))
- .collect(Collectors.toList());
- } else {
- LOG.warn("no otn links in otn-topology");
- }
- if (allNodes == null || allNodes.isEmpty()) {
- LOG.error("readMdSal: no nodes ");
- return false;
- }
- LOG.info("readMdSal: network nodes: {} nodes added", allNodes.size());
- LOG.debug("readMdSal: network nodes: {} nodes added", allNodes);
-
- if (allLinks == null || allLinks.isEmpty()) {
- LOG.error("readMdSal: no links ");
- return false;
- }
- LOG.info("readMdSal: network links: {} links added", allLinks.size());
- LOG.debug("readMdSal: network links: {} links added", allLinks);
+ if (readTopology(nwInstanceIdentifier) == null) {
+ LOG.error("readMdSal: network is null: {}", nwInstanceIdentifier);
+ return false;
+ }
- return true;
+ allNodes = readTopology(nwInstanceIdentifier).nonnullNode().values().stream().sorted((n1, n2)
+ -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())).collect(Collectors.toList());
+ Network1 nw1 = readTopology(nwInstanceIdentifier).augmentation(Network1.class);
+ if (nw1 == null) {
+ LOG.warn("no otn links in otn-topology");
} else {
- LOG.error("readMdSal: network is null: {}", nwInstanceIdentifier);
+ allLinks = nw1.nonnullLink().values().stream().sorted((l1, l2)
+ -> l1.getSource().getSourceTp().toString().compareTo(l2.getSource().getSourceTp().toString()))
+ .collect(Collectors.toList());
+ }
+ if (allNodes == null || allNodes.isEmpty()) {
+ LOG.error("readMdSal: no nodes ");
+ return false;
+ }
+ LOG.info("readMdSal: network nodes: {} nodes added", allNodes.size());
+ LOG.debug("readMdSal: network nodes: {} nodes added", allNodes);
+
+ if (allLinks == null || allLinks.isEmpty()) {
+ LOG.error("readMdSal: no links ");
return false;
}
+ LOG.info("readMdSal: network links: {} links added", allLinks.size());
+ LOG.debug("readMdSal: network links: {} links added", allLinks);
+
+ return true;
}
private Network readTopology(InstanceIdentifier<Network> nwInstanceIdentifier) {
private boolean analyzeNw() {
LOG.debug("analyzeNw: allNodes size {}, allLinks size {}", allNodes.size(), allLinks.size());
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_100GE_T:
+ case StringConstants.SERVICE_TYPE_OTU4:
+ case StringConstants.SERVICE_TYPE_400GE:
+ case StringConstants.SERVICE_TYPE_OTUC4:
+ // 100GE service and OTU4 service are handled at the openroadm-topology layer
+ for (Node node : allNodes) {
+ validateNode(node);
+ }
- if (StringConstants.SERVICE_TYPE_100GE_T.equals(serviceType)
- || StringConstants.SERVICE_TYPE_OTU4.equals(serviceType)
- || StringConstants.SERVICE_TYPE_400GE.equals(serviceType)
- || StringConstants.SERVICE_TYPE_OTUC4.equals(serviceType)) {
- // 100GE service and OTU4 service are handled at the openroadm-topology layer
- for (Node node : allNodes) {
- validateNode(node);
- }
-
- LOG.debug("analyzeNw: allPceNodes size {}", allPceNodes.size());
+ LOG.debug("analyzeNw: allPceNodes size {}", allPceNodes.size());
- if (aendPceNode == null || zendPceNode == null) {
- LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
- return false;
- }
- for (Link link : allLinks) {
- validateLink(link);
- }
- // debug prints
- LOG.debug("analyzeNw: addLinks size {}, dropLinks size {}", addLinks.size(), dropLinks.size());
- // debug prints
- LOG.debug("analyzeNw: azSrgs size = {}", azSrgs.size());
- for (NodeId srg : azSrgs) {
- LOG.debug("analyzeNw: A/Z Srgs SRG = {}", srg.getValue());
- }
- // debug prints
- for (PceLink link : addLinks) {
- filteraddLinks(link);
- }
- for (PceLink link : dropLinks) {
- filterdropLinks(link);
- }
+ if (aendPceNode == null || zendPceNode == null) {
+ LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
+ return false;
+ }
+ for (Link link : allLinks) {
+ validateLink(link);
+ }
+ // debug prints
+ LOG.debug("analyzeNw: addLinks size {}, dropLinks size {}", addLinks.size(), dropLinks.size());
+ // debug prints
+ LOG.debug("analyzeNw: azSrgs size = {}", azSrgs.size());
+ for (NodeId srg : azSrgs) {
+ LOG.debug("analyzeNw: A/Z Srgs SRG = {}", srg.getValue());
+ }
+ // debug prints
+ for (PceLink link : addLinks) {
+ filteraddLinks(link);
+ }
+ for (PceLink link : dropLinks) {
+ filterdropLinks(link);
+ }
+ break;
- } else {
- // ODU4, 10GE/ODU2e or 1GE/ODU0 services are handled at openroadm-otn layer
+ default:
+ // ODU4, 10GE/ODU2e or 1GE/ODU0 services are handled at openroadm-otn layer
- for (Node node : allNodes) {
- validateOtnNode(node);
- }
+ for (Node node : allNodes) {
+ validateOtnNode(node);
+ }
- LOG.info("analyzeNw: allPceNodes {}", allPceNodes);
+ LOG.info("analyzeNw: allPceNodes {}", allPceNodes);
- if (aendPceNode == null || zendPceNode == null) {
- LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
- return false;
- }
- for (Link link : allLinks) {
- validateLink(link);
- }
+ if (aendPceNode == null || zendPceNode == null) {
+ LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
+ return false;
+ }
+ for (Link link : allLinks) {
+ validateLink(link);
+ }
+ break;
}
LOG.info("analyzeNw: allPceNodes size {}, allPceLinks size {}", allPceNodes.size(), allPceLinks.size());
private void validateOtnNode(Node node) {
LOG.info("validateOtnNode: {} ", node.getNodeId().getValue());
// PceOtnNode will be used in Graph algorithm
- if (node.augmentation(Node1.class) != null) {
- OpenroadmNodeType nodeType = node.augmentation(Node1.class).getNodeType();
+ if (node.augmentation(Node1.class) == null) {
+ LOG.error("ValidateOtnNode: no node-type augmentation. Node {} is ignored", node.getNodeId().getValue());
+ return;
+ }
- PceOtnNode pceOtnNode = new PceOtnNode(node, nodeType, node.getNodeId(), "otn", serviceType);
- pceOtnNode.validateXponder(anodeId, znodeId);
+ OpenroadmNodeType nodeType = node.augmentation(Node1.class).getNodeType();
- if (!pceOtnNode.isValid()) {
- LOG.warn(" validateOtnNode: Node {} is ignored", node.getNodeId().getValue());
- return;
- }
- if (validateNodeConstraints(pceOtnNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
- return;
- }
- if (pceOtnNode.getNodeId().getValue().equals(anodeId) && this.aendPceNode == null) {
- this.aendPceNode = pceOtnNode;
- }
- if (pceOtnNode.getNodeId().getValue().equals(znodeId) && this.zendPceNode == null) {
- this.zendPceNode = pceOtnNode;
- }
- allPceNodes.put(pceOtnNode.getNodeId(), pceOtnNode);
- LOG.info("validateOtnNode: node {} is saved", node.getNodeId().getValue());
+ PceOtnNode pceOtnNode = new PceOtnNode(node, nodeType, node.getNodeId(), "otn", serviceType);
+ pceOtnNode.validateXponder(anodeId, znodeId);
+
+ if (!pceOtnNode.isValid()) {
+ LOG.warn(" validateOtnNode: Node {} is ignored", node.getNodeId().getValue());
return;
- } else {
- LOG.error("ValidateOtnNode: no node-type augmentation. Node {} is ignored", node.getNodeId().getValue());
+ }
+ if (validateNodeConstraints(pceOtnNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
return;
}
+ if (pceOtnNode.getNodeId().getValue().equals(anodeId) && this.aendPceNode == null) {
+ this.aendPceNode = pceOtnNode;
+ }
+ if (pceOtnNode.getNodeId().getValue().equals(znodeId) && this.zendPceNode == null) {
+ this.zendPceNode = pceOtnNode;
+ }
+ allPceNodes.put(pceOtnNode.getNodeId(), pceOtnNode);
+ LOG.info("validateOtnNode: node {} is saved", node.getNodeId().getValue());
+ return;
}
private ConstraintTypes validateNodeConstraints(PceNode pcenode) {
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirection;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToA;
+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.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;
private static final Logger LOG = LoggerFactory.getLogger(ModelMappingUtils.class);
private static final String TERMINATION_POINT = "TerminationPoint";
+ private static final String LINK = "Link";
private ModelMappingUtils() {
}
// 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 =
new ArrayList<>();
- NodeLists nodeLists;
- if (asideToZside) {
- nodeLists = getNodesListAToZ(pathDescription.getAToZDirection().nonnullAToZ().values().iterator());
- } else {
- nodeLists = getNodesListZtoA(pathDescription.getZToADirection().nonnullZToA().values().iterator());
- }
+ NodeLists nodeLists =
+ (asideToZside)
+ ? getNodesListAToZ(pathDescription.getAToZDirection().nonnullAToZ().values().iterator())
+ : getNodesListZtoA(pathDescription.getZToADirection().nonnullZToA().values().iterator());
LOG.info("These are node-lists {}, {}", nodeLists.getRendererNodeList(), nodeLists.getOlmNodeList());
for (Nodes node: nodeLists.getRendererNodeList()) {
nodes.add(new org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.otn.renderer.nodes
Map<Integer, NodeIdPair> treeMap = new TreeMap<>();
List<Nodes> olmList = new ArrayList<>();
List<Nodes> list = new ArrayList<>();
- String resourceType;
- TerminationPoint tp;
- String tpID = "";
- String nodeID = "";
- String sortId = "";
+
while (iterator.hasNext()) {
ZToA pathDesObj = iterator.next();
- resourceType = pathDesObj.getResource().getResource().implementedInterface().getSimpleName();
- LOG.info("Inside ZtoA {}", resourceType);
-
try {
- if (TERMINATION_POINT.equals(resourceType)) {
- tp = (TerminationPoint) pathDesObj.getResource().getResource();
- LOG.info(" TP is {} {}", tp.getTpId(),
- tp.getTpNodeId());
- tpID = tp.getTpId();
- sortId = pathDesObj.getId();
-
- //TODO: do not rely on ID to be in certain format
- if (tpID.contains("CTP") || tpID.contains("CP")) {
- continue;
- }
- if (tpID.contains(StringConstants.TTP_TOKEN)) {
- nodeID = tp.getTpNodeId().split("-DEG")[0];
- } else if (tpID.contains(StringConstants.PP_TOKEN)) {
- nodeID = tp.getTpNodeId().split("-SRG")[0];
- } else if (tpID.contains(StringConstants.NETWORK_TOKEN)
- || tpID.contains(StringConstants.CLIENT_TOKEN) || tpID.isEmpty()) {
- nodeID = tp.getTpNodeId().split("-XPDR")[0];
- } else {
- continue;
- }
- int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID, tpID));
- } else if ("Link".equals(resourceType)) {
- LOG.info("The type is link");
- } else {
- LOG.info("The type is not identified: {}", resourceType);
- }
+ populateTreeMap(treeMap, pathDesObj.getResource().getResource(), pathDesObj.getId(), "ZtoA");
} catch (IllegalArgumentException | SecurityException e) {
- LOG.error("Dont find the getResource method", e);
+ //TODO: Auto-generated catch block
+ LOG.error("Did not find the getResource method", e);
}
}
populateNodeLists(treeMap, list, olmList, false);
Map<Integer, NodeIdPair> treeMap = new TreeMap<>();
List<Nodes> list = new ArrayList<>();
List<Nodes> olmList = new ArrayList<>();
- String resourceType;
- TerminationPoint tp;
- String tpID = "";
- String nodeID = "";
- String sortId = "";
while (iterator.hasNext()) {
AToZ pathDesObj = iterator.next();
- resourceType = pathDesObj.getResource().getResource().implementedInterface().getSimpleName();
- LOG.info("Inside AtoZ {}", resourceType);
try {
- if (TERMINATION_POINT.equals(resourceType)) {
- tp = (TerminationPoint) pathDesObj.getResource().getResource();
- LOG.info("TP is {} {}", tp.getTpId(),
- tp.getTpNodeId());
- tpID = tp.getTpId();
- sortId = pathDesObj.getId();
-
- //TODO: do not rely on ID to be in certain format
- if (tpID.contains("CTP") || tpID.contains("CP")) {
- continue;
- }
- if (tpID.contains(StringConstants.TTP_TOKEN)) {
- nodeID = tp.getTpNodeId().split("-DEG")[0];
- } else if (tpID.contains(StringConstants.PP_TOKEN)) {
- nodeID = tp.getTpNodeId().split("-SRG")[0];
- } else if (tpID.contains(StringConstants.NETWORK_TOKEN)
- || tpID.contains(StringConstants.CLIENT_TOKEN) || tpID.isEmpty()) {
- nodeID = tp.getTpNodeId().split("-XPDR")[0];
- } else {
- continue;
- }
- int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID, tpID));
- } else if ("Link".equals(resourceType)) {
- LOG.info("The type is link");
- } else {
- LOG.info("The type is not identified: {}", resourceType);
- }
+ populateTreeMap(treeMap, pathDesObj.getResource().getResource(), pathDesObj.getId(), "AtoZ");
} catch (IllegalArgumentException | SecurityException e) {
//TODO: Auto-generated catch block
LOG.error("Did not find the getResource method", e);
return new NodeLists(olmList, list);
}
+ private static void populateTreeMap(Map<Integer, NodeIdPair> treeMap, Resource rsrc, String sortId,
+ String direction) {
+ String resourceType = rsrc.implementedInterface().getSimpleName();
+ LOG.info("Inside {} {}", direction, resourceType);
+ switch (resourceType) {
+ case TERMINATION_POINT:
+ TerminationPoint tp = (TerminationPoint) rsrc;
+ LOG.info(" TP is {} {}", tp.getTpId(), tp.getTpNodeId());
+ String tpID = tp.getTpId();
+
+ //TODO: do not rely on ID to be in certain format
+ if (tpID.contains("CTP") || tpID.contains("CP")) {
+ return;
+ }
+ String nodeID = "";
+ if (tpID.contains(StringConstants.TTP_TOKEN)) {
+ nodeID = tp.getTpNodeId().split("-DEG")[0];
+ } else if (tpID.contains(StringConstants.PP_TOKEN)) {
+ nodeID = tp.getTpNodeId().split("-SRG")[0];
+ } else if (tpID.contains(StringConstants.NETWORK_TOKEN)
+ || tpID.contains(StringConstants.CLIENT_TOKEN) || tpID.isEmpty()) {
+ nodeID = tp.getTpNodeId().split("-XPDR")[0];
+ } else {
+ return;
+ }
+ int id = Integer.parseInt(sortId);
+ treeMap.put(id, new NodeIdPair(nodeID, tpID));
+ return;
+ case LINK:
+ LOG.info("The type is link");
+ return;
+ default:
+ LOG.info("The type is not identified: {}", resourceType);
+ return;
+ }
+ }
+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = {"NP_LOAD_OF_KNOWN_NULL_VALUE","RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"},
justification = "loop when value is not always null - "
+ "TODO: check if something exists in Java lib")
private static void populateNodeLists(Map<Integer, NodeIdPair> treeMap, List<Nodes> list, List<Nodes> olmList,
- boolean isAToz) {
+ boolean isAToz) {
String desID = null;
String srcID = null;
LOG.info("treeMap values = {}", treeMap.values());
srcID = null;
desID = null;
} else {
- LOG.warn("both, the source and destination id are null!");
+ LOG.warn("both, the source and destination id are not null!");
}
}
}
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS",
- justification = "not relevant to return and zero length array"
+ justification = "not relevant to return a zero length array"
+ " as we need real pos")
public static int[] findTheLongestSubstring(String s1, String s2) {
if ((s1 == null) || (s2 == null)) {
public class DeviceRendererServiceImpl implements DeviceRendererService {
private static final String IS_NOT_MOUNTED_ON_THE_CONTROLLER = " is not mounted on the controller";
- private static final String ODU4 = "-ODU4";
private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
nodeId, destTp, spectrumInformation);
createdOchInterfaces.add(supportingOchInterface);
// Here we pass logical connection-point of z-end to set SAPI and DAPI
- Nodes tgtNode = null;
- if (nodeIndex + 1 == nodes.size()) {
- // For the end node, tgtNode becomes the first node in the list
- tgtNode = nodes.get(0);
- } else {
- tgtNode = nodes.get(nodeIndex + 1);
- }
- // tgtNode srcTp is null in this if cond
- String supportingOtuInterface = this.openRoadmInterfaceFactory
- .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface,
- tgtNode.getNodeId(), tgtNode.getDestTp());
+ Nodes tgtNode =
+ nodeIndex + 1 == nodes.size()
+ // For the end node, tgtNode becomes the first node in the list
+ ? nodes.get(0)
+ : nodes.get(nodeIndex + 1);
+ // tgtNode srcTp is null in this last cond
+ String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
+ nodeId, destTp, supportingOchInterface, tgtNode.getNodeId(), tgtNode.getDestTp());
createdOtuInterfaces.add(supportingOtuInterface);
if (srcTp == null) {
- LinkTp linkTp = new LinkTpBuilder()
- .setNodeId(nodeId)
- .setTpId(destTp)
- .build();
- otnLinkTps.add(linkTp);
+ otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(destTp).build());
} else {
createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
destTp, supportingOtuInterface));
LOG.info("Adding supporting EThernet interface for node {}, src tp {}", nodeId, srcTp);
crossConnectFlag++;
// create OpenRoadm Xponder Client Interfaces
- createdEthInterfaces.add(
- this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
+ createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+ nodeId, srcTp));
}
if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
nodeId, srcTp, spectrumInformation);
createdOchInterfaces.add(supportingOchInterface);
- String supportingOtuInterface = this.openRoadmInterfaceFactory
- .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
+ String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
+ nodeId, srcTp, supportingOchInterface);
createdOtuInterfaces.add(supportingOtuInterface);
- createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
- srcTp, supportingOtuInterface));
+ createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(
+ nodeId, srcTp, supportingOtuInterface));
Mapping mapping = this.portMapping.getMapping(nodeId,srcTp);
- if (mapping != null && mapping.getXponderType() != null
+ createdOduInterfaces.add(
+ mapping != null
+ && mapping.getXponderType() != null
&& (mapping.getXponderType().getIntValue() == 3
- || mapping.getXponderType().getIntValue() == 2)) {
- createdOduInterfaces.add(this.openRoadmInterfaceFactory
- .createOpenRoadmOtnOdu4Interface(nodeId, destTp, supportingOtuInterface));
- } else {
- createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
- destTp, supportingOtuInterface));
- }
+ || mapping.getXponderType().getIntValue() == 2)
+ ? this.openRoadmInterfaceFactory.createOpenRoadmOtnOdu4Interface(
+ nodeId, destTp, supportingOtuInterface)
+ : this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(
+ nodeId, destTp, supportingOtuInterface));
}
if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
LOG.info("Adding supporting EThernet interface for node {}, dest tp {}", nodeId, destTp);
crossConnectFlag++;
// create OpenRoadm Xponder Client Interfaces
- createdEthInterfaces.add(
- this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
+ createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+ nodeId, destTp));
}
if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
|| srcTp.contains(StringConstants.PP_TOKEN))) {
LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
nodeId, srcTp, spectrumInformation);
- createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(nodeId,
- srcTp, spectrumInformation));
+ createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
+ nodeId, srcTp, spectrumInformation));
}
if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
|| destTp.contains(StringConstants.PP_TOKEN))) {
LOG.info("Adding supporting OCH interface for node {}, dest tp {}, spectrumInformation {}",
nodeId, destTp, spectrumInformation);
- createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(nodeId,
- destTp, spectrumInformation));
+ createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
+ nodeId, destTp, spectrumInformation));
}
if (crossConnectFlag < 1) {
LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
success.set(false);
}
- NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
+ NodeInterface nodeInterface = new NodeInterfaceBuilder()
.withKey(new NodeInterfaceKey(nodeId))
.setNodeId(nodeId)
.setConnectionId(createdConnections)
.setEthInterfaceId(createdEthInterfaces)
.setOtuInterfaceId(createdOtuInterfaces)
.setOduInterfaceId(createdOduInterfaces)
- .setOchInterfaceId(createdOchInterfaces);
- NodeInterface nodeInterface = nodeInterfaceBuilder.build();
+ .setOchInterfaceId(createdOchInterfaces)
+ .build();
nodeInterfaces.put(nodeInterface.key(),nodeInterface);
}));
try {
if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
LOG.error("Alarm suppresion node removal failed!!!!");
}
- ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
- .setNodeInterface(nodeInterfaces)
- .setSuccess(success.get())
- .setResult(String.join("\n", results))
- .setLinkTp(otnLinkTps);
- return setServBldr.build();
+ return new ServicePathOutputBuilder()
+ .setNodeInterface(nodeInterfaces)
+ .setSuccess(success.get())
+ .setResult(String.join("\n", results))
+ .setLinkTp(otnLinkTps)
+ .build();
}
private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
@Override
public ServicePathOutput deleteServicePath(ServicePathInput input) {
- List<Nodes> nodes = input.getNodes();
- AtomicBoolean success = new AtomicBoolean(true);
- ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
if (!alarmSuppressionNodeRegistration(input)) {
LOG.warn("Alarm suppresion node registraion failed!!!!");
}
+ 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;
- String destTp;
if (node.getDestTp() == null) {
LOG.error("Destination termination point must not be null.");
return;
- } else {
- destTp = node.getDestTp();
}
- if (node.getSrcTp() != null) {
- srcTp = node.getSrcTp();
- } else {
- srcTp = "";
- LinkTp linkTp = new LinkTpBuilder()
- .setNodeId(nodeId)
- .setTpId(destTp)
- .build();
- otnLinkTps.add(linkTp);
- }
- // if the node is currently mounted then proceed.
- if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
- interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp,
- input.getLowerSpectralSlotNumber().intValue(),
- input.getHigherSpectralSlotNumber().intValue()));
- } else {
+ if (!this.deviceTransactionManager.isDeviceMounted(nodeId)) {
String result = nodeId + IS_NOT_MOUNTED_ON_THE_CONTROLLER;
results.add(result);
success.set(false);
return;
//TODO should deletion end here?
}
+ // if the node is currently mounted then proceed.
+
+ String destTp = node.getDestTp();
+ String srcTp = "";
+ if (node.getSrcTp() == null) {
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(destTp)
+ .build());
+ } else {
+ srcTp = node.getSrcTp();
+ }
+ List<String> interfacesToDelete = new LinkedList<>();
+ interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp,
+ input.getLowerSpectralSlotNumber().intValue(),
+ input.getHigherSpectralSlotNumber().intValue()));
for (String interfaceId : interfacesToDelete) {
try {
this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
LOG.error("Alarm suppresion node removal failed!!!!");
}
- ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder()
- .setSuccess(success.get())
- .setLinkTp(otnLinkTps);
- if (results.isEmpty()) {
- return delServBldr.setResult("Request processed").build();
- } else {
- return delServBldr.setResult(String.join("\n", results)).build();
- }
+ return new ServicePathOutputBuilder()
+ .setSuccess(success.get())
+ .setLinkTp(otnLinkTps)
+ .setResult(
+ results.isEmpty()
+ ? "Request processed"
+ : String.join("\n", results))
+ .build();
}
- private List<String> getInterfaces2delete(
+ private List<String> getInterfaces2delete(
String nodeId, String srcTp, String destTp, int lowerSpectralSlotNumber, int higherSpectralSlotNumber) {
String spectralSlotName = String.join(GridConstant.SPECTRAL_SLOT_SEPARATOR,
String.valueOf(lowerSpectralSlotNumber),
String.valueOf(higherSpectralSlotNumber));
- OpenroadmNodeVersion nodeOpenRoadmVersion = this.portMapping.getNode(nodeId).getNodeInfo()
- .getOpenroadmVersion();
- List<String> interfacesToDelete = new LinkedList<>();
if (destTp.contains(StringConstants.NETWORK_TOKEN)
|| srcTp.contains(StringConstants.CLIENT_TOKEN)
|| srcTp.contains(StringConstants.NETWORK_TOKEN)
|| destTp.contains(StringConstants.CLIENT_TOKEN)) {
- if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
- if (nodeOpenRoadmVersion.equals(OpenroadmNodeVersion._71)) {
- try {
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODUFLEX").isPresent()) {
- interfacesToDelete.add(destTp + "-ODUFLEX");
- }
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODUC4").isPresent()) {
- interfacesToDelete.add(destTp + "-ODUC4");
- }
- } catch (OpenRoadmInterfaceException e) {
- LOG.error("impossible to get interface {} or {}", destTp + "-ODUFLEX", destTp + "-ODUC4", e);
- }
- interfacesToDelete.add(destTp + "-OTUC4");
- interfacesToDelete.add(destTp + "-OTSI-GROUP");
- interfacesToDelete.add(destTp + "-" + lowerSpectralSlotNumber + ":" + higherSpectralSlotNumber);
- } else {
- try {
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
- interfacesToDelete.add(destTp + "-ODU");
- }
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) {
- interfacesToDelete.add(destTp + ODU4);
- }
- }
- catch (OpenRoadmInterfaceException e) {
- LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e);
- }
- interfacesToDelete.add(destTp + "-OTU");
- interfacesToDelete.add(
- this.openRoadmInterfaceFactory
- .createOpenRoadmOchInterfaceName(destTp,spectralSlotName));
- }
+ return getInterfacesTodelete(nodeId, srcTp, destTp, spectralSlotName);
+ }
+
+ List<String> interfacesToDelete = new LinkedList<>();
+ String connectionNumber = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, destTp, spectralSlotName);
+ List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
+ for (String interf : intToDelete == null ? new ArrayList<String>() : intToDelete) {
+ if (!this.openRoadmInterfaceFactory.isUsedByXc(
+ nodeId, interf, connectionNumber, this.deviceTransactionManager)) {
+ interfacesToDelete.add(interf);
}
- if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
- if (nodeOpenRoadmVersion.equals(OpenroadmNodeVersion._71)) {
- interfacesToDelete.add(srcTp + "-ODUC4");
- interfacesToDelete.add(srcTp + "-OTUC4");
- interfacesToDelete.add(srcTp + "-OTSI-GROUP");
- interfacesToDelete.add(srcTp + "-" + lowerSpectralSlotNumber + ":" + higherSpectralSlotNumber);
- } else {
- interfacesToDelete.add(srcTp + "-ODU");
- interfacesToDelete.add(srcTp + "-OTU");
- interfacesToDelete
- .add(this.openRoadmInterfaceFactory
- .createOpenRoadmOchInterfaceName(srcTp, spectralSlotName));
+ }
+ return interfacesToDelete;
+ }
+
+ private List<String> getInterfacesTodelete(String nodeId, String srcTp, String destTp, String spectralSlotName) {
+
+ OpenroadmNodeVersion nodeOpenRoadmVersion =
+ this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
+ List<String> interfacesToDelete = new LinkedList<>();
+ Map<String, List<String>> suffixListMap =
+ nodeOpenRoadmVersion.equals(OpenroadmNodeVersion._71)
+ ? Map.of(
+ "ODU", List.of("ODUC4","ODUFLEX"),
+ "other", List.of("OTUC4", "OTSI-GROUP", spectralSlotName))
+ : Map.of(
+ "ODU", List.of("ODU", "ODU4"),
+ "other", List.of("OTU", spectralSlotName));
+ // this last suffix used to be retrieved from openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName
+ // i.e. String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, spectralSlotName) with
+ // common GridConstant that states NAME_PARAMETERS_SEPARATOR = "-"
+
+ if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
+ try {
+ for (String suffix : suffixListMap.get("ODU")) {
+ if (this.openRoadmInterfaces.getInterface(
+ nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)).isPresent()) {
+ interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix));
+ }
}
}
- if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
- interfacesToDelete.add(srcTp + "-ETHERNET");
+ catch (OpenRoadmInterfaceException e) {
+ LOG.error("impossible to get one of the interfaces {}",
+ destTp + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join(
+ " or " + destTp + GridConstant.NAME_PARAMETERS_SEPARATOR,
+ suffixListMap.get("ODU")),
+ e);
}
- if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
- interfacesToDelete.add(destTp + "-ETHERNET");
+ for (String suffix : suffixListMap.get("other")) {
+ interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix));
}
- } else {
- String connectionNumber = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, destTp,
- spectralSlotName);
- List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
- connectionNumber = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, srcTp, spectralSlotName);
- if (intToDelete != null) {
- for (String interf : intToDelete) {
- if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber,
- this.deviceTransactionManager)) {
- interfacesToDelete.add(interf);
- }
- }
+ }
+ if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
+ interfacesToDelete.add(
+ String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, suffixListMap.get("ODU").get(0)));
+ for (String suffix : suffixListMap.get("other")) {
+ interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, suffix));
}
}
+ if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
+ interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, "ETHERNET"));
+ }
+ if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
+ interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, "ETHERNET"));
+ }
return interfacesToDelete;
}
+
+
@Override
public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
boolean success = true;
.setNodeId(nodeId).setInterface(failedInterfaces).build();
failedToRollbackList.put(failedToRollack.key(),failedToRollack);
}
- return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
+ return new RendererRollbackOutputBuilder()
+ .setSuccess(success)
+ .setFailedToRollback(failedToRollbackList)
.build();
}
private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
- NodelistBuilder nodeListBuilder = new NodelistBuilder()
- .withKey(new NodelistKey(input.getServiceName()))
- .setServiceName(input.getServiceName());
Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
- .nodelist.nodelist.NodesKey,
+ .nodelist.nodelist.NodesKey,
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
- .nodelist.nodelist.Nodes> nodeList =
- new HashMap<>();
+ .nodelist.nodelist.Nodes> nodeList = new HashMap<>();
if (input.getNodes() != null) {
for (Nodes node : input.getNodes()) {
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
nodeList.put(nodes.key(),nodes);
}
}
- nodeListBuilder.setNodes(nodeList);
InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
.service.nodelist.Nodelist> nodeListIID =
InstanceIdentifier.create(ServiceNodelist.class)
.child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
.service.nodelist.Nodelist.class, new NodelistKey(input.getServiceName()));
final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
+ writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
+ nodeListIID,
+ new NodelistBuilder()
+ .withKey(new NodelistKey(input.getServiceName()))
+ .setServiceName(input.getServiceName())
+ .setNodes(nodeList)
+ .build());
FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
try {
commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
}
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "SLF4J_FORMAT_SHOULD_BE_CONST",
+ justification = "Log messages content needs to be formatted before"
+ + "since they are used in the returned object")
@Override
public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
- CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
- String result = "";
- Boolean success = false;
+ if (!this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
+ String result = input.getNodeId() + IS_NOT_MOUNTED_ON_THE_CONTROLLER;
+ LOG.warn(result);
+ return new CreateOtsOmsOutputBuilder().setResult(result).setSuccess(false).build();
+ }
// if the node is currently mounted then proceed.
- if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
- Mapping oldMapping = null;
- Mapping newMapping = null;
- oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
- if (oldMapping != null) {
- String otsInterface =
- this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
- newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
- int count = 0;
- Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
- while (!isSupportingOtsPresent && (count < 6)) {
- LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
- try {
- Thread.sleep(10000);
- this.portMapping.updateMapping(input.getNodeId(), oldMapping);
- } catch (InterruptedException e) {
- LOG.error("Failed to wait for post interface operation ");
- }
- newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
- isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
- count++;
- }
- if (count < 6) {
- String omsInterface =
- this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
- if (omsInterface != null) {
- result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
- + input.getNodeId();
- success = true;
- } else {
- LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
- result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
- }
- } else {
- LOG.error("Unable to get ots interface from mapping {} for node {}",
- oldMapping.getLogicalConnectionPoint(), input.getNodeId());
- result = String.format("Unable to get ots interface from mapping %s - %s",
- oldMapping.getLogicalConnectionPoint(), input.getNodeId());
- }
- } else {
- result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
- + input.getNodeId();
+ Mapping oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
+ if (oldMapping == null) {
+ return new CreateOtsOmsOutputBuilder()
+ .setResult(String.format("Logical Connection point %s does not exist for %s",
+ input.getLogicalConnectionPoint(), input.getNodeId()))
+ .setSuccess(false)
+ .build();
+ }
+
+ String otsInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
+ int count = 0;
+ Mapping newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
+ while (!isSupportingOtsPresent(newMapping)) {
+ LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
+ try {
+ Thread.sleep(10000);
+ this.portMapping.updateMapping(input.getNodeId(), oldMapping);
+ } catch (InterruptedException e) {
+ LOG.error("Failed to wait for post interface operation");
}
- } else {
- result = input.getNodeId() + IS_NOT_MOUNTED_ON_THE_CONTROLLER;
- LOG.warn("{} is not mounted on the controller",input.getNodeId());
+ count++;
+ if (count >= 6) {
+ String result = String.format("Unable to get ots interface from mapping %s - %s",
+ oldMapping.getLogicalConnectionPoint(), input.getNodeId());
+ LOG.error(result);
+ return new CreateOtsOmsOutputBuilder().setResult(result).setSuccess(false).build();
+ }
+ newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
}
- return output.setResult(result).setSuccess(success).build();
+
+ String omsInterface = this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
+ if (omsInterface == null) {
+ String result = String.format("Fail to create OpenRoadmOms Interface for node : %s", input.getNodeId());
+ LOG.error(result);
+ return new CreateOtsOmsOutputBuilder().setResult(result).setSuccess(false).build();
+ }
+ return new CreateOtsOmsOutputBuilder()
+ .setResult(String.format("Interfaces %s - %s successfully created on node %s",
+ otsInterface, omsInterface, input.getNodeId()))
+ .setSuccess(true)
+ .build();
}
private Boolean isSupportingOtsPresent(Mapping mapping) {
- Boolean result = false;
- if (mapping != null) {
- if (mapping.getSupportingOts() != null) {
- LOG.info("SupportingOts info is present in mapping {}", mapping);
- result = true;
- } else {
- LOG.warn("SupportingOts info not present in mapping {}", mapping);
- }
+ if (mapping == null) {
+ return false;
+ }
+ if (mapping.getSupportingOts() == null) {
+ LOG.warn("SupportingOts info is not present in mapping {}", mapping);
+ return false;
}
- return result;
+ LOG.info("SupportingOts info is present in mapping {}", mapping);
+ return true;
}
}
private DeviceRenderingResult(boolean success, String message, List<Nodes> olmList,
List<NodeInterface> renderedNodeInterfaces, List<LinkTp> otnLinkTps) {
super(success, message);
- if (olmList != null) {
- this.olmList = Collections.unmodifiableList(olmList);
- } else {
- this.olmList = Collections.emptyList();
- }
- if (renderedNodeInterfaces != null) {
- this.renderedNodeInterfaces = Collections.unmodifiableList(renderedNodeInterfaces);
- } else {
- this.renderedNodeInterfaces = Collections.emptyList();
- }
- if (otnLinkTps != null) {
- this.otnLinkTps = Collections.unmodifiableList(otnLinkTps);
- } else {
- this.otnLinkTps = Collections.emptyList();
- }
+ this.olmList =
+ olmList == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(olmList);
+ this.renderedNodeInterfaces =
+ renderedNodeInterfaces == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(renderedNodeInterfaces);
+ this.otnLinkTps =
+ otnLinkTps == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(otnLinkTps);
}
public List<Nodes> getOlmList() {
}
public static DeviceRenderingResult ok(List<Nodes> olmNodeList, List<NodeInterface> renderedNodeInterfaces,
- List<LinkTp> otnLinkTps) {
+ List<LinkTp> otnLinkTps) {
return new DeviceRenderingResult(true, "", olmNodeList, renderedNodeInterfaces, otnLinkTps);
}
this.networkModelService = networkModelService;
}
+//TODO Align log messages and returned results messages
@Override
public OtnServicePathOutput setupOtnServicePath(OtnServicePathInput input) {
LOG.info("Calling setup otn-service path");
- boolean success = true;
- List<NodeInterface> nodeInterfaces = new ArrayList<>();
- List<String> results = new ArrayList<>();
if (input.getServiceFormat() == null || input.getServiceRate() == null) {
- OtnServicePathOutputBuilder otnServicePathOutputBuilder = new OtnServicePathOutputBuilder()
+ return new OtnServicePathOutputBuilder()
.setSuccess(false)
- .setResult("Error - service-type and service-rate must be presents");
- return otnServicePathOutputBuilder.build();
+ .setResult("Error - service-type and service-rate must be present")
+ .build();
}
+ List<NodeInterface> nodeInterfaces = new ArrayList<>();
CopyOnWriteArrayList<LinkTp> otnLinkTps = new CopyOnWriteArrayList<>();
String serviceType = ServiceTypes.getOtnServiceType(input.getServiceFormat(), input.getServiceRate());
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_1GE:
- case StringConstants.SERVICE_TYPE_10GE:
- case StringConstants.SERVICE_TYPE_100GE_M:
- try {
+ 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(),
createLowOrderInterfaces(input, nodeInterfaces, otnLinkTps);
LOG.info("Node interfaces created just fine ");
}
- } catch (OpenRoadmInterfaceException e) {
- LOG.warn("Set up service path failed", e);
- success = false;
- }
- break;
- case StringConstants.SERVICE_TYPE_ODU4:
- try {
+ break;
+ case StringConstants.SERVICE_TYPE_ODU4:
createODU4TtpInterface(input, nodeInterfaces, otnLinkTps);
- } catch (OpenRoadmInterfaceException e) {
- LOG.warn("Set up service path failed", e);
- success = false;
- }
- break;
- case StringConstants.SERVICE_TYPE_ODUC4:
- try {
+ break;
+ case StringConstants.SERVICE_TYPE_ODUC4:
createOduc4TtpInterface(input, nodeInterfaces, otnLinkTps);
- } catch (OpenRoadmInterfaceException e) {
- LOG.warn("Set up service path failed", e);
- success = false;
- }
- break;
- default:
- LOG.error("service-type {} not managed yet", serviceType);
- break;
- }
- if (success) {
- LOG.info("Result is success");
+ break;
+ default:
+ LOG.error("Service-type {} not managed yet", serviceType);
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(false)
+ .setResult("Service-type not managed")
+ .build();
+ }
+ } catch (OpenRoadmInterfaceException e) {
+ LOG.warn("Service path set-up failed", e);
+ Map<NodeInterfaceKey,NodeInterface> nodeInterfacesMap = new HashMap<>();
for (NodeInterface nodeInterface : nodeInterfaces) {
- results.add("Otn Service path was set up successfully for node :" + nodeInterface.getNodeId());
+ 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();
}
+ 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);
}
}
- OtnServicePathOutputBuilder otnServicePathOutputBuilder = new OtnServicePathOutputBuilder()
- .setSuccess(success)
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(true)
.setNodeInterface(nodeInterfacesMap)
.setResult(String.join("\n", results))
- .setLinkTp(otnLinkTps);
- return otnServicePathOutputBuilder.build();
+ .setLinkTp(otnLinkTps)
+ .build();
}
public OtnServicePathOutput deleteOtnServicePath(OtnServicePathInput input) {
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();
+ 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);
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 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());
+ 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().intValue()) {
- case 100:
- if ("ODU".equals(input.getServiceFormat())) {
- interfacesToDelete.add(networkTp + "-ODU4");
- 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");
- if (node.getNetwork2Tp() != null) {
- interfacesToDelete.add(node.getNetwork2Tp() + "-ODUC4");
- }
- }
- break;
- case 10:
- connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU2e");
- break;
- case 1:
- connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU0");
- break;
- default:
- LOG.error("service rate {} not managed yet", input.getServiceRate());
- String result = input.getServiceRate() + " is not supported";
- results.add(result);
- success.set(false);
- return;
- }
- List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, true);
- if (intToDelete != null) {
- for (String interf : intToDelete) {
- if (!this.openRoadmInterfaceFactory.isUsedByOtnXc(nodeId, interf, connectionNumber,
- this.deviceTransactionManager)) {
-
- interfacesToDelete.add(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);
- }
- }
- }
- }
- }
- } else {
+ if (!this.deviceTransactionManager.isDeviceMounted(nodeId)) {
String result = nodeId + " is not mounted on the controller";
results.add(result);
success.set(false);
return;
// TODO should deletion end here?
}
+ // if the node is currently mounted then proceed.
+ List<String> interfacesToDelete = new LinkedList<>();
+ String connectionNumber = "";
+ switch (input.getServiceRate().intValue()) {
+ case 100:
+ if ("ODU".equals(input.getServiceFormat())) {
+ interfacesToDelete.add(networkTp + "-ODU4");
+ 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");
+ if (node.getNetwork2Tp() != null) {
+ interfacesToDelete.add(node.getNetwork2Tp() + "-ODUC4");
+ }
+ }
+ break;
+ case 10:
+ connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU2e");
+ break;
+ case 1:
+ connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU0");
+ break;
+ default:
+ LOG.error("service rate {} not managed yet", input.getServiceRate());
+ String result = input.getServiceRate() + " 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 (input.getServiceRate().intValue() == 100) {
+ if (!supportedInterface.contains("ODUC4")) {
+ interfacesToDelete.add(supportedInterface);
+ }
+ } else {
+ if (!supportedInterface.contains("ODU4")) {
+ interfacesToDelete.add(supportedInterface);
+ }
+ }
+ }
+ }
+
for (String interfaceId : interfacesToDelete) {
try {
this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
results.add(result);
}
}
- List<String> interList = interfacesToDelete.stream().filter(ele -> ele.contains("NETWORK"))
- .collect(Collectors.toList());
+ List<String> interList =
+ interfacesToDelete.stream().filter(ele -> ele.contains("NETWORK")).collect(Collectors.toList());
if (!interList.isEmpty()) {
for (String inter : interList) {
- String tp = inter.split("-ODU")[0];
- LinkTp otnLinkTp = new LinkTpBuilder()
- .setNodeId(nodeId)
- .setTpId(tp)
- .build();
- otnLinkTps.add(otnLinkTp);
+ otnLinkTps.add(new LinkTpBuilder()
+ .setNodeId(nodeId)
+ .setTpId(inter.split("-ODU")[0])
+ .build());
}
}
}));
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();
+ return new OtnServicePathOutputBuilder()
+ .setResult("Error while deleting service paths!")
+ .setSuccess(false)
+ .build();
}
forkJoinPool.shutdown();
- OtnServicePathOutputBuilder delServBldr = new OtnServicePathOutputBuilder()
- .setSuccess(success.get())
- .setLinkTp(otnLinkTps);
- if (results.isEmpty()) {
- return delServBldr.setResult("Request processed").build();
- } else {
- return delServBldr.setResult(String.join("\n", results)).build();
- }
+ return new OtnServicePathOutputBuilder()
+ .setSuccess(success.get())
+ .setLinkTp(otnLinkTps)
+ .setResult(
+ results.isEmpty()
+ ? "Request processed"
+ : String.join("\n", results))
+ .build();
}
private String getConnectionNumber(String serviceName, Nodes node, String networkTp, String oduType) {
createdOduInterfaces.add(
openRoadmInterfaceFactory.createOpenRoadmOdu0Interface(node.getNodeId(), node.getNetworkTp(),
input.getServiceName(), PT_07, true, input.getTribPortNumber(), input.getTribSlot()));
- LinkTp otnLinkTp = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp);
+ 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(), PT_07, true, input.getTribPortNumber(),
input.getTribSlot()));
- LinkTp otnLinkTp2 = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp2);
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
}
break;
case 10:
// supporting interface? payload ?
openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(), node.getNetworkTp(),
input.getServiceName(), PT_03, true, input.getTribPortNumber(), input.getTribSlot()));
- LinkTp otnLinkTp3 = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp3);
+ 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(), input.getServiceName(), PT_03, true, input.getTribPortNumber(),
input.getTribSlot()));
- LinkTp otnLinkTp4 = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp4);
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
}
break;
case 100:
openRoadmInterfaceFactory.createOpenRoadmOtnOdu4LoInterface(node.getNodeId(),
node.getNetworkTp(), input.getServiceName(), PT_07, true, minOpucnTs,
maxOpucnTs));
- LinkTp otnLinkTp5 = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp5);
+ 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) {
openRoadmInterfaceFactory.createOpenRoadmOtnOdu4LoInterface(node.getNodeId(),
node.getNetwork2Tp(), input.getServiceName(), PT_07, true, minOpucnTs,
maxOpucnTs));
- LinkTp otnLinkTp6 = new LinkTpBuilder()
- .setNodeId(node.getNodeId())
- .setTpId(node.getNetworkTp())
- .build();
- linkTpList.add(otnLinkTp6);
+ linkTpList.add(
+ new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
}
break;
default:
createdConnections.add(connectionNameOpt.get());
LOG.info("Created cross connects");
}
- NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
- .withKey(new NodeInterfaceKey(node.getNodeId()))
- .setNodeId(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());
}
}
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()) {
+
+ Nodes tgtNode =
+ 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()));
+ ? input.getNodes().get(0)
+ : input.getNodes().get(i + 1);
- 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());
- LinkTp otnLinkTp = new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build();
- linkTpList.add(otnLinkTp);
+ nodeInterfaces.add(new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setOduInterfaceId(List.of(
+ // though this is odu, actually it has ODUC4 interfaces
+ openRoadmInterfaceFactory.createOpenRoadmOtnOduc4Interface(node.getNodeId(),
+ node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp())))
+ .build());
+ linkTpList.add(new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
}
}
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()) {
+
+ Nodes tgtNode =
+ 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);
- }
+ ? input.getNodes().get(0)
+ : input.getNodes().get(i + 1);
- createdOdu4Interfaces.add(openRoadmInterfaceFactory.createOpenRoadmOtnOdu4Interface(node.getNodeId(),
- node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp()));
- NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
- .withKey(new NodeInterfaceKey(node.getNodeId()))
- .setNodeId(node.getNodeId())
- .setOduInterfaceId(createdOdu4Interfaces);
- nodeInterfaces.add(nodeInterfaceBuilder.build());
- LinkTp otnLinkTp = new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build();
- linkTpList.add(otnLinkTp);
+ nodeInterfaces.add(new NodeInterfaceBuilder()
+ .withKey(new NodeInterfaceKey(node.getNodeId()))
+ .setNodeId(node.getNodeId())
+ .setOduInterfaceId(List.of(
+ openRoadmInterfaceFactory.createOpenRoadmOtnOdu4Interface(node.getNodeId(),
+ node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp())))
+ .build());
+ linkTpList.add(new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
}
}
}
private OtnDeviceRenderingResult(boolean success, String message, List<NodeInterface> renderedNodeInterfaces,
- List<LinkTp> otnLinkTps) {
+ List<LinkTp> otnLinkTps) {
super(success, message);
- if (renderedNodeInterfaces != null) {
- this.renderedNodeInterfaces = Collections.unmodifiableList(renderedNodeInterfaces);
- } else {
- this.renderedNodeInterfaces = Collections.emptyList();
- }
- if (otnLinkTps != null) {
- this.otnLinkTps = Collections.unmodifiableList(otnLinkTps);
- } else {
- this.otnLinkTps = Collections.emptyList();
- }
+ this.renderedNodeInterfaces =
+ renderedNodeInterfaces == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(renderedNodeInterfaces);
+ this.otnLinkTps =
+ otnLinkTps == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(otnLinkTps);
}
public List<NodeInterface> getRenderedNodeInterfaces() {
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.RendererRpcResultSp;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.RendererRpcResultSpBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceDeleteInput;
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
RpcStatusEx.Pending, "Service compliant, submitting service implementation Request ...");
Uint32 serviceRate = getServiceRate(input);
- String serviceType;
- if (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId())
+ String serviceType = ServiceTypes.getServiceType(
+ input.getServiceAEnd().getServiceFormat().getName(),
+ serviceRate,
+ (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId())
.getNodeInfo().getNodeType())
- && input.getServiceAEnd().getTxDirection() != null
- && input.getServiceAEnd().getTxDirection().getPort() != null
- && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null) {
- Mapping mapping = portMapping.getMapping(input.getServiceAEnd().getNodeId(),
- input.getServiceAEnd().getTxDirection().getPort().getPortName());
- serviceType = ServiceTypes.getServiceType(input.getServiceAEnd().getServiceFormat().getName(),
- serviceRate, mapping);
- } else {
- serviceType = ServiceTypes.getServiceType(input.getServiceAEnd().getServiceFormat().getName(),
- serviceRate, null);
- }
+ && input.getServiceAEnd().getTxDirection() != null
+ && input.getServiceAEnd().getTxDirection().getPort() != null
+ && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null)
+ ? portMapping.getMapping(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getTxDirection().getPort().getPortName())
+ : null);
switch (serviceType) {
case StringConstants.SERVICE_TYPE_100GE_T:
break;
default:
LOG.error("unsupported service-type");
- break;
+ return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_OK,
OPERATION_SUCCESSFUL);
Optional<
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.service
.path.PathDescription> pathDescriptionOpt = getPathDescriptionFromDatastore(serviceName);
- PathDescription pathDescription;
- if (pathDescriptionOpt.isPresent()) {
- pathDescription = pathDescriptionOpt.get();
- } else {
+ if (pathDescriptionOpt.isEmpty()) {
LOG.error("Unable to get path description for service {}!", serviceName);
sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName,
RpcStatusEx.Failed, "Unable to get path description for service");
return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
OPERATION_FAILED);
}
+ PathDescription pathDescription = pathDescriptionOpt.get();
String serviceType = ServiceTypes.getServiceType(service.getServiceAEnd().getServiceFormat().getName(),
service.getServiceAEnd().getServiceRate(), null);
switch (serviceType) {
break;
default:
LOG.error("unsupported service-type");
- break;
+ return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_OK, OPERATION_SUCCESSFUL);
}
if (input.getServiceAEnd().getServiceRate() != null) {
return input.getServiceAEnd().getServiceRate();
}
- if (ServiceFormat.OTU.equals(input.getServiceAEnd().getServiceFormat())
- && input.getServiceAEnd().getOtuServiceRate() != null) {
- switch (input.getServiceAEnd().getOtuServiceRate().getSimpleName()) {
- case "OTUCn":
- return Uint32.valueOf(400);
- case "OTU4":
- return Uint32.valueOf(100);
- case "OTU2":
- case "OTU2e":
- return Uint32.valueOf(10);
- default:
- LOG.warn("otu-service-rate {} not managed yet", input.getServiceAEnd().getOtuServiceRate()
- .getSimpleName());
- return Uint32.ZERO;
- }
- } else if (ServiceFormat.ODU.equals(input.getServiceAEnd().getServiceFormat())
- && input.getServiceAEnd().getOduServiceRate() != null) {
- switch (input.getServiceAEnd().getOduServiceRate().getSimpleName()) {
- case "ODUCn":
- return Uint32.valueOf(400);
- case "ODU4":
- return Uint32.valueOf(100);
- case "ODU2":
- case "ODU2e":
- return Uint32.valueOf(10);
- case "ODU0":
- return Uint32.valueOf(1);
- default:
- LOG.warn("odu-service-rate {} not managed yet", input.getServiceAEnd().getOduServiceRate()
- .getSimpleName());
- return Uint32.ZERO;
- }
- } else {
- LOG.warn("Unable to get service-rate for service {} - otu-service-rate should not be null",
- input.getServiceName());
+ Map<ServiceFormat, Map<String, Uint32>> formatRateMap = Map.of(
+ ServiceFormat.OTU, Map.of(
+ "OTUCn", Uint32.valueOf(400),
+ "OTU4", Uint32.valueOf(100),
+ "OTU2", Uint32.valueOf(10),
+ "OTU2e", Uint32.valueOf(10)),
+ ServiceFormat.ODU, Map.of(
+ "ODUCn",Uint32.valueOf(400),
+ "ODU4", Uint32.valueOf(100),
+ "ODU2", Uint32.valueOf(10),
+ "ODU2e", Uint32.valueOf(10),
+ "ODU0", Uint32.valueOf(1)));
+ if (!formatRateMap.containsKey(input.getServiceAEnd().getServiceFormat())) {
+ LOG.warn("Unable to get service-rate for service {} - unsupported service format {}",
+ input.getServiceName(), input.getServiceAEnd().getServiceFormat());
+ return Uint32.ZERO;
+ }
+ String serviceName =
+ ServiceFormat.OTU.equals(input.getServiceAEnd().getServiceFormat())
+ ? input.getServiceAEnd().getOtuServiceRate().getSimpleName()
+ : input.getServiceAEnd().getOduServiceRate().getSimpleName();
+ if (!formatRateMap.get(input.getServiceAEnd().getServiceFormat()).containsKey(serviceName)) {
+ LOG.warn("Unable to get service-rate for service {} - unsupported service name {}",
+ input.getServiceName(), serviceName);
return Uint32.ZERO;
}
+ return formatRateMap.get(input.getServiceAEnd().getServiceFormat()).get(serviceName);
}
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
LOG.info("Starting service activation test on node {} and tp {}", nodeId, tpId);
for (int i = 0; i < 3; i++) {
List<Measurements> measurements = getMeasurements(nodeId, tpId);
- if ((measurements != null) && verifyPreFecBer(measurements)) {
- return true;
- } else if (measurements == null) {
+ if (measurements == null) {
LOG.warn("Device {} is not reporting PreFEC on TP: {}", nodeId, tpId);
return true;
- } else {
- try {
- Thread.sleep(Timeouts.SERVICE_ACTIVATION_TEST_RETRY_TIME);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
+ }
+ if (verifyPreFecBer(measurements)) {
+ return true;
+ }
+ try {
+ Thread.sleep(Timeouts.SERVICE_ACTIVATION_TEST_RETRY_TIME);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
}
}
LOG.error("Service activation test failed on node {} and termination point {}!", nodeId, tpId);
}
private List<Measurements> getMeasurements(String nodeId, String tp) {
- GetPmInputBuilder getPmIpBldr = new GetPmInputBuilder();
- getPmIpBldr.setNodeId(nodeId);
- getPmIpBldr.setGranularity(PmGranularity._15min);
- ResourceIdentifierBuilder rsrcBldr = new ResourceIdentifierBuilder();
- rsrcBldr.setResourceName(tp + "-OTU");
- getPmIpBldr.setResourceIdentifier(rsrcBldr.build());
- getPmIpBldr.setResourceType(ResourceTypeEnum.Interface);
+ GetPmInputBuilder getPmIpBldr = new GetPmInputBuilder()
+ .setNodeId(nodeId)
+ .setGranularity(PmGranularity._15min)
+ .setResourceIdentifier(new ResourceIdentifierBuilder().setResourceName(tp + "-OTU").build())
+ .setResourceType(ResourceTypeEnum.Interface);
try {
Future<RpcResult<GetPmOutput>> getPmFuture = this.olmService.getPm(getPmIpBldr.build());
double fecUncorrectableBlocks = Double.MIN_VALUE;
for (Measurements measurement : measurements) {
- if (measurement.getPmparameterName().equals("preFECCorrectedErrors")) {
- preFecCorrectedErrors = Double.parseDouble(measurement.getPmparameterValue());
- }
- if (measurement.getPmparameterName().equals("FECUncorrectableBlocks")) {
- fecUncorrectableBlocks = Double.parseDouble(measurement.getPmparameterValue());
+ switch (measurement.getPmparameterName()) {
+ case "preFECCorrectedErrors":
+ preFecCorrectedErrors = Double.parseDouble(measurement.getPmparameterValue());
+ break;
+ case "FECUncorrectableBlocks":
+ fecUncorrectableBlocks = Double.parseDouble(measurement.getPmparameterValue());
+ break;
+ default:
+ break;
}
}
if (fecUncorrectableBlocks > Double.MIN_VALUE) {
LOG.error("Data has uncorrectable errors, BER test failed");
return false;
- } else {
- double numOfBitsPerSecond = 112000000000d;
- double threshold = 0.00002d;
- double result = preFecCorrectedErrors / numOfBitsPerSecond;
- LOG.info("PreFEC value is {}", Double.toString(result));
- return result <= threshold;
}
+
+ double numOfBitsPerSecond = 112000000000d;
+ double threshold = 0.00002d;
+ double result = preFecCorrectedErrors / numOfBitsPerSecond;
+ LOG.info("PreFEC value is {}", Double.toString(result));
+ return result <= threshold;
}
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
Nodes sourceNode = nodes.get(0);
Nodes destNode = nodes.get(nodes.size() - 1);
- String srcNetworkTp;
- String dstNetowrkTp;
- if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
- srcNetworkTp = sourceNode.getDestTp();
- } else {
- srcNetworkTp = sourceNode.getSrcTp();
- }
- if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
- dstNetowrkTp = destNode.getDestTp();
- } else {
- dstNetowrkTp = destNode.getSrcTp();
- }
+ String srcNetworkTp =
+ sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)
+ ? sourceNode.getDestTp()
+ : sourceNode.getSrcTp();
+ String dstNetowrkTp =
+ destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)
+ ? destNode.getDestTp()
+ : destNode.getSrcTp();
+
if (!isServiceActivated(sourceNode.getNodeId(), srcNetworkTp)
|| !isServiceActivated(destNode.getNodeId(), dstNetowrkTp)) {
rollbackProcessor.rollbackAll();
}
private Link createLinkForNotif(List<LinkTp> otnLinkTerminationPoints) {
- if (otnLinkTerminationPoints.size() != 2 || otnLinkTerminationPoints.isEmpty()) {
+ if (otnLinkTerminationPoints == null || otnLinkTerminationPoints.size() != 2) {
return null;
- } else {
- return new LinkBuilder()
+ }
+ return new LinkBuilder()
.setATermination(new ATerminationBuilder()
.setNodeId(otnLinkTerminationPoints.get(0).getNodeId())
.setTpId(otnLinkTerminationPoints.get(0).getTpId())
.setTpId(otnLinkTerminationPoints.get(1).getTpId())
.build())
.build();
- }
}
}
@Override
public DeviceRenderingResult call() throws Exception {
ServicePathOutput output;
+ String operation;
+ List<Nodes> olmList = null;
switch (this.servicePathInputData.getServicePathInput().getOperation()) {
case Create:
+ operation = "setup";
output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(),
this.direction);
- if (!output.getSuccess()) {
- LOG.error("Device rendering setup service path failed.");
- return DeviceRenderingResult.failed("Operation Failed");
- }
- List<Nodes> olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
- LOG.info("Device rendering setup service path finished successfully.");
- return DeviceRenderingResult.ok(olmList, new ArrayList<>(output.nonnullNodeInterface().values()),
- new ArrayList<>(output.nonnullLinkTp()));
+ olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
+ break;
case Delete:
+ operation = "delete";
output = this.deviceRenderer.deleteServicePath(this.servicePathInputData.getServicePathInput());
- if (!output.getSuccess()) {
- LOG.error("Device rendering delete service path failed.");
- return DeviceRenderingResult.failed("Operation Failed");
- }
- LOG.info("Device rendering delete service path finished successfully.");
- return DeviceRenderingResult.ok(null, new ArrayList<>(output.nonnullNodeInterface().values()),
- new ArrayList<>(output.nonnullLinkTp()));
+ break;
default:
- return DeviceRenderingResult.failed("Device rendering failed - unknwon operation");
+ return DeviceRenderingResult.failed("Device rendering failed - unknown operation");
}
+ if (!output.getSuccess()) {
+ LOG.error("Device rendering {} service path failed.", operation);
+ return DeviceRenderingResult.failed("Operation Failed");
+ }
+ LOG.info("Device rendering {} service path finished successfully.", operation);
+ return DeviceRenderingResult.ok(olmList, new ArrayList<>(output.nonnullNodeInterface().values()),
+ new ArrayList<>(output.nonnullLinkTp()));
+
}
}
@Override
public OtnDeviceRenderingResult call() throws Exception {
OtnServicePathOutput output;
+ String operation;
switch (this.otnServicePathInput.getOperation()) {
case Create:
+ operation = "setup";
output = this.otnDeviceRenderer.setupOtnServicePath(this.otnServicePathInput);
- if (!output.getSuccess()) {
- LOG.error("Device rendering setup otn service path failed.");
- return OtnDeviceRenderingResult.failed("Operation Failed");
- }
- LOG.info("Device rendering setup otn service path finished successfully.");
- return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
- new ArrayList<>(output.nonnullLinkTp()));
+ break;
case Delete:
+ operation = "delete";
output = this.otnDeviceRenderer.deleteOtnServicePath(this.otnServicePathInput);
- if (!output.getSuccess()) {
- LOG.error("Device rendering delete otn service path failed.");
- return OtnDeviceRenderingResult.failed("Operation Failed");
- }
- LOG.info("Device rendering delete otn service path finished successfully.");
- return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
- new ArrayList<>(output.nonnullLinkTp()));
+ break;
default:
- return OtnDeviceRenderingResult.failed("Device rendering failed - unknwon operation");
+ return OtnDeviceRenderingResult.failed("Device rendering failed - unknown operation");
}
+ if (!output.getSuccess()) {
+ LOG.error("Device rendering {} otn service path failed.", operation);
+ return OtnDeviceRenderingResult.failed("Operation Failed");
+ }
+ LOG.info("Device rendering {} otn service path finished successfully.", operation);
+ return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
+ new ArrayList<>(output.nonnullLinkTp()));
}
}
package org.opendaylight.transportpce.servicehandler.listeners;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Map;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder;
-import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private void onServiceDeleteResult(RendererRpcResultSp notification) {
switch (serviceRpcResultSp.getStatus()) {
case Successful:
- String serviceType = notification.getServiceType();
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_1GE:
- case StringConstants.SERVICE_TYPE_10GE:
- case StringConstants.SERVICE_TYPE_100GE_M:
- Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[0]);
- Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[1]);
- Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
- .split("\\.")[1]);
- updateOtnTopology(notification.getLink(), true, notification.getServiceType(),
- notification.getAToZDirection().getRate(), tribPort, minTribSlot, maxTribSlot);
- break;
- case StringConstants.SERVICE_TYPE_OTU4:
- case StringConstants.SERVICE_TYPE_OTUC4:
- case StringConstants.SERVICE_TYPE_ODU4:
- case StringConstants.SERVICE_TYPE_ODUC4:
- updateOtnTopology(notification.getLink(), true, notification.getServiceType(), null, null,
- null, null);
- break;
- default:
- break;
- }
+ updateOtnTopology(notification, true);
break;
case Failed:
LOG.error("Renderer service delete failed !");
LOG.debug("serviceDataStoreOperations is null");
return;
}
- String serviceType = notification.getServiceType();
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_1GE:
- case StringConstants.SERVICE_TYPE_10GE:
- case StringConstants.SERVICE_TYPE_100GE_M:
- Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[0]);
- Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[1]);
- Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
- .split("\\.")[1]);
- updateOtnTopology(notification.getLink(), false, notification.getServiceType(),
- notification.getAToZDirection().getRate(), tribPort, minTribSlot, maxTribSlot);
- break;
- case StringConstants.SERVICE_TYPE_OTU4:
- case StringConstants.SERVICE_TYPE_OTUC4:
- case StringConstants.SERVICE_TYPE_ODU4:
- case StringConstants.SERVICE_TYPE_ODUC4:
- updateOtnTopology(notification.getLink(), false, notification.getServiceType(), null, null, null, null);
- break;
- default:
- break;
- }
+
+ updateOtnTopology(notification, false);
+
PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder()
.setServiceName(input.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
value = "ES_COMPARING_STRINGS_WITH_EQ",
justification = "false positives, not strings but real object references comparisons")
private Boolean compareServiceRpcResultSp(RendererRpcResultSp notification) {
- if (serviceRpcResultSp == null) {
- return false;
- }
- if (serviceRpcResultSp.getNotificationType() != notification.getNotificationType()) {
- return false;
- }
- if (serviceRpcResultSp.getServiceName() != notification.getServiceName()) {
- return false;
- }
- if (serviceRpcResultSp.getStatus() != notification.getStatus()) {
- return false;
- }
- if (serviceRpcResultSp.getStatusMessage() != notification.getStatusMessage()) {
+ if (serviceRpcResultSp == null
+ || serviceRpcResultSp.getNotificationType() != notification.getNotificationType()
+ || serviceRpcResultSp.getServiceName() != notification.getServiceName()
+ || serviceRpcResultSp.getStatus() != notification.getStatus()
+ || serviceRpcResultSp.getStatusMessage() != notification.getStatusMessage()) {
return false;
}
return true;
}
}
- private void updateOtnTopology(Link link, boolean isDeletion, String serviceType, Uint32 rate, Short portNb,
- Short minSlotNb, Short maxSlotNb) {
+
+ private void updateOtnTopology(RendererRpcResultSp notification, boolean isDeletion) {
+ Link link = notification.getLink();
if (link == null) {
return;
}
- OtnLinkType otnLinkType;
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_OTU4:
- otnLinkType = OtnLinkType.OTU4;
- break;
- case StringConstants.SERVICE_TYPE_OTUC4:
- otnLinkType = OtnLinkType.OTUC4;
- break;
- case StringConstants.SERVICE_TYPE_ODU4:
- otnLinkType = OtnLinkType.ODTU4;
- break;
- case StringConstants.SERVICE_TYPE_ODUC4:
- otnLinkType = OtnLinkType.ODUC4;
- break;
- default:
- otnLinkType = null;
- LOG.warn("No otn-link-type corresponds to service-type {}", serviceType);
- break;
- }
+
+ String serviceType = notification.getServiceType();
switch (serviceType) {
case StringConstants.SERVICE_TYPE_OTU4:
case StringConstants.SERVICE_TYPE_OTUC4:
case StringConstants.SERVICE_TYPE_ODU4:
case StringConstants.SERVICE_TYPE_ODUC4:
+ Map<String, OtnLinkType> otnLinkTypeMap = Map.of(
+ StringConstants.SERVICE_TYPE_OTU4, OtnLinkType.OTU4,
+ StringConstants.SERVICE_TYPE_OTUC4, OtnLinkType.OTUC4,
+ StringConstants.SERVICE_TYPE_ODU4, OtnLinkType.ODTU4,
+ StringConstants.SERVICE_TYPE_ODUC4, OtnLinkType.ODUC4);
if (isDeletion) {
LOG.info("updating otn-topology removing links");
this.networkModelService.deleteOtnLinks(link.getATermination().getNodeId(),
link.getATermination().getTpId(), link.getZTermination().getNodeId(),
- link.getZTermination().getTpId(), otnLinkType);
+ link.getZTermination().getTpId(), otnLinkTypeMap.get(serviceType));
} else {
LOG.info("updating otn-topology adding links");
this.networkModelService.createOtnLinks(link.getATermination().getNodeId(),
link.getATermination().getTpId(), link.getZTermination().getNodeId(),
- link.getZTermination().getTpId(), otnLinkType);
+ link.getZTermination().getTpId(), otnLinkTypeMap.get(serviceType));
}
break;
case StringConstants.SERVICE_TYPE_1GE:
case StringConstants.SERVICE_TYPE_10GE:
case StringConstants.SERVICE_TYPE_100GE_M:
+ Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
+ .split("\\.")[0]);
+ Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
+ .split("\\.")[1]);
+ Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
+ .split("\\.")[1]);
LOG.info("updating otn-topology node tps -tps and tpn pools");
- this.networkModelService.updateOtnLinks(link, rate, portNb, minSlotNb, maxSlotNb, isDeletion);
+ this.networkModelService.updateOtnLinks(link, notification.getAToZDirection().getRate(),
+ tribPort, minTribSlot, maxTribSlot, isDeletion);
break;
default:
break;