X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Futil%2FOpenRoadmOtnTopology.java;h=fa02061f1d0de0215bc455d6b7ebabb2ac3a343d;hb=b5ee86a522ce3cf5c6216f10647edb08b31c72e9;hp=a6fd1014f7c4f58a9ba7958377000f692702e878;hpb=0d1c0746ea2b384ce5e7dc9309fdb9eef04567ce;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java index a6fd1014f..fa02061f1 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java @@ -18,8 +18,8 @@ import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.transportpce.common.NetworkUtils; import org.opendaylight.transportpce.networkmodel.dto.OtnTopoNode; import org.opendaylight.transportpce.networkmodel.dto.TopologyShard; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210425.mapping.Mapping; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210425.network.Nodes; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.network.Nodes; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; @@ -36,10 +36,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.x import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTU4TsAllocated; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTUCnTs; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU0; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2e; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OdtuTypeIdentity; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OduRateIdentity; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1; import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1Builder; @@ -60,7 +62,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.Supp 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; import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev200529.xpdr.otn.tp.attributes.OdtuTpnPoolBuilder; -import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.OtnLinkType; +import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node; @@ -122,32 +124,77 @@ public final class OpenRoadmOtnTopology { public static TopologyShard createOtnLinks(String nodeA, String tpA, String nodeZ, String tpZ, OtnLinkType linkType) { List links = null; - if (OtnLinkType.OTU4.equals(linkType)) { - links = initialiseOtnLinks(nodeA, tpA, nodeZ, tpZ, linkType, "OTU4"); + if (OtnLinkType.OTU4.equals(linkType) || OtnLinkType.OTUC4.equals(linkType)) { + links = initialiseOtnLinks(nodeA, tpA, nodeZ, tpZ, linkType); } return new TopologyShard(null, links); } - public static TopologyShard createOtnLinks(List suppOtu4Links, List oldTps) { + public static TopologyShard createOtnLinks( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp + .Link notifLink, + OtnLinkType linkType) { + + return new TopologyShard(null, initialiseOtnLinks(notifLink.getATermination().getNodeId(), + notifLink.getATermination().getTpId(), notifLink.getZTermination().getNodeId(), + notifLink.getZTermination().getTpId(), linkType)); + } + + public static TopologyShard createOtnLinks( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp + .Link notifLink, + List supportedOtu4links, + List supportedTPs, + OtnLinkType linkType) { + + List links; + switch (linkType) { + case OTU4: + case OTUC4: + links = initialiseOtnLinks( + notifLink.getATermination().getNodeId(), notifLink.getATermination().getTpId(), + notifLink.getZTermination().getNodeId(), notifLink.getZTermination().getTpId(), linkType); + return new TopologyShard(null, links); + case ODTU4: + case ODUC4: + links = initialiseOtnLinks( + notifLink.getATermination().getNodeId(), notifLink.getATermination().getTpId(), + notifLink.getZTermination().getNodeId(), notifLink.getZTermination().getTpId(), linkType); + links.addAll(updateOtnLinkBwParameters(supportedOtu4links, linkType)); + List updatedTPs = new ArrayList<>(); + for (TerminationPoint tp : supportedTPs) { + updatedTPs.add(updateTp(tp, true, linkType)); + } + return new TopologyShard(null, links, updatedTPs); + default: + return null; + } + } + + public static TopologyShard createOtnLinks(List suppOtuLinks, List oldTps, + OtnLinkType linkType) { List links = new ArrayList<>(); - for (Link link : suppOtu4Links) { - if (link.augmentation(Link1.class) != null + for (Link link : suppOtuLinks) { + if (OtnLinkType.ODTU4.equals(linkType) && link.augmentation(Link1.class) != null && link.augmentation(Link1.class).getAvailableBandwidth().equals(Uint32.valueOf(100000))) { links.add(updateOtnLinkBwParameters(link, 0L, 100000L)); + } else if (OtnLinkType.ODUC4.equals(linkType) && link.augmentation(Link1.class) != null + && link.augmentation(Link1.class).getAvailableBandwidth().equals(Uint32.valueOf(400000))) { + links.add(updateOtnLinkBwParameters(link, 0L, 400000L)); } else { LOG.error("Error with otn parameters of supported link {}", link.getLinkId().getValue()); } } if (links.size() == 2) { - links.addAll(initialiseOtnLinks(suppOtu4Links.get(0).getSource().getSourceNode().getValue(), - suppOtu4Links.get(0).getSource().getSourceTp().toString(), - suppOtu4Links.get(0).getDestination().getDestNode().getValue(), - suppOtu4Links.get(0).getDestination().getDestTp().toString(), - OtnLinkType.ODTU4, "ODU4")); + links.addAll(initialiseOtnLinks(suppOtuLinks.get(0).getSource().getSourceNode().getValue(), + suppOtuLinks.get(0).getSource().getSourceTp().getValue(), + suppOtuLinks.get(0).getDestination().getDestNode().getValue(), + suppOtuLinks.get(0).getDestination().getDestTp().getValue(), + linkType)); } List tps = new ArrayList<>(); for (TerminationPoint tp : oldTps) { - tps.add(updateTp(tp, true)); + tps.add(updateTp(tp, true, linkType)); } if (links.size() == 4 && tps.size() == 2) { return new TopologyShard(null, links, tps); @@ -156,14 +203,25 @@ public final class OpenRoadmOtnTopology { } } - public static TopologyShard updateOtnLinks(List suppOdu4Links, List oldTps, - String serviceRate, Short tribPortNb, Short tribSoltNb, boolean isDeletion) { + public static TopologyShard updateOtnLinks(List suppOduLinks, List oldTps, + Uint32 serviceRate, Short tribPortNb, Short minTribSlotNb, Short maxTribSlotNb, boolean isDeletion) { List links = new ArrayList<>(); - Long bwIncr = 10000L; - if ("1G".equals(serviceRate)) { - bwIncr = 1000L; + Long bwIncr; + switch (serviceRate.intValue()) { + case 1: + bwIncr = 1000L; + break; + case 10: + bwIncr = 10000L; + break; + case 100: + bwIncr = 100000L; + break; + default: + LOG.warn("Error with not managed service rate {}", serviceRate.toString()); + return new TopologyShard(null, null, null); } - for (Link link : suppOdu4Links) { + for (Link link : suppOduLinks) { if (link.augmentation(Link1.class) != null && link.augmentation(Link1.class).getAvailableBandwidth() != null && link.augmentation(Link1.class).getUsedBandwidth() != null) { Uint32 avlBw = link.augmentation(Link1.class).getAvailableBandwidth(); @@ -185,7 +243,7 @@ public final class OpenRoadmOtnTopology { List tps = new ArrayList<>(); for (TerminationPoint tp : oldTps) { if (bwIncr != 0) { - tps.add(updateNodeTpTsPool(tp, serviceRate, tribPortNb, tribSoltNb, isDeletion)); + tps.add(updateNodeTpTsPool(tp, serviceRate, tribPortNb, minTribSlotNb, maxTribSlotNb, isDeletion)); } } if (!links.isEmpty() && !tps.isEmpty()) { @@ -196,20 +254,55 @@ public final class OpenRoadmOtnTopology { } } - public static TopologyShard deleteOtnLinks(List suppOtu4Links, List oldTps) { + public static TopologyShard updateOtnLinks(List suppOtuLinks, boolean isDeletion) { + List links = new ArrayList<>(); + for (Link link : suppOtuLinks) { + if (link.augmentation(Link1.class) == null + || link.augmentation(Link1.class).getAvailableBandwidth() == null + || link.augmentation(Link1.class).getUsedBandwidth() == null) { + LOG.error("Error with otn parameters of supported link {}", link.getLinkId().getValue()); + } else { + if (isDeletion) { + links.add(updateOtnLinkBwParameters(link, Long.valueOf(100000), Long.valueOf(0))); + } else { + links.add(updateOtnLinkBwParameters(link, Long.valueOf(0), Long.valueOf(100000))); + } + } + } + if (links.isEmpty()) { + LOG.error("unable to update otn links"); + return new TopologyShard(null, null, null); + } else { + return new TopologyShard(null, links, null); + } + } + + public static TopologyShard deleteOtnLinks(List suppOtuLinks, List oldTps, + OtnLinkType linkType) { List links = new ArrayList<>(); - for (Link link : suppOtu4Links) { - if (link.augmentation(Link1.class) != null) { - links.add(updateOtnLinkBwParameters(link, 100000L, 0L)); + OtnLinkType otnLinkType = null; + for (Link link : suppOtuLinks) { + if (link.augmentation(Link1.class) != null && link.augmentation( + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class) != null) { + otnLinkType = link.augmentation( + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class).getOtnLinkType(); + if (OtnLinkType.OTU4.equals(otnLinkType)) { + links.add(updateOtnLinkBwParameters(link, 100000L, 0L)); + } else if (OtnLinkType.OTUC4.equals(otnLinkType)) { + links.add(updateOtnLinkBwParameters(link, 400000L, 0L)); + } else { + LOG.warn("Unexpected otn-link-type {} for link {}", otnLinkType, link.getLinkId()); + } } else { LOG.error("Error with otn parameters of supported link {}", link.getLinkId().getValue()); + return new TopologyShard(null, null, null); } } List tps = new ArrayList<>(); for (TerminationPoint tp : oldTps) { - tps.add(updateTp(tp, false)); + tps.add(updateTp(tp, false, linkType)); } - if (links.size() == 2 && tps.size() == 2) { + if (!links.isEmpty() && !tps.isEmpty()) { return new TopologyShard(null, links, tps); } else { return new TopologyShard(null, null, null); @@ -217,29 +310,33 @@ public final class OpenRoadmOtnTopology { } private static List initialiseOtnLinks(String nodeA, String tpA, String nodeZ, String tpZ, - OtnLinkType linkType, String linkIdPrefix) { + OtnLinkType linkType) { List links = new ArrayList<>(); - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1 tpceLink1 - = new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1Builder() + String nodeATopo = formatNodeName(nodeA, tpA); + String nodeZTopo = formatNodeName(nodeZ, tpZ); + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1 tpceLink1 + = new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1Builder() .setOtnLinkType(linkType).build(); - Link1 otnLink1 = new Link1Builder() - .setAvailableBandwidth(Uint32.valueOf(100000)) - .setUsedBandwidth(Uint32.valueOf(0)) - .build(); - // create link A-Z - String nodeATopo; - String nodeZTopo; - if (nodeA.contains(XPDR) && nodeZ.contains(XPDR)) { - nodeATopo = nodeA; - nodeZTopo = nodeZ; - } else { - nodeATopo = nodeA + "-" + tpA.split("-")[0]; - nodeZTopo = nodeZ + "-" + tpZ.split("-")[0]; + Link1Builder otnLink1Bldr = new Link1Builder() + .setUsedBandwidth(Uint32.valueOf(0)); + switch (linkType) { + case OTU4: + case ODTU4: + otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(100000)); + break; + case OTUC4: + case ODUC4: + otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(400000)); + break; + default: + LOG.error("unable to set available bandwidth to unknown link type"); + break; } - LinkBuilder ietfLinkAZBldr = TopologyUtils.createLink(nodeATopo, nodeZTopo, tpA, tpZ, linkIdPrefix); + // create link A-Z + LinkBuilder ietfLinkAZBldr = TopologyUtils.createLink(nodeATopo, nodeZTopo, tpA, tpZ, linkType.getName()); ietfLinkAZBldr .addAugmentation(tpceLink1) - .addAugmentation(otnLink1) + .addAugmentation(otnLink1Bldr.build()) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder( ietfLinkAZBldr.augmentation( @@ -250,10 +347,10 @@ public final class OpenRoadmOtnTopology { .build()); links.add(ietfLinkAZBldr.build()); // create link Z-A - LinkBuilder ietfLinkZABldr = TopologyUtils.createLink(nodeZTopo, nodeATopo, tpZ, tpA, linkIdPrefix); + LinkBuilder ietfLinkZABldr = TopologyUtils.createLink(nodeZTopo, nodeATopo, tpZ, tpA, linkType.getName()); ietfLinkZABldr .addAugmentation(tpceLink1) - .addAugmentation(otnLink1) + .addAugmentation(otnLink1Bldr.build()) .addAugmentation( new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder( ietfLinkZABldr.augmentation( @@ -276,7 +373,34 @@ public final class OpenRoadmOtnTopology { return updatedLinkBldr.build(); } - private static TerminationPoint updateTp(TerminationPoint originalTp, boolean addingTsTpnPoolTermination) { + private static List updateOtnLinkBwParameters(List supportedLinks, OtnLinkType linkType) { + LOG.debug("in updateOtnLinkBwParameters with supportedLinks = {}, linkType = {}", supportedLinks, linkType); + Uint32 usedBw; + switch (linkType) { + case ODTU4: + usedBw = Uint32.valueOf(100000); + break; + case ODUC4: + usedBw = Uint32.valueOf(400000); + break; + default: + usedBw = Uint32.valueOf(0); + break; + } + List updatedlinks = new ArrayList<>(); + for (Link link : supportedLinks) { + LinkBuilder updatedLinkBldr = new LinkBuilder(link); + updatedLinkBldr.addAugmentation(new Link1Builder(link.augmentation(Link1.class)) + .setAvailableBandwidth(Uint32.valueOf(0)) + .setUsedBandwidth(usedBw) + .build()); + updatedlinks.add(updatedLinkBldr.build()); + } + return updatedlinks; + } + + private static TerminationPoint updateTp(TerminationPoint originalTp, boolean addingTsTpnPoolTermination, + OtnLinkType linkType) { LOG.debug("in updateTp"); TerminationPointBuilder tpBldr = new TerminationPointBuilder(originalTp); TerminationPoint1Builder otnTp1Bldr = new TerminationPoint1Builder( @@ -285,12 +409,16 @@ public final class OpenRoadmOtnTopology { .getXpdrTpPortConnectionAttributes()); if (addingTsTpnPoolTermination) { List tsPool = new ArrayList<>(); - for (int i = 0; i < NB_TRIB_SLOTS; i++) { - tsPool.add(Uint16.valueOf(i + 1)); + for (int i = 1; i <= NB_TRIB_SLOTS; i++) { + tsPool.add(Uint16.valueOf(i)); } xtpcaBldr.setTsPool(tsPool); List tpnPool = new ArrayList<>(); - for (int i = 1; i <= NB_TRIB_PORTS; i++) { + int nbTribPort = NB_TRIB_PORTS; + if (OtnLinkType.ODUC4.equals(linkType)) { + nbTribPort = 4; + } + for (int i = 1; i <= nbTribPort; i++) { tpnPool.add(Uint16.valueOf(i)); } OdtuTpnPool oduTpnPool = new OdtuTpnPoolBuilder().setOdtuType(ODTU4TsAllocated.class) @@ -303,36 +431,22 @@ public final class OpenRoadmOtnTopology { return tpBldr.addAugmentation(otnTp1Bldr.setXpdrTpPortConnectionAttributes(xtpcaBldr.build()).build()).build(); } - private static TerminationPoint updateNodeTpTsPool(TerminationPoint tp, String serviceRate, Short tribPortNb, - Short tribSlotNb, boolean isDeletion) { + private static TerminationPoint updateNodeTpTsPool(TerminationPoint tp, Uint32 serviceRate, Short tribPortNb, + Short minTribSlotNb, Short maxTribSlotNb, boolean isDeletion) { LOG.debug("in updateNodeTpTsPool"); TerminationPointBuilder tpBldr = new TerminationPointBuilder(tp); @Nullable XpdrTpPortConnectionAttributesBuilder xtpcaBldr = new XpdrTpPortConnectionAttributesBuilder( tpBldr.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes()); List tsPool = new ArrayList<>(xtpcaBldr.getTsPool()); - switch (serviceRate) { - case "1G": - if (isDeletion) { - tsPool.add(Uint16.valueOf(tribSlotNb)); - } else { - tsPool.remove(Uint16.valueOf(tribSlotNb)); - } - break; - case "10G": - if (isDeletion) { - for (int i = 0; i < NB_TRIB_SLOT_PER_10GE; i++) { - tsPool.add(Uint16.valueOf(tribSlotNb + i)); - } - } else { - for (int i = 0; i < NB_TRIB_SLOT_PER_10GE; i++) { - tsPool.remove(Uint16.valueOf(tribSlotNb + i)); - } - } - break; - default: - LOG.error("error updating tpn and ts pool for tp {}", tp.getTpId().getValue()); - break; + if (isDeletion) { + for (int i = minTribSlotNb; i <= maxTribSlotNb; i++) { + tsPool.add(Uint16.valueOf(i)); + } + } else { + for (int i = minTribSlotNb; i <= maxTribSlotNb; i++) { + tsPool.remove(Uint16.valueOf(i)); + } } xtpcaBldr.setTsPool(tsPool); List tpnPool; @@ -347,7 +461,20 @@ public final class OpenRoadmOtnTopology { } else { tpnPool = new ArrayList<>(); } - OdtuTpnPool odtuTpnPool = new OdtuTpnPoolBuilder().setOdtuType(ODTU4TsAllocated.class) + Class odtuType = null; + switch (serviceRate.intValue()) { + case 1: + case 10: + odtuType = ODTU4TsAllocated.class; + break; + case 100: + odtuType = ODTUCnTs.class; + break; + default: + LOG.warn("Unable to set the odtu-type"); + break; + } + OdtuTpnPool odtuTpnPool = new OdtuTpnPoolBuilder().setOdtuType(odtuType) .setTpnPool(tpnPool).build(); xtpcaBldr.setOdtuTpnPool(ImmutableMap.of(odtuTpnPool.key(),odtuTpnPool)); @@ -607,16 +734,19 @@ public final class OpenRoadmOtnTopology { .setSupportedInterfaceCapability(supIfMap) .build(); otnTp1Bldr.setTpSupportedInterfaces(tpSupIf); + //TODO: It is not logical to assign a priori one of the possible rate to the TP. + //Would be worth assigning per default "unallocated" at the tp creation step, + //and updating it with correct rate when it supports a specific service. if (withRate) { - xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability().get(0))); + xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability())); otnTp1Bldr.setXpdrTpPortConnectionAttributes(xtpcaBldr.build()); } } else { LOG.warn("mapping {} of node {} has no if-cap-type", mapping.getLogicalConnectionPoint(), node.getNodeId()); } - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder tpceTp1Bldr = - new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder(); + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1Builder tpceTp1Bldr = + new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1Builder(); TpId tpId = new TpId(mapping.getLogicalConnectionPoint()); setclientNwTpAttr(tpMap, node, tpId, tpType, otnTp1Bldr.build(), tpceTp1Bldr, mapping); } @@ -624,7 +754,7 @@ public final class OpenRoadmOtnTopology { private static void setclientNwTpAttr(Map tpMap, OtnTopoNode node, TpId tpId, OpenroadmTpType tpType, TerminationPoint1 otnTp1, - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder tpceTp1Bldr, + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1Builder tpceTp1Bldr, Mapping mapping) { switch (tpType) { case XPONDERNETWORK: @@ -634,7 +764,7 @@ public final class OpenRoadmOtnTopology { SupportingTerminationPoint stp = new SupportingTerminationPointBuilder() .setNetworkRef(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)) .setNodeRef(new NodeId(node.getNodeId() + XPDR + node.getXpdrNb())) - .setTpRef(tpId.getValue()) + .setTpRef(tpId) .build(); TerminationPoint ietfTpNw = buildIetfTp(tpceTp1Bldr, otnTp1, tpType, tpId, Map.of(stp.key(), stp), mapping); @@ -653,21 +783,19 @@ public final class OpenRoadmOtnTopology { } } - private static Class fixRate(Class ifCapType) { - switch (ifCapType.getSimpleName()) { - case "If100GEODU4": - case "IfOCHOTU4ODU4": - return ODU4.class; - case "If1GEODU0": - return ODU0.class; - case "If10GEODU2": - return ODU2.class; - case "If10GEODU2e": - return ODU2e.class; - default: - return null; + private static Class fixRate(List> list) { + Map> rateMap = Map.of( + "If100GEODU4", ODU4.class, + "IfOCHOTU4ODU4", ODU4.class, + "If1GEODU0", ODU0.class, + "If10GEODU2", ODU2.class, + "If10GEODU2e", ODU2e.class); + for (Class class1 : list) { + if (rateMap.containsKey(class1.getSimpleName())) { + return rateMap.get(class1.getSimpleName()); + } } + return null; } private static Map createSupportingNodes(OtnTopoNode node) { @@ -697,7 +825,7 @@ public final class OpenRoadmOtnTopology { } private static TerminationPoint buildIetfTp( - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1Builder tpceTp1Bldr, + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1Builder tpceTp1Bldr, TerminationPoint1 otnTp1, OpenroadmTpType tpType, TpId tpId, Map supportTpMap, Mapping mapping) { @@ -715,10 +843,16 @@ public final class OpenRoadmOtnTopology { .setOperationalState(TopologyUtils.setNetworkOperState(mapping.getPortOperState())) .build(); - ietfTpBldr.setTpId(tpId) - .withKey(new TerminationPointKey(tpId)) - .addAugmentation(otnTp1) - .addAugmentation(ocnTp); - return ietfTpBldr.build(); + return ietfTpBldr.setTpId(tpId) + .withKey(new TerminationPointKey(tpId)) + .addAugmentation(otnTp1) + .addAugmentation(ocnTp) + .build(); + } + + private static String formatNodeName(String nodeName, String tpName) { + return nodeName.contains(XPDR) + ? nodeName + : new StringBuilder(nodeName).append("-").append(tpName.split("-")[0]).toString(); } }