From: Gilles Thouenon Date: Thu, 9 Sep 2021 13:23:29 +0000 (+0200) Subject: Adapt network module to update OTU links only X-Git-Tag: 5.0.0~178 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=d7fecc8acc65d73716d7a6b9ac9468f6ceb7cb16 Adapt network module to update OTU links only Add a new updateOtnLink method in NetworkModelService and implement it to update bandwidth parameters of OTU4 links only when creating/deleting 100GE service that is not supported over a structured ODU4. This is the case when the service is terminated on an OTN Switch. JIRA: TRNSPRTPCE-512 Signed-off-by: Gilles Thouenon Change-Id: I9db5ecaba843093b3a9543ef9e24b03ff3a227fb --- diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelService.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelService.java index aaa515238..3e8b342f5 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelService.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelService.java @@ -93,7 +93,10 @@ public interface NetworkModelService { void deleteOtnLinks(String nodeA, String tpA, String nodeZ, String tpZ, OtnLinkType linkType); /** - * update otn links from otn-topology. + * Update otn links from otn-topology. + * For services using low-order odu, updates bandwidth parameters + * for both the direct parent high-order odu link, and also its server + * otu link. * * @param link * link containing termination points to be updated @@ -110,4 +113,16 @@ public interface NetworkModelService { */ void updateOtnLinks(Link link, Uint32 serviceRate, Short tribPortNb, Short minTribSoltNb, Short maxTribSoltNb, boolean isDeletion); + + /** + * Update otn links from otn-topology. + * For services using directly a high-order odu, updates bandwidth parameters + * of the direct parent otu link. + * + * @param link + * link containing termination points to be updated + * @param isDeletion + * True indicates if the low-order otn service must be deleted + */ + void updateOtnLinks(Link link, boolean isDeletion); } diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java index 5c1ab9dac..74567811e 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java @@ -400,8 +400,6 @@ public class NetworkModelServiceImpl implements NetworkModelService { break; case ODTU4: case ODUC4: - String nodeTopoA = new StringBuilder(nodeA).append("-").append(tpA.split("-")[0]).toString(); - String nodeTopoZ = new StringBuilder(nodeZ).append("-").append(tpZ.split("-")[0]).toString(); List linkIdList = new ArrayList<>(); String prefix; if (OtnLinkType.ODTU4.equals(linkType)) { @@ -409,10 +407,13 @@ public class NetworkModelServiceImpl implements NetworkModelService { } else { prefix = OtnLinkType.OTUC4.getName(); } - linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, prefix)); - linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, prefix)); + linkIdList.add(LinkIdUtil.buildOtnLinkId(convertNetconfNodeIdToTopoNodeId(nodeA, tpA), tpA, + convertNetconfNodeIdToTopoNodeId(nodeZ, tpZ), tpZ, prefix)); + linkIdList.add(LinkIdUtil.buildOtnLinkId(convertNetconfNodeIdToTopoNodeId(nodeZ, tpZ), tpZ, + convertNetconfNodeIdToTopoNodeId(nodeA, tpA), tpA, prefix)); List supportedOtu4links = getOtnLinks(linkIdList); - List tps = getOtnNodeTps(nodeTopoA, tpA, nodeTopoZ, tpZ); + List tps = getOtnNodeTps(convertNetconfNodeIdToTopoNodeId(nodeA, tpA), tpA, + convertNetconfNodeIdToTopoNodeId(nodeZ, tpZ), tpZ); otnTopologyShard = OpenRoadmOtnTopology.createOtnLinks(supportedOtu4links, tps, linkType); break; default: @@ -604,6 +605,43 @@ public class NetworkModelServiceImpl implements NetworkModelService { } } + @Override + public void updateOtnLinks( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.renderer.rpc.result.sp.Link + notifLink, boolean isDeletion) { + + List linkIdList = new ArrayList<>(); + String nodeTopoA = convertNetconfNodeIdToTopoNodeId(notifLink.getATermination().getNodeId(), + notifLink.getATermination().getTpId()); + String nodeTopoZ = convertNetconfNodeIdToTopoNodeId(notifLink.getZTermination().getNodeId(), + notifLink.getZTermination().getTpId()); + linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, notifLink.getATermination().getTpId(), + nodeTopoZ, notifLink.getZTermination().getTpId(), OtnLinkType.OTU4.getName())); + linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, notifLink.getZTermination().getTpId(), + nodeTopoA, notifLink.getATermination().getTpId(), OtnLinkType.OTU4.getName())); + List supportedOtu4links = getOtnLinks(linkIdList); + + TopologyShard otnTopologyShard = OpenRoadmOtnTopology.updateOtnLinks(supportedOtu4links, isDeletion); + if (otnTopologyShard.getLinks() != null) { + for (Link otnTopologyLink : otnTopologyShard.getLinks()) { + LOG.info("creating and updating otn links {} in {}", otnTopologyLink.getLinkId().getValue(), + NetworkUtils.OVERLAY_NETWORK_ID); + InstanceIdentifier iiOtnTopologyLink = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID))) + .augmentation(Network1.class) + .child(Link.class, otnTopologyLink.key()) + .build(); + networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyLink, otnTopologyLink); + } + } + try { + networkTransactionService.commit().get(); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Error adding OTN links in otn-topology", e); + } + LOG.info("OTN links updated"); + } + private List getOtnLinks(List linkIds) { List links = new ArrayList<>(); for (LinkId linkId : linkIds) { @@ -821,6 +859,10 @@ public class NetworkModelServiceImpl implements NetworkModelService { } } + private String convertNetconfNodeIdToTopoNodeId(String nodeId, String tpId) { + return new StringBuilder(nodeId).append("-").append(tpId.split("-")[0]).toString(); + } + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "false positive, this method is used by public updateOpenRoadmNetworkTopology") 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 dd5325563..4f65190f7 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 @@ -213,6 +213,29 @@ public final class OpenRoadmOtnTopology { } } + 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<>(); diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index 0a6e6f1e6..27bbff5f8 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -342,7 +342,11 @@ public class RendererListenerImpl implements TransportpceRendererListener { this.networkModelService.updateOtnLinks(link, notification.getAToZDirection().getRate(), tribPort, minTribSlot, maxTribSlot, isDeletion); break; + case StringConstants.SERVICE_TYPE_100GE_S: + this.networkModelService.updateOtnLinks(link, isDeletion); + break; default: + LOG.warn("service-type {} not managed yet", serviceType); break; } }