Manage 400G in portmapping and topologies 05/95005/1
authorGilles Thouenon <gilles.thouenon@orange.com>
Tue, 9 Feb 2021 18:09:43 +0000 (19:09 +0100)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 10 Mar 2021 08:36:43 +0000 (08:36 +0000)
- retrieve if-cap-type from port-capabilities from device to populate
portmapping
- add protection in otn-topology when building TP if if-cap-type absent
from mapping
- manage 400G if-cap-type case in otn-topology

JIRA: TRNSPRTPCE-373
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: Iaf0e50f76da91f3815c99d9e7f0107f18dc0ddc7
(cherry picked from commit 8fa7e1e25b411f111f198152af6e6244727e71a9)

common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java

index b0abc79207786ac956658de44d226487c9e80508..164ba730c6d5ab5e4b4c78aae29897245cd72fe2 100644 (file)
@@ -89,6 +89,9 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnO
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.Protocols1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.lldp.container.Lldp;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.lldp.container.lldp.PortConfig;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.Ports1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.port.capability.grp.port.capabilities.SupportedInterfaceCapability;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.port.capability.grp.port.capabilities.SupportedInterfaceCapabilityKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
@@ -864,7 +867,7 @@ public class PortMappingVersion710 {
         return mpBldr.build();
     }
 
-    private Mapping createXpdrMappingObject(String nodeId, Ports ports, String circuitPackName,
+    private Mapping createXpdrMappingObject(String nodeId, Ports port, String circuitPackName,
             String logicalConnectionPoint, String partnerLcp, Mapping mapping, String connectionMapLcp,
             XpdrNodeTypes xpdrNodeType) {
 
@@ -880,11 +883,11 @@ public class PortMappingVersion710 {
                 .withKey(new MappingKey(logicalConnectionPoint))
                 .setLogicalConnectionPoint(logicalConnectionPoint)
                 .setSupportingCircuitPackName(circuitPackName)
-                .setSupportingPort(ports.getPortName())
-                .setPortDirection(ports.getPortDirection().getName())
+                .setSupportingPort(port.getPortName())
+                .setPortDirection(port.getPortDirection().getName())
                 .setLcpHashVal(FnvUtils.fnv1_64(nodeIdLcp));
-        if (ports.getPortQual() != null) {
-            mpBldr.setPortQual(ports.getPortQual().getName());
+        if (port.getPortQual() != null) {
+            mpBldr.setPortQual(port.getPortQual().getName());
         }
         if (xpdrNodeType != null) {
             mpBldr.setXponderType(xpdrNodeType);
@@ -892,6 +895,16 @@ public class PortMappingVersion710 {
         if (partnerLcp != null) {
             mpBldr.setPartnerLcp(partnerLcp);
         }
+        if (port.augmentation(Ports1.class) != null && port.augmentation(Ports1.class).getPortCapabilities() != null) {
+            List<Class<? extends org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327
+                .SupportedIfCapability>> supportedIntf = new ArrayList<>();
+            Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfCapMap = port
+                .augmentation(Ports1.class).getPortCapabilities().nonnullSupportedInterfaceCapability();
+            for (SupportedInterfaceCapability sic : supIfCapMap.values()) {
+                supportedIntf.add(sic.getIfCapType());
+            }
+            mpBldr.setSupportedInterfaceCapability(supportedIntf);
+        }
         return mpBldr.build();
     }
 
index 12b69c3666eb1755c3bdbb29652883cb27bc6d13..429390854f4e1432f758163aee245f3ca9e2d082 100644 (file)
@@ -60,8 +60,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GE;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If400GE;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOTUCnODUCn;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev200529.xpdr.otn.tp.attributes.OdtuTpnPool;
@@ -586,28 +588,32 @@ public final class OpenRoadmOtnTopology {
         for (Mapping mapping : mappings) {
             // openroadm-otn-topoology augmentation
             Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
-            for (Class<? extends SupportedIfCapability> supInterCapa : mapping.getSupportedInterfaceCapability()) {
-                SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
-                    .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa)))
-                    .setIfCapType(convertSupIfCapa(supInterCapa))
+            TerminationPoint1Builder otnTp1Bldr = new TerminationPoint1Builder();
+            if (mapping.getSupportedInterfaceCapability() != null) {
+                XpdrTpPortConnectionAttributesBuilder xtpcaBldr = new XpdrTpPortConnectionAttributesBuilder();
+                for (Class<? extends SupportedIfCapability> supInterCapa : mapping.getSupportedInterfaceCapability()) {
+                    SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
+                        .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa)))
+                        .setIfCapType(convertSupIfCapa(supInterCapa))
+                        .build();
+                    supIfMap.put(supIfCapa.key(), supIfCapa);
+                }
+                TpSupportedInterfaces tpSupIf = new TpSupportedInterfacesBuilder()
+                    .setSupportedInterfaceCapability(supIfMap)
                     .build();
-                supIfMap.put(supIfCapa.key(), supIfCapa);
-            }
-            TpSupportedInterfaces tpSupIf = new TpSupportedInterfacesBuilder()
-                .setSupportedInterfaceCapability(supIfMap)
-                .build();
-            XpdrTpPortConnectionAttributesBuilder xtpcaBldr = new XpdrTpPortConnectionAttributesBuilder();
-            if (withRate) {
-                xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability().get(0)));
+                otnTp1Bldr.setTpSupportedInterfaces(tpSupIf);
+                if (withRate) {
+                    xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability().get(0)));
+                    otnTp1Bldr.setXpdrTpPortConnectionAttributes(xtpcaBldr.build());
+                }
+            } else {
+                LOG.warn("mapping {} of node {} has no if-cap-type", mapping.getLogicalConnectionPoint(),
+                    node.getNodeId());
             }
-            TerminationPoint1 otnTp1 = new TerminationPoint1Builder()
-                .setTpSupportedInterfaces(tpSupIf)
-                .setXpdrTpPortConnectionAttributes(xtpcaBldr.build())
-                .build();
             org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder tpceTp1Bldr =
                 new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder();
             TpId tpId = new TpId(mapping.getLogicalConnectionPoint());
-            setclientNwTpAttr(tpMap, node, tpId, tpType, otnTp1, tpceTp1Bldr);
+            setclientNwTpAttr(tpMap, node, tpId, tpType, otnTp1Bldr.build(), tpceTp1Bldr);
         }
     }
 
@@ -658,24 +664,28 @@ public final class OpenRoadmOtnTopology {
     private static Class<? extends SupportedIfCapability> convertSupIfCapa(Class<? extends
             SupportedIfCapability> ifCapType) {
         switch (ifCapType.getSimpleName()) {
-            case "If100GEODU4":
-                return If100GEODU4.class;
+            case "IfOTUCnODUCn":
+                return IfOTUCnODUCn.class;
             case "IfOCHOTU4ODU4":
                 return IfOCHOTU4ODU4.class;
-            case "If1GEODU0":
-                return If1GEODU0.class;
+            case "IfOCH":
+                return IfOCH.class;
+            case "If100GEODU4":
+                return If100GEODU4.class;
             case "If10GEODU2e":
                 return If10GEODU2e.class;
             case "If10GEODU2":
                 return If10GEODU2.class;
+            case "If1GEODU0":
+                return If1GEODU0.class;
+            case "If400GE":
+                return If400GE.class;
             case "If100GE":
                 return If100GE.class;
             case "If10GE":
                 return If10GE.class;
             case "If1GE":
                 return If1GE.class;
-            case "IfOCH":
-                return IfOCH.class;
             default:
                 return null;
         }