Migrate TAPI module to Aluminium 71/92171/11
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 17 Aug 2020 12:55:07 +0000 (14:55 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Thu, 17 Sep 2020 08:28:01 +0000 (10:28 +0200)
JIRA: TRNSPRTPCE-292 TRNSPRTPCE-304
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Co-authored-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I23c0277460a265525e18662ba127691dd71fa284

tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoObjectToTapiTopoObject.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiListener.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/validation/CreateConnectivityServiceValidation.java
tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java

index a43e638bbf5a2398dca6cd6152c5baa58f056bab..773e82cb6e38042b603ebe1b6c245f331512552a 100644 (file)
@@ -8,8 +8,7 @@
 package org.opendaylight.transportpce.tapi.impl;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import org.opendaylight.transportpce.common.OperationResult;
@@ -44,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev18121
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.output.ServiceBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -76,12 +76,17 @@ public class TapiImpl implements TapiConnectivityService {
             // check uuid of SIP in the map
             Map<Uuid, GenericServiceEndpoint> map = MappingUtils.getMap();
 
-            if (map.containsKey(input.getEndPoint().get(0).getServiceInterfacePoint().getServiceInterfacePointUuid())
-                && map.containsKey(input.getEndPoint().get(1).getServiceInterfacePoint()
-                    .getServiceInterfacePointUuid())) {
-                ServiceCreateInput sci = TapiUtils.buildServiceCreateInput(map.get(input.getEndPoint().get(0)
+            if (map.containsKey(input.getEndPoint().values().stream().findFirst().get()
+                    .getServiceInterfacePoint().getServiceInterfacePointUuid())
+                && map.containsKey(input.getEndPoint().values().stream().skip(1).findFirst().get()
                     .getServiceInterfacePoint()
-                    .getServiceInterfacePointUuid()), map.get(input.getEndPoint().get(1).getServiceInterfacePoint()
+                    .getServiceInterfacePointUuid())) {
+                ServiceCreateInput sci = TapiUtils.buildServiceCreateInput(
+                    map.get(input.getEndPoint().values().stream().findFirst().get()
+                        .getServiceInterfacePoint()
+                        .getServiceInterfacePointUuid()),
+                    map.get(input.getEndPoint().values().stream().skip(1).findFirst().get()
+                        .getServiceInterfacePoint()
                         .getServiceInterfacePointUuid()));
                 this.serviceHandler.serviceCreate(sci);
             } else {
@@ -90,7 +95,7 @@ public class TapiImpl implements TapiConnectivityService {
 
         }
 
-        List<EndPoint> endPointList = new ArrayList<>();
+        Map<EndPointKey, EndPoint> endPointList = new HashMap<>();
         EndPoint endpoint1 = new EndPointBuilder()
             .setLocalId(UUID.randomUUID().toString())
             .setServiceInterfacePoint(new ServiceInterfacePointBuilder().setServiceInterfacePointUuid(new Uuid(UUID
@@ -101,23 +106,19 @@ public class TapiImpl implements TapiConnectivityService {
             .setServiceInterfacePoint(new ServiceInterfacePointBuilder().setServiceInterfacePointUuid(new Uuid(UUID
                 .randomUUID().toString())).build())
             .build();
-        endPointList.add(endpoint1);
-        endPointList.add(endpoint2);
-        List<Connection> connectionList = new ArrayList<>();
-        Connection connection1 = new ConnectionBuilder().setConnectionUuid(new Uuid(UUID.randomUUID().toString()))
+        endPointList.put(endpoint1.key(), endpoint1);
+        endPointList.put(endpoint2.key(), endpoint2);
+        Connection connection = new ConnectionBuilder().setConnectionUuid(new Uuid(UUID.randomUUID().toString()))
             .build();
-        connectionList.add(connection1);
         ConnectivityService service = new ConnectivityServiceBuilder().build();
-        List<Name> serviceNameList = new ArrayList<>();
         Name serviceName = new NameBuilder().setValueName("Service Name").setValue("SENDATE Service 1").build();
-        serviceNameList.add(serviceName);
         CreateConnectivityServiceOutput output = new CreateConnectivityServiceOutputBuilder()
             .setService(new ServiceBuilder(service)
                 .setUuid(new Uuid(UUID.randomUUID().toString()))
-                .setName(serviceNameList)
-                .setServiceLayer(input.getEndPoint().get(0).getLayerProtocolName())
+                .setName(Map.of(serviceName.key(), serviceName))
+                .setServiceLayer(input.getEndPoint().values().stream().findFirst().get().getLayerProtocolName())
                 .setEndPoint(endPointList)
-                .setConnection(connectionList)
+                .setConnection(Map.of(connection.key(), connection))
                 .build())
             .build();
 
index 8c760b236da0d62258cbabd1d3b6303cebc152d8..5762fea75e62335ecb4b2e7676b7d3e80f73d6c0 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capa
 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.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;
 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;
@@ -51,17 +52,24 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Fo
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -79,28 +87,32 @@ public class ConvertORTopoObjectToTapiTopoObject {
     private List<TerminationPoint> oorNetworkPortList;
     private OduSwitchingPools oorOduSwitchingPool;
     private Uuid tapiTopoUuid;
-    private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes;
-    private List<Link> tapiLinks;
+    private Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
+        tapiNodes;
+    private Map<LinkKey, Link> tapiLinks;
     private Map<String, Uuid> uuidMap;
 
     public ConvertORTopoObjectToTapiTopoObject(Node ietfNode, Link1 otnLink, Uuid tapiTopoUuid) {
         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).getTerminationPoint().stream()
+        this.oorClientPortList = ietfNode.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
+            .getTerminationPoint().values().stream()
             .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
             == OpenroadmTpType.XPONDERCLIENT.getIntValue())
             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
             .collect(Collectors.toList());
-        this.oorNetworkPortList = ietfNode.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
-            .network.topology.rev180226.Node1.class).getTerminationPoint().stream()
+        this.oorNetworkPortList = ietfNode.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
+            .getTerminationPoint().values().stream()
             .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
             == OpenroadmTpType.XPONDERNETWORK.getIntValue())
             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
             .collect(Collectors.toList());
-        this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools().get(0);
+        this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
+            .values().stream().findFirst().get();
         this.tapiTopoUuid = tapiTopoUuid;
-        this.tapiNodes = new ArrayList<>();
-        this.tapiLinks = new ArrayList<>();
+        this.tapiNodes = new HashMap<>();
+        this.tapiLinks = new HashMap<>();
         this.uuidMap = new HashMap<>();
     }
 
@@ -110,31 +122,22 @@ public class ConvertORTopoObjectToTapiTopoObject {
         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((this.ietfNodeId + PLUS_DSR).getBytes(Charset.forName("UTF-8")))
             .toString());
         this.uuidMap.put(this.ietfNodeId + PLUS_DSR, nodeUuid);
-        List<Name> dsrNodeNames = Arrays.asList(
-            new NameBuilder()
-                .setValueName("dsr/odu node name")
-                .setValue(this.ietfNodeId)
-                .build());
-
+        Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(this.ietfNodeId).build();
         List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, LayerProtocolName.ODU);
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
-            .Node dsrNode = createTapiNode(dsrNodeNames, dsrLayerProtocols);
-        tapiNodes.add(dsrNode);
+            .Node dsrNode = createTapiNode(Map.of(nameDsr.key(), nameDsr), dsrLayerProtocols);
+        tapiNodes.put(dsrNode.key(), dsrNode);
 
         // 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);
-        List<Name> otsiNodeNames = Arrays.asList(
-            new NameBuilder()
-                .setValueName("otsi node name")
-                .setValue(this.ietfNodeId)
-                .build());
+        Name nameOtsi =  new NameBuilder().setValueName("otsi node name").setValue(this.ietfNodeId).build();
         List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
-            .Node otsiNode = createTapiNode(otsiNodeNames, otsiLayerProtocols);
-        tapiNodes.add(otsiNode);
+            .Node otsiNode = createTapiNode(Map.of(nameOtsi.key(), nameOtsi), otsiLayerProtocols);
+        tapiNodes.put(otsiNode.key(), otsiNode);
 
         // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
         LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
@@ -142,24 +145,24 @@ public class ConvertORTopoObjectToTapiTopoObject {
     }
 
     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
-        .Node createTapiNode(List<Name> nodeNames, List<LayerProtocolName> layerProtocols) {
+        .Node createTapiNode(Map<NameKey, Name> nodeNames, List<LayerProtocolName> layerProtocols) {
         Uuid nodeUuid = null;
-        List<OwnedNodeEdgePoint> onepl = new ArrayList<>();
-        List<NodeRuleGroup> nodeRuleGroupList = new ArrayList<>();
-        List<Rule> ruleList = new ArrayList<>();
+        Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
+        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
+        Map<RuleKey, Rule> ruleList = new HashMap<>();
         Rule rule = new RuleBuilder()
             .setLocalId("forward")
             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
             .setRuleType(RuleType.FORWARDING)
             .build();
-        ruleList.add(rule);
+        ruleList.put(rule.key(), rule);
         if (layerProtocols.contains(LayerProtocolName.DSR)) {
             nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, ruleList);
         } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
             nodeUuid = getNodeUuid4Phonic(onepl, nodeRuleGroupList, ruleList);
         } else {
-            LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(0).getValueName(),
-                    nodeNames.get(0).getValue());
+            LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(nodeNames.keySet().iterator().next())
+                .getValueName(), nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
         }
 
         // create tapi node
@@ -176,8 +179,8 @@ public class ConvertORTopoObjectToTapiTopoObject {
                 .build();
     }
 
-    private Uuid getNodeUuid4Phonic(List<OwnedNodeEdgePoint> onepl, List<NodeRuleGroup> nodeRuleGroupList,
-            List<Rule> ruleList) {
+    private Uuid getNodeUuid4Phonic(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
+        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
         Uuid nodeUuid;
         nodeUuid = this.uuidMap.get(this.ietfNodeId + OT_SI);
         // iNep creation on otsi node
@@ -186,15 +189,14 @@ public class ConvertORTopoObjectToTapiTopoObject {
                     (I_OT_SI + oorNetworkPortList.get(i).getTpId().getValue()).getBytes(Charset.forName("UTF-8")))
                 .toString());
             this.uuidMap.put(I_OT_SI + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid1);
-            List<Name> onedNames = Arrays.asList(
-                    new NameBuilder()
-                    .setValueName(new StringBuilder("iNodeEdgePoint_").append(i + 1).toString())
-                    .setValue(oorNetworkPortList.get(i).getTpId().getValue())
-                    .build());
+            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), onedNames,
+            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, I_OT_SI);
-            onepl.add(onep);
+            onepl.put(onep.key(), onep);
         }
         // eNep creation on otsi node
         for (int i = 0; i < oorNetworkPortList.size(); i++) {
@@ -202,21 +204,21 @@ public class ConvertORTopoObjectToTapiTopoObject {
                     (E_OT_SI + oorNetworkPortList.get(i).getTpId().getValue()).getBytes(Charset.forName("UTF-8")))
                 .toString());
             this.uuidMap.put(E_OT_SI + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid2);
-            List<Name> onedNames = Arrays.asList(
-                    new NameBuilder()
-                    .setValueName(new StringBuilder("eNodeEdgePoint_").append(i + 1).toString())
-                    .setValue(oorNetworkPortList.get(i).getTpId().getValue())
-                    .build());
+            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), onedNames,
+            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true, E_OT_SI);
-            onepl.add(onep);
+            onepl.put(onep.key(), onep);
         }
         // create NodeRuleGroup
+        int count = 1;
         for (TerminationPoint tp : this.oorNetworkPortList) {
-            int count = 1;
-            List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
-                .NodeEdgePoint> nepList = new ArrayList<>();
+            Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
+                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
+                nepList = new HashMap<>();
             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
                 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
                 .node.rule.group.NodeEdgePointBuilder()
@@ -231,22 +233,23 @@ public class ConvertORTopoObjectToTapiTopoObject {
                 .setNodeUuid(this.uuidMap.get(this.ietfNodeId + OT_SI))
                 .setNodeEdgePointUuid(this.uuidMap.get(E_OT_SI + tp.getTpId().getValue()))
                 .build();
-            nepList.add(inep);
-            nepList.add(enep);
+            nepList.put(inep.key(), inep);
+            nepList.put(enep.key(), enep);
             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
                 .setUuid(new Uuid(
-                    UUID.nameUUIDFromBytes(("node rule group " + count).getBytes(Charset.forName("UTF-8"))).toString()))
+                        UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
+                    .toString()))
                 .setRule(ruleList)
                 .setNodeEdgePoint(nepList)
                 .build();
-            nodeRuleGroupList.add(nodeRuleGroup);
+            nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
             count++;
         }
         return nodeUuid;
     }
 
-    private Uuid getNodeUuid4Dsr(List<OwnedNodeEdgePoint> onepl, List<NodeRuleGroup> nodeRuleGroupList,
-            List<Rule> ruleList) {
+    private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
+        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
         Uuid nodeUuid;
         nodeUuid = this.uuidMap.get(this.ietfNodeId + PLUS_DSR);
         // client nep creation on DSR/ODU node
@@ -254,36 +257,35 @@ public class ConvertORTopoObjectToTapiTopoObject {
             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((DSR_PLUS + oorClientPortList.get(i).getTpId().getValue())
                 .getBytes(Charset.forName("UTF-8"))).toString());
             this.uuidMap.put(DSR_PLUS + oorClientPortList.get(i).getTpId().getValue(), nepUuid);
-            List<Name> onedNames = Arrays.asList(
-                    new NameBuilder()
-                    .setValueName(new StringBuilder("NodeEdgePoint_C").append(i + 1).toString())
-                    .setValue(oorClientPortList.get(i).getTpId().getValue())
-                    .build());
+            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), onedNames, LayerProtocolName.ETH,
-                LayerProtocolName.DSR, true, DSR_PLUS);
-            onepl.add(onep);
+            OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
+                LayerProtocolName.ETH, LayerProtocolName.DSR, true, DSR_PLUS);
+            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())
                 .getBytes(Charset.forName("UTF-8"))).toString());
             this.uuidMap.put(DSR_PLUS + oorNetworkPortList.get(i).getTpId().getValue(), nepUuid);
-            List<Name> onedNames = Arrays.asList(
-                    new NameBuilder()
-                    .setValueName(new StringBuilder("NodeEdgePoint_N").append(i + 1).toString())
-                    .setValue(oorNetworkPortList.get(i).getTpId().getValue())
-                    .build());
+            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), onedNames, LayerProtocolName.ODU,
-                LayerProtocolName.DSR, true, DSR_PLUS);
-            onepl.add(onep);
+            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
+                LayerProtocolName.ODU, LayerProtocolName.DSR, true, DSR_PLUS);
+            onepl.put(onep.key(), onep);
         }
         // create NodeRuleGroup
-        for (NonBlockingList nbl : this.oorOduSwitchingPool.getNonBlockingList()) {
-            int count = 1;
-            List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
-                .NodeEdgePoint> nepList = new ArrayList<>();
+        int count = 1;
+        for (NonBlockingList nbl : this.oorOduSwitchingPool.getNonBlockingList().values()) {
+            Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
+                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
+                nepList = new HashMap<>();
             for (TpId tp : nbl.getTpList()) {
                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
                     .NodeEdgePoint nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
@@ -292,22 +294,23 @@ public class ConvertORTopoObjectToTapiTopoObject {
                     .setNodeUuid(this.uuidMap.get(this.ietfNodeId + PLUS_DSR))
                     .setNodeEdgePointUuid(this.uuidMap.get(DSR_PLUS + tp.getValue()))
                     .build();
-                nepList.add(nep);
+                nepList.put(nep.key(), nep);
             }
             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
                 .setUuid(new Uuid(
-                    UUID.nameUUIDFromBytes(("node rule group " + count).getBytes(Charset.forName("UTF-8"))).toString()))
+                        UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
+                    .toString()))
                 .setRule(ruleList)
                 .setNodeEdgePoint(nepList)
                 .build();
-            nodeRuleGroupList.add(nodeRuleGroup);
+            nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
             count++;
         }
         return nodeUuid;
     }
 
-    private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, List<Name> nepNames, LayerProtocolName nepProtocol,
-        LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
+    private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
+        LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
         String key = keyword + oorTp.getTpId().getValue();
         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
             .setUuid(this.uuidMap.get(key))
@@ -324,12 +327,12 @@ public class ConvertORTopoObjectToTapiTopoObject {
         return onepBldr.build();
     }
 
-    private List<MappedServiceInterfacePoint> createSIP(int nb) {
-        List<MappedServiceInterfacePoint> msipl = new ArrayList<>();
+    private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createSIP(int nb) {
+        Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
         for (int i = 0; i < nb; i++) {
             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
                 .setServiceInterfacePointUuid(new Uuid(UUID.randomUUID().toString())).build();
-            msipl.add(msip);
+            msipl.put(msip.key(), msip);
         }
         return msipl;
     }
@@ -337,9 +340,10 @@ public class ConvertORTopoObjectToTapiTopoObject {
     private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedCepLayerProtocolQualifier(TerminationPoint tp,
         LayerProtocolName lpn) {
         List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
-        List<SupportedInterfaceCapability> sicList = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
+        List<SupportedInterfaceCapability> sicList = new ArrayList<>(
+            tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
             .otn.network.topology.rev181130.TerminationPoint1.class).getTpSupportedInterfaces()
-            .getSupportedInterfaceCapability();
+            .getSupportedInterfaceCapability().values());
         for (SupportedInterfaceCapability sic : sicList) {
             switch (lpn.getName()) {
                 case "DSR":
@@ -369,7 +373,7 @@ public class ConvertORTopoObjectToTapiTopoObject {
 
     private void createTapiTransitionalLinks() {
         for (TerminationPoint tp : this.oorNetworkPortList) {
-            List<NodeEdgePoint> nepList = new ArrayList<>();
+            Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
             String sourceKey = DSR_PLUS + tp.getTpId().getValue();
             Uuid sourceUuidTp = this.uuidMap.get(sourceKey);
             String destKey = I_OT_SI + tp.getTpId().getValue();
@@ -379,14 +383,14 @@ public class ConvertORTopoObjectToTapiTopoObject {
                 .setNodeUuid(this.uuidMap.get(this.ietfNodeId + PLUS_DSR))
                 .setNodeEdgePointUuid(sourceUuidTp)
                 .build();
-            nepList.add(sourceNep);
+            nepList.put(sourceNep.key(), sourceNep);
             NodeEdgePoint destNep = new NodeEdgePointBuilder()
                 .setTopologyUuid(this.tapiTopoUuid)
                 .setNodeUuid(this.uuidMap.get(this.ietfNodeId + OT_SI))
                 .setNodeEdgePointUuid(destUuidTp)
                 .build();
-            nepList.add(destNep);
-            LinkBuilder transiLinkBldr = new LinkBuilder()
+            nepList.put(destNep.key(), destNep);
+            Link transiLink = new LinkBuilder()
                 .setUuid(new Uuid(
                         UUID.nameUUIDFromBytes((sourceKey + "--" + destKey).getBytes(Charset.forName("UTF-8")))
                     .toString()))
@@ -395,16 +399,18 @@ public class ConvertORTopoObjectToTapiTopoObject {
                 .setNodeEdgePoint(nepList)
                 .setDirection(ForwardingDirection.BIDIRECTIONAL)
                 .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
-                    new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build()).build());
-            this.tapiLinks.add(transiLinkBldr.build());
+                    new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build()).build())
+                .build();
+            this.tapiLinks.put(transiLink.key(), transiLink);
         }
     }
 
-    public List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> getTapiNodes() {
+    public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
+        getTapiNodes() {
         return tapiNodes;
     }
 
-    public List<Link> getTapiLinks() {
+    public Map<LinkKey, Link> getTapiLinks() {
         return tapiLinks;
     }
 }
index 6e9a1795a3f14c8cf3b8acecbf9bdbb585567ec7..b8e85a95adae66d14784217830ad664e878bf848 100644 (file)
@@ -11,7 +11,6 @@ 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.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -52,6 +51,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.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;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsOutput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsInput;
@@ -68,9 +68,13 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ge
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.topology.details.output.TopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -145,10 +149,10 @@ public class TapiTopologyImpl implements TapiTopologyService {
             return null;
         }
         Network openroadmTopo = optionalOpenroadmTop.get();
-        List<Node> nodeList = openroadmTopo.getNode();
+        List<Node> nodeList = new ArrayList<>(openroadmTopo.getNode().values());
         List<Link> linkList = null;
         if (openroadmTopo.augmentation(Network1.class) != null) {
-            linkList = openroadmTopo.augmentation(Network1.class).getLink();
+            linkList = new ArrayList<>(openroadmTopo.augmentation(Network1.class).getLink().values());
         } else {
             linkList = new ArrayList<>();
         }
@@ -167,9 +171,12 @@ public class TapiTopologyImpl implements TapiTopologyService {
                         .getNodeType().equals(OpenroadmNodeType.XPONDER)).collect(Collectors.toList());
         Map<String, List<String>> clientPortMap = new HashMap<>();
         for (Node node : xpdrNodeList) {
-            String nodeId = node.getSupportingNode().get(0).getNodeRef().getValue();
+            String nodeId = node.getSupportingNode().values().stream()
+                .filter(sn -> sn.getNetworkRef().getValue().equals(NetworkUtils.UNDERLAY_NETWORK_ID))
+                .findFirst()
+                .get().getNodeRef().getValue();
             List<String> clientPortList = new ArrayList<>();
-            for (TerminationPoint tp : node.augmentation(Node1.class).getTerminationPoint()) {
+            for (TerminationPoint tp : node.augmentation(Node1.class).getTerminationPoint().values()) {
                 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERCLIENT)
                         && checkTp(node.getNodeId().getValue(), nodeId, tp, xponderOutLinkList, xponderInLinkList)) {
                     clientPortList.add(tp.getTpId().getValue());
@@ -181,12 +188,15 @@ public class TapiTopologyImpl implements TapiTopologyService {
         }
         List<String> goodTpList = extractGoodTpList(clientPortMap);
         // tapi topology creation
-        List<Name> names = new ArrayList<>();
-        names.add(new NameBuilder().setValue(ETH_TOPO).setValueName("Topo Name").build());
+        Map<NameKey, Name> names = new HashMap<>();
+        Name name = new NameBuilder().setValue(ETH_TOPO).setValueName("Topo Name").build();
+        names.put(name.key(), name);
         Uuid uuid = new Uuid(UUID.nameUUIDFromBytes(ETH_TOPO.getBytes(Charset.forName("UTF-8"))).toString());
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
-            tapiNodeList = new ArrayList<>();
-        tapiNodeList.add(createTapiNode(goodTpList));
+        Map<NodeKey ,org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
+            tapiNodeList = new HashMap<>();
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node
+            = createTapiNode(goodTpList);
+        tapiNodeList.put(node.key(), node);
         return new TopologyBuilder().setName(names).setUuid(uuid).setNode(tapiNodeList).build();
 
     }
@@ -216,28 +226,28 @@ public class TapiTopologyImpl implements TapiTopologyService {
                 LOG.error("Impossible to retreive otn-topology from mdsal",e);
                 return null;
             }
-            List<Node> nodeList = otnTopo.getNode();
+            List<Node> nodeList = new ArrayList<>(otnTopo.getNode().values());
             List<Node> otnNodeList = nodeList.stream().filter(nt -> nt.augmentation(
                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1.class)
                 .getNodeType().equals(OpenroadmNodeType.SWITCH) || nt.augmentation(
                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1.class)
                     .getNodeType().equals(OpenroadmNodeType.MUXPDR)).collect(Collectors.toList());
-            List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodeList =
-                new ArrayList<>();
-            List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> tapiLinkList =
-                new ArrayList<>();
+            Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
+                tapiNodeList = new HashMap<>();
+            Map<LinkKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link>
+                tapiLinkList = new HashMap<>();
             Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(T0_MULTI_LAYER_TOPO.getBytes(Charset.forName("UTF-8")))
                 .toString());
             for (Node node : otnNodeList) {
                 ConvertORTopoObjectToTapiTopoObject tapiFactory =
                     new ConvertORTopoObjectToTapiTopoObject(node, null, topoUuid);
                 tapiFactory.convertNode();
-                tapiNodeList.addAll(tapiFactory.getTapiNodes());
-                tapiLinkList.addAll(tapiFactory.getTapiLinks());
+                tapiNodeList.putAll(tapiFactory.getTapiNodes());
+                tapiLinkList.putAll(tapiFactory.getTapiLinks());
             }
+            Name name = new NameBuilder().setValue(T0_MULTI_LAYER_TOPO).setValueName("TAPI Topology Name").build();
             return new TopologyBuilder()
-                    .setName(Arrays.asList(new NameBuilder().setValue(T0_MULTI_LAYER_TOPO)
-                            .setValueName("TAPI Topology Name").build()))
+                    .setName(Map.of(name.key(), name))
                     .setUuid(topoUuid)
                     .setNode(tapiNodeList)
                     .setLink(tapiLinkList).build();
@@ -267,31 +277,29 @@ public class TapiTopologyImpl implements TapiTopologyService {
 
     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node createTapiNode(List<
         String> tpList) {
-        List<Name> names = new ArrayList<>();
         Name name = new NameBuilder().setValueName("node name").setValue("TAPI Ethernet Node").build();
-        names.add(name);
         List<LayerProtocolName> layerProtocols = new ArrayList<>();
         layerProtocols.add(LayerProtocolName.ETH);
-        List<OwnedNodeEdgePoint> onepl = new ArrayList<>();
+        Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
         for (int i = 0; i < tpList.size(); i++) {
-            List<Name> onedNames = new ArrayList<>();
-            onedNames.add(new NameBuilder().setValueName("OwnedNodeEdgePoint " + i).setValue(tpList.get(i)).build());
+            Name onedName = new NameBuilder().setValueName("OwnedNodeEdgePoint " + i).setValue(tpList.get(i)).build();
             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
                 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("OwnedNodeEdgePoint " + i).getBytes(Charset.forName("UTF-8")))
                     .toString()))
                 .setLayerProtocolName(LayerProtocolName.ETH).setMappedServiceInterfacePoint(createSIP(1))
                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
                 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
-                .setLifecycleState(LifecycleState.INSTALLED).setName(onedNames).setTerminationDirection(
+                .setLifecycleState(LifecycleState.INSTALLED).setName(Map.of(onedName.key(), onedName))
+                .setTerminationDirection(
                     TerminationDirection.BIDIRECTIONAL).setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
                 .build();
-            onepl.add(onep);
+            onepl.put(onep.key(), onep);
         }
 
         return new NodeBuilder()
                 .setUuid(new Uuid(UUID.nameUUIDFromBytes(name.getValue().getBytes(Charset.forName("UTF-8")))
                     .toString()))
-                .setName(names).setLayerProtocolName(layerProtocols)
+                .setName(Map.of(name.key(), name)).setLayerProtocolName(layerProtocols)
                 .setAdministrativeState(AdministrativeState.UNLOCKED)
                 .setOperationalState(OperationalState.ENABLED)
                 .setLifecycleState(LifecycleState.INSTALLED)
@@ -299,12 +307,12 @@ public class TapiTopologyImpl implements TapiTopologyService {
                 .build();
     }
 
-    private List<MappedServiceInterfacePoint> createSIP(int nb) {
-        List<MappedServiceInterfacePoint> msipl = new ArrayList<>();
+    private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createSIP(int nb) {
+        Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
         for (int i = 0; i < nb; i++) {
             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder().setServiceInterfacePointUuid(
                 new Uuid(UUID.randomUUID().toString())).build();
-            msipl.add(msip);
+            msipl.put(msip.key(), msip);
         }
         return msipl;
     }
index c1e598d56c3eedb100449b28852d51580e6fb2eb..eee640f42effb7437473c1ab07c52cd2fcbffb47 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.transportpce.tapi.utils;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -34,7 +35,7 @@ public class TapiListener implements DataTreeChangeListener<ServiceInterfacePoin
                 case WRITE:
                     LOG.info("onDataTreeChanged in TapiListener : WRITE");
                     ServiceInterfacePoints data = rootSIP.getDataAfter();
-                    List<ServiceEndPoint> listSEP = data.getServiceEndPoint();
+                    List<ServiceEndPoint> listSEP = new ArrayList<>(data.getServiceEndPoint().values());
                     MappingUtils.deleteMap();
                     for (ServiceEndPoint sep : listSEP) {
                         MappingUtils.addMapSEP(sep);
index f97fc663121d8876bfe8918a969d711b0e0d3a52..e0e20d4da564e0d68653ab1346e34ef01fcd44b0 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.transportpce.tapi.validation;
 
+import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
@@ -34,7 +35,7 @@ public final class CreateConnectivityServiceValidation {
         LOG.info("checking rpc create-connectivity-service input parameters...");
         try {
             LOG.info("checking EndPoints...");
-            List<EndPoint> endPointList = input.getEndPoint();
+            List<EndPoint> endPointList = new ArrayList<>(input.getEndPoint().values());
             ComplianceCheckResult endPointCheckResult = EndPointCheck.check(endPointList);
             if (endPointCheckResult.hasPassed()) {
                 LOG.info("create-connectivity-service end-points compliant !");
index 86edb516b67f91223b4cf128974b1f5ec97d858f..a68dbe4365c072d81cb8ea40b67bdbede7dd45d5 100644 (file)
@@ -114,9 +114,9 @@ public class TapiTopologyImplTest extends AbstractTest {
         Uuid onep1Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 0".getBytes()).toString());
         Uuid onep2Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 1".getBytes()).toString());
         assertEquals("incorrect uuid for nep1",
-            onep1Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(0).getUuid());
+            onep1Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(1).getUuid());
         assertEquals("incorrect uuid for nep1",
-            onep2Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(1).getUuid());
+            onep2Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(0).getUuid());
     }
 
     @Test
@@ -143,7 +143,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             "T0 - Multi-layer topology",
             topology.getName().get(0).getValue());
 
-        List<Node> nodes = topology.getNode().stream()
+        List<Node> nodes = topology.getNode().values().stream()
             .sorted((n1,n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
             .collect(Collectors.toList());
         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
@@ -159,7 +159,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             .toString());
         checkOtsiNode(nodes.get(3), node4Uuid, true);
 
-        List<Link> links = topology.getLink().stream()
+        List<Link> links = topology.getLink().values().stream()
             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
             .collect(Collectors.toList());
         checkTransitionalLink(links.get(0), topoUuid, node1Uuid, node3Uuid, "DSR+XPDR1-NETWORK1",
@@ -180,7 +180,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             2, node.getLayerProtocolName().size());
         assertThat("dsr node should manage 2 protocol layers : dsr and odu",
             node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
-        List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().stream()
+        List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().values().stream()
             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
             .collect(Collectors.toList());
         if (isSwitch) {
@@ -193,7 +193,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             Uuid networkNepUuid = new Uuid(
                     UUID.nameUUIDFromBytes("DSR+XPDR2-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
             checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "NodeEdgePoint_N1");
-            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().stream()
+            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
                 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
                 .collect(Collectors.toList());
             checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
@@ -208,7 +208,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             Uuid networkNepUuid = new Uuid(
                     UUID.nameUUIDFromBytes("DSR+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
             checkNepNetworkODU4(nep2, networkNepUuid, "XPDR1-NETWORK1", "NodeEdgePoint_N1");
-            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().stream()
+            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
                 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
                 .collect(Collectors.toList());
             checkNodeRuleGroupForMuxDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
@@ -227,7 +227,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             1, node.getLayerProtocolName().size());
         assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
             LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().get(0));
-        List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().stream()
+        List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().values().stream()
             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
             .collect(Collectors.toList());
         if (isSwitch) {
@@ -240,7 +240,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             Uuid enepUuid = new Uuid(
                     UUID.nameUUIDFromBytes("eOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString());
             checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint_2");
-            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().stream()
+            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
                 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
                 .collect(Collectors.toList());
             checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
@@ -254,7 +254,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             Uuid inepUuid = new Uuid(
                     UUID.nameUUIDFromBytes("iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
             checkNepOtsiNode(nep2, inepUuid, "XPDR1-NETWORK1", "iNodeEdgePoint_1");
-            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().stream()
+            List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
                 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
                 .collect(Collectors.toList());
             checkNodeRuleGroupForMuxOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
@@ -321,7 +321,7 @@ public class TapiTopologyImplTest extends AbstractTest {
         Uuid nodeUuid) {
         assertEquals("Switch-DSR should contain a single node rule group", 1, nrgList.size());
         assertEquals("Switch-DSR node-rule-group should contain 8 NEP", 8, nrgList.get(0).getNodeEdgePoint().size());
-        List<NodeEdgePoint> nrg = nrgList.get(0).getNodeEdgePoint().stream()
+        List<NodeEdgePoint> nrg = nrgList.get(0).getNodeEdgePoint().values().stream()
             .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
                 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
             .collect(Collectors.toList());
@@ -475,4 +475,4 @@ public class TapiTopologyImplTest extends AbstractTest {
             link.getNodeEdgePoint().get(1).getNodeEdgePointUuid().getValue(),
             either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
     }
-}
\ No newline at end of file
+}