From 1badcea7eeb5bd7066749900658c06b027c75745 Mon Sep 17 00:00:00 2001 From: Gilles Thouenon Date: Wed, 7 Oct 2020 17:48:01 +0200 Subject: [PATCH] Add OTN links support in TAPI topology - Add OTN OTU4 and ODU4 links in TAPI topology. Replace 2 unidirectional OTU4 links in OpenROADM otn-topology by a single bidirectional Photonics link in TAPI. In the same way, replace 2 unidirectional ODU4 links in OpenROADM otn-topology by a single bidirectional ODU link in TAPI topology - add new Unitary tests for TAPI otn links - add a new sample OpenROADM otn-topology XML file containing more nodes with OTN links as input for UTs - adapt UUID creation to take into account new OTN topology context - wait that the XML input file has been written in datastore before getting topology from it in UT JIRA: TRNSPRTPCE-185 Signed-off-by: Gilles Thouenon Co-authored-by: Christophe Betoule Change-Id: I5c762f30d3bd290b98d04d7f960fb1077be3a111 (cherry picked from commit a01f4032cd7dc71e3f047db5b3e2db77c4733b2c) --- .../ConvertORTopoObjectToTapiTopoObject.java | 227 +++- .../tapi/topology/TapiTopologyImpl.java | 13 +- .../tapi/topology/TapiTopologyImplTest.java | 175 +++- .../tapi/utils/TopologyDataUtils.java | 25 +- .../resources/otn-topology-with-otn-links.xml | 968 ++++++++++++++++++ 5 files changed, 1321 insertions(+), 87 deletions(-) create mode 100644 tapi/src/test/resources/otn-topology-with-otn-links.xml diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoObjectToTapiTopoObject.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoObjectToTapiTopoObject.java index 7203fa124..12d81cb6d 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoObjectToTapiTopoObject.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoObjectToTapiTopoObject.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Term import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey; @@ -74,13 +75,13 @@ import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + public class ConvertORTopoObjectToTapiTopoObject { - private static final String DSR_PLUS = "DSR+"; - private static final String PLUS_DSR = "+DSR"; - private static final String OT_SI = "+OTSi"; - private static final String E_OT_SI = "eOTSi+"; - private static final String I_OT_SI = "iOTSi+"; + private static final String DSR = "DSR"; + private static final String OTSI = "OTSi"; + private static final String E_OTSI = "eOTSi"; + private static final String I_OTSI = "iOTSi"; private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoObjectToTapiTopoObject.class); private String ietfNodeId; private List oorClientPortList; @@ -92,7 +93,15 @@ public class ConvertORTopoObjectToTapiTopoObject { private Map tapiLinks; private Map uuidMap; - public ConvertORTopoObjectToTapiTopoObject(Node ietfNode, Link1 otnLink, Uuid tapiTopoUuid) { + + public ConvertORTopoObjectToTapiTopoObject(Uuid tapiTopoUuid) { + this.tapiTopoUuid = tapiTopoUuid; + this.tapiNodes = new HashMap<>(); + this.tapiLinks = new HashMap<>(); + this.uuidMap = new HashMap<>(); + } + + public void convertNode(Node ietfNode) { this.ietfNodeId = ietfNode.getNodeId().getValue(); this.oorClientPortList = ietfNode.augmentation( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) @@ -110,18 +119,12 @@ public class ConvertORTopoObjectToTapiTopoObject { .collect(Collectors.toList()); this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools() .values().stream().findFirst().get(); - this.tapiTopoUuid = tapiTopoUuid; - this.tapiNodes = new HashMap<>(); - this.tapiLinks = new HashMap<>(); - this.uuidMap = new HashMap<>(); - } - public void convertNode() { // node creation [DSR/ODU] LOG.info("creation of a DSR/ODU node"); - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((this.ietfNodeId + PLUS_DSR).getBytes(Charset.forName("UTF-8"))) - .toString()); - this.uuidMap.put(this.ietfNodeId + PLUS_DSR, nodeUuid); + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, DSR)) + .getBytes(Charset.forName("UTF-8"))).toString()); + this.uuidMap.put(String.join("+", this.ietfNodeId, DSR), nodeUuid); Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(this.ietfNodeId).build(); List dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, LayerProtocolName.ODU); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology @@ -130,9 +133,9 @@ public class ConvertORTopoObjectToTapiTopoObject { // node creation [otsi] LOG.info("creation of an OTSi node"); - nodeUuid = new Uuid(UUID.nameUUIDFromBytes((this.ietfNodeId + OT_SI).getBytes(Charset.forName("UTF-8"))) - .toString()); - this.uuidMap.put(this.ietfNodeId + OT_SI, nodeUuid); + nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, OTSI)) + .getBytes(Charset.forName("UTF-8"))).toString()); + this.uuidMap.put(String.join("+", this.ietfNodeId, OTSI), nodeUuid); Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(this.ietfNodeId).build(); List otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology @@ -144,6 +147,23 @@ public class ConvertORTopoObjectToTapiTopoObject { createTapiTransitionalLinks(); } + public void convertLinks(List + + otnLinkList) { + List linksToNotConvert = new ArrayList<>(); + LOG.info("creation of {} otn links", otnLinkList.size() / 2); + for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network + .Link link : otnLinkList) { + if (!linksToNotConvert.contains(link.getLinkId().getValue())) { + Link tapiLink = createTapiLink(link); + linksToNotConvert.add(link + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class) + .getOppositeLink().getValue()); + tapiLinks.put(tapiLink.key(), tapiLink); + } + } + } + private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology .Node createTapiNode(Map nodeNames, List layerProtocols) { Uuid nodeUuid = null; @@ -182,35 +202,41 @@ public class ConvertORTopoObjectToTapiTopoObject { private Uuid getNodeUuid4Phonic(Map onepl, Map nodeRuleGroupList, Map ruleList) { Uuid nodeUuid; - nodeUuid = this.uuidMap.get(this.ietfNodeId + OT_SI); + nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)); // iNep creation on otsi node for (int i = 0; i < oorNetworkPortList.size(); i++) { Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes( - (I_OT_SI + oorNetworkPortList.get(i).getTpId().getValue()).getBytes(Charset.forName("UTF-8"))) + (String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue())) + .getBytes(Charset.forName("UTF-8"))) .toString()); - this.uuidMap.put(I_OT_SI + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid1); + this.uuidMap.put(String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue()), + nepUuid1); Name onedName = new NameBuilder() .setValueName(new StringBuilder("iNodeEdgePoint_").append(i + 1).toString()) .setValue(oorNetworkPortList.get(i).getTpId().getValue()) .build(); OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName), - LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, I_OT_SI); + LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, + String.join("+", this.ietfNodeId, I_OTSI)); onepl.put(onep.key(), onep); } // eNep creation on otsi node for (int i = 0; i < oorNetworkPortList.size(); i++) { Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes( - (E_OT_SI + oorNetworkPortList.get(i).getTpId().getValue()).getBytes(Charset.forName("UTF-8"))) + (String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue())) + .getBytes(Charset.forName("UTF-8"))) .toString()); - this.uuidMap.put(E_OT_SI + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid2); + this.uuidMap.put(String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue()), + nepUuid2); Name onedName = new NameBuilder() .setValueName(new StringBuilder("eNodeEdgePoint_").append(i + 1).toString()) .setValue(oorNetworkPortList.get(i).getTpId().getValue()) .build(); OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName), - LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, E_OT_SI); + LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, + String.join("+", this.ietfNodeId, E_OTSI)); onepl.put(onep.key(), onep); } // create NodeRuleGroup @@ -223,15 +249,17 @@ public class ConvertORTopoObjectToTapiTopoObject { .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210 .node.rule.group.NodeEdgePointBuilder() .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(this.uuidMap.get(this.ietfNodeId + OT_SI)) - .setNodeEdgePointUuid(this.uuidMap.get(I_OT_SI + tp.getTpId().getValue())) + .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI))) + .setNodeEdgePointUuid( + this.uuidMap.get(String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue()))) .build(); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210 .node.rule.group.NodeEdgePointBuilder() .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(this.uuidMap.get(this.ietfNodeId + OT_SI)) - .setNodeEdgePointUuid(this.uuidMap.get(E_OT_SI + tp.getTpId().getValue())) + .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI))) + .setNodeEdgePointUuid( + this.uuidMap.get(String.join("+", this.ietfNodeId, E_OTSI, tp.getTpId().getValue()))) .build(); nepList.put(inep.key(), inep); nepList.put(enep.key(), enep); @@ -251,33 +279,37 @@ public class ConvertORTopoObjectToTapiTopoObject { private Uuid getNodeUuid4Dsr(Map onepl, Map nodeRuleGroupList, Map ruleList) { Uuid nodeUuid; - nodeUuid = this.uuidMap.get(this.ietfNodeId + PLUS_DSR); + nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, DSR)); // client nep creation on DSR/ODU node for (int i = 0; i < oorClientPortList.size(); i++) { - Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((DSR_PLUS + oorClientPortList.get(i).getTpId().getValue()) + Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue())) .getBytes(Charset.forName("UTF-8"))).toString()); - this.uuidMap.put(DSR_PLUS + oorClientPortList.get(i).getTpId().getValue(), nepUuid); + this.uuidMap.put(String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()), + nepUuid); Name name = new NameBuilder() .setValueName(new StringBuilder("NodeEdgePoint_C").append(i + 1).toString()) .setValue(oorClientPortList.get(i).getTpId().getValue()) .build(); OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name), - LayerProtocolName.ETH, LayerProtocolName.DSR, true, DSR_PLUS); + LayerProtocolName.ETH, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, DSR)); onepl.put(onep.key(), onep); } // network nep creation on DSR/ODU node for (int i = 0; i < oorNetworkPortList.size(); i++) { - Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((DSR_PLUS + oorNetworkPortList.get(i).getTpId().getValue()) + Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", this.ietfNodeId, DSR, oorNetworkPortList.get(i).getTpId().getValue())) .getBytes(Charset.forName("UTF-8"))).toString()); - this.uuidMap.put(DSR_PLUS + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid); + this.uuidMap.put(String.join("+", this.ietfNodeId, DSR, oorNetworkPortList.get(i).getTpId().getValue()), + nepUuid); Name onedName = new NameBuilder() .setValueName(new StringBuilder("NodeEdgePoint_N").append(i + 1).toString()) .setValue(oorNetworkPortList.get(i).getTpId().getValue()) .build(); OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName), - LayerProtocolName.ODU, LayerProtocolName.DSR, true, DSR_PLUS); + LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, DSR)); onepl.put(onep.key(), onep); } // create NodeRuleGroup @@ -291,8 +323,8 @@ public class ConvertORTopoObjectToTapiTopoObject { .NodeEdgePoint nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210 .node.rule.group.NodeEdgePointBuilder() .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(this.uuidMap.get(this.ietfNodeId + PLUS_DSR)) - .setNodeEdgePointUuid(this.uuidMap.get(DSR_PLUS + tp.getValue())) + .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR))) + .setNodeEdgePointUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR, tp.getValue()))) .build(); nepList.put(nep.key(), nep); } @@ -311,7 +343,7 @@ public class ConvertORTopoObjectToTapiTopoObject { private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map nepNames, LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) { - String key = keyword + oorTp.getTpId().getValue(); + String key = String.join("+", keyword, oorTp.getTpId().getValue()); OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder() .setUuid(this.uuidMap.get(key)) .setLayerProtocolName(nepProtocol) @@ -374,28 +406,28 @@ public class ConvertORTopoObjectToTapiTopoObject { private void createTapiTransitionalLinks() { for (TerminationPoint tp : this.oorNetworkPortList) { Map nepList = new HashMap<>(); - String sourceKey = DSR_PLUS + tp.getTpId().getValue(); + String sourceKey = String.join("+", this.ietfNodeId, DSR, tp.getTpId().getValue()); Uuid sourceUuidTp = this.uuidMap.get(sourceKey); - String destKey = I_OT_SI + tp.getTpId().getValue(); + String destKey = String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue()); Uuid destUuidTp = this.uuidMap.get(destKey); NodeEdgePoint sourceNep = new NodeEdgePointBuilder() .setTopologyUuid(this.tapiTopoUuid) - .setNodeUuid(this.uuidMap.get(this.ietfNodeId + PLUS_DSR)) + .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR))) .setNodeEdgePointUuid(sourceUuidTp) .build(); nepList.put(sourceNep.key(), sourceNep); NodeEdgePoint destNep = new NodeEdgePointBuilder() .setTopologyUuid(this.tapiTopoUuid) - .setNodeUuid(this.uuidMap.get(this.ietfNodeId + OT_SI)) + .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI))) .setNodeEdgePointUuid(destUuidTp) .build(); nepList.put(destNep.key(), destNep); Name linkName = new NameBuilder().setValueName("transitional link name") - .setValue(this.ietfNodeId + "-" + sourceKey + "--" + destKey) + .setValue(String.join("--", this.ietfNodeId, sourceKey, destKey)) .build(); Link transiLink = new LinkBuilder() .setUuid(new Uuid( - UUID.nameUUIDFromBytes((this.ietfNodeId + "-" + sourceKey + "--" + destKey) + UUID.nameUUIDFromBytes((String.join("--", this.ietfNodeId, sourceKey, destKey)) .getBytes(Charset.forName("UTF-8"))) .toString())) .setName(Map.of(linkName.key(), linkName)) @@ -410,6 +442,104 @@ public class ConvertORTopoObjectToTapiTopoObject { } } + private Link createTapiLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.Link link) { + String prefix = link.getLinkId().getValue().split("-")[0]; + String sourceNode = link.getSource().getSourceNode().getValue(); + String sourceTp = link.getSource().getSourceTp().toString(); + String destNode = link.getDestination().getDestNode().getValue(); + String destTp = link.getDestination().getDestTp().toString(); + Map nepList = new HashMap<>(); + Uuid sourceUuidTp; + Uuid sourceUuidNode; + Uuid destUuidTp; + Uuid destUuidNode; + Name linkName; + switch (prefix) { + case "OTU4": + sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, I_OTSI, sourceTp)); + sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, OTSI)); + NodeEdgePoint sourceNep = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(sourceUuidNode) + .setNodeEdgePointUuid(sourceUuidTp) + .build(); + nepList.put(sourceNep.key(), sourceNep); + destUuidTp = this.uuidMap.get(String.join("+", destNode, I_OTSI, destTp)); + destUuidNode = this.uuidMap.get(String.join("+", destNode, OTSI)); + NodeEdgePoint destNep = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(destUuidNode) + .setNodeEdgePointUuid(destUuidTp) + .build(); + nepList.put(destNep.key(), destNep); + linkName = new NameBuilder().setValueName("otn link name") + .setValue(link.getLinkId().getValue()) + .build(); + return new LinkBuilder() + .setUuid(new Uuid( + UUID.nameUUIDFromBytes((link.getLinkId().getValue()) + .getBytes(Charset.forName("UTF-8"))) + .toString())) + .setName(Map.of(linkName.key(), linkName)) + .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA)) + .setAdministrativeState(AdministrativeState.UNLOCKED) + .setOperationalState(OperationalState.ENABLED) + .setDirection(ForwardingDirection.BIDIRECTIONAL) + .setNodeEdgePoint(nepList) + .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize( + new TotalSizeBuilder().setUnit(CapacityUnit.GBPS) + .setValue(Uint64.valueOf(100)).build()).build()) + .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize( + new TotalSizeBuilder().setUnit(CapacityUnit.MBPS) + .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build()) + .build()) + .build(); + case "ODU4": + sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, DSR, sourceTp)); + sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, DSR)); + NodeEdgePoint sourceNep2 = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(sourceUuidNode) + .setNodeEdgePointUuid(sourceUuidTp) + .build(); + nepList.put(sourceNep2.key(), sourceNep2); + destUuidTp = this.uuidMap.get(String.join("+", destNode, DSR, destTp)); + destUuidNode = this.uuidMap.get(String.join("+", destNode, DSR)); + NodeEdgePoint destNep2 = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(destUuidNode) + .setNodeEdgePointUuid(destUuidTp) + .build(); + nepList.put(destNep2.key(), destNep2); + linkName = new NameBuilder().setValueName("otn link name") + .setValue(link.getLinkId().getValue()) + .build(); + return new LinkBuilder() + .setUuid(new Uuid( + UUID.nameUUIDFromBytes((link.getLinkId().getValue()) + .getBytes(Charset.forName("UTF-8"))) + .toString())) + .setName(Map.of(linkName.key(), linkName)) + .setLayerProtocolName(Arrays.asList(LayerProtocolName.ODU)) + .setAdministrativeState(AdministrativeState.UNLOCKED) + .setOperationalState(OperationalState.ENABLED) + .setDirection(ForwardingDirection.BIDIRECTIONAL) + .setNodeEdgePoint(nepList) + .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize( + new TotalSizeBuilder().setUnit(CapacityUnit.GBPS) + .setValue(Uint64.valueOf(100)).build()).build()) + .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize( + new TotalSizeBuilder().setUnit(CapacityUnit.MBPS) + .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build()) + .build()) + .build(); + default: + LOG.error("OTN link of type {} not managed yet", prefix); + return null; + } + } + public Map getTapiNodes() { return tapiNodes; @@ -418,4 +548,9 @@ public class ConvertORTopoObjectToTapiTopoObject { public Map getTapiLinks() { return tapiLinks; } -} + + public Map getUuidMap() { + return uuidMap; + } + +} \ No newline at end of file diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java index b8e85a95a..6b23a299c 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java @@ -11,6 +11,7 @@ import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -238,13 +239,19 @@ public class TapiTopologyImpl implements TapiTopologyService { tapiLinkList = new HashMap<>(); Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(T0_MULTI_LAYER_TOPO.getBytes(Charset.forName("UTF-8"))) .toString()); + ConvertORTopoObjectToTapiTopoObject tapiFactory = new ConvertORTopoObjectToTapiTopoObject(topoUuid); for (Node node : otnNodeList) { - ConvertORTopoObjectToTapiTopoObject tapiFactory = - new ConvertORTopoObjectToTapiTopoObject(node, null, topoUuid); - tapiFactory.convertNode(); + tapiFactory.convertNode(node); tapiNodeList.putAll(tapiFactory.getTapiNodes()); tapiLinkList.putAll(tapiFactory.getTapiLinks()); } + if (otnTopo.augmentation(Network1.class) != null) { + List otnLinkList = new ArrayList<>(otnTopo.augmentation(Network1.class).getLink().values()); + Collections.sort(otnLinkList, (l1, l2) -> l1.getLinkId().getValue() + .compareTo(l2.getLinkId().getValue())); + tapiFactory.convertLinks(otnLinkList); + tapiLinkList.putAll(tapiFactory.getTapiLinks()); + } Name name = new NameBuilder().setValue(T0_MULTI_LAYER_TOPO).setValueName("TAPI Topology Name").build(); return new TopologyBuilder() .setName(Map.of(name.key(), name)) diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java index 72770195a..026c5744b 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java @@ -45,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Term import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E; @@ -75,7 +76,7 @@ public class TapiTopologyImplTest extends AbstractTest { private static final int NUM_THREADS = 3; @Before - public void setUp() throws InterruptedException { + public void setUp() throws InterruptedException, ExecutionException { executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS)); endSignal = new CountDownLatch(1); TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(), @@ -151,27 +152,85 @@ public class TapiTopologyImplTest extends AbstractTest { .collect(Collectors.toList()); Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8"))) .toString()); - checkDsrNode(nodes.get(0), node1Uuid, false); + checkDsrNode(nodes.get(0), node1Uuid, false, "SPDR-SA1-XPDR1"); Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8"))) .toString()); - checkDsrNode(nodes.get(1), node2Uuid, true); + checkDsrNode(nodes.get(1), node2Uuid, true, "SPDR-SA1-XPDR2"); Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8"))) .toString()); - checkOtsiNode(nodes.get(2), node3Uuid, false); + checkOtsiNode(nodes.get(2), node3Uuid, false, "SPDR-SA1-XPDR1"); Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8"))) .toString()); - checkOtsiNode(nodes.get(3), node4Uuid, true); + checkOtsiNode(nodes.get(3), node4Uuid, true, "SPDR-SA1-XPDR2"); List links = topology.nonnullLink().values().stream() .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue())) .collect(Collectors.toList()); - checkTransitionalLink(links.get(1), topoUuid, node1Uuid, node3Uuid, "DSR+XPDR1-NETWORK1", - "iOTSi+XPDR1-NETWORK1", "SPDR-SA1-XPDR1"); - checkTransitionalLink(links.get(4), topoUuid, node2Uuid, node4Uuid, "DSR+XPDR2-NETWORK1", - "iOTSi+XPDR2-NETWORK1", "SPDR-SA1-XPDR2"); + checkTransitionalLink(links.get(4), topoUuid, node1Uuid, node3Uuid, "SPDR-SA1-XPDR1+DSR+XPDR1-NETWORK1", + "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1", "SPDR-SA1-XPDR1"); + checkTransitionalLink(links.get(2), topoUuid, node2Uuid, node4Uuid, "SPDR-SA1-XPDR2+DSR+XPDR2-NETWORK1", + "SPDR-SA1-XPDR2+iOTSi+XPDR2-NETWORK1", "SPDR-SA1-XPDR2"); } - private void checkDsrNode(Node node, Uuid nodeUuid, boolean isSwitch) { + @Test + public void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful() + throws ExecutionException, InterruptedException { + executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS)); + endSignal = new CountDownLatch(1); + TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(), + TopologyDataUtils.OTN_TOPOLOGY_WITH_OTN_LINKS_FILE, InstanceIdentifiers.OTN_NETWORK_II); + + GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(NetworkUtils.OTN_NETWORK_ID); + TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker()); + ListenableFuture> result = tapiTopoImpl.getTopologyDetails(input); + result.addListener(new Runnable() { + @Override + public void run() { + endSignal.countDown(); + } + }, executorService); + endSignal.await(); + RpcResult rpcResult = result.get(); + @Nullable + Topology topology = rpcResult.getResult().getTopology(); + assertNotNull("Topology should not be null", topology); + assertEquals("Node list size should be 8", 8, topology.getNode().size()); + assertEquals("Link list size should be 12", 12, topology.getLink().size()); + + Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString()); + Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8"))) + .toString()); + Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(Charset.forName("UTF-8"))) + .toString()); + Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8"))) + .toString()); + Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8"))) + .toString()); + Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR+XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR+XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid link1Uuid = + new Uuid(UUID.nameUUIDFromBytes("ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid link2Uuid = + new Uuid(UUID.nameUUIDFromBytes("OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1" + .getBytes(Charset.forName("UTF-8"))).toString()); + + List links = topology.nonnullLink().values().stream() + .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue())) + .collect(Collectors.toList()); + checkOtnLink(links.get(3), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid, + "ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"); + checkOtnLink(links.get(9), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid, + "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"); + } + + private void checkDsrNode(Node node, Uuid nodeUuid, boolean isSwitch, String nodeId) { assertEquals("incorrect node uuid", nodeUuid, node.getUuid()); assertEquals("administrative state should be UNLOCKED", AdministrativeState.UNLOCKED, node.getAdministrativeState()); @@ -188,13 +247,15 @@ public class TapiTopologyImplTest extends AbstractTest { .collect(Collectors.toList()); if (isSwitch) { assertEquals("Switch-DSR node should have 8 NEPs", 8, neps.size()); - OwnedNodeEdgePoint nep1 = neps.get(5); + OwnedNodeEdgePoint nep1 = neps.get(3); Uuid client4NepUuid = new Uuid( - UUID.nameUUIDFromBytes("DSR+XPDR2-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepClient100G(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C4"); - OwnedNodeEdgePoint nep2 = neps.get(1); + OwnedNodeEdgePoint nep2 = neps.get(4); Uuid networkNepUuid = new Uuid( - UUID.nameUUIDFromBytes("DSR+XPDR2-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "NodeEdgePoint_N1"); List nrgList = node.nonnullNodeRuleGroup().values().stream() .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue())) @@ -204,12 +265,14 @@ public class TapiTopologyImplTest extends AbstractTest { assertEquals("Mux-DSR node should have 5 NEPs", 5, neps.size()); OwnedNodeEdgePoint nep1 = neps.get(0); Uuid client4NepUuid = new Uuid( - UUID.nameUUIDFromBytes("DSR+XPDR1-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT4").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepClient10G(nep1, client4NepUuid, "XPDR1-CLIENT4", "NodeEdgePoint_C4"); OwnedNodeEdgePoint nep2 = neps.get(1); Uuid networkNepUuid = new Uuid( - UUID.nameUUIDFromBytes("DSR+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepNetworkODU4(nep2, networkNepUuid, "XPDR1-NETWORK1", "NodeEdgePoint_N1"); List nrgList = node.nonnullNodeRuleGroup().values().stream() .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue())) @@ -218,7 +281,7 @@ public class TapiTopologyImplTest extends AbstractTest { } } - private void checkOtsiNode(Node node, Uuid nodeUuid, boolean isSwitch) { + private void checkOtsiNode(Node node, Uuid nodeUuid, boolean isSwitch, String nodeId) { assertEquals("incorrect node uuid", nodeUuid, node.getUuid()); assertEquals("administrative state should be UNLOCKED", AdministrativeState.UNLOCKED, node.getAdministrativeState()); @@ -235,13 +298,15 @@ public class TapiTopologyImplTest extends AbstractTest { .collect(Collectors.toList()); if (isSwitch) { assertEquals("Switch-OTSi node should have 8 NEPs", 8, neps.size()); - OwnedNodeEdgePoint nep1 = neps.get(0); + OwnedNodeEdgePoint nep1 = neps.get(2); Uuid inepUuid = new Uuid( - UUID.nameUUIDFromBytes("iOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint_2"); - OwnedNodeEdgePoint nep2 = neps.get(5); + OwnedNodeEdgePoint nep2 = neps.get(0); Uuid enepUuid = new Uuid( - UUID.nameUUIDFromBytes("eOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint_2"); List nrgList = node.nonnullNodeRuleGroup().values().stream() .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue())) @@ -251,11 +316,13 @@ public class TapiTopologyImplTest extends AbstractTest { assertEquals("Mux-OTSi node should have 2 NEPs", 2, neps.size()); OwnedNodeEdgePoint nep1 = neps.get(0); Uuid enepUuid = new Uuid( - UUID.nameUUIDFromBytes("eOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepOtsiNode(nep1, enepUuid, "XPDR1-NETWORK1", "eNodeEdgePoint_1"); OwnedNodeEdgePoint nep2 = neps.get(1); Uuid inepUuid = new Uuid( - UUID.nameUUIDFromBytes("iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString()); + UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8"))) + .toString()); checkNepOtsiNode(nep2, inepUuid, "XPDR1-NETWORK1", "iNodeEdgePoint_1"); List nrgList = node.nonnullNodeRuleGroup().values().stream() .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue())) @@ -335,13 +402,13 @@ public class TapiTopologyImplTest extends AbstractTest { .compareTo(nrg2.getNodeEdgePointUuid().getValue())) .collect(Collectors.toList()); assertEquals("in the sorted node-rule-group, nep number 2 should be XPDR2-NETWORK1", - networkNepUuid, nrg.get(1).getNodeEdgePointUuid()); + networkNepUuid, nrg.get(4).getNodeEdgePointUuid()); assertEquals("in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4", - clientNepUuid, nrg.get(5).getNodeEdgePointUuid()); + clientNepUuid, nrg.get(3).getNodeEdgePointUuid()); assertEquals("any item of the node-rule-group should have the same nodeUuid", - nodeUuid, nrg.get(1).getNodeUuid()); + nodeUuid, nrg.get(4).getNodeUuid()); assertEquals("any item of the node-rule-group should have the same nodeUuid", - nodeUuid, nrg.get(5).getNodeUuid()); + nodeUuid, nrg.get(3).getNodeUuid()); @Nullable List ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values()); assertEquals("node-rule-group should contain a single rule", 1, ruleList.size()); @@ -460,7 +527,7 @@ public class TapiTopologyImplTest extends AbstractTest { private void checkTransitionalLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, String tp1, String tp2, String ietfNodeId) { - Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((ietfNodeId + "-" + tp1 + "--" + tp2) + Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((ietfNodeId + "--" + tp1 + "--" + tp2) .getBytes(Charset.forName("UTF-8"))).toString()); assertEquals("bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2, linkUuid, link.getUuid()); assertEquals("Available capacity unit should be GBPS", @@ -495,4 +562,56 @@ public class TapiTopologyImplTest extends AbstractTest { nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(), either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue()))); } + + private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, + Uuid linkUuid, String linkName) { + assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("otn link name")).getValue()); + assertEquals("bad uuid for link", linkUuid, link.getUuid()); + assertEquals("Available capacity unit should be MBPS", + CapacityUnit.MBPS, link.getAvailableCapacity().getTotalSize().getUnit()); + String prefix = linkName.split("-")[0]; + if ("OTU4".equals(prefix)) { + assertEquals("Available capacity -total size value should be 0", + Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue()); + } else if ("ODU4".equals(prefix)) { + assertEquals("Available capacity -total size value should be 100 000", + Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue()); + } + assertEquals("Total capacity unit should be GBPS", + CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit()); + assertEquals("Total capacity -total size value should be 100", + Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue()); + if ("OTU4".equals(prefix)) { + assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA", + LayerProtocolName.PHOTONICMEDIA.getName(), link.getLayerProtocolName().get(0).getName()); + } else if ("ODU4".equals(prefix)) { + assertEquals("otn link should be between 2 nodes of protocol layers ODU", + LayerProtocolName.ODU.getName(), link.getLayerProtocolName().get(0).getName()); + } + assertEquals("transitional link should be BIDIRECTIONAL", + ForwardingDirection.BIDIRECTIONAL, link.getDirection()); + List nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values()); + assertEquals("topology uuid should be the same for the two termination point of the link", + topoUuid, nodeEdgePointList.get(0).getTopologyUuid()); + assertEquals("topology uuid should be the same for the two termination point of the link", + topoUuid, nodeEdgePointList.get(1).getTopologyUuid()); + assertThat("otn links should terminate on two distinct nodes", + nodeEdgePointList.get(0).getNodeUuid().getValue(), + either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue()))); + assertThat("otn links should terminate on two distinct nodes", + nodeEdgePointList.get(1).getNodeUuid().getValue(), + either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue()))); + assertThat("otn links should terminate on two distinct tps", + nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(), + either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue()))); + assertThat("otn links should terminate on two distinct tps", + nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(), + either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue()))); + assertEquals("operational state should be ENABLED", + OperationalState.ENABLED, link.getOperationalState()); + assertEquals("administrative state should be UNLOCKED", + AdministrativeState.UNLOCKED, link.getAdministrativeState()); + } + } diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java index fac97ffd9..2d669c1c3 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java @@ -7,14 +7,16 @@ */ package org.opendaylight.transportpce.tapi.utils; -import edu.umd.cs.findbugs.annotations.NonNull; +import com.google.common.util.concurrent.FluentFuture; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Optional; +import java.util.concurrent.ExecutionException; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.test.DataStoreContext; import org.opendaylight.transportpce.test.converter.XMLDataObjectConverter; @@ -33,6 +35,7 @@ public final class TopologyDataUtils { private static final Logger LOG = LoggerFactory.getLogger(TopologyDataUtils.class); public static final String OPENROADM_TOPOLOGY_FILE = "src/test/resources/openroadm-topology2.xml"; public static final String OTN_TOPOLOGY_FILE = "src/test/resources/otn-topology.xml"; + public static final String OTN_TOPOLOGY_WITH_OTN_LINKS_FILE = "src/test/resources/otn-topology-with-otn-links.xml"; public static final String PORTMAPPING_FILE = "src/test/resources/portmapping-example.xml"; public static GetTopologyDetailsInput buildGetTopologyDetailsInput(String topoName) { @@ -42,7 +45,7 @@ public final class TopologyDataUtils { } public static void writeTopologyFromFileToDatastore(DataStoreContext dataStoreContextUtil, String file, - InstanceIdentifier ii) { + InstanceIdentifier ii) throws InterruptedException, ExecutionException { Networks networks = null; File topoFile = new File(file); if (topoFile.exists()) { @@ -70,22 +73,22 @@ public final class TopologyDataUtils { } else { LOG.error("xml file {} not found at {}", topoFile.getName(), topoFile.getAbsolutePath()); } - writeTransaction(dataStoreContextUtil.getDataBroker(), ii, + FluentFuture commitFuture = writeTransaction(dataStoreContextUtil.getDataBroker(), ii, networks.nonnullNetwork().values().stream().findFirst().get()); + commitFuture.get(); LOG.info("extraction from {} stored with success in datastore", topoFile.getName()); } @SuppressWarnings("unchecked") - private static boolean writeTransaction(DataBroker dataBroker, InstanceIdentifier instanceIdentifier, - DataObject object) { - @NonNull + private static FluentFuture writeTransaction(DataBroker dataBroker, + InstanceIdentifier instanceIdentifier, DataObject object) { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, instanceIdentifier, object); - transaction.commit(); - return true; + return transaction.commit(); } - public static void writePortmappingFromFileToDatastore(DataStoreContext dataStoreContextUtil) { + public static void writePortmappingFromFileToDatastore(DataStoreContext dataStoreContextUtil) + throws InterruptedException, ExecutionException { Network result = null; File portmappingFile = new File(PORTMAPPING_FILE); if (portmappingFile.exists()) { @@ -114,7 +117,9 @@ public final class TopologyDataUtils { LOG.error("xml file {} not found at {}", portmappingFile.getName(), portmappingFile.getAbsolutePath()); } InstanceIdentifier portmappingIID = InstanceIdentifier.builder(Network.class).build(); - writeTransaction(dataStoreContextUtil.getDataBroker(), portmappingIID, result); + FluentFuture writeTransaction = writeTransaction(dataStoreContextUtil.getDataBroker(), + portmappingIID, result); + writeTransaction.get(); LOG.info("portmapping-example stored with success in datastore"); } diff --git a/tapi/src/test/resources/otn-topology-with-otn-links.xml b/tapi/src/test/resources/otn-topology-with-otn-links.xml new file mode 100644 index 000000000..237abf401 --- /dev/null +++ b/tapi/src/test/resources/otn-topology-with-otn-links.xml @@ -0,0 +1,968 @@ + + + + otn-topology + + + + + SPDR-SA1-XPDR1 + + XPDR1-CLIENT1 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-CLIENT3 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-CLIENT2 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-NETWORK1 + + openroadm-topology + SPDR-SA1-XPDR1 + XPDR1-NETWORK1 + + + + x:ODTU4.ts-Allocated + 2 + 1 + 12 + 11 + 14 + 13 + 16 + 15 + 18 + 17 + 4 + 3 + 6 + 5 + 8 + 7 + 10 + 9 + 28 + 27 + 30 + 29 + 32 + 31 + 34 + 33 + 20 + 19 + 22 + 21 + 24 + 23 + 26 + 25 + 44 + 43 + 46 + 45 + 48 + 47 + 50 + 49 + 36 + 35 + 38 + 37 + 40 + 39 + 42 + 41 + 60 + 59 + 62 + 61 + 64 + 63 + 66 + 65 + 52 + 51 + 54 + 53 + 56 + 55 + 58 + 57 + 76 + 75 + 78 + 77 + 80 + 79 + 68 + 67 + 70 + 69 + 72 + 71 + 74 + 73 + + x:ODU4 + 48 + 49 + 46 + 47 + 52 + 53 + 50 + 51 + 40 + 41 + 38 + 39 + 44 + 45 + 42 + 43 + 64 + 65 + 62 + 63 + 68 + 69 + 66 + 67 + 56 + 57 + 54 + 55 + 60 + 61 + 58 + 59 + 80 + 78 + 79 + 72 + 73 + 70 + 71 + 76 + 77 + 74 + 75 + 1 + 4 + 5 + 2 + 3 + 16 + 17 + 14 + 15 + 20 + 21 + 18 + 19 + 8 + 9 + 6 + 7 + 12 + 13 + 10 + 11 + 32 + 33 + 30 + 31 + 36 + 37 + 34 + 35 + 24 + 25 + 22 + 23 + 28 + 29 + 26 + 27 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR1-CLIENT4 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + openroadm-network + SPDR-SA1 + + + clli-network + NodeSA + + + openroadm-topology + SPDR-SA1-XPDR1 + + MUXPDR + + + 1 + + 4 + 10 + + 1000000000 + + XPDR1-CLIENT4 + XPDR1-NETWORK1 + + + 1 + 10 + + 1000000000 + + XPDR1-CLIENT1 + XPDR1-NETWORK1 + + + 2 + 10 + + 1000000000 + + XPDR1-NETWORK1 + XPDR1-CLIENT2 + + + 3 + 10 + + 1000000000 + + XPDR1-NETWORK1 + XPDR1-CLIENT3 + + non-blocking + + + + + 1 + + + + SPDR-SC1-XPDR1 + + XPDR1-CLIENT1 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-CLIENT3 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-CLIENT2 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + XPDR1-NETWORK1 + + openroadm-topology + SPDR-SC1-XPDR1 + XPDR1-NETWORK1 + + + + x:ODTU4.ts-Allocated + 2 + 1 + 12 + 11 + 14 + 13 + 16 + 15 + 18 + 17 + 4 + 3 + 6 + 5 + 8 + 7 + 10 + 9 + 28 + 27 + 30 + 29 + 32 + 31 + 34 + 33 + 20 + 19 + 22 + 21 + 24 + 23 + 26 + 25 + 44 + 43 + 46 + 45 + 48 + 47 + 50 + 49 + 36 + 35 + 38 + 37 + 40 + 39 + 42 + 41 + 60 + 59 + 62 + 61 + 64 + 63 + 66 + 65 + 52 + 51 + 54 + 53 + 56 + 55 + 58 + 57 + 76 + 75 + 78 + 77 + 80 + 79 + 68 + 67 + 70 + 69 + 72 + 71 + 74 + 73 + + x:ODU4 + 48 + 49 + 46 + 47 + 52 + 53 + 50 + 51 + 40 + 41 + 38 + 39 + 44 + 45 + 42 + 43 + 64 + 65 + 62 + 63 + 68 + 69 + 66 + 67 + 56 + 57 + 54 + 55 + 60 + 61 + 58 + 59 + 80 + 78 + 79 + 72 + 73 + 70 + 71 + 76 + 77 + 74 + 75 + 1 + 4 + 5 + 2 + 3 + 16 + 17 + 14 + 15 + 20 + 21 + 18 + 19 + 8 + 9 + 6 + 7 + 12 + 13 + 10 + 11 + 32 + 33 + 30 + 31 + 36 + 37 + 34 + 35 + 24 + 25 + 22 + 23 + 28 + 29 + 26 + 27 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR1-CLIENT4 + + x:ODU2e + + + + x:if-10GE-ODU2e + + + XPONDER-CLIENT + + + openroadm-network + SPDR-SC1 + + + clli-network + NodeSC + + + openroadm-topology + SPDR-SC1-XPDR1 + + MUXPDR + + + 1 + + 4 + 10 + + 1000000000 + + XPDR1-CLIENT4 + XPDR1-NETWORK1 + + + 1 + 10 + + 1000000000 + + XPDR1-CLIENT1 + XPDR1-NETWORK1 + + + 2 + 10 + + 1000000000 + + XPDR1-NETWORK1 + XPDR1-CLIENT2 + + + 3 + 10 + + 1000000000 + + XPDR1-NETWORK1 + XPDR1-CLIENT3 + + non-blocking + + + + + 1 + + + + SPDR-SA1-XPDR2 + + XPDR2-NETWORK1 + + openroadm-topology + SPDR-SA1-XPDR2 + XPDR2-NETWORK1 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK3 + + openroadm-topology + SPDR-SA1-XPDR2 + XPDR2-NETWORK3 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK2 + + openroadm-topology + SPDR-SA1-XPDR2 + XPDR2-NETWORK2 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK4 + + openroadm-topology + SPDR-SA1-XPDR2 + XPDR2-NETWORK4 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-CLIENT3 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT4 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT1 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT2 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + openroadm-network + SPDR-SA1 + + + clli-network + NodeSA + + + openroadm-topology + SPDR-SA1-XPDR2 + + SWITCH + + + 1 + + 1 + XPDR2-CLIENT1 + XPDR2-NETWORK4 + XPDR2-CLIENT2 + XPDR2-NETWORK1 + XPDR2-CLIENT3 + XPDR2-NETWORK2 + XPDR2-CLIENT4 + XPDR2-NETWORK3 + + non-blocking + + + + + 2 + + + + SPDR-SC1-XPDR2 + + XPDR2-NETWORK1 + + openroadm-topology + SPDR-SC1-XPDR2 + XPDR2-NETWORK1 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK3 + + openroadm-topology + SPDR-SC1-XPDR2 + XPDR2-NETWORK3 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK2 + + openroadm-topology + SPDR-SC1-XPDR2 + XPDR2-NETWORK2 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-NETWORK4 + + openroadm-topology + SPDR-SC1-XPDR2 + XPDR2-NETWORK4 + + + x:ODU4 + + + + x:if-OCH-OTU4-ODU4 + + + XPONDER-NETWORK + + + XPDR2-CLIENT3 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT4 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT1 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + XPDR2-CLIENT2 + + x:ODU4 + + + + x:if-100GE-ODU4 + + + XPONDER-CLIENT + + + openroadm-topology + SPDR-SC1-XPDR2 + + + openroadm-network + SPDR-SC1 + + + clli-network + NodeSC + + SWITCH + + + 1 + + 1 + XPDR2-CLIENT1 + XPDR2-NETWORK4 + XPDR2-CLIENT2 + XPDR2-NETWORK1 + XPDR2-CLIENT3 + XPDR2-NETWORK2 + XPDR2-CLIENT4 + XPDR2-NETWORK3 + + non-blocking + + + + + 2 + + + + OTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1 + + + SPDR-SC1-XPDR1 + XPDR1-NETWORK1 + + OTU4 + + XPDR1-NETWORK1 + SPDR-SA1-XPDR1 + + 0 + 100000 + OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1 + + OTN-LINK + + + OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1 + + + SPDR-SA1-XPDR1 + XPDR1-NETWORK1 + + OTU4 + + XPDR1-NETWORK1 + SPDR-SC1-XPDR1 + + 0 + 100000 + OTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1 + + OTN-LINK + + + ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1 + + + SPDR-SC1-XPDR1 + XPDR1-NETWORK1 + + ODTU4 + + XPDR1-NETWORK1 + SPDR-SA1-XPDR1 + + 100000 + 0 + ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1 + + OTN-LINK + + + ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1 + + + SPDR-SA1-XPDR1 + XPDR1-NETWORK1 + + ODTU4 + + XPDR1-NETWORK1 + SPDR-SC1-XPDR1 + + 100000 + 0 + ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1 + + OTN-LINK + + + + \ No newline at end of file -- 2.36.6