Use version 13.1.0 of openroadm-network models
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToTapiTopo.java
index 0d788c5c82be59739c5765be95bf94593289c5a7..8fe16f870a7f547d30e7e22e119c3a3aff0aa182 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.transportpce.tapi.topology;
 
 import java.nio.charset.Charset;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -23,19 +22,19 @@ import java.util.UUID;
 import java.util.stream.Collectors;
 import org.opendaylight.transportpce.tapi.TapiStringConstants;
 import org.opendaylight.transportpce.tapi.utils.TapiLink;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmTpType;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.Node1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
@@ -115,17 +114,17 @@ public class ConvertORTopoToTapiTopo {
 
     public void convertNode(Node ietfNode, List<String> networkPorts) {
         this.ietfNodeId = ietfNode.getNodeId().getValue();
-        if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1.class)
+        if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
                 == null) {
             return;
         }
         this.ietfNodeType = ietfNode.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1.class).getNodeType();
+            org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
         this.ietfNodeAdminState = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1.class)
+                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
             .getAdministrativeState();
         this.ietfNodeOperState = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1.class)
+                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
             .getOperationalState();
         this.oorNetworkPortList = ietfNode.augmentation(
                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
@@ -137,7 +136,7 @@ public class ConvertORTopoToTapiTopo {
             .collect(Collectors.toList());
         if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
             this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
-                .values().stream().findFirst().get();
+                .values().stream().findFirst().orElseThrow();
             this.oorClientPortList = ietfNode.augmentation(
                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
                 .getTerminationPoint().values().stream()
@@ -169,7 +168,7 @@ public class ConvertORTopoToTapiTopo {
             .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.DSR)).build();
         Name nameNodeType = new NameBuilder().setValueName("Node Type")
             .setValue(this.ietfNodeType.getName()).build();
-        List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, LayerProtocolName.ODU);
+        Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
             .Node dsrNode = createTapiNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
             dsrLayerProtocols);
@@ -182,7 +181,7 @@ public class ConvertORTopoToTapiTopo {
         this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI), nodeUuid);
         Name nameOtsi =  new NameBuilder().setValueName("otsi node name")
             .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI)).build();
-        List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
+        Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
             .Node otsiNode = createTapiNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
             otsiLayerProtocols);
@@ -241,8 +240,8 @@ public class ConvertORTopoToTapiTopo {
                 Link tapLink = this.tapiLink.createTapiLink(otnlink.getSource().getSourceNode().getValue(),
                     otnlink.getSource().getSourceTp().getValue(), otnlink.getDestination().getDestNode().getValue(),
                     otnlink.getDestination().getDestTp().getValue(), TapiStringConstants.OTN_XPDR_XPDR_LINK, nodesQual,
-                    nodesQual, tpsQual, tpsQual, adminState, operState, List.of(layerProtocolName),
-                    List.of(layerProtocolName.getName()), this.tapiTopoUuid);
+                    nodesQual, tpsQual, tpsQual, adminState, operState, Set.of(layerProtocolName),
+                    Set.of(layerProtocolName.getName()), this.tapiTopoUuid);
                 linksToNotConvert.add(oppositeLinkId);
                 tapiLinks.put(tapLink.key(), tapLink);
             }
@@ -257,7 +256,7 @@ public class ConvertORTopoToTapiTopo {
             .build();
         Name nameNodeType = new NameBuilder().setValueName("Node Type")
             .setValue(OpenroadmNodeType.ROADM.getName()).build();
-        List<LayerProtocolName> nodeLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
+        Set<LayerProtocolName> nodeLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
 
         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiPhotonicNodes
             = pruneTapiPhotonicNodes();
@@ -294,10 +293,10 @@ public class ConvertORTopoToTapiTopo {
         int count = 1;
         for (TerminationPoint tp : this.oorNetworkPortList) {
             TpId tpid1 = tp.getTpId();
-            TpId tpid2 = new TpId(tp.augmentation(
-                    org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1.class)
-                .getAssociatedConnectionMapPort());
-            List<TpId> tpList = new ArrayList<>();
+            TpId tpid2 = tp.augmentation(
+                    org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1.class)
+                .getAssociatedConnectionMapTp().iterator().next();
+            Set<TpId> tpList = new HashSet<>();
             tpList.add(tpid1);
             tpList.add(tpid2);
             NonBlockingList nbl = new NonBlockingListBuilder()
@@ -319,7 +318,8 @@ public class ConvertORTopoToTapiTopo {
             prunedTapiPhotonicNodes = new ArrayList<>();
         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiPhotonicNodes
             = this.tapiNodes.values().stream()
-            .filter(n -> LayerProtocolName.PHOTONICMEDIA.equals(n.getLayerProtocolName().get(0)))
+            .filter(n -> LayerProtocolName.PHOTONICMEDIA.equals(n.getLayerProtocolName().stream().findFirst()
+                    .orElseThrow()))
             .collect(Collectors.toList());
         for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node
             : tapiPhotonicNodes) {
@@ -345,7 +345,8 @@ public class ConvertORTopoToTapiTopo {
                 String nodeUuid = node.getUuid().getValue();
                 String nepUuid = nep.getUuid().getValue();
                 String nodeName = node.getName().get(new NameKey("otsi node name")).getValue();
-                String nepName = nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst().get()))
+                String nepName = nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst()
+                        .orElseThrow()))
                     .getValue();
                 uuidNameMap.put(String.join("--", nodeUuid, nepUuid), String.join("--", nodeName, nepName));
             }
@@ -354,7 +355,7 @@ public class ConvertORTopoToTapiTopo {
     }
 
     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
-            createTapiNode(Map<NameKey, Name> nodeNames, List<LayerProtocolName> layerProtocols) {
+            createTapiNode(Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
         Uuid nodeUuid = null;
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
@@ -589,7 +590,7 @@ public class ConvertORTopoToTapiTopo {
                 .setUuid(nepUuid)
                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
                 .setName(Map.of(nepName.key(), nepName))
-                .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
+                .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
                 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
                 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
@@ -646,38 +647,39 @@ public class ConvertORTopoToTapiTopo {
         return msipl;
     }
 
-    private List<Class<? extends LAYERPROTOCOLQUALIFIER>>
+    private Set<LAYERPROTOCOLQUALIFIER>
             createSupportedCepLayerProtocolQualifier(TerminationPoint tp, LayerProtocolName lpn) {
-        Set<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqSet = new HashSet<>();
-        List<SupportedInterfaceCapability> sicList = new ArrayList<>(
-            tp.augmentation(org.opendaylight.yang.gen.v1.http
-                    .org.openroadm.otn.network.topology.rev211210.TerminationPoint1.class).getTpSupportedInterfaces()
-                .getSupportedInterfaceCapability().values());
+        Set<LAYERPROTOCOLQUALIFIER> sclpqSet = new HashSet<>();
+        Collection<SupportedInterfaceCapability> sicList = tp.augmentation(
+                org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class)
+            .getTpSupportedInterfaces()
+            .getSupportedInterfaceCapability().values();
         for (SupportedInterfaceCapability sic : sicList) {
+            String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
             switch (lpn.getName()) {
                 case "DSR":
-                    switch (sic.getIfCapType().getSimpleName()) {
+                    switch (ifCapType) {
                         case "If10GEODU2e":
-                            sclpqSet.add(ODUTYPEODU2E.class);
-                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
+                            sclpqSet.add(ODUTYPEODU2E.VALUE);
+                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
                             break;
                         case "If10GEODU2":
-                            sclpqSet.add(ODUTYPEODU2.class);
-                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
+                            sclpqSet.add(ODUTYPEODU2.VALUE);
+                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
                             break;
                         case "If10GE":
-                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
+                            sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
                             break;
                         case "If100GEODU4":
-                            sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
-                            sclpqSet.add(ODUTYPEODU4.class);
+                            sclpqSet.add(DIGITALSIGNALTYPE100GigE.VALUE);
+                            sclpqSet.add(ODUTYPEODU4.VALUE);
                             break;
                         case "If100GE":
-                            sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
+                            sclpqSet.add(DIGITALSIGNALTYPE100GigE.VALUE);
                             break;
                         case "IfOCHOTU4ODU4":
                         case "IfOCH":
-                            sclpqSet.add(ODUTYPEODU4.class);
+                            sclpqSet.add(ODUTYPEODU4.VALUE);
                             break;
                         default:
                             LOG.error("IfCapability type not managed");
@@ -685,10 +687,9 @@ public class ConvertORTopoToTapiTopo {
                     }
                     break;
                 case "PHOTONIC_MEDIA":
-                    if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
-                            || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
-                        sclpqSet.add(PHOTONICLAYERQUALIFIEROTSi.class);
-                        sclpqSet.add(PHOTONICLAYERQUALIFIEROMS.class);
+                    if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
+                        sclpqSet.add(PHOTONICLAYERQUALIFIEROTSi.VALUE);
+                        sclpqSet.add(PHOTONICLAYERQUALIFIEROMS.VALUE);
                     }
                     break;
                 default:
@@ -696,7 +697,7 @@ public class ConvertORTopoToTapiTopo {
                     break;
             }
         }
-        return new ArrayList<>(sclpqSet);
+        return sclpqSet;
     }
 
     private void createTapiTransitionalLinks() {
@@ -704,9 +705,8 @@ public class ConvertORTopoToTapiTopo {
             Link transiLink = tapiLink.createTapiLink(this.ietfNodeId, tp.getTpId().getValue(), this.ietfNodeId,
                 tp.getTpId().getValue(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
                 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
-                "inService", "inService", Arrays.asList(LayerProtocolName.ODU,
-                    LayerProtocolName.PHOTONICMEDIA),
-                Arrays.asList(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
+                "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
+                Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
                 this.tapiTopoUuid);
             this.tapiLinks.put(transiLink.key(), transiLink);
         }
@@ -744,7 +744,7 @@ public class ConvertORTopoToTapiTopo {
                             .getBytes(Charset.forName("UTF-8")))
                         .toString()))
                 .setName(Map.of(linkName.key(), linkName))
-                .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
+                .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA))
                 .setNodeEdgePoint(nepMap)
                 .setDirection(ForwardingDirection.BIDIRECTIONAL)
                 .build();