From f5d953af7c15afde27e06fb55498118541d551d0 Mon Sep 17 00:00:00 2001 From: orenais Date: Fri, 29 Mar 2024 15:42:11 +0100 Subject: [PATCH] Consolidate ConnectivityUtils - Add spectrum information to Cep - Centralize Topological_mode & TopoUUID handling in TapiProvider - Refactor ConnectivityUtils adding CreateRoadmCepAndClientNeps to factorize & backporting createCepRoadm and createRoadmNep into ConvertORToTapiTopology to call it from Tapilink - Move method to calculate fiber parameters from PceLink to NetworkUtils to call them in TapiLink - Add methods to create OTS & OMS Cep in TapiLinkImpl at init - Add method to build OTS-Cep-Spec from OR OMS - Add Test for OTS & OMS cep - Refactor TapiLinkImpl & TapiORListener - AddTest for PhotonicMediaNodeEdgePointSpec in Test of convertORTopoToFullTapiTopoTest - adapt tapi constructors in lighty build JIRA: TRNSPRTPCE-759 Signed-off-by: orenais Change-Id: I2a1aeb3c413b315c46c66723342888c497365b6f --- .../transportpce/common/NetworkUtils.java | 221 +++++++++ .../pce/networkanalyzer/PceLink.java | 202 +------- .../tapi/TapiStringConstants.java | 2 +- .../tapi/connectivity/ConnectivityUtils.java | 434 ++++++++---------- .../transportpce/tapi/impl/TapiProvider.java | 17 +- .../tapi/impl/rpc/GetNodeDetailsImpl.java | 56 ++- .../topology/ConvertORToTapiTopology.java | 253 +++++++--- .../topology/ConvertORTopoToTapiFullTopo.java | 129 ++++-- .../topology/TapiNetworkModelServiceImpl.java | 70 ++- .../tapi/topology/TapiOrLinkListener.java | 67 ++- .../topology/TapiPortMappingListener.java | 72 ++- .../tapi/topology/TopologyUtils.java | 40 +- .../transportpce/tapi/utils/TapiContext.java | 28 +- .../tapi/utils/TapiInitialORMapping.java | 4 +- .../transportpce/tapi/utils/TapiLink.java | 4 + .../transportpce/tapi/utils/TapiLinkImpl.java | 295 +++++++++++- .../TapiConnectivityImplTest.java | 10 +- .../tapi/provider/TapiProviderTest.java | 12 +- .../ConvertORTopoToFullTapiTopoTest.java | 275 +++++++++-- .../topology/ConvertORTopoToTapiTopoTest.java | 3 +- .../tapi/topology/TapiTopologyImplTest.java | 6 +- 21 files changed, 1506 insertions(+), 694 deletions(-) diff --git a/common/src/main/java/org/opendaylight/transportpce/common/NetworkUtils.java b/common/src/main/java/org/opendaylight/transportpce/common/NetworkUtils.java index f7d78fde1..be6177df4 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/NetworkUtils.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/NetworkUtils.java @@ -7,8 +7,28 @@ */ package org.opendaylight.transportpce.common; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev230526.span.attributes.LinkConcatenation1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev230526.span.attributes.LinkConcatenation1.FiberType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.link.oms.attributes.Span; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.link.concatenation.LinkConcatenation; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.link.concatenation.LinkConcatenationKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public final class NetworkUtils { + private static final Logger LOG = LoggerFactory.getLogger(NetworkUtils.class); + private static final double GLASSCELERITY = 2.99792458 * 1e5 / 1.5; + private static final double PMD_CONSTANT = 0.04; + private static final String NETWORK_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG = + "NetworkUtils: No Link augmentation available. {}"; + private NetworkUtils() { } @@ -25,4 +45,205 @@ public final class NetworkUtils { DELETE } + + public static Span getOmsAttributesSpan(Link link) { + org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.Link1 link1 = + link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.Link1.class); + + if (link1 == null) { + LOG.error(NETWORK_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG, link.getLinkId().getValue()); + return null; + } + if (link1.getOMSAttributes() == null) { + LOG.error("NetworkUtils No Link getOMSAttributes available. {}", link.getLinkId().getValue()); + return null; + } + return link1.getOMSAttributes().getSpan(); + } + + //Compute the link latency : if the latency is not defined, the latency is computed from the length + public static Long calcLatency(Link link) { + var augLinkLatency = link.augmentation(Link1.class).getLinkLatency(); + if (augLinkLatency != null) { + return augLinkLatency.toJava(); + } + Double linkLength = calcLength(link); + if (linkLength == null) { + LOG.debug("In NetworkUtils: cannot compute the latency for the link {}", link.getLinkId().getValue()); + return 1L; + } + double latency = Math.ceil(linkLength / GLASSCELERITY); + LOG.debug("In NetworkUtils: The latency of link {} is extrapolated from link length and == {}", + link.getLinkId(), latency); + return (long) latency; + } + + public static Double calcLength(Link link) { + var augLinkLength = link.augmentation(Link1.class).getLinkLength(); + if (augLinkLength != null) { + return augLinkLength.doubleValue(); + } + var omsAttribute = getOmsAttributesSpan(link); + if (omsAttribute == null) { + LOG.debug("In NetworkUtils: cannot compute the length for the link {}", link.getLinkId().getValue()); + return null; + } + double linkLength = 0; + for (Map.Entry entry : + omsAttribute.nonnullLinkConcatenation().entrySet()) { + // Length is expressed in meter according to OpenROADM MSA + if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null) { + LOG.debug("In NetworkUtils: cannot compute the length for the link {}", link.getLinkId().getValue()); + return null; + } + linkLength += entry.getValue().getSRLGLength().doubleValue(); + LOG.debug("In NetworkUtils: The length of the link {} == {}", link.getLinkId(), linkLength / 1000.0); + } + return linkLength / 1000.0; + } + + //Calculate CD and PMD of the link from link length + private static Map calcCDandPMDfromLength(Double length) { + return length == null + ? new HashMap<>() + : new HashMap<>( + Map.of( + "CD", 16.5 * length, + "PMD2", Math.pow(length * PMD_CONSTANT, 2))); + } + + //Calculate CD and PMD of the link + public static Map calcCDandPMD(Link link) { + double linkCd = 0.0; + double linkPmd2 = 0.0; + var omsAttributesSpan = getOmsAttributesSpan(link); + Double length = calcLength(link); + if (omsAttributesSpan == null) { + LOG.debug("NetworkUtils {} no OMS present, assume G.652 fiber, calculation based on fiber length of {} km", + link.getLinkId(), calcLength(link)); + return calcCDandPMDfromLength(calcLength(link)); + } + for (Map.Entry entry : + omsAttributesSpan.nonnullLinkConcatenation().entrySet()) { + // If the link-concatenation list is not populated or partially populated CD & + // PMD shall be derived from link-length (expressed in km in OR topology) + if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null + || entry.getValue().augmentation(LinkConcatenation1.class).getFiberType() == null) { + if (length > 0.0) { + LOG.debug("NetworkUtils: no OMS present; cd & PMD for the link {} extrapolated from link length {}" + + "assuming SMF fiber type", link.getLinkId().getValue(), length); + return calcCDandPMDfromLength(length); + } + // If Link-length upper attributes not present or incorrectly populated, no way + // to calculate CD & PMD + LOG.error("In NetworkUtils: no Link length declared and no OMS present for the link {}." + + " No Way to compute CD and PMD", link.getLinkId().getValue()); + return Map.of(); + } + // SRLG length is expressed in OR topology in meter + var entryAug = entry.getValue().augmentation(LinkConcatenation1.class); + linkCd += entry.getValue().getSRLGLength().doubleValue() / 1000.0 + * retrieveCdFromFiberType(entryAug.getFiberType()); + if (entryAug.getPmd() == null + || entryAug.getPmd().getValue().doubleValue() == 0.0 + || entryAug.getPmd().getValue().toString().isEmpty()) { + linkPmd2 += Math.pow( + entry.getValue().getSRLGLength().doubleValue() / 1000.0 + * retrievePmdFromFiberType(entryAug.getFiberType()), + 2); + } else { + linkPmd2 += Math.pow(entryAug.getPmd().getValue().doubleValue(), 2); + } + } + LOG.debug("In NetworkUtils: The CD and PMD2 of link {} are respectively {} ps and {} ps", + link.getLinkId(), linkCd, linkPmd2); + return Map.of("CD", linkCd, "PMD2", linkPmd2); + } + + // compute default spanLoss and power correction from fiber length + // when no OMS attribute defined + private static Map calcDefaultSpanLoss(Link link) { + var augLinkLength = link.augmentation(Link1.class).getLinkLength(); + if (augLinkLength == null || augLinkLength.doubleValue() == 0) { + LOG.error("In NetworkUtils, no link length present or length declared = 0," + + " unable to calculate default span Loss "); + return new HashMap<>(); + } + long linkLength = augLinkLength.longValue(); + LOG.warn("In NetworkUtils {}, assume G.652 fiber, calculation " + + "based on fiber length of {} km and typical loss of 0.25dB per Km ", + link.getLinkId(), linkLength); + return new HashMap<>( + Map.of( + "SpanLoss", linkLength * 0.25, + "PoutCorrection", retrievePower(FiberType.Smf) + )); + } + + // Compute the attenuation of a span from OMS attribute + public static Map calcSpanLoss(Link link) { + var omsAttributesSpan = getOmsAttributesSpan(link); + if (omsAttributesSpan == null) { + return calcDefaultSpanLoss(link); + } + Collection linkConcatenationList = + omsAttributesSpan.nonnullLinkConcatenation().values(); + if (linkConcatenationList == null) { + LOG.error("In NetworkUtils : Null field in the OmsAttrubtesSpan"); + return calcDefaultSpanLoss(link); + } + Iterator linkConcatenationiterator = linkConcatenationList.iterator(); + if (!linkConcatenationiterator.hasNext()) { + return calcDefaultSpanLoss(link); + } + // Reference of power to be launched at input of ROADM (dBm) + return new HashMap<>(Map.of( + "PoutCorrection", retrievePower( + linkConcatenationiterator.next().augmentation(LinkConcatenation1.class).getFiberType()) - 2.0, + "SpanLoss", omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue())); + } + + private static double retrievePower(FiberType fiberType) { + switch (fiberType) { + case Smf: + return 2; + case Eleaf: + return 1; + case Truewavec: + return -1; + case Oleaf: + case Dsf: + case Truewave: + case NzDsf: + case Ull: + default: + return 0; + } + } + + private static double retrievePmdFromFiberType(FiberType fiberType) { + return fiberType.toString().equalsIgnoreCase("Dsf") + ? 0.2 + : PMD_CONSTANT; + } + + private static double retrieveCdFromFiberType(FiberType fiberType) { + switch (fiberType) { + case Dsf: + return 0.0; + case Truewavec: + return 3.0; + case Eleaf: + case Oleaf: + case NzDsf: + return 4.3; + case Truewave: + return 4.4; + case Smf: + case Ull: + default: + return 16.5; + } + } + } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java index dbec53d6f..eafec5115 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java @@ -10,21 +10,15 @@ package org.opendaylight.transportpce.pce.networkanalyzer; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; +import org.opendaylight.transportpce.common.NetworkUtils; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1; 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.link.rev230526.span.attributes.LinkConcatenation1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev230526.span.attributes.LinkConcatenation1.FiberType; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.link.oms.attributes.Span; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.link.concatenation.LinkConcatenation; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.link.concatenation.LinkConcatenationKey; 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.topology.rev180226.LinkId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId; @@ -68,16 +62,12 @@ public class PceLink implements Serializable { private final Long availableBandwidth; private final Long usedBandwidth; private final List srlgList; -// private final double osnr; private final Double length; private final Double cd; private final Double pmd2; private final Double spanLoss; private final Double powerCorrection; private final transient Span omsAttributesSpan; - //meter per ms - private static final double GLASSCELERITY = 2.99792458 * 1e5 / 1.5; - private static final double PMD_CONSTANT = 0.04; public PceLink(Link link, PceNode source, PceNode dest) { LOG.debug("PceLink: : PceLink start "); @@ -105,15 +95,15 @@ public class PceLink implements Serializable { switch (this.linkType) { case ROADMTOROADM: this.omsAttributesSpan = MapUtils.getOmsAttributesSpan(link); - this.length = calcLength(link); + this.length = NetworkUtils.calcLength(link); this.srlgList = MapUtils.getSRLG(link); - this.latency = calcLatency(link); + this.latency = NetworkUtils.calcLatency(link); this.availableBandwidth = 0L; this.usedBandwidth = 0L; - Map spanLossMap = calcSpanLoss(link); + Map spanLossMap = NetworkUtils.calcSpanLoss(link); this.spanLoss = spanLossMap.get("SpanLoss"); this.powerCorrection = spanLossMap.get("PoutCorrection"); - Map cdAndPmdMap = calcCDandPMD(link); + Map cdAndPmdMap = NetworkUtils.calcCDandPMD(link); this.cd = cdAndPmdMap.get("CD"); this.pmd2 = cdAndPmdMap.get("PMD2"); break; @@ -155,188 +145,6 @@ public class PceLink implements Serializable { return tmpoppositeLink; } - //Compute the link latency : if the latency is not defined, the latency is computed from the length - private Long calcLatency(Link link) { - var augLinkLatency = link.augmentation(Link1.class).getLinkLatency(); - if (augLinkLatency != null) { - return augLinkLatency.toJava(); - } - Double linkLength = calcLength(link); - if (linkLength == null) { - LOG.debug("In PceLink: cannot compute the latency for the link {}", link.getLinkId().getValue()); - return 1L; - } - LOG.debug("In PceLink: The latency of link {} is extrapolated from link length and == {}", - link.getLinkId(), linkLength / GLASSCELERITY); - return (long) Math.ceil(linkLength / GLASSCELERITY); - } - - private Double calcLength(Link link) { - var augLinkLength = link.augmentation(Link1.class).getLinkLength(); - if (augLinkLength != null) { - return augLinkLength.doubleValue(); - } - if (this.omsAttributesSpan == null) { - LOG.debug("In PceLink: cannot compute the length for the link {}", link.getLinkId().getValue()); - return null; - } - double linkLength = 0; - Map linkConcatenationMap = - this.omsAttributesSpan.nonnullLinkConcatenation(); - for (Map.Entry entry : linkConcatenationMap.entrySet()) { - // Length is expressed in meter according to OpenROADM MSA - if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null) { - LOG.debug("In PceLink: cannot compute the length for the link {}", link.getLinkId().getValue()); - return null; - } - linkLength += entry.getValue().getSRLGLength().doubleValue(); - LOG.debug("In PceLink: The length of the link {} == {}", link.getLinkId(), linkLength / 1000.0); - } - return linkLength / 1000.0; - } - - //Calculate CD and PMD of the link from link length - private Map calcCDandPMDfromLength() { - return this.length == null - ? new HashMap<>() - : new HashMap<>( - Map.of( - "CD", 16.5 * this.length, - "PMD2", Math.pow(this.length * PMD_CONSTANT, 2))); - } - - //Calculate CD and PMD of the link - private Map calcCDandPMD(Link link) { - double linkCd = 0.0; - double linkPmd2 = 0.0; - if (this.omsAttributesSpan == null) { - LOG.debug("In PceLink {} no OMS present, assume G.652 fiber, calculation based on fiber length of {} km", - link.getLinkId(), this.length); - return calcCDandPMDfromLength(); - } - Map linkConcatenationMap = - this.omsAttributesSpan.nonnullLinkConcatenation(); - for (Map.Entry entry : linkConcatenationMap.entrySet()) { - // If the link-concatenation list is not populated or partially populated CD & - // PMD shall be derived from link-length (expressed in km in OR topology) - if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null - || entry.getValue().augmentation(LinkConcatenation1.class).getFiberType() == null) { - if (this.length > 0.0) { - LOG.debug("In PceLink: no OMS present; cd and PMD for the link {} extrapolated from link length {}" - + "assuming SMF fiber type", link.getLinkId().getValue(), this.length); - return calcCDandPMDfromLength(); - } - // If Link-length upper attributes not present or incorrectly populated, no way - // to calculate CD & PMD - LOG.error("In PceLink: no Link length declared and no OMS present for the link {}." - + " No Way to compute CD and PMD", link.getLinkId().getValue()); - return Map.of(); - } - // SRLG length is expressed in OR topology in meter - var entryAug = entry.getValue().augmentation(LinkConcatenation1.class); - linkCd += entry.getValue().getSRLGLength().doubleValue() / 1000.0 - * retrieveCdFromFiberType(entryAug.getFiberType()); - if (entryAug.getPmd() == null - || entryAug.getPmd().getValue().doubleValue() == 0.0 - || entryAug.getPmd().getValue().toString().isEmpty()) { - linkPmd2 += Math.pow( - entry.getValue().getSRLGLength().doubleValue() / 1000.0 - * retrievePmdFromFiberType(entryAug.getFiberType()), - 2); - } else { - linkPmd2 += Math.pow(entryAug.getPmd().getValue().doubleValue(), 2); - } - } - LOG.debug("In PceLink: The CD and PMD2 of link {} are respectively {} ps and {} ps", - link.getLinkId(), linkCd, linkPmd2); - return Map.of("CD", linkCd, "PMD2", linkPmd2); - } - - // compute default spanLoss and power correction from fiber length - // when no OMS attribute defined - private Map calcDefaultSpanLoss(Link link) { - var augLinkLength = link.augmentation(Link1.class).getLinkLength(); - if (augLinkLength == null || augLinkLength.doubleValue() == 0) { - LOG.error("In PceLink, no link length present or length declared = 0," - + " unable to calculate default span Loss "); - return new HashMap<>(); - } - long linkLength = augLinkLength.longValue(); - LOG.warn("In PceLink {}, assume G.652 fiber, calculation " - + "based on fiber length of {} km and typical loss of 0.25dB per Km ", - link.getLinkId(), linkLength); - return new HashMap<>( - Map.of( - "SpanLoss", linkLength * 0.25, - "PoutCorrection", retrievePower(FiberType.Smf) - )); - } - - // Compute the attenuation of a span from OMS attribute - private Map calcSpanLoss(Link link) { - if (this.omsAttributesSpan == null) { - return calcDefaultSpanLoss(link); - } - Collection linkConcatenationList = - this.omsAttributesSpan.nonnullLinkConcatenation().values(); - if (linkConcatenationList == null) { - LOG.error("in PceLink : Null field in the OmsAttrubtesSpan"); - return calcDefaultSpanLoss(link); - } - Iterator linkConcatenationiterator = linkConcatenationList.iterator(); - if (!linkConcatenationiterator.hasNext()) { - return calcDefaultSpanLoss(link); - } - // Reference of power to be launched at input of ROADM (dBm) - return new HashMap<>(Map.of( - "PoutCorrection", retrievePower( - linkConcatenationiterator.next().augmentation(LinkConcatenation1.class).getFiberType()) - 2.0, - "SpanLoss", this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue())); - } - - private double retrievePower(FiberType fiberType) { - switch (fiberType) { - case Smf: - return 2; - case Eleaf: - return 1; - case Truewavec: - return -1; - case Oleaf: - case Dsf: - case Truewave: - case NzDsf: - case Ull: - default: - return 0; - } - } - - private double retrievePmdFromFiberType(FiberType fiberType) { - return fiberType.toString().equalsIgnoreCase("Dsf") - ? 0.2 - : PMD_CONSTANT; - } - - private double retrieveCdFromFiberType(FiberType fiberType) { - switch (fiberType) { - case Dsf: - return 0.0; - case Truewavec: - return 3.0; - case Eleaf: - case Oleaf: - case NzDsf: - return 4.3; - case Truewave: - return 4.4; - case Smf: - case Ull: - default: - return 16.5; - } - } - public LinkId getOppositeLink() { return oppositeLink; } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/TapiStringConstants.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/TapiStringConstants.java index 0efaaccae..f712f03d3 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/TapiStringConstants.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/TapiStringConstants.java @@ -25,7 +25,7 @@ public final class TapiStringConstants { // They allow to have a reference somewhere of the UUID to be used when testing. public static final String T0_MULTILAYER_UUID = "747c670e-7a07-3dab-b379-5b1cd17402a3"; public static final String T0_TAPI_MULTILAYER_UUID = "a6c5aed1-dc75-333a-b3a3-b6b70534eae8"; - public static final String T0_FULL_MULTILAYER_UUID = "393f09a4-0a0b-3d82-a4f6-1fbbc14ca1a8"; + public static final String T0_FULL_MULTILAYER_UUID = "393f09a4-0a0b-3d82-a4f6-1fbbc14ca1a7"; public static final String TPDR_100G = "Transponder 100GE"; public static final String DSR = "DSR"; public static final String ODU = "ODU"; diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java index e5a64b5ae..2ddc91e27 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java @@ -21,9 +21,11 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.transportpce.common.fixedflex.GridUtils; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.topology.ConvertORToTapiTopology; import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint; import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType; import org.opendaylight.transportpce.tapi.utils.TapiContext; @@ -86,6 +88,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev22112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey; @@ -109,10 +112,8 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey; @@ -127,9 +128,8 @@ import org.slf4j.LoggerFactory; public final class ConnectivityUtils { - private final Uuid tapiTopoUuid = new Uuid( - UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()); private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class); + private final Uuid tapiTopoUuid; private final ServiceDataStoreOperations serviceDataStoreOperations; private final TapiContext tapiContext; @@ -143,11 +143,12 @@ public final class ConnectivityUtils { private Connection topConnRdmRdm; private Connection topConnXpdrXpdrPhtn; private Connection topConnXpdrXpdrOdu; + private ConvertORToTapiTopology tapiFactory; // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations, Map sipMap, TapiContext tapiContext, - NetworkTransactionService networkTransactionService) { + NetworkTransactionService networkTransactionService, Uuid tapiTopoUuid) { this.serviceDataStoreOperations = serviceDataStoreOperations; this.tapiContext = tapiContext; this.sipMap = sipMap; @@ -156,6 +157,8 @@ public final class ConnectivityUtils { this.topConnRdmRdm = null; this.topConnXpdrXpdrPhtn = null; this.topConnXpdrXpdrOdu = null; + this.tapiTopoUuid = tapiTopoUuid; + this.tapiFactory = new ConvertORToTapiTopology(tapiTopoUuid); } public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) { @@ -301,7 +304,6 @@ public final class ConnectivityUtils { LOG.debug("connectionMap for service {} = {} ", name, connMap); ConnectivityConstraint conConstr = new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build(); - // TODO: full connectivity service?? With constraints and the rest of fields... return new ConnectivityServiceBuilder() .setAdministrativeState(AdministrativeState.UNLOCKED) .setOperationalState(OperationalState.ENABLED) @@ -404,10 +406,7 @@ public final class ConnectivityUtils { } // create corresponding CEPs and Connections. Connections should be added to the corresponding context // CEPs must be included in the topology context as an augmentation for each ONEP!! - // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist?? // As mentioned above, for 100GbE service creation there are ROADMs in the path description. - // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed? - // this needs to be changed // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist); Map connectionServMap = new HashMap<>(); @@ -416,21 +415,41 @@ public final class ConnectivityUtils { // Identify number of ROADMs // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm) // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm) - // - Top Connection MC betwwen MC CEPs of different roadms - // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms + // - In Roadms, only one NEP modeled for both OTSi_MC and MC on both TTP and PPs. + // - Changed naming convention of CEPs and connections, to include the frequency and allow several + // - OTSiMC and MC Ceps to be attached to the same NEP and support all related connections (1/Lambda) + // - Top Connection MC between MC CEPs of different roadms + // - Top Connection OTSiMC between OTSiMC CEPs of extreme roadms + LOG.debug("CONNECTIVITYUTILS 422 SpectralIndexLow = {}, High = {}", + GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue()), + GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue())); connectionServMap.putAll( - createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2)); + createRoadmCepsAndConnections( + GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue()), + GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMaxFrequency().getValue()), + rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2)); + LOG.debug("CONNECTIVITYUTILS 434 Connservmap = {}", connectionServMap); if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId() .contains("ROADM")) { // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi - connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist)); + connectionServMap.putAll(createXpdrCepsAndConnectionsPht( + GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue()), + GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMaxFrequency().getValue()), + xpdrNetworkTplist, xpdrNodelist)); + LOG.debug("CONNECTIVITYUTILS 445 Connservmap = {}", connectionServMap); } this.topConnRdmRdm = null; break; case ODU: // TODO: verify if this is correct - // - XC Connection OTSi betwwen iODU and eODU of xpdr + // - XC Connection OTSi between iODU and eODU of xpdr // - Top connection in the ODU layer, between xpdr eODU ports (?) if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) { connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist)); @@ -443,8 +462,19 @@ public final class ConnectivityUtils { LOG.info("WDM ETH service"); connectionServMap.putAll( createRoadmCepsAndConnections( - rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2)); - connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist)); + GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue()), + GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMaxFrequency().getValue()), + rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, + edgeRoadm2)); + connectionServMap.putAll( + createXpdrCepsAndConnectionsPht( + GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMinFrequency().getValue()), + GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection() + .getAToZMaxFrequency().getValue()), + xpdrNetworkTplist, xpdrNodelist)); this.topConnRdmRdm = null; xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist); LOG.info("Associated client ports = {}", xpdrClientTplist); @@ -459,7 +489,6 @@ public final class ConnectivityUtils { // - Top connection between eODU ports // - Top connection between DSR ports if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) { - // TODO: We create both ODU and DSR because there is no ODU service creation for the switch // - XC Connection OTSi between iODU and eODU of xpdr // - Top connection in the ODU layer, between xpdr eODU ports (?) connectionServMap.putAll( @@ -467,7 +496,6 @@ public final class ConnectivityUtils { this.topConnXpdrXpdrPhtn = null; } if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) { - // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist connectionServMap.putAll( createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist)); this.topConnXpdrXpdrOdu = null; @@ -476,12 +504,11 @@ public final class ConnectivityUtils { default: LOG.error("Service type format not supported"); } - LOG.debug("CONNSERVERMAP = {}", connectionServMap); + LOG.debug("CONNSERVERMAP 508 = {}", connectionServMap); return connectionServMap; } - public void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) { - // TODO: verify this is correct. Should we identify the context IID with the context UUID?? + private void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) { InstanceIdentifier onepIID = InstanceIdentifier.builder(Context.class) .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class) .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class) @@ -652,7 +679,6 @@ public final class ConnectivityUtils { } return null; } - //TODO factorize these two similar methods private OpenroadmNodeType getOpenroadmType(String nodeName) { LOG.info("Node name = {}", nodeName); @@ -685,7 +711,8 @@ public final class ConnectivityUtils { String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow(); ConnectionEndPoint netCep1 = - createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR); + createCepXpdr(0, 0, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, + LayerProtocolName.DSR); putXpdrCepInTopologyContext( xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, netCep1); cepMapDsr.put(netCep1.key(), netCep1); @@ -725,11 +752,12 @@ public final class ConnectivityUtils { String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow(); ConnectionEndPoint clientCep1 = - createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR); + createCepXpdr(0, 0, + spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR); putXpdrCepInTopologyContext( xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, clientCep1); - ConnectionEndPoint clientCep2 = createCepXpdr( - spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU); + ConnectionEndPoint clientCep2 = createCepXpdr(0, 0, spcXpdrClient, TapiStringConstants.E_ODU, + TapiStringConstants.XPDR, LayerProtocolName.ODU); putXpdrCepInTopologyContext( xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, clientCep2); cepMapDsr.put(clientCep1.key(), clientCep1); @@ -792,11 +820,11 @@ public final class ConnectivityUtils { // Create 1 cep per Xpdr in the I_ODU and a top // connection iODU between the xpdrs for (String xpdr:xpdrNodelist) { - LOG.info("Creating ceps and xc for xpdr {}", xpdr); + LOG.info("Creating iODU ceps and xc for xpdr {}", xpdr); String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow(); ConnectionEndPoint netCep1 = - createCepXpdr( + createCepXpdr(0, 0, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU); putXpdrCepInTopologyContext( xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, netCep1); @@ -822,65 +850,107 @@ public final class ConnectivityUtils { return connServMap; } - private Map createXpdrCepsAndConnectionsPht( + private Map createXpdrCepsAndConnectionsPht(int lowerFreqIndex, int higherFreqIndex, List xpdrNetworkTplist, List xpdrNodelist) { // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will // be added to the lower connection of a top connection Map cepMap = new HashMap<>(); // create ceps and x connections within xpdr + LOG.debug("CONNECTIVITYUTILS 866 CreateXpdrCep1ConnPht"); + String slotFreqExtension = ""; for (String xpdr:xpdrNodelist) { LOG.info("Creating ceps and xc for xpdr {}", xpdr); String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow(); // There should be 1 network tp per xpdr // Just create 2 different CEPs (1 OTS + 1 OTSI_MC) - ConnectionEndPoint netCep1 = createCepXpdr( + ConnectionEndPoint netCep1 = createCepXpdr(0, 0, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); putXpdrCepInTopologyContext( xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, netCep1); - ConnectionEndPoint netCep2 = createCepXpdr( + ConnectionEndPoint netCep2 = createCepXpdr(lowerFreqIndex, higherFreqIndex, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); putXpdrCepInTopologyContext( xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, netCep2); -// ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI, -// TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); -// putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI, -// netCep3); cepMap.put(netCep1.key(), netCep1); cepMap.put(netCep2.key(), netCep2); -// cepMap.put(netCep3.key(), netCep3); + slotFreqExtension = "[" + netCep2.getName().entrySet().iterator().next().getValue().getValue() + .split("\\[")[1]; } + LOG.debug("CONNECTIVITYUTILS 894 CreateXpdrCep1ConnPht"); // OTSi top connection between edge OTSI_MC Xpdr org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection = createTopConnection( - //spcXpdr1, - xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0))) - .findFirst().orElseThrow(), - //spcXpdr2, - xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1))) - .findFirst().orElseThrow(), + String.join("-", xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0))) + .findFirst().orElseThrow(), slotFreqExtension), + String.join("-", xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist + .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow(), slotFreqExtension), cepMap, TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA, new HashMap<>(), this.topConnRdmRdm); this.connectionFullMap.put(connection.key(), connection); // OTSi top connection that will be added to the service object Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); this.topConnXpdrXpdrPhtn = conn; + LOG.info("ReturnedMap904 {}", new HashMap<>(Map.of(conn.key(), conn))); return new HashMap<>(Map.of(conn.key(), conn)); } - private Map createRoadmCepsAndConnections( + private Map createRoadmCepsAndClientNeps(String roadm, + int lowerFreqIndex, int higherFreqIndex, String rdmTp, boolean withOMS) { + Map cepMap = new HashMap<>(); + String clientQualifier = ""; + // Create 3 CEPs (OTS, MC, OTSi_MC) for ADD and (OMS, MC, OTSi_MC) for DEG and add them to CepMap + + if (withOMS) { + // WithOMS is true for degree for which OTS Cep is created during link discovery/update + clientQualifier = TapiStringConstants.MC; + OwnedNodeEdgePoint onepMC = tapiFactory.createRoadmNep(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1], + false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); + putRdmNepInTopologyContext(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1], TapiStringConstants.MC, onepMC); + } else { + // WithOMS is false for Add/drop ports for which no OTS was created during initial mapping + ConnectionEndPoint rdmCep0 = tapiFactory.createCepRoadm(0, 0, rdmTp, + TapiStringConstants.PHTNC_MEDIA_OTS, null); + putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.PHTNC_MEDIA_OTS, rdmCep0); + cepMap.put(rdmCep0.key(), rdmCep0); + } + + clientQualifier = TapiStringConstants.OTSI_MC; + OwnedNodeEdgePoint onepOTSiMC = tapiFactory.createRoadmNep(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1], + false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); + putRdmNepInTopologyContext(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1], + TapiStringConstants.OTSI_MC, onepOTSiMC); + ConnectionEndPoint rdmCep2 = tapiFactory.createCepRoadm(lowerFreqIndex, higherFreqIndex, rdmTp, + TapiStringConstants.MC, null); + putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.MC, rdmCep2); + cepMap.put(rdmCep2.key(), rdmCep2); + + ConnectionEndPoint rdmCep3 = tapiFactory.createCepRoadm(lowerFreqIndex, higherFreqIndex, rdmTp, + TapiStringConstants.OTSI_MC, null); + putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.OTSI_MC, rdmCep3); + cepMap.put(rdmCep3.key(), rdmCep3); + return cepMap; + } + + private Map createRoadmCepsAndConnections(int lowerFreqIndex, int higherFreqIndex, List rdmAddDropTplist, List rdmDegTplist, List rdmNodelist, String edgeRoadm1, String edgeRoadm2) { - // TODO: will need to check if things exist already or not + + Map intermediateCepMap = new HashMap<>(); + LOG.debug("IntermediateCepMap {}", intermediateCepMap); Map cepMap = new HashMap<>(); + .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>(); // create ceps and x connections within roadm Map xcLowerMap = new HashMap<>(); + String slotFreqExtension = "[" + lowerFreqIndex + "-" + higherFreqIndex + "]"; + LOG.debug("slotFreqExtension in createRoadmCepsAndConnections is {}", slotFreqExtension); for (String roadm : rdmNodelist) { LOG.info("Creating ceps and xc for roadm {}", roadm); if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) { @@ -888,50 +958,45 @@ public final class ConnectivityUtils { String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)) .findFirst().orElseThrow(); LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD); - // There should be only 1 AD and 1 DEG per roadm - // TODO photonic media model should be updated to have the corresponding CEPs. I will just create - // 3 different MC CEPs giving different IDs to show that they are different - // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs + // Create CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs // created in the topology creation // add CEPs to the topology to the corresponding ONEP - ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS); - putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS, adCep1); - ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC); - putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2); - ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3); - cepMap.put(adCep1.key(), adCep1); - cepMap.put(adCep2.key(), adCep2); - cepMap.put(adCep3.key(), adCep3); - + intermediateCepMap = createRoadmCepsAndClientNeps( + roadm, lowerFreqIndex, higherFreqIndex, spcRdmAD, false); + ConnectionEndPoint adCepMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("adCepMC is {}", adCepMC); + ConnectionEndPoint adCepOTSiMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("adCepOTSiMC is {}", adCepOTSiMC); + cepMap.putAll(intermediateCepMap); String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow(); LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG); - - ConnectionEndPoint degCep0 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS); - putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS, degCep0); - ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS); - putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS, degCep1); - ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2); - ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3); - cepMap.put(degCep0.key(), degCep0); - cepMap.put(degCep1.key(), degCep1); - cepMap.put(degCep2.key(), degCep2); - cepMap.put(degCep3.key(), degCep3); - + intermediateCepMap = createRoadmCepsAndClientNeps( + roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG, true); + ConnectionEndPoint degCepMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("degCepMC is {}", degCepMC); + ConnectionEndPoint degCepOTSiMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("degCepOTSiMC is {}", degCepOTSiMC); + cepMap.putAll(intermediateCepMap); LOG.info("Going to create cross connections for ROADM {}", roadm); // Create X connections between MC and OTSi_MC for full map org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection1 = createXCBetweenCeps( - adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC, + adCepMC, degCepMC, spcRdmAD, spcRdmDEG, TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA); LOG.info("Cross connection 1 created = {}", connection1); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection2 = createXCBetweenCeps( - adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC, + adCepOTSiMC, degCepOTSiMC, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA); LOG.info("Cross connection 2 created = {}", connection2); this.connectionFullMap.put(connection1.key(), connection1); @@ -947,49 +1012,45 @@ public final class ConnectivityUtils { LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG"); String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow(); LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1); - - ConnectionEndPoint deg1Cep0 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS); - putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS, deg1Cep0); - ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS); - putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS, deg1Cep1); - ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2); - ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3); - cepMap.put(deg1Cep0.key(), deg1Cep0); - cepMap.put(deg1Cep1.key(), deg1Cep1); - cepMap.put(deg1Cep2.key(), deg1Cep2); - cepMap.put(deg1Cep3.key(), deg1Cep3); + intermediateCepMap = createRoadmCepsAndClientNeps( + roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG1, true); + ConnectionEndPoint deg1CepMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("deg1CepMC is {}", deg1CepMC); + ConnectionEndPoint deg1CepOTSiMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("deg1CepOTSiMC is {}", deg1CepOTSiMC); + cepMap.putAll(intermediateCepMap); String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().orElseThrow(); LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2); - - ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS); - putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS, deg2Cep0); - ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS); - putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS, deg2Cep1); - ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2); - ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3); - cepMap.put(deg2Cep0.key(), deg2Cep0); - cepMap.put(deg2Cep1.key(), deg2Cep1); - cepMap.put(deg2Cep2.key(), deg2Cep2); - cepMap.put(deg2Cep3.key(), deg2Cep3); + intermediateCepMap = createRoadmCepsAndClientNeps( + roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG2, true); + ConnectionEndPoint deg2CepMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("deg2CepMC is {}", deg2CepMC); + ConnectionEndPoint deg2CepOTSiMC = intermediateCepMap.entrySet().stream().filter( + cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)) + .findFirst().orElseThrow().getValue(); + LOG.debug("deg2CepOTSiMC is {}", deg2CepOTSiMC); + cepMap.putAll(intermediateCepMap); LOG.info("Going to create cross connections for ROADM {}", roadm); // Create X connections between MC and OTSi_MC for full map org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection1 = createXCBetweenCeps( - deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2, + deg1CepMC, deg2CepMC, spcRdmDEG1, spcRdmDEG2, TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA); LOG.info("Cross connection 1 created = {}", connection1); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection2 = createXCBetweenCeps( - deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2, + deg1CepOTSiMC, deg2CepOTSiMC, spcRdmDEG1, spcRdmDEG2, TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA); LOG.info("Cross connection 2 created = {}", connection2.toString()); this.connectionFullMap.put(connection1.key(), connection1); @@ -1009,30 +1070,32 @@ public final class ConnectivityUtils { LOG.info("Going to created top connection between MC"); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection = - createTopConnection( - spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC, + createTopConnection(String.join("-", spcRdmAD1, slotFreqExtension), + String.join("-", spcRdmAD2, slotFreqExtension), cepMap, TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null); this.connectionFullMap.put(connection.key(), connection); LOG.info("Top connection created = {}", connection); LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); // OTSiMC top connection between edge roadms - LOG.info("Going to created top connection between OTSiMC"); + LOG.debug("Going to created top connection between OTSiMC"); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connectivity.context.Connection connection1 = - createTopConnection( - spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC, + createTopConnection(String.join("-", spcRdmAD1, slotFreqExtension), + String.join("-", spcRdmAD2, slotFreqExtension), cepMap, TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA, //topLowerMap, new HashMap<>(Map.of(conn1.key(), conn1)), null); this.connectionFullMap.put(connection1.key(), connection1); - LOG.info("Top connection created = {}", connection1); + LOG.info("Top connection OTSiMC created = {}", connection1); + LOG.debug("Map of All connections = {}", this.connectionFullMap); // OTSiMC top connections that will be added to the service object Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build(); this.topConnRdmRdm = conn2; + LOG.debug("ReturnedMap1102 {}", new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2))); return new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2)); } @@ -1047,14 +1110,14 @@ public final class ConnectivityUtils { Connection additionalLowerConn) { // find cep for each AD MC of roadm 1 and 2 String topConnName = String.join("+", "TOP", tp1, tp2, qual); - LOG.info("Top connection name = {}", topConnName); + LOG.info("Creation of Top connection, name = {}", topConnName); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 = cepMap.get( new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .cep.list.ConnectionEndPointKey(new Uuid(UUID.nameUUIDFromBytes( (String.join("+", "CEP", tp1.split("\\+")[0], qual, tp1.split("\\+")[1])) .getBytes(StandardCharsets.UTF_8)).toString()))); - LOG.info("ADCEP1 = {}", adCep1); + LOG.debug("ADCEP1 = {}", adCep1); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connection.ConnectionEndPoint cep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 @@ -1071,7 +1134,7 @@ public final class ConnectivityUtils { new Uuid(UUID.nameUUIDFromBytes( (String.join("+", "CEP", tp2.split("\\+")[0], qual, tp2.split("\\+")[1])) .getBytes(StandardCharsets.UTF_8)).toString()))); - LOG.info("ADCEP2 = {}", adCep2); + LOG.debug("ADCEP2 = {}", adCep2); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 .connection.ConnectionEndPoint cep2 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 @@ -1107,9 +1170,10 @@ public final class ConnectivityUtils { .connectivity.context.Connection createXCBetweenCeps( ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual, LayerProtocolName xcProtocol) { - String crossConnName = String.join("+", "XC", tp1, tp2, qual); + String crossConnName = String.join("+", "XC", cep1.getName().entrySet().iterator().next().getValue().getValue(), + cep2.getName().entrySet().iterator().next().getValue().getValue()); LOG.info("Creation cross connection between: {} and {}", tp1, tp2); - LOG.info("Cross connection name = {}", crossConnName); + LOG.info("CONNECTIVITYUTILS 1145 : Cross connection name = {}", crossConnName); LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint()); LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint()); org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121 @@ -1147,108 +1211,35 @@ public final class ConnectivityUtils { .build(); } - private ConnectionEndPoint createCepRoadm(String id, String qualifier) { - String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]); - String nodeNepId = String.join("+",id.split("\\+")[0], TapiStringConstants.PHTNC_MEDIA); - LOG.info("NEP = {}", nepId); - Name cepName = new NameBuilder() - .setValueName("ConnectionEndPoint name") - .setValue(nepId) - .build(); - ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder() - .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( - nepId.getBytes(StandardCharsets.UTF_8)) - .toString())) - .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( - nodeNepId.getBytes(StandardCharsets.UTF_8)) - .toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)) - .toString())) - .build(); - String clientQualifier = ""; - switch (qualifier) { - case TapiStringConstants.PHTNC_MEDIA_OTS: - clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS; - break; - case TapiStringConstants.PHTNC_MEDIA_OMS: - clientQualifier = TapiStringConstants.MC; - OwnedNodeEdgePoint onepMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1], - false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); - putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], TapiStringConstants.MC, onepMC); - break; - case TapiStringConstants.MC: - clientQualifier = TapiStringConstants.OTSI_MC; - OwnedNodeEdgePoint onepOTSiMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1], - false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); - putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], - TapiStringConstants.OTSI_MC, onepOTSiMC); - break; - default: - LOG.debug("not currently handling client NEP for OTSiMC CEP {}", nepId); - break; - } - ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder() - .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1])) - .getBytes(StandardCharsets.UTF_8)) - .toString())) - .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( - nodeNepId.getBytes(StandardCharsets.UTF_8)) - .toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)) - .toString())) - .build(); - // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...) - // TODO: add parent ONEP?? - ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder() - .setUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1])) - .getBytes(StandardCharsets.UTF_8)) - .toString())) - .setParentNodeEdgePoint(pnep) - .setName(Map.of(cepName.key(), cepName)) - .setConnectionPortRole(PortRole.SYMMETRIC) - .setDirection(Direction.BIDIRECTIONAL) - .setOperationalState(OperationalState.ENABLED) - .setLifecycleState(LifecycleState.INSTALLED) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA); - return TapiStringConstants.OTSI_MC.equals(qualifier) - ? cepBldr.build() - : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build(); - } - - private ConnectionEndPoint createCepXpdr( + private ConnectionEndPoint createCepXpdr(int lowerFreqIndex, int higherFreqIndex, String id, String qualifier, String nodeLayer, LayerProtocolName cepProtocol) { String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]); String nepNodeId = String.join("+",id.split("\\+")[0], TapiStringConstants.XPDR); + String extendedNepId = (lowerFreqIndex == 0 && higherFreqIndex == 0) + ? nepId + : String.join("-",nepId, ("[" + lowerFreqIndex + "-" + higherFreqIndex + "]")); + LOG.debug("CONNECTIVITYUTILS 1307 CreateCepXpdr {}", extendedNepId); Name cepName = new NameBuilder() .setValueName("ConnectionEndPoint name") - .setValue(nepId) + .setValue(extendedNepId) .build(); ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder() .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( nepId.getBytes(StandardCharsets.UTF_8)).toString())) .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( nepNodeId.getBytes(StandardCharsets.UTF_8)).toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER - .getBytes(StandardCharsets.UTF_8)).toString())) + .setTopologyUuid(this.tapiTopoUuid) .build(); String clientQualifier = ""; - String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA; switch (qualifier) { case TapiStringConstants.PHTNC_MEDIA_OTS: clientQualifier = TapiStringConstants.OTSI_MC; break; case TapiStringConstants.OTSI_MC: clientQualifier = TapiStringConstants.E_ODU; - clientNodeLayer = TapiStringConstants.ODU; break; case TapiStringConstants.E_ODU: clientQualifier = TapiStringConstants.DSR; - clientNodeLayer = TapiStringConstants.DSR; break; default : LOG.debug("no client CEP for DSR NEP {}", nepId); @@ -1260,15 +1251,12 @@ public final class ConnectivityUtils { .getBytes(StandardCharsets.UTF_8)).toString())) .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( nepNodeId.getBytes(StandardCharsets.UTF_8)).toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER - .getBytes(StandardCharsets.UTF_8)).toString())) + .setTopologyUuid(this.tapiTopoUuid) .build(); // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...) - // TODO: add parent ONEP?? ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder() .setUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1])) + (String.join("+", "CEP", extendedNepId)) .getBytes(StandardCharsets.UTF_8)).toString())) .setParentNodeEdgePoint(pnep) .setName(Map.of(cepName.key(), cepName)) @@ -1536,7 +1524,7 @@ public final class ConnectivityUtils { return null; } - private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) { + public void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) { String nepId = String.join("+", node, qual, spcRdmAD.split("\\+")[1]); String nodeNepId = String.join("+", node, TapiStringConstants.PHTNC_MEDIA); LOG.info("NEP id before Merge = {}", nepId); @@ -1544,8 +1532,7 @@ public final class ConnectivityUtils { // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep this.tapiContext.updateTopologyWithCep( //topoUuid, - new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()), + this.tapiTopoUuid, //nodeUuid, new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()), //nepUuid, @@ -1558,9 +1545,7 @@ public final class ConnectivityUtils { // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep this.tapiContext.updateTopologyWithCep( //topoUuid, - new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)) - .toString()), + this.tapiTopoUuid, //nodeUuid, new Uuid(UUID.nameUUIDFromBytes( String.join("+", node, nodeLayer).getBytes(StandardCharsets.UTF_8)) @@ -1572,8 +1557,7 @@ public final class ConnectivityUtils { cep); } - - private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) { + public void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) { String nepId = String.join("+", orNodeId, qual, orTpId); String nepNodeId = String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA); LOG.info("NEP id before Merge = {}", nepId); @@ -1581,9 +1565,7 @@ public final class ConnectivityUtils { // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep updateTopologyWithNep( //topoUuid, - new Uuid(UUID.nameUUIDFromBytes( - TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8"))) - .toString()), + this.tapiTopoUuid, //nodeUuid, new Uuid(UUID.nameUUIDFromBytes( nepNodeId.getBytes(Charset.forName("UTF-8"))) @@ -1765,8 +1747,6 @@ public final class ConnectivityUtils { LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName); // TODO --> get clli from datastore? String clli = "NodeSA"; - LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName); - LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName); ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder() .setClli(clli) .setNodeId(new NodeIdType(nodeid)) @@ -1961,34 +1941,4 @@ public final class ConnectivityUtils { return null; } - private OwnedNodeEdgePoint createRoadmNep( - String orNodeId, String tpId, boolean withSip, - OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) { - //TODO : complete implementation with SIP - Name nepName = new NameBuilder() - .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint") - .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId)) - .build(); - return new OwnedNodeEdgePointBuilder() - .setUuid( - new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", orNodeId, nepPhotonicSublayer,tpId)).getBytes(StandardCharsets.UTF_8)) - .toString())) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) - .setName(Map.of(nepName.key(), nepName)) - .setSupportedCepLayerProtocolQualifierInstances( - new ArrayList<>(List.of( - new SupportedCepLayerProtocolQualifierInstancesBuilder() - .setLayerProtocolQualifier( - TapiStringConstants.MC.equals(nepPhotonicSublayer) - ? PHOTONICLAYERQUALIFIERMC.VALUE - : PHOTONICLAYERQUALIFIEROTSiMC.VALUE) - .setNumberOfCepInstances(Uint64.valueOf(1)) - .build()))) - .setDirection(Direction.BIDIRECTIONAL) - .setLinkPortRole(PortRole.SYMMETRIC) - .setAdministrativeState(adminState).setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED) - .build(); - } } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java index f5cb9dd76..f12b6a606 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java @@ -7,9 +7,11 @@ */ package org.opendaylight.transportpce.tapi.impl; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.UUID; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; import org.opendaylight.mdsal.binding.api.NotificationPublishService; @@ -21,6 +23,7 @@ import org.opendaylight.transportpce.common.InstanceIdentifiers; import org.opendaylight.transportpce.common.NetworkUtils; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; +import org.opendaylight.transportpce.tapi.TapiStringConstants; import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils; import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl; import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl; @@ -46,7 +49,6 @@ import org.opendaylight.transportpce.tapi.topology.TopologyUtils; import org.opendaylight.transportpce.tapi.utils.TapiContext; import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping; import org.opendaylight.transportpce.tapi.utils.TapiLink; -import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl; import org.opendaylight.transportpce.tapi.utils.TapiListener; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes; @@ -55,6 +57,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev230728.ServiceInterfacePoints; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yangtools.concepts.Registration; @@ -84,6 +87,9 @@ public class TapiProvider { org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).augmentation(Network1.class) .child(Link.class); + public static final Uuid TAPI_TOPO_UUID = new Uuid(UUID.nameUUIDFromBytes( + TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()); + public static final String TOPOLOGICAL_MODE = "Full"; private final DataBroker dataBroker; private final NetworkTransactionService networkTransactionService; private final ServiceDataStoreOperations serviceDataStoreOperations; @@ -103,17 +109,17 @@ public class TapiProvider { @Reference NetworkTransactionService networkTransactionService, @Reference ServiceDataStoreOperations serviceDataStoreOperations, @Reference TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler, - @Reference TapiNetworkModelService tapiNetworkModelServiceImpl) { + @Reference TapiNetworkModelService tapiNetworkModelServiceImpl, + @Reference TapiLink tapiLink, + @Reference TapiContext tapiContext) { this.dataBroker = dataBroker; this.networkTransactionService = networkTransactionService; this.serviceDataStoreOperations = serviceDataStoreOperations; LOG.info("TapiProvider Session Initiated"); - TapiContext tapiContext = new TapiContext(this.networkTransactionService); LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext()); - TapiLink tapiLink = new TapiLinkImpl(this.networkTransactionService); TopologyUtils topologyUtils = new TopologyUtils(this.networkTransactionService, this.dataBroker, tapiLink); ConnectivityUtils connectivityUtils = new ConnectivityUtils(this.serviceDataStoreOperations, new HashMap<>(), - tapiContext, this.networkTransactionService); + tapiContext, this.networkTransactionService, TAPI_TOPO_UUID); TapiInitialORMapping tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils, tapiContext, this.serviceDataStoreOperations); tapiInitialORMapping.performTopoInitialMapping(); @@ -184,5 +190,4 @@ public class TapiProvider { public Registration getRegisteredRpcs() { return rpcRegistration; } - } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeDetailsImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeDetailsImpl.java index 80cf31db6..c9c34061e 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeDetailsImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeDetailsImpl.java @@ -8,12 +8,16 @@ package org.opendaylight.transportpce.tapi.impl.rpc; import com.google.common.util.concurrent.ListenableFuture; +import java.util.HashMap; +import java.util.Map; import org.opendaylight.transportpce.tapi.utils.TapiContext; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetails; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsInput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.details.output.NodeBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node; import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -32,9 +36,9 @@ public class GetNodeDetailsImpl implements GetNodeDetails { @Override public ListenableFuture> invoke(GetNodeDetailsInput input) { - // TODO Auto-generated method stub - // TODO -> maybe we get errors when having CEPs? + // Node id: if roadm -> ROADM+PHOTONIC_MEDIA. if xpdr -> XPDR-XPDR+DSR/OTSi + Node node = this.tapiContext.getTapiNode(input.getTopologyId(), input.getNodeId()); if (node == null) { LOG.error("Invalid TAPI node name"); @@ -42,9 +46,53 @@ public class GetNodeDetailsImpl implements GetNodeDetails { .withError(ErrorType.RPC, "Invalid Tapi Node name") .buildFuture(); } + // OwnedNodeEdgePoint1 augmentation not supported in get.node.details.output.Node + // Cast as follows not tolerated by spotBugs +// org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.details.output.Node gndNode +// = org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.details.output.Node +// .class.cast(node); + // Recreate OwnedNodeEdgePoint and Node builders straping the unsupported OwnedNodeEdgePoint1 Augmentation + Map onepmap = node.getOwnedNodeEdgePoint(); + Map gndonepmap = new HashMap<>(); + + for (Map.Entry onep : onepmap.entrySet()) { + gndonepmap.put(onep.getKey(), new OwnedNodeEdgePointBuilder() + .setUuid(onep.getValue().getUuid()) + .setLayerProtocolName(onep.getValue().getLayerProtocolName()) + .setName(onep.getValue().getName()) + .setSupportedCepLayerProtocolQualifierInstances( + onep.getValue().getSupportedCepLayerProtocolQualifierInstances()) + .setAdministrativeState(onep.getValue().getAdministrativeState()) + .setOperationalState(onep.getValue().getOperationalState()) + .setLifecycleState(onep.getValue().getLifecycleState()) + .setDirection(onep.getValue().getDirection()) + .setLinkPortRole(onep.getValue().getLinkPortRole()) + .build()); + } + var gndNode = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121 + .get.node.details.output.NodeBuilder() + .setUuid(node.getUuid()) + .setName(node.getName()) + .setLayerProtocolName(node.getLayerProtocolName()) + .setAdministrativeState(node.getAdministrativeState()) + .setOperationalState(node.getOperationalState()) + .setLifecycleState(node.getLifecycleState()) + .setOwnedNodeEdgePoint(gndonepmap) + .setNodeRuleGroup(node.getNodeRuleGroup()) + .setInterRuleGroup(node.getInterRuleGroup()) + .setCostCharacteristic(node.getCostCharacteristic()) + .setLatencyCharacteristic(node.getLatencyCharacteristic()) + .setErrorCharacteristic(node.getErrorCharacteristic()) + .setLossCharacteristic(node.getLossCharacteristic()) + .setRepeatDeliveryCharacteristic(node.getRepeatDeliveryCharacteristic()) + .setDeliveryOrderCharacteristic(node.getDeliveryOrderCharacteristic()) + .setUnavailableTimeCharacteristic(node.getUnavailableTimeCharacteristic()) + .setServerIntegrityProcessCharacteristic(node.getServerIntegrityProcessCharacteristic()) + .build(); + return RpcResultBuilder .success(new GetNodeDetailsOutputBuilder() - .setNode(new NodeBuilder(node).build()) + .setNode(gndNode) .build()) .buildFuture(); } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java index b049f2822..4bba3a4ca 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.tapi.topology; import java.math.RoundingMode; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -64,6 +65,12 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.payl import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E; @@ -73,10 +80,15 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPEGigE; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ConnectionEndPoint2Builder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpec; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpecBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.cep.list.connection.end.point.OtsMediaConnectionEndPointSpec; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.photonic.media.node.edge.point.spec.SpectrumCapabilityPacBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumBuilder; @@ -90,7 +102,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULE; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP; -//import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.InterRuleGroup; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroup; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroupBuilder; @@ -534,6 +545,94 @@ public class ConvertORToTapiTopology { return sps.stream().distinct().toList(); } + public ConnectionEndPoint createCepRoadm(int lowerFreqIndex, int higherFreqIndex, String id, String qualifier, + OtsMediaConnectionEndPointSpec omCepSpec) { + String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]); + String nodeNepId = String.join("+",id.split("\\+")[0], TapiStringConstants.PHTNC_MEDIA); + String extendedNepId = lowerFreqIndex == 0 && higherFreqIndex == 0 + ? nepId + : String.join("-",nepId, ("[" + lowerFreqIndex + "-" + higherFreqIndex + "]")); + LOG.info("NEP = {}", nepId); + Name cepName = new NameBuilder() + .setValueName("ConnectionEndPoint name") + .setValue(extendedNepId) + .build(); + ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder() + .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( + nepId.getBytes(StandardCharsets.UTF_8)) + .toString())) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( + nodeNepId.getBytes(StandardCharsets.UTF_8)) + .toString())) + .setTopologyUuid(this.tapiTopoUuid) + .build(); + String clientQualifier = ""; + + switch (qualifier) { + case TapiStringConstants.PHTNC_MEDIA_OTS: + clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS; + break; + case TapiStringConstants.PHTNC_MEDIA_OMS: + clientQualifier = TapiStringConstants.MC; + break; + case TapiStringConstants.MC: + clientQualifier = TapiStringConstants.OTSI_MC; + break; + default: + LOG.debug("not currently handling client NEP for OTSiMC CEP {}", nepId); + break; + } + ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder() + .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1])) + .getBytes(StandardCharsets.UTF_8)) + .toString())) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( + nodeNepId.getBytes(StandardCharsets.UTF_8)) + .toString())) + .setTopologyUuid(this.tapiTopoUuid) + .build(); + // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...) + ConnectionEndPoint2Builder cep2builder = new ConnectionEndPoint2Builder(); + ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder() + .setUuid(new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", "CEP", extendedNepId)).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setParentNodeEdgePoint(pnep) + .setName(Map.of(cepName.key(), cepName)) + .setConnectionPortRole(PortRole.SYMMETRIC) + .setDirection(Direction.BIDIRECTIONAL) + .setOperationalState(OperationalState.ENABLED) + .setLifecycleState(LifecycleState.INSTALLED) + .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA); + switch (qualifier) { + case TapiStringConstants.PHTNC_MEDIA_OTS: + cepBldr.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE); + if (omCepSpec != null) { + cepBldr.addAugmentation(cep2builder.setOtsMediaConnectionEndPointSpec(omCepSpec).build()); + LOG.info("In ConverTORToTapiTopology LINE599, add Augment to cep {}", cepBldr.build()); + } + break; + case TapiStringConstants.PHTNC_MEDIA_OMS: + cepBldr.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROMS.VALUE); + break; + case TapiStringConstants.MC: + cepBldr.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE); + break; + case TapiStringConstants.OTSI_MC: + cepBldr.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE); + break; + default: + break; + } + + return TapiStringConstants.OTSI_MC.equals(qualifier) + ? cepBldr.build() + : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build(); + } + + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "SF_SWITCH_FALLTHROUGH", + justification = "Voluntarily No break in switchcase where comment is inserted in following method") public List createSupportedCepLayerProtocolQualifier( Collection sicList, LayerProtocolName lpn) { if (sicList == null) { @@ -864,66 +963,78 @@ public class ConvertORToTapiTopology { return onepBldr; } - public OwnedNodeEdgePointBuilder addPhotSpecToRoadmOnep(String nodeId, Map usedFreqMap, Map availableFreqMap, OwnedNodeEdgePointBuilder onepBldr, String keyword) { - if (!String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword) - && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) { - return onepBldr; - } - // Creating OTS/OMS NEP specific attributes - double naz = 0.01; - Double lowSupFreq = GridConstant.START_EDGE_FREQUENCY * 1E09 ; - Double upSupFreq = lowSupFreq + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz; - lowSupFreq += naz; - SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder(); - Map freqMap = null; - if (usedFreqMap == null || usedFreqMap.isEmpty()) { - freqMap = Map.of(lowSupFreq, upSupFreq); - } else { - Map ospecMap = new HashMap<>(); - OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder(); - for (Map.Entry frequency : usedFreqMap.entrySet()) { - ospecBd - .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09))) - .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09))); - OccupiedSpectrum ospec = ospecBd.build(); - ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec); - } - spectrumPac.setOccupiedSpectrum(ospecMap); - } - if (availableFreqMap != null && !availableFreqMap.isEmpty()) { - freqMap = availableFreqMap; - } - if (freqMap != null) { - Map aspecMap = new HashMap<>(); - AvailableSpectrumBuilder aspecBd = new AvailableSpectrumBuilder(); - for (Map.Entry frequency : availableFreqMap.entrySet()) { - aspecBd - .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09))) - .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09))); - AvailableSpectrum aspec = aspecBd.build(); - aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec); + LOG.debug("Entering Add PhotSpec to Roadm, ConvertToTopology LINE 1050 , availfreqmap is {} Used FreqMap {}", + availableFreqMap, usedFreqMap); + if (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword) + || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) { + // Creating OTS/OMS NEP specific attributes + SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder(); + if ((usedFreqMap == null || usedFreqMap.isEmpty()) + && (availableFreqMap == null || availableFreqMap.isEmpty())) { + double naz = 0.01; + AvailableSpectrum aspec = new AvailableSpectrumBuilder() + .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + naz))) + .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09 + naz))) + .build(); + Map aspecMap = new HashMap<>(); + aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(), + aspec.getUpperFrequency()), aspec); + spectrumPac.setAvailableSpectrum(aspecMap); + } else { + if (availableFreqMap != null && !availableFreqMap.isEmpty()) { + Map aspecMap = new HashMap<>(); + AvailableSpectrumBuilder aspecBd = new AvailableSpectrumBuilder(); + for (Map.Entry frequency : availableFreqMap.entrySet()) { + aspecBd + .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue()))) + .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue()))); + AvailableSpectrum aspec = aspecBd.build(); + aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(), + aspec.getUpperFrequency()), aspec); + } + spectrumPac.setAvailableSpectrum(aspecMap); + } + if (usedFreqMap != null && !usedFreqMap.isEmpty()) { + Map ospecMap = new HashMap<>(); + OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder(); + for (Map.Entry frequency : usedFreqMap.entrySet()) { + ospecBd + .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue()))) + .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue()))); + OccupiedSpectrum ospec = ospecBd.build(); + ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), + ospec.getUpperFrequency()), ospec); + } + spectrumPac.setOccupiedSpectrum(ospecMap); + } } - spectrumPac.setAvailableSpectrum(aspecMap); + double nazz = 0.01; + SupportableSpectrum sspec = new SupportableSpectrumBuilder() + .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + nazz))) + .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09 + nazz))) + .build(); + Map sspecMap = new HashMap<>(); + sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(), + sspec.getUpperFrequency()), sspec); + spectrumPac.setSupportableSpectrum(sspecMap); + PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder() + .setSpectrumCapabilityPac(spectrumPac.build()) + .build(); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 = + new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121 + .OwnedNodeEdgePoint1Builder() + .setPhotonicMediaNodeEdgePointSpec(pnepSpec) + .build(); + onepBldr.addAugmentation(onep1); + LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ", + onepBldr.getName(), + onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum()); } - SupportableSpectrum sspec = new SupportableSpectrumBuilder() - .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq))) - .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq))) - .build(); - spectrumPac.setSupportableSpectrum( - new HashMap(Map.of( - new SupportableSpectrumKey(sspec.getLowerFrequency(), sspec.getUpperFrequency()), sspec))); - var onep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121 - .OwnedNodeEdgePoint1Builder() - .setPhotonicMediaNodeEdgePointSpec( - new PhotonicMediaNodeEdgePointSpecBuilder().setSpectrumCapabilityPac(spectrumPac.build()).build()) - .build(); - onepBldr.addAugmentation(onep1); - LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ", - onepBldr.getName(), - onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum()); return onepBldr; } @@ -1267,6 +1378,36 @@ public class ConvertORToTapiTopology { return onep; } + public OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId, boolean withSip, + OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) { + //TODO : complete implementation with SIP + Name nepName = new NameBuilder() + .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint") + .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId)) + .build(); + return new OwnedNodeEdgePointBuilder() + .setUuid( + new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", orNodeId, nepPhotonicSublayer,tpId)).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) + .setName(Map.of(nepName.key(), nepName)) + .setSupportedCepLayerProtocolQualifierInstances( + new ArrayList<>(List.of( + new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setLayerProtocolQualifier( + TapiStringConstants.MC.equals(nepPhotonicSublayer) + ? PHOTONICLAYERQUALIFIERMC.VALUE + : PHOTONICLAYERQUALIFIEROTSiMC.VALUE) + .setNumberOfCepInstances(Uint64.valueOf(1)) + .build()))) + .setDirection(Direction.BIDIRECTIONAL) + .setLinkPortRole(PortRole.SYMMETRIC) + .setAdministrativeState(adminState).setOperationalState(operState) + .setLifecycleState(LifecycleState.INSTALLED) + .build(); + } + private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpId, String nodeid, Collection supportedInterfaceCapability, OperationalState operState, AdministrativeState adminState) { diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java index 2ffad9c0b..1974b482f 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java @@ -17,6 +17,7 @@ import java.util.UUID; import java.util.stream.Collectors; import org.opendaylight.transportpce.common.fixedflex.GridConstant; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.impl.TapiProvider; import org.opendaylight.transportpce.tapi.utils.TapiLink; 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; @@ -40,6 +41,11 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.glob import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1Builder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepList; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS; @@ -79,7 +85,7 @@ public class ConvertORTopoToTapiFullTopo { private Map tapiLinks; private Map tapiSips; private final TapiLink tapiLink; - private static String topologicalMode; + private static String topologicalMode = TapiProvider.TOPOLOGICAL_MODE; public ConvertORTopoToTapiFullTopo(Uuid tapiTopoUuid, TapiLink tapiLink) { @@ -88,9 +94,6 @@ public class ConvertORTopoToTapiFullTopo { this.tapiLinks = new HashMap<>(); this.tapiSips = new HashMap<>(); this.tapiLink = tapiLink; - if (topologicalMode == null) { - ConvertORTopoToTapiFullTopo.topologicalMode = "Full"; - } } public void convertRdmToRdmLinks( @@ -140,6 +143,9 @@ public class ConvertORTopoToTapiFullTopo { this.tapiTopoUuid); linksToNotConvert.add(lnk1OppLnk.getValue()); tapiLinks.put(tapLink.key(), tapLink); + Map, ConnectionEndPoint> cepMap = this.tapiLink.getCepMap(); + LOG.debug("CONVERTTOFULL147, cepMap is {}", cepMap); + addCepToOnepAndNode(cepMap); } } @@ -152,6 +158,51 @@ public class ConvertORTopoToTapiFullTopo { } } + private void addCepToOnepAndNode(Map, ConnectionEndPoint> cepMap) { + + for (Map.Entry, ConnectionEndPoint> cepEntry : cepMap.entrySet()) { + String nepNodeId = cepEntry.getKey().entrySet().stream().findFirst().orElseThrow().getValue(); + LOG.debug("CONVERTTOFULL165, Node UUID is {}", nepNodeId); + List listKey = tapiNodes.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList()); + //.forEach(Function.identity().toString()); + LOG.debug("CONVERTTOFULL168, TapiNode Keys are {}", tapiNodes + .entrySet().stream() + .map(Map.Entry::getKey) + .collect(Collectors.toList())); + LOG.debug("CONVERTTOFULL172, TapiNode Keys are {}", tapiNodes + .entrySet().stream() + .map(nep -> nep.getValue().getName().toString()) + .collect(Collectors.toList())); + if (!listKey.toString().contains(nepNodeId)) { + LOG.info("ConvertToFullLINE178, ListKey {} of TapiNodes does not contain NodeUuid {}", + listKey, nepNodeId); + } + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node = tapiNodes + .entrySet().stream() + .filter(theNode -> theNode.getKey().getUuid().toString().equals(nepNodeId)) + .map(Map.Entry::getValue).findFirst().orElseThrow(); + var onepMap = node.getOwnedNodeEdgePoint(); + OwnedNodeEdgePoint ownedNep = onepMap.entrySet().stream() + .filter(onep -> onep.getKey().getUuid().toString() + .equals(cepEntry.getKey().entrySet().stream().findFirst().orElseThrow().getKey())) + .map(Map.Entry::getValue).findFirst().orElseThrow(); + CepList cepList = new CepListBuilder() + .setConnectionEndPoint(Map.of(cepEntry.getValue().key(), cepEntry.getValue())) + .build(); + OwnedNodeEdgePoint1 onep1Bldr = new OwnedNodeEdgePoint1Builder().setCepList(cepList).build(); + OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder(ownedNep) + .addAugmentation(onep1Bldr) + .build(); + onepMap.put(newOnep.key(), newOnep); + var newNode = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology + .NodeBuilder(node) + .setOwnedNodeEdgePoint(onepMap) + .build(); + this.tapiNodes.put(newNode.key(), newNode); + LOG.debug("CONVERTTOFULL201, successfully create node {} with CepList {} ", newNode.getName(), cepList); + } + } + private void convertRoadmNodeFull(Node roadm, Network openroadmTopo) { this.ietfNodeId = roadm.getNodeId().getValue(); this.ietfNodeType = roadm.augmentation( @@ -420,7 +471,36 @@ public class ConvertORTopoToTapiFullTopo { break; } //List sclpqiList = new ArrayList<>(List.of(sclpqiBd.build())); - OwnedNodeEdgePointBuilder onepBd = new OwnedNodeEdgePointBuilder(); + +// OwnedNodeEdgePointBuilder onepBd = new OwnedNodeEdgePointBuilder(); + + + AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState(); + State oper = tp.augmentation(TerminationPoint1.class).getOperationalState(); + Name nepName = new NameBuilder() + .setValueName(nepPhotonicSublayer + "NodeEdgePoint") + .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId)) + .build(); + OwnedNodeEdgePointBuilder onepBdd = new OwnedNodeEdgePointBuilder() + .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId)) + .getBytes(Charset.forName("UTF-8"))).toString())) + .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) + .setName(Map.of(nepName.key(), nepName)) + .setSupportedCepLayerProtocolQualifierInstances( + new ArrayList<>(List.of( + new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setLayerProtocolQualifier( + TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer) + ? PHOTONICLAYERQUALIFIEROMS.VALUE + : PHOTONICLAYERQUALIFIEROTS.VALUE) + .setNumberOfCepInstances(Uint64.valueOf(1)) + .build()))) + .setDirection(Direction.BIDIRECTIONAL) + .setLinkPortRole(PortRole.SYMMETRIC) + .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName())) + .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName())) + .setLifecycleState(LifecycleState.INSTALLED); + if (!nepPhotonicSublayer.equals(TapiStringConstants.MC) && !nepPhotonicSublayer.equals(TapiStringConstants.OTSI_MC)) { ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(this.tapiTopoUuid); @@ -434,9 +514,9 @@ public class ConvertORTopoToTapiFullTopo { case SRGTXRXPP: usedFreqMap = tapiFactory.getPPUsedWavelength(tp); if (usedFreqMap == null || usedFreqMap.isEmpty()) { - availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E09, - GridConstant.START_EDGE_FREQUENCY * 1E09 - + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06); + availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E12, + GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09); } else { LOG.debug("EnteringLOOPcreateOTSiMC & MC with usedFreqMap non empty {} NEP {} for Node {}", usedFreqMap, String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId), nodeId); @@ -456,35 +536,12 @@ public class ConvertORTopoToTapiFullTopo { break; } LOG.debug("calling add Photonic NEP spec for Roadm"); - onepBd = tapiFactory.addPhotSpecToRoadmOnep( - nodeId, usedFreqMap, availableFreqMap, onepBd, nepPhotonicSublayer); + onepBdd = tapiFactory.addPhotSpecToRoadmOnep( + nodeId, usedFreqMap, availableFreqMap, onepBdd, String.join("+", nodeId, nepPhotonicSublayer)); } - AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState(); - State oper = tp.augmentation(TerminationPoint1.class).getOperationalState(); - Name nepName = new NameBuilder() - .setValueName(nepPhotonicSublayer + "NodeEdgePoint") - .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId)) - .build(); - OwnedNodeEdgePoint onep = onepBd - .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId)) - .getBytes(Charset.forName("UTF-8"))).toString())) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) - .setName(Map.of(nepName.key(), nepName)) - .setSupportedCepLayerProtocolQualifierInstances( - new ArrayList<>(List.of( - new SupportedCepLayerProtocolQualifierInstancesBuilder() - .setLayerProtocolQualifier( - TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer) - ? PHOTONICLAYERQUALIFIEROMS.VALUE - : PHOTONICLAYERQUALIFIEROTS.VALUE) - .setNumberOfCepInstances(Uint64.valueOf(1)) - .build()))) - .setDirection(Direction.BIDIRECTIONAL) - .setLinkPortRole(PortRole.SYMMETRIC) - .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName())) - .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName())) - .setLifecycleState(LifecycleState.INSTALLED) - .build(); + + OwnedNodeEdgePoint onep = onepBdd.build(); + LOG.debug("ConvertORToTapiTopology.populateNepsForRdmNode onep is {}", onep); onepMap.put(onep.key(), onep); } return onepMap; diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java index 2166c8ac3..d095d92e5 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java @@ -31,6 +31,7 @@ import org.opendaylight.transportpce.common.fixedflex.GridConstant; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.impl.TapiProvider; import org.opendaylight.transportpce.tapi.utils.TapiLink; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes; @@ -153,14 +154,12 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class); - private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER - .getBytes(StandardCharsets.UTF_8)).toString()); + private final Uuid tapiTopoUuid = TapiProvider.TAPI_TOPO_UUID; + private static final String TOPOLOGICAL_MODE = TapiProvider.TOPOLOGICAL_MODE; private final NetworkTransactionService networkTransactionService; private final R2RTapiLinkDiscovery linkDiscovery; private final TapiLink tapiLink; private final ConvertORToTapiTopology tapiFactory; - private String topologicalMode; - private final ConvertORTopoToTapiFullTopo tapiFullFactory; private final NotificationPublishService notificationPublishService; private Map sipMap = new HashMap<>(); @@ -174,8 +173,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { this.notificationPublishService = notificationPublishService; this.tapiFactory = new ConvertORToTapiTopology(tapiTopoUuid); this.tapiLink = tapiLink; - this.tapiFullFactory = new ConvertORTopoToTapiFullTopo(tapiTopoUuid, tapiLink); - this.topologicalMode = tapiFullFactory.getTopologicalMode(); + } @Override @@ -213,7 +211,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { // Transform LCPs into ONEP Map onepMap = new HashMap<>(transformSrgToOnep(orNodeId, mapSrg)); - LOG.debug("CreateTapiNode NetworkModelServiceImpl, TopologicalMode = {}", topologicalMode); + LOG.debug("CreateTapiNode NetworkModelServiceImpl, TopologicalMode = {}", TOPOLOGICAL_MODE); LOG.debug("TAPINETWORKMODELSERVICEIMPL call transformSRGtoONEP (OrNodeId {} ", orNodeId); LOG.debug("TAPINETWORKMODELSERVICEIMPL SRG OTSNode of retrieved OnepMap {} ", onepMap.entrySet().stream() @@ -224,7 +222,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE) .build())) .collect(Collectors.toList())); - if (!topologicalMode.equals("Full")) { + if (!TOPOLOGICAL_MODE.equals("Full")) { // create tapi Node Node roadmNode = createRoadmTapiNode("ROADMINFRA", onepMap); mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode)); @@ -257,6 +255,8 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { Map rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion, this.tapiTopoUuid); if (!rdm2rdmLinks.isEmpty()) { + Map, ConnectionEndPoint> cepMap = this.tapiLink.getCepMap(); + addCepToOnep(onepMap, cepMap); mergeLinkinTopology(rdm2rdmLinks); } LOG.info("TAPI node for or node {} successfully merged", orNodeId); @@ -326,8 +326,33 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } } - private Map getChangedAttributes( - List changedOneps, Mapping mapping) { + private void addCepToOnep(Map onepMap, + Map, ConnectionEndPoint> cepMap) { + LOG.debug("TAPINetModServImpl332, Entering addCepToOnep, with cepMap {} and onepMapKeyList {}", cepMap, + onepMap.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList())); + for (Map.Entry, ConnectionEndPoint> cepEntry : cepMap.entrySet()) { + if (!onepMap.entrySet().stream().map(onep -> onep.getKey().toString()).collect(Collectors.toList()) + .contains(cepEntry.getKey().entrySet().stream().findFirst().orElseThrow().getKey())) { + continue; + } + OwnedNodeEdgePoint ownedNep = onepMap.entrySet().stream() + .filter(onep -> onep.getKey().getUuid().toString() + .equals(cepEntry.getKey().entrySet().stream().findAny().orElseThrow().getKey())) + .map(Map.Entry::getValue).findFirst().orElseThrow(); + CepList cepList = new CepListBuilder() + .setConnectionEndPoint(Map.of(cepEntry.getValue().key(), cepEntry.getValue())).build(); + OwnedNodeEdgePoint1 onep1Bldr = new OwnedNodeEdgePoint1Builder().setCepList(cepList).build(); + OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder(ownedNep) + .addAugmentation(onep1Bldr) + .build(); + onepMap.put(newOnep.key(), newOnep); + LOG.info("TAPINetModServImpl345, getting out of addCepToOnep with no Exception"); + } + + } + + private Map getChangedAttributes(List changedOneps, + Mapping mapping) { Map changedAttributes = new HashMap<>(); String operState = mapping.getPortOperState(); String oldState = operState.equals("InService") ? "OutOfService" : "InService"; @@ -674,7 +699,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { return; } if (nodeId.contains("ROADM")) { - if (topologicalMode.equals("Full")) { + if (TOPOLOGICAL_MODE.equals("Full")) { // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA Uuid nodeUuid = new Uuid( UUID.nameUUIDFromBytes( @@ -1018,8 +1043,8 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .setRiskCharacteristicName("risk characteristic") .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2")) .build(); - Map nodeRuleGroupMap = - tapiFactory.createAllNodeRuleGroupForRdmNode(topologicalMode, nodeUuid, orNodeId, onepMap.values()); + Map nodeRuleGroupMap + = tapiFactory.createAllNodeRuleGroupForRdmNode(TOPOLOGICAL_MODE, nodeUuid, orNodeId, onepMap.values()); return new NodeBuilder() .setUuid(nodeUuid) .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType)) @@ -1030,7 +1055,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .setOwnedNodeEdgePoint(onepMap) .setNodeRuleGroup(nodeRuleGroupMap) .setInterRuleGroup( - tapiFactory.createInterRuleGroupForRdmNode(topologicalMode, nodeUuid, orNodeId, + tapiFactory.createInterRuleGroupForRdmNode(TOPOLOGICAL_MODE, nodeUuid, orNodeId, nodeRuleGroupMap.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toList()))) .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic)) .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic)) @@ -1435,10 +1460,9 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { usedFreqMap = tapiFactory.getPP11UsedWavelength( getNetworkTerminationPoint11FromDatastore(nodeId, entry.getKey())); if (usedFreqMap == null || usedFreqMap.isEmpty()) { - availableFreqMap.put( - GridConstant.START_EDGE_FREQUENCY * 1E09, - GridConstant.START_EDGE_FREQUENCY * 1E09 - + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06); + availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E12, + GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09); } else { LOG.debug("EnteringLOOPcreateOTSiMC & MC with usedFreqMap non empty {} for Node {}, tp {}", usedFreqMap, nodeId, tpMap); @@ -1462,8 +1486,8 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { break; } LOG.debug("calling add Photonic NEP spec for Roadm"); - onepBd = tapiFactory.addPhotSpecToRoadmOnep( - nodeId, usedFreqMap, availableFreqMap, onepBd, nepPhotonicSublayer); + onepBd = tapiFactory.addPhotSpecToRoadmOnep(nodeId, usedFreqMap, availableFreqMap, onepBd, + String.join("+", nodeId, nepPhotonicSublayer)); } Name nepName = new NameBuilder().setValueName(nepPhotonicSublayer + "NodeEdgePoint").setValue(nepNameValue).build(); @@ -1513,7 +1537,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { Optional tpOptional = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); if (tpOptional.isEmpty()) { - LOG.error("readMdSal: Error reading tp {} , empty list", tpIID); + LOG.debug("readMdSal: Error reading tp {} , empty list",tpIID); return null; } LOG.debug("SUCCES getting LCP TP for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl", @@ -1554,7 +1578,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { Optional tpOptional = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); if (tpOptional.isEmpty()) { - LOG.error("readMdSal: Error reading tp {} , empty list",tpIID); + LOG.debug("readMdSal: Error reading tp {} , empty list",tpIID); return null; } LOG.debug("SUCCES getting LCP TP1 for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl", @@ -1591,7 +1615,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { Optional tpOptional = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); if (tpOptional.isEmpty()) { - LOG.error("readMdSal: Error reading tp {} , empty list", tpIID); + LOG.debug("readMdSal: Error reading tp {} , empty list",tpIID); return null; } LOG.debug("SUCCESS getting LCP TP11 for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl" diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiOrLinkListener.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiOrLinkListener.java index 37d24071f..e7b13b5fa 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiOrLinkListener.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiOrLinkListener.java @@ -10,6 +10,7 @@ package org.opendaylight.transportpce.tapi.topology; import java.nio.charset.Charset; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ExecutionException; @@ -61,9 +62,7 @@ public class TapiOrLinkListener implements DataTreeChangeListener { public void onDataTreeChanged(@NonNull List> changes) { LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName()); for (DataTreeModification change : changes) { - if (change.getRootNode().dataBefore() != null) { - continue; - } + Link link = change.getRootNode().dataAfter(); if (link == null) { continue; @@ -76,22 +75,50 @@ public class TapiOrLinkListener implements DataTreeChangeListener { LOG.error("No type in link. We cannot trigger the TAPI link creation"); return; } + if (!(link1.getLinkType().equals(OpenroadmLinkType.XPONDERINPUT) - || link1.getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))) { + || link1.getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT)) + || link1.getLinkType().equals(OpenroadmLinkType.ROADMTOROADM)) { + // No creation of link for ADD/DROP/EXPRESS links LOG.warn("Not triggering creation of link for type = {}", link1.getLinkType().getName()); - return; + continue; } + if (!oppositeLinkExists(link1.getOppositeLink())) { LOG.warn("Opposite link doest exist. Not creating TAPI link"); return; } - LOG.info("Opposite link already in datastore. Creatin TAPI bidirectional link"); + LOG.info("Opposite link already in datastore. Creating TAPI bidirectional link"); + String srcNode = getRoadmOrXpdr(link.getSource().getSourceNode().getValue()); String srcTp = link.getSource().getSourceTp().getValue(); String destNode = getRoadmOrXpdr(link.getDestination().getDestNode().getValue()); String destTp = link.getDestination().getDestTp().getValue(); + //Configuring link type to default OMS_XPDR-RDM + String linkType = TapiStringConstants.OMS_XPDR_RDM_LINK; + + if (link1.getLinkType().equals(OpenroadmLinkType.ROADMTOROADM)) { + // For ROADM to ROADM link, only capture change on existing links to track change in OMS + // Avoid creating 2 unidirectional links since these links are bidirectional in TAPI : + // Links are created at initialization through a process that guarantees the creation of a unique link + // Thus check that the link already exist in Datastore to upgrade it rather than creating an additional + // unidirectional link + if (!(linkExistInTopology(srcNode, srcTp, destNode, destTp, getQual(srcNode), getQual(destNode), + TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS))) { + continue; + } + LOG.warn("Now triggering creation of link for type = {} to account for OMS change", + link1.getLinkType().getName()); + linkType = TapiStringConstants.OMS_RDM_RDM_LINK; + } + + // for Xpdr to roadm link, create Link only if it was not before in datastore since links are created + // through rpcs and do not contain characteristics subject to potential updates + if (change.getRootNode().dataBefore() != null) { + continue; + } putTapiLinkInTopology(this.tapiLink.createTapiLink(srcNode, srcTp, destNode, destTp, - TapiStringConstants.OMS_XPDR_RDM_LINK, getQual(srcNode), getQual(destNode), + linkType, getQual(srcNode), getQual(destNode), TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, link1.getAdministrativeState().getName(), link1.getOperationalState().getName(), Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()), @@ -99,6 +126,32 @@ public class TapiOrLinkListener implements DataTreeChangeListener { } } + private boolean linkExistInTopology(String srcNodeId, String srcTpId, String dstNodeId, String dstTpId, + String srcNodeQual, String dstNodeQual, String srcTpQual, String dstTpQual) { + String sourceNepKey = String.join("+", srcNodeId, srcTpQual, srcTpId); + String destNepKey = String.join("+", dstNodeId, dstTpQual, dstTpId); + String linkKey = String.join("to", sourceNepKey, destNepKey); + Uuid linkUuid = new Uuid( + UUID.nameUUIDFromBytes(linkKey.getBytes(Charset.forName("UTF-8"))).toString()); + InstanceIdentifier + linkIID = InstanceIdentifier.builder(Context.class) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(tapiTopoUuid)) + .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link.class, + new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey(linkUuid)) + .build(); + try { + Optional optLink = + this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, linkIID).get(); + if (optLink.isEmpty()) { + return false; + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Could not read TAPI link in DataStore checking that rdm2rdm link is present"); + } + return true; + } + private void putTapiLinkInTopology( org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link tapiXpdrLink) { LOG.info("Creating tapi link in TAPI topology context"); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiPortMappingListener.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiPortMappingListener.java index da3d0e5e2..a25858a70 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiPortMappingListener.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiPortMappingListener.java @@ -31,49 +31,41 @@ public class TapiPortMappingListener implements DataTreeChangeListener { @Override public void onDataTreeChanged(@NonNull List> changes) { for (DataTreeModification change : changes) { - var rootNode = change.getRootNode(); - LOG.debug("TAPI module: Change in Node = {}", rootNode); + LOG.debug("TAPI module: Change in Node = {}", change.getRootNode()); // Data before needs to be not null - Nodes nodesAft = rootNode.dataAfter(); - if (nodesAft == null) { - continue; - } - Nodes nodesBef = rootNode.dataBefore(); - if (nodesBef == null) { - this.tapiNetworkModelService.createTapiNode( - nodesAft.getNodeId(), nodesAft.getNodeInfo().getOpenroadmVersion().getIntValue(), nodesAft); - continue; - } - // TODO -> need to filter out the ones that are not after creation. - // (Mapping before = null & Mapping after != null) is the rule for a first time connected device - String nodeId = nodesAft.getNodeId(); - Map mappingAft = nodesAft.getMapping(); - Map mappingBef = nodesBef.getMapping(); - LOG.info("Change in node {} with OR version = {}", - nodeId, nodesAft.getNodeInfo().getOpenroadmVersion().getName()); - //TODO avoid long message and concatenation in following LOG messages - if (mappingAft == null) { - LOG.warn("Mapping already existed in the datastore, which means that node {} already existed " - + "in TAPI topology. The action to take will be different", nodeId); - continue; - } - if (mappingBef == null) { - LOG.info("New mapping for node {} = {}", nodeId, mappingAft); - LOG.info("As the mapping is now created for the first time, " - + "we can proceed with the creation of the node {} in the TAPI topology", nodeId); - this.tapiNetworkModelService.createTapiNode( - nodeId, nodesAft.getNodeInfo().getOpenroadmVersion().getIntValue(), nodesAft); - continue; - } - for (Map.Entry entry : mappingAft.entrySet()) { - Mapping oldMapping = mappingBef.get(entry.getKey()); - Mapping newMapping = mappingAft.get(entry.getKey()); - if (oldMapping == null || newMapping == null) { + if (change.getRootNode().dataAfter() != null && change.getRootNode().dataBefore() != null) { + Nodes nodesAft = change.getRootNode().dataAfter(); + Nodes nodesBef = change.getRootNode().dataBefore(); + // TODO -> need to filter out the ones that are not after creation. + // (Mapping before = null & Mapping after != null) is the rule for a first time connected device + String nodeId = nodesAft.getNodeId(); + Map mappingAft = nodesAft.getMapping(); + Map mappingBef = nodesBef.getMapping(); + LOG.info("Change in node {} with OR version = {}", nodeId, + nodesAft.getNodeInfo().getOpenroadmVersion().getName()); + if (mappingAft == null) { + LOG.warn("Mapping already existed in the datastore, which means that node {} already existed " + + "in TAPI topology. The action to take will be different", nodeId); continue; } - if (!oldMapping.getPortAdminState().equals(newMapping.getPortAdminState()) - || !oldMapping.getPortOperState().equals(newMapping.getPortOperState())) { - this.tapiNetworkModelService.updateTapiTopology(nodeId, entry.getValue()); + if (mappingBef == null) { + LOG.info("New mapping for node {} = {}", nodeId, mappingAft); + LOG.info("As the mapping is now created for the first time, " + + "we can proceed with the creation of the node {} in the TAPI topology", nodeId); + this.tapiNetworkModelService.createTapiNode(nodeId, + nodesAft.getNodeInfo().getOpenroadmVersion().getIntValue(), nodesAft); + } else { + for (Map.Entry entry : mappingAft.entrySet()) { + Mapping oldMapping = mappingBef.get(entry.getKey()); + Mapping newMapping = mappingAft.get(entry.getKey()); + if (oldMapping == null || newMapping == null) { + continue; + } + if (!oldMapping.getPortAdminState().equals(newMapping.getPortAdminState()) + || !oldMapping.getPortOperState().equals(newMapping.getPortOperState())) { + this.tapiNetworkModelService.updateTapiTopology(nodeId, entry.getValue()); + } + } } } else if (change.getRootNode().getDataAfter() != null && change.getRootNode().getDataBefore() == null) { Nodes nodesAft = change.getRootNode().getDataAfter(); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TopologyUtils.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TopologyUtils.java index db93b9ebb..8e3acc9e4 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TopologyUtils.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TopologyUtils.java @@ -27,6 +27,7 @@ import org.opendaylight.transportpce.common.InstanceIdentifiers; import org.opendaylight.transportpce.common.NetworkUtils; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.impl.TapiProvider; import org.opendaylight.transportpce.tapi.utils.TapiLink; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingKey; @@ -50,7 +51,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.glob import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey; -//import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder; @@ -73,7 +73,7 @@ public final class TopologyUtils { private static final Logger LOG = LoggerFactory.getLogger(TopologyUtils.class); private Map tapiSips; private final TapiLink tapiLink; - private String topologicalMode; + private static final String TOPOLOGICAL_MODE = TapiProvider.TOPOLOGICAL_MODE; public static final String NOOPMODEDECLARED = "No operational mode declared in Topo for Tp {}, assumes by default "; public TopologyUtils( @@ -83,7 +83,6 @@ public final class TopologyUtils { this.tapiSips = new HashMap<>(); this.tapiLink = tapiLink; // TODO: Initially set topological mode to Full. Shall be set through the setter at controller initialization - this.topologicalMode = "Full"; } public Network readTopology(InstanceIdentifier networkIID) throws TapiTopologyException { @@ -134,11 +133,12 @@ public final class TopologyUtils { return nameList; } - public Topology createFullOtnTopology() throws TapiTopologyException { + public Topology createOtnTopology() throws TapiTopologyException { // read openroadm-topology Network openroadmTopo = readTopology(InstanceIdentifiers.OVERLAY_NETWORK_II); - String topoType = this.topologicalMode.equals("Full") ? TapiStringConstants.T0_FULL_MULTILAYER + String topoType = TOPOLOGICAL_MODE.equals("Full") ? TapiStringConstants.T0_FULL_MULTILAYER : TapiStringConstants.T0_TAPI_MULTILAYER; + LOG.info("TOPOUTILS, createOtnTopology, the TOPOLOGICAL_MODE is {} ",topoType); Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(topoType.getBytes(Charset.forName("UTF-8"))).toString()); Name name = new NameBuilder().setValue(topoType).setValueName("TAPI Topology Name").build(); var topoBdr = new TopologyBuilder() @@ -226,21 +226,20 @@ public final class TopologyUtils { LOG.warn("No roadm nodes exist in the network"); } else { // map roadm nodes - if (this.topologicalMode.equals("Full")) { + if (TOPOLOGICAL_MODE.equals("Full")) { for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 .networks.network.Node roadm : rdmList) { tapiFullFactory.convertRoadmNode(roadm, openroadmTopo, "Full"); this.tapiSips.putAll(tapiFullFactory.getTapiSips()); tapiNodeList.putAll(tapiFullFactory.getTapiNodes()); - tapiLinkList.putAll(tapiFullFactory.getTapiLinks()); - tapiFullFactory.convertRdmToRdmLinks( - // map roadm to roadm link - linkList.stream() - .filter(lk -> lk.augmentation(Link1.class).getLinkType() - .equals(OpenroadmLinkType.ROADMTOROADM)) - .collect(Collectors.toList())); - tapiLinkList.putAll(tapiFullFactory.getTapiLinks()); } + tapiLinkList.putAll(tapiFullFactory.getTapiLinks()); + // map roadm to roadm link + List rdmTordmLinkList = linkList.stream() + .filter(lk -> lk.augmentation(Link1.class).getLinkType() + .equals(OpenroadmLinkType.ROADMTOROADM)) + .collect(Collectors.toList()); + tapiFullFactory.convertRdmToRdmLinks(rdmTordmLinkList); } else { tapiFullFactory.convertRoadmNode(null, openroadmTopo, "Abstracted"); this.tapiSips.putAll(tapiFullFactory.getTapiSips()); @@ -316,11 +315,6 @@ public final class TopologyUtils { for (Node node: topology.nonnullNode().values()) { Map onepMap = new HashMap<>(); for (OwnedNodeEdgePoint onep: node.nonnullOwnedNodeEdgePoint().values()) { -// OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class); -// if (onep1 == null) { -// onepMap.put(onep.key(), onep); -// continue; -// } OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder() .setUuid(onep.getUuid()) .setLayerProtocolName(onep.getLayerProtocolName()) @@ -360,12 +354,4 @@ public final class TopologyUtils { return tapiSips; } - public void setTopologicalMode(String topoMode) { - this.topologicalMode = topoMode; - } - - public String getTopologicalMode() { - return topologicalMode; - } - } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java index 123d5673a..0681306f3 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev22112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.ConnectivityContextBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepList; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContextBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext; @@ -52,9 +53,13 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.to import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Component(immediate = true, service = TapiContext.class) public class TapiContext { private static final Logger LOG = LoggerFactory.getLogger(TapiContext.class); @@ -62,9 +67,11 @@ public class TapiContext { public static final String NODE_NOT_PRESENT = "Node is not present in datastore"; private final NetworkTransactionService networkTransactionService; - public TapiContext(NetworkTransactionService networkTransactionService) { + @Activate + public TapiContext(@Reference NetworkTransactionService networkTransactionService) { this.networkTransactionService = networkTransactionService; createTapiContext(); + LOG.info("TapiContext initialized"); } private void createTapiContext() { @@ -230,17 +237,24 @@ public class TapiContext { LOG.info("ONEP found = {}", onep); // TODO -> If cep exists -> skip merging to datasore OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class); + Map existingCepMap = new HashMap<>(); if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null && onep1.getCepList().getConnectionEndPoint().containsKey(new ConnectionEndPointKey(cep.key()))) { - LOG.info("CEP already in topology, skipping merge"); - return; + existingCepMap.putAll(onep1.getCepList().getConnectionEndPoint()); + LOG.info("CEP already in topology, but may need to be updated with new OMS parameters"); + LOG.debug("TAPICONTEXT254, Cep List is as follows {} ", existingCepMap); + //LOG.info("CEP already in topology, skipping merge"); + LOG.debug("TAPICONTEXT256, passed cep for update is as follows {} ", cep); } // Updated ONEP + existingCepMap.put(cep.key(), cep); + LOG.debug("TAPICONTEXT262, UpdateCep List is as follows {} ", existingCepMap); + CepList cepList = new CepListBuilder().setConnectionEndPoint(existingCepMap).build(); OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder(onep) - .addAugmentation(new OwnedNodeEdgePoint1Builder() - .setCepList(new CepListBuilder().setConnectionEndPoint(Map.of(cep.key(), cep)).build()) - .build()) - .build(); + .addAugmentation(onep1 == null + ? new OwnedNodeEdgePoint1Builder().setCepList(cepList).build() + : new OwnedNodeEdgePoint1Builder(onep1).setCepList(cepList).build()) + .build(); LOG.info("New ONEP is {}", newOnep); // merge in datastore this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, newOnep); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiInitialORMapping.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiInitialORMapping.java index ab23e7c4e..3e9374832 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiInitialORMapping.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiInitialORMapping.java @@ -49,9 +49,9 @@ public class TapiInitialORMapping { // creation of both topologies but with the fully roadm infrastructure. try { LOG.info("Performing initial mapping between OR and TAPI models."); - Topology t0FullMultiLayer = this.topologyUtils.createFullOtnTopology(); + Topology t0topology = this.topologyUtils.createOtnTopology(); Map topologyMap = new HashMap<>(); - topologyMap.put(t0FullMultiLayer.key(), t0FullMultiLayer); + topologyMap.put(t0topology.key(), t0topology); this.tapiContext.updateTopologyContext(topologyMap); Map sipMap = this.topologyUtils.getSipMap(); this.tapiContext.updateSIPContext(sipMap); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLink.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLink.java index 150af47bd..fbbe826fb 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLink.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLink.java @@ -7,6 +7,7 @@ */ package org.opendaylight.transportpce.tapi.utils; +import java.util.Map; import java.util.Set; 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; @@ -14,6 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Admi import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link; public interface TapiLink { @@ -34,4 +36,6 @@ public interface TapiLink { String getOperState(String srcNodeId, String destNodeId, String sourceTpId, String destTpId); String getAdminState(String srcNodeId, String destNodeId, String sourceTpId, String destTpId); + + Map, ConnectionEndPoint> getCepMap(); } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLinkImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLinkImpl.java index f8ee80f99..18c1618f1 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLinkImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiLinkImpl.java @@ -7,18 +7,30 @@ */ package org.opendaylight.transportpce.tapi.utils; +import java.math.RoundingMode; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ExecutionException; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.transportpce.common.NetworkUtils; import org.opendaylight.transportpce.common.network.NetworkTransactionService; +import org.opendaylight.transportpce.networkmodel.util.LinkIdUtil; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.topology.ConvertORToTapiTopology; 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.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.NetworkKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context; @@ -31,6 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capa import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.AvailableCapacityBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.TotalPotentialCapacityBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.cep.list.connection.end.point.OtsMediaConnectionEndPointSpec; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.cep.list.connection.end.point.OtsMediaConnectionEndPointSpecBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.impairment.route.entry.OtsConcentratedLossBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.impairment.route.entry.OtsFiberSpanImpairments; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.impairment.route.entry.OtsFiberSpanImpairmentsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ots.impairments.ImpairmentRouteEntry; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ots.impairments.ImpairmentRouteEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ots.media.connection.end.point.spec.OtsImpairments; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ots.media.connection.end.point.spec.OtsImpairmentsBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.ProtectionType; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RestorationPolicy; @@ -56,6 +77,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.va import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.validation.pac.ValidationMechanismBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.Decimal64; +import org.opendaylight.yangtools.yang.common.Uint64; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -67,27 +89,32 @@ public class TapiLinkImpl implements TapiLink { private static final Logger LOG = LoggerFactory.getLogger(TapiLinkImpl.class); private final NetworkTransactionService networkTransactionService; + private final TapiContext tapiContext; + private Map, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list + .ConnectionEndPoint> cepMap; @Activate - public TapiLinkImpl(@Reference NetworkTransactionService networkTransactionService) { + public TapiLinkImpl(@Reference NetworkTransactionService networkTransactionService, + @Reference TapiContext tapiContext) { this.networkTransactionService = networkTransactionService; + this.tapiContext = tapiContext; + this.cepMap = new HashMap<>(); } - public Link createTapiLink( - String srcNodeid, String srcTpId, String dstNodeId, String dstTpId, - String linkType, + public Link createTapiLink(String srcNodeId, String srcTpId, String dstNodeId, String dstTpId, String linkType, String srcNodeQual, String dstNodeQual, String srcTpQual, String dstTpQual, - String adminState, String operState, - Set layerProtoNameList, Set transLayerNameList, - Uuid tapiTopoUuid) { - String sourceNepKey = String.join("+", srcNodeid, srcTpQual, srcTpId); + String adminState, String operState, Set layerProtoNameList, + Set transLayerNameList, Uuid tapiTopoUuid) { + + LOG.info("LINKIMPL111, entering create tapiLink from {} to {}", srcNodeId, dstNodeId); + String sourceNepKey = String.join("+", srcNodeId, srcTpQual, srcTpId); String destNepKey = String.join("+", dstNodeId, dstTpQual, dstTpId); String linkKey = String.join("to", sourceNepKey, destNepKey); NodeEdgePoint sourceNep = new NodeEdgePointBuilder() .setTopologyUuid(tapiTopoUuid) .setNodeUuid( new Uuid(UUID.nameUUIDFromBytes( - String.join("+", srcNodeid, srcNodeQual).getBytes(Charset.forName("UTF-8"))).toString())) + String.join("+", srcNodeId, srcNodeQual).getBytes(Charset.forName("UTF-8"))).toString())) .setNodeEdgePointUuid( new Uuid(UUID.nameUUIDFromBytes(sourceNepKey.getBytes(Charset.forName("UTF-8"))).toString())) .build(); @@ -104,9 +131,16 @@ public class TapiLinkImpl implements TapiLink { switch (linkType) { case TapiStringConstants.OMS_RDM_RDM_LINK: LOG.info("Roadm to roadm link"); + LOG.info("TAPILinkImpl Building LinkId {}", buildORLinkId( + String.join("-", srcNodeId, srcTpId.split("\\-")[0]), srcTpId, + String.join("-", dstNodeId, dstTpId.split("\\-")[0]),dstTpId) + .toString()); linkName .setValueName(TapiStringConstants.VALUE_NAME_OMS_RDM_RDM_LINK) .setValue(linkKey); + createCepForLink(getORLinkFromLinkId(buildORLinkId( + String.join("-", srcNodeId, srcTpId.split("\\-")[0]), srcTpId, + String.join("-", dstNodeId, dstTpId.split("\\-")[0]),dstTpId))); break; case TapiStringConstants.TRANSITIONAL_LINK: LOG.info("Transitional link"); @@ -152,11 +186,16 @@ public class TapiLinkImpl implements TapiLink { .setValidationRobustness("validation robustness") .setLayerProtocolAdjacencyValidated("layer protocol adjacency") .build(); + LOG.info("LINKIMPL195, successfully created tapiLink {} of type {}", linkKey, linkType); return new LinkBuilder() .setUuid(new Uuid( UUID.nameUUIDFromBytes(linkKey.getBytes(Charset.forName("UTF-8"))).toString())) .setName(Map.of(linkName.build().key(), linkName.build())) - .setTransitionedLayerProtocolName(transLayerNameList) + //Bug in TAPI : transitioned layer protocol name is mandatory (whether this concept has disappeared) + // Additionally, the grouping defining it requires at least 2 elements. + // Seems that yang tools check has been enforced and check this --> set translayerNameList arbitrary + .setTransitionedLayerProtocolName(Set.of(TapiStringConstants.PHTNC_MEDIA_OMS, + TapiStringConstants.PHTNC_MEDIA_OTS)) .setLayerProtocolName(layerProtoNameList) .setNodeEdgePoint( new HashMap<>(Map.of(sourceNep.key(), sourceNep, destNep.key(), destNep))) @@ -186,6 +225,212 @@ public class TapiLinkImpl implements TapiLink { .build(); } + public LinkId buildORLinkId(String srcNode, String srcTp, String destNode, String destTp) { + LOG.info("InTapiLinkImpl, retrieves link ID {} from source and destination Nodes & tps", + LinkIdUtil.buildLinkId(srcNode, srcTp, destNode, destTp)); + return LinkIdUtil.buildLinkId(srcNode, srcTp, destNode, destTp); + } + + private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network + .topology.rev180226.networks.network.Link getORLinkFromLinkId(LinkId linkId) { + + InstanceIdentifier linkIID = InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.Network.class, + new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .augmentation(Network1.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.Link.class, new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.LinkKey(linkId)) + .build(); + try { + Optional link = this.networkTransactionService.read( + LogicalDatastoreType.CONFIGURATION, linkIID).get(); + if (link.isEmpty()) { + LOG.error("Link {} not present in the datastore", linkId); + return null; + } + //return link + return link.orElseThrow(); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Failed getting Link data from Datastore",e); + } + return null; + } + + public void createCepForLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network + .topology.rev180226.networks.network.Link link) { + //Retrieve OMS from OR link for both end + //Build OTS media connection End Point spec + //Build Cep and put them in DataStore + LOG.info("In TapiLinkImpl, creating CEP"); + Map lossPoutcorrect = NetworkUtils.calcSpanLoss(link); + Decimal64 linkLoss = Decimal64.valueOf("9999"); + if (lossPoutcorrect != null && lossPoutcorrect.containsKey("SpanLoss")) { + linkLoss = Decimal64.valueOf(lossPoutcorrect.entrySet().stream() + .filter(res -> res.getKey().equals("SpanLoss")).findFirst().orElseThrow().getValue().doubleValue(), + RoundingMode.UP); + } + Map pmd = NetworkUtils.calcCDandPMD(link); + Decimal64 pmdValue = Decimal64.valueOf("0"); + if (pmd != null && pmd.containsKey("PMD")) { + pmdValue = Decimal64.valueOf(pmd.entrySet().stream().filter(res -> res.getKey() + .equals("PMD")).findFirst().orElseThrow().getValue().doubleValue(),RoundingMode.UP); + } + Decimal64 oppLinkLoss; + OtsFiberSpanImpairments otsFSimp = new OtsFiberSpanImpairmentsBuilder() + .setConnectorIn(Decimal64.valueOf("0")) + .setConnectorOut(Decimal64.valueOf("0")) + .setLength( + NetworkUtils.calcLength(link) != null + ? Uint64.valueOf(Math.round(NetworkUtils.calcLength(link))) + : Uint64.valueOf(9999)) + .setPmd(pmdValue) + .setTotalLoss(linkLoss) + .build(); + OtsFiberSpanImpairments otsFSimpOppLink; + if (link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526 + .Link1.class).getOppositeLink() == null) { + otsFSimpOppLink = otsFSimp; + oppLinkLoss = linkLoss; + } else { + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.Link oppLink = getORLinkFromLinkId( + link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526 + .Link1.class).getOppositeLink()); + Map opplossPoutcorrect = NetworkUtils.calcSpanLoss(oppLink); + oppLinkLoss = Decimal64.valueOf("9999"); + if (opplossPoutcorrect != null && opplossPoutcorrect.containsKey("SpanLoss")) { + oppLinkLoss = Decimal64.valueOf(opplossPoutcorrect.entrySet().stream() + .filter(res -> res.getKey().equals("SpanLoss")).findFirst().orElseThrow().getValue().doubleValue(), + RoundingMode.UP); + } + Map opppmd = NetworkUtils.calcCDandPMD(link); + Decimal64 opppmdValue = Decimal64.valueOf("0"); + if (opppmd != null && opppmd.containsKey("PMD")) { + opppmdValue = Decimal64.valueOf(opppmd.entrySet().stream().filter(res -> res.getKey() + .equals("PMD")).findFirst().orElseThrow().getValue().doubleValue(),RoundingMode.UP); + } + otsFSimpOppLink = new OtsFiberSpanImpairmentsBuilder() + .setConnectorIn(Decimal64.valueOf("0")) + .setConnectorOut(Decimal64.valueOf("0")) + .setLength(NetworkUtils.calcLength(oppLink) != null + ? Uint64.valueOf(Math.round(NetworkUtils.calcLength(oppLink))) + : Uint64.valueOf(9999)) + .setPmd(opppmdValue) + .setTotalLoss(oppLinkLoss) + .build(); + } + LOG.info("In TapiLinkImpl, building Impairments for CEP"); + ImpairmentRouteEntry ire = new ImpairmentRouteEntryBuilder() + .setOtsConcentratedLoss(new OtsConcentratedLossBuilder() + .setConcentratedLoss(linkLoss).build()) + .setOtsFiberSpanImpairments(otsFSimp) + .build(); + ImpairmentRouteEntry ire2 = new ImpairmentRouteEntryBuilder() + .setOtsConcentratedLoss(new OtsConcentratedLossBuilder() + .setConcentratedLoss(oppLinkLoss).build()) + .setOtsFiberSpanImpairments(otsFSimpOppLink) + .build(); + List otsImpairmentListA = new ArrayList<>(List.of( + new OtsImpairmentsBuilder() + .setImpairmentRouteEntry(List.of(ire)) + .setIngressDirection(true) + .build(), + new OtsImpairmentsBuilder() + .setImpairmentRouteEntry(List.of(ire2)) + .setIngressDirection(false) + .build())); + List otsImpairmentListZ = new ArrayList<>(List.of( + new OtsImpairmentsBuilder() + .setImpairmentRouteEntry(List.of(ire)) + .setIngressDirection(false) + .build(), + new OtsImpairmentsBuilder() + .setImpairmentRouteEntry(List.of(ire2)) + .setIngressDirection(true) + .build())); + OtsMediaConnectionEndPointSpec otsMCmCepSpecA = new OtsMediaConnectionEndPointSpecBuilder() + .setOtsImpairments(otsImpairmentListA).build(); + OtsMediaConnectionEndPointSpec otsMCCepSpecZ = new OtsMediaConnectionEndPointSpecBuilder() + .setOtsImpairments(otsImpairmentListZ).build(); + LOG.debug("LINKIMPL365 OtsMediaConnectionEndSpec for link {} on A end is {}",link.getLinkId(), otsMCmCepSpecA); + LOG.debug("LINKIMPL366 OtsMediaConnectionEndSpec for link {} on Z end is {}}",link.getLinkId(), otsMCCepSpecZ); + + + ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(new Uuid(UUID.nameUUIDFromBytes( + TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString())); + + String intermediateSupNodeId = getSupportingNodeFromNodeId(link.getSource().getSourceNode().getValue()); + String intermediateTp = link.getSource().getSourceTp().getValue(); + + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint + cepNodeAots = tapiFactory.createCepRoadm(0, 0, String.join("+", intermediateSupNodeId, + intermediateTp), TapiStringConstants.PHTNC_MEDIA_OTS, otsMCmCepSpecA); + LOG.debug("TAPILINKIMPLLINE378 CepSpec is {}", otsMCmCepSpecA); + LOG.debug("TAPILINKIMPLLINE379 Cep Node A OTS is {}", cepNodeAots); + + putRdmCepInTopoContextAndAddToCepList(intermediateSupNodeId, intermediateTp, + TapiStringConstants.PHTNC_MEDIA_OTS, cepNodeAots); + LOG.info("In TapiLinkImpl create Cep {} with otsCepSpec {}", cepNodeAots.getName(), otsMCmCepSpecA); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint + cepNodeAoms = tapiFactory.createCepRoadm(0, 0, String.join("+", intermediateSupNodeId, + intermediateTp), TapiStringConstants.PHTNC_MEDIA_OMS, null); + putRdmCepInTopoContextAndAddToCepList(intermediateSupNodeId, intermediateTp, + TapiStringConstants.PHTNC_MEDIA_OMS, cepNodeAoms); + LOG.info("In TapiLinkImpl create Cep {} ", cepNodeAoms.getName()); + intermediateSupNodeId = getSupportingNodeFromNodeId(link.getDestination().getDestNode().getValue()); + intermediateTp = link.getDestination().getDestTp().getValue(); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint + cepNodeZots = tapiFactory.createCepRoadm(0, 0, String.join("+", intermediateSupNodeId, + intermediateTp), TapiStringConstants.PHTNC_MEDIA_OTS, otsMCCepSpecZ); + putRdmCepInTopoContextAndAddToCepList(intermediateSupNodeId, intermediateTp, + TapiStringConstants.PHTNC_MEDIA_OTS, cepNodeZots); + LOG.info("In TapiLinkImpl create Cep {} with otsCepSpec {}", cepNodeZots.getName(), otsMCCepSpecZ); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint + cepNodeZoms = tapiFactory.createCepRoadm(0, 0, String.join("+", intermediateSupNodeId, + intermediateTp), TapiStringConstants.PHTNC_MEDIA_OMS, null); + putRdmCepInTopoContextAndAddToCepList(intermediateSupNodeId, intermediateTp, + TapiStringConstants.PHTNC_MEDIA_OMS, cepNodeZoms); + LOG.info("In TapiLinkImpl create Cep {} ", cepNodeZoms.getName()); + + } + + private String getSupportingNodeFromNodeId(String overlayNodeId) { + InstanceIdentifier nodeIID = InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network + .rev180226.Networks.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.Network.class, + new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.Node.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks + .network.NodeKey(new NodeId(overlayNodeId))) + .build(); + try { + Optional node = this.networkTransactionService.read( + LogicalDatastoreType.CONFIGURATION, nodeIID).get(); + if (node.isEmpty()) { + LOG.error("TAPILINKIMPL Node {} not present in the datastore", node); + return null; + } + //return node + return node.orElseThrow().getSupportingNode().entrySet().stream() + .filter(supn -> supn.getKey().getNetworkRef().getValue().equals(NetworkUtils.UNDERLAY_NETWORK_ID)) + .findFirst().orElseThrow().getKey().getNodeRef().getValue(); + } catch (InterruptedException | ExecutionException e) { + LOG.error("TAPILINKIMPL Failed getting Mapping data from portMapping",e); + } + return null; + } + @Override public AdministrativeState setTapiAdminState(String adminState) { if (adminState == null) { @@ -224,6 +469,12 @@ public class TapiLinkImpl implements TapiLink { ? OperationalState.ENABLED : OperationalState.DISABLED; } + @Override + public Map, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list + .ConnectionEndPoint> getCepMap() { + return this.cepMap; + } + @Override public String getOperState(String srcNodeId, String destNodeId, String sourceTpId, String destTpId) { Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes( @@ -343,4 +594,28 @@ public class TapiLinkImpl implements TapiLink { return null; } } + + public void putRdmCepInTopoContextAndAddToCepList(String nodeId, String tpId, String qual, + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint + cep) { + LOG.debug("TAPILINKIMPLLINE566 nodeId {}, tpId {}, qual {}", nodeId, tpId, qual); + String nepId = String.join("+", nodeId, qual, tpId); + String nodeNepId = String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA); + var uuidMap = new HashMap<>(Map.of( + new Uuid(UUID.nameUUIDFromBytes(nepId.getBytes(StandardCharsets.UTF_8)).toString()).toString(), + new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()).toString())); + + LOG.debug("TAPILINKIMPL569, CEP is {}", cep); + this.cepMap.put(uuidMap, cep); + LOG.debug("TAPILINKIMPL570, Before calling TapiContext.updateTopologyWith CEP cepMap is {}", this.cepMap); + tapiContext.updateTopologyWithCep( + //TopoUuid + new Uuid(UUID.nameUUIDFromBytes( + TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()), + //nodeUuid, + new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()), + //nepUuid, + new Uuid(UUID.nameUUIDFromBytes(nepId.getBytes(StandardCharsets.UTF_8)).toString()), cep); + } + } diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java index 8e1313ea9..a4fa0eda3 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java @@ -16,7 +16,9 @@ import static org.mockito.Mockito.when; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -39,6 +41,7 @@ import org.opendaylight.transportpce.servicehandler.listeners.PceListener; import org.opendaylight.transportpce.servicehandler.listeners.RendererListener; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl; +import org.opendaylight.transportpce.tapi.TapiStringConstants; import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl; import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl; import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler; @@ -59,6 +62,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDelete; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityService; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInputBuilder; @@ -132,13 +136,15 @@ public class TapiConnectivityImplTest extends AbstractTest { TapiTopologyDataUtils.PORTMAPPING_FILE); networkTransactionService = new NetworkTransactionImpl(getDataBroker()); - tapilink = new TapiLinkImpl(networkTransactionService); + tapilink = new TapiLinkImpl(networkTransactionService, new TapiContext(networkTransactionService)); serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker()); tapiContext = new TapiContext(networkTransactionService); topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(), tapilink); connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext, - networkTransactionService); + networkTransactionService, + new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)) + .toString())); tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils, tapiContext, serviceDataStoreOperations); tapiInitialORMapping.performTopoInitialMapping(); diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java index 4e2a9f22c..411c4e028 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java @@ -8,11 +8,9 @@ package org.opendaylight.transportpce.tapi.provider; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.opendaylight.mdsal.common.api.CommitInfo.emptyFluentFuture; import com.google.common.util.concurrent.Futures; import java.util.Optional; @@ -42,6 +40,8 @@ import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl; import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl; import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler; import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService; +import org.opendaylight.transportpce.tapi.utils.TapiContext; +import org.opendaylight.transportpce.tapi.utils.TapiLink; @ExtendWith(MockitoExtension.class) public class TapiProviderTest { @@ -64,14 +64,18 @@ public class TapiProviderTest { private TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler; @Mock private TapiNetworkModelService tapiNetworkModelServiceImpl; + @Mock + private TapiLink tapilink; + @Mock + private TapiContext tapiContext; @Test void testInitRegisterTapiToRpcRegistry() { when(networkTransactionService.read(any(), any())).thenReturn(Futures.immediateFuture(Optional.empty())); - doReturn(emptyFluentFuture()).when(networkTransactionService).commit(); +// doReturn(emptyFluentFuture()).when(networkTransactionService).commit(); new TapiProvider(dataBroker, rpcProviderService, rpcService, notificationService, notificationPublishService, networkTransactionService, serviceDataStoreOperations, - tapiNetworkModelNotificationHandler, tapiNetworkModelServiceImpl); + tapiNetworkModelNotificationHandler, tapiNetworkModelServiceImpl, tapilink, tapiContext); verify(rpcProviderService, times(1)).registerRpcImplementations( any(CreateConnectivityServiceImpl.class), diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToFullTapiTopoTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToFullTapiTopoTest.java index b3d554a96..911dae89a 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToFullTapiTopoTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToFullTapiTopoTest.java @@ -31,9 +31,11 @@ import org.junit.jupiter.api.Test; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.InstanceIdentifiers; +import org.opendaylight.transportpce.common.fixedflex.GridConstant; import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.utils.TapiContext; import org.opendaylight.transportpce.tapi.utils.TapiLink; import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl; import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils; @@ -72,24 +74,39 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Port import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ConnectionEndPoint2; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.cep.list.connection.end.point.OtsMediaConnectionEndPointSpec; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.ots.impairments.ImpairmentRouteEntry; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrum; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrum; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroup; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroup; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -190,7 +207,7 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8"))) .toString()); networkTransactionService = new NetworkTransactionImpl(getDataBroker()); - tapiLink = new TapiLinkImpl(networkTransactionService); + tapiLink = new TapiLinkImpl(networkTransactionService, new TapiContext(networkTransactionService)); LOG.info("TEST SETUP READY"); } @@ -283,7 +300,8 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { new Uuid(UUID.nameUUIDFromBytes( (roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA").getBytes(Charset.forName("UTF-8"))) .toString()), - "roadm", "ROADM-A1"); + "roadm", "ROADM-A1", + false); } @Test @@ -315,7 +333,8 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA") .getBytes(Charset.forName("UTF-8"))) .toString()), - "roadm", "ROADM-A1"); + "roadm", "ROADM-A1", + true); String roadmA1seed = "ROADM-A1+PHOTONIC_MEDIA"; String roadmC1seed = "ROADM-C1+PHOTONIC_MEDIA"; String roadmA1deg2seed = roadmA1seed + "_OTS+DEG2-TTP-TXRX"; @@ -371,7 +390,8 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA") .getBytes(Charset.forName("UTF-8"))) .toString()), - "roadm", "ROADM-A1"); + "roadm", "ROADM-A1", + false); String spdrSA1seed = "SPDR-SA1-XPDR1"; String roadmA1seed = "ROADM-A1+PHOTONIC_MEDIA"; String spdrSA1tpseed = spdrSA1seed + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"; @@ -520,7 +540,7 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { private void checkOtsiNode( org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node, - Uuid nodeUuid, String otsiNodeType, String nodeId) { + Uuid nodeUuid, String otsiNodeType, String nodeId, boolean includingCep) { if (!node.getUuid().equals(nodeUuid)) { LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName(), nodeId); LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid); @@ -582,27 +602,64 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { // assertEquals(0, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs"); assertEquals(12, nepsPhot.size(), "Roadm node should have 12 PHOT_MEDIA NEPs (2x4 OTS +2x(OTS+OMS)"); // For Degree node - String mcnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX"; - checkNepOtsiRdmNode( - getOnep("DEG1-TTP", nepsOMS), - new Uuid(UUID.nameUUIDFromBytes(mcnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), - mcnepUuidSeed, pmOMSnep , false); - String otmcnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX"; - checkNepOtsiRdmNode( - getOnep("DEG1-TTP", nepsOTS), - new Uuid(UUID.nameUUIDFromBytes(otmcnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), - otmcnepUuidSeed, pmOTSnep, false); +//<<<<<<< HEAD +// String mcnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX"; +// checkNepOtsiRdmNode( +// getOnep("DEG1-TTP", nepsOMS), +// new Uuid(UUID.nameUUIDFromBytes(mcnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), +// mcnepUuidSeed, pmOMSnep , false); +// String otmcnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX"; +// checkNepOtsiRdmNode( +// getOnep("DEG1-TTP", nepsOTS), +// new Uuid(UUID.nameUUIDFromBytes(otmcnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), +// otmcnepUuidSeed, pmOTSnep, false); +// // For srg node +// String otscnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX"; +// checkNepOtsiRdmNode( +// getOnep("SRG1-PP1", nepsOTS), +// new Uuid(UUID.nameUUIDFromBytes(otscnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), +// otscnepUuidSeed, pmOTSnep, false); +// String otscnep4UuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX"; +// checkNepOtsiRdmNode( +// getOnep("SRG1-PP3", nepsOTS), +// new Uuid(UUID.nameUUIDFromBytes(otscnep4UuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), +// otscnep4UuidSeed, pmOTSnep, false); +//======= + OwnedNodeEdgePoint nepOmsDeg = getOnep("DEG2-TTP", nepsOMS); + Uuid omsNepDegUuid = new Uuid( + UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG2-TTP-TXRX").getBytes(Charset + .forName("UTF-8"))).toString()); + checkNepOtsiRdmNode(nepOmsDeg, omsNepDegUuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG2-TTP-TXRX", + "PHOTONIC_MEDIA_OMSNodeEdgePoint", false); + OwnedNodeEdgePoint nepOtsDeg = getOnep("DEG2-TTP", nepsOTS); + Uuid otsNepDegUuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX") + .getBytes(Charset.forName("UTF-8"))).toString()); + LOG.info("Line797, NEP {} with UUID put in checkCepOtsi Rdm Node {}", + String.join("+", nodeId, "PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"), otsNepDegUuid); + checkNepOtsiRdmNode(nepOtsDeg, otsNepDegUuid, nodeId + "+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX", + "PHOTONIC_MEDIA_OTSNodeEdgePoint", false); + OwnedNodeEdgePoint omsNep3 = getOnep("DEG2-TTP", nepsOMS); + LOG.info("Node tested in 800 is Node {}", node); + if (includingCep) { + checkCepOtsiRdmNode(nepOmsDeg, omsNepDegUuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG2-TTP-TXRX", + "PHOTONIC_MEDIA_OMSNodeEdgePoint", false); + LOG.info("Calling CheckCepOtsiRdmNode for NodeId {}, NepUuid {}", nodeId, otsNepDegUuid); + checkCepOtsiRdmNode(nepOtsDeg, otsNepDegUuid, nodeId + "+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX", + "PHOTONIC_MEDIA_OTSNodeEdgePoint", false); + } + // For srg node - String otscnepUuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX"; - checkNepOtsiRdmNode( - getOnep("SRG1-PP1", nepsOTS), - new Uuid(UUID.nameUUIDFromBytes(otscnepUuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), - otscnepUuidSeed, pmOTSnep, false); - String otscnep4UuidSeed = nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX"; - checkNepOtsiRdmNode( - getOnep("SRG1-PP3", nepsOTS), - new Uuid(UUID.nameUUIDFromBytes(otscnep4UuidSeed.getBytes(Charset.forName("UTF-8"))).toString()), - otscnep4UuidSeed, pmOTSnep, false); + OwnedNodeEdgePoint nepOtsSrg = getOnep("SRG1-PP1", nepsOTS); + Uuid otsNepUuidSrg = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX") + .getBytes(Charset.forName("UTF-8"))).toString()); + checkNepOtsiRdmNode(nepOtsSrg, otsNepUuidSrg, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX", + "PHOTONIC_MEDIA_OTSNodeEdgePoint", false); + OwnedNodeEdgePoint nepOtsSrg2 = getOnep("SRG1-PP3", nepsOTS); + Uuid otsNepUuidSrg2 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX") + .getBytes(Charset.forName("UTF-8"))).toString()); + checkNepOtsiRdmNode(nepOtsSrg2, otsNepUuidSrg2, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX", + "PHOTONIC_MEDIA_OTSNodeEdgePoint", false); +//>>>>>>> 381b4f2d (Consolidate ConnectivityUtils) List nrgList4 = node.nonnullNodeRuleGroup().values().stream() .sorted((nrg1, nrg2) -> nrg1.getName().entrySet().iterator().next().getValue().toString() .compareTo(nrg2.getName().entrySet().iterator().next().getValue().toString())) @@ -610,6 +667,9 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4); List nepNumber = new ArrayList<>(List.of(2, 4, 4)); checkNodeRuleGroupForRdm(nrgList4, nepNumber); + List irgList = node.nonnullInterRuleGroup().values().stream() + .collect(Collectors.toList()); + checkInterRuleGroupForRdm(irgList); return; case "switch": nepSize = 4; @@ -796,6 +856,20 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { rawCheckNodeRuleGroupOTsi("Tpdr", nrgList, enepUuid, inepUuid, nodeUuid); } + private void checkInterRuleGroupForRdm(List irgList) { + assertEquals(1, irgList.size(), "RDM infra node - OTS should contain 1 inter rule group"); + List anrgList = new ArrayList<>(irgList.get(0).getAssociatedNodeRuleGroup().values()); + assertEquals(3, anrgList.size(), "RDM infra node inter-rule-group should contain 3 associated nrg"); + List + ruleList = new ArrayList<>(irgList.get(0).nonnullRule().values()); + assertEquals(1, ruleList.size(), "inter-rule-group should contain a single rule"); + assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'"); + assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(), + "the rule type should be 'FORWARDING'"); + assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(), + "the forwarding rule should be 'MAYFORWARDACROSSGROUP'"); + } + private void checkNodeRuleGroupForMuxOTSi( List nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) { rawCheckNodeRuleGroupOTsi("Mux", nrgList, enepUuid, inepUuid, nodeUuid); @@ -867,6 +941,27 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { false, nep, nepUuid, portName, nepName, withSip); } +// private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, +// boolean withSip) { +// assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName); +// List nameList = new ArrayList<>(nep.nonnullName().values()); +// assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'"); +// assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'"); +// List lpql = new ArrayList<>(); +// List lsclpqi = nep +// .getSupportedCepLayerProtocolQualifierInstances(); +// for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) { +// lpql.add(entry.getLayerProtocolQualifier()); +// } +// assertEquals(2, lpql.size(), "OTSi nep should support 2 kind of cep"); +// assertThat("OTSi nep should support 2 kind of cep", +// lpql, hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE)); +// assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(), +// "OTSi nep should be of PHOTONIC_MEDIA protocol type"); +// checkCommonPartOfNep(nep, withSip); +// checkPhotPartOfNep(nep); +// } + private void checkNepOtsiRdmNode( OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) { if (!nep.getUuid().equals(nepUuid)) { @@ -876,6 +971,99 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { ? List.of(PHOTONICLAYERQUALIFIEROMS.VALUE) : nepName.contains("OTS") ? List.of(PHOTONICLAYERQUALIFIEROTS.VALUE) : null, LayerProtocolName.PHOTONICMEDIA, false, nep, nepUuid, portName, nepName, withSip); +//======= +// assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName); +// List nameList = new ArrayList<>(nep.nonnullName().values()); +// assertEquals(portName, nameList.get(0).getValue(), +// "value of OTSi nep should be '" + portName + "'"); +// assertEquals(nepName, nameList.get(0).getValueName(), +// "value-name of OTSi nep should be '" + nepName + "'"); +// List lpql = new ArrayList<>(); +// List lsclpqi = nep +// .getSupportedCepLayerProtocolQualifierInstances(); +// for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) { +// lpql.add(entry.getLayerProtocolQualifier()); +// } +// if (nepName.contains("OMS")) { +// assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep"); +// assertThat("OTSi nep should support 1 kind of cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE)); +// assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(), +// "OTSi nep should be of PHOTONIC_MEDIA protocol type"); +// checkPhotPartOfNep(nep); +// } else if (nepName.contains("OTS")) { +// assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep"); +// assertThat("OTSi nep should support 1 kind of cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROTS.VALUE)); +// assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(), +// "OTSi nep should be of PHOTONIC_MEDIA protocol type"); +// checkPhotPartOfNep(nep); +// } +// checkCommonPartOfNep(nep, withSip); + } + + + private void checkCepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, + boolean withSip) { + if (!nep.getUuid().equals(nepUuid)) { + LOG.info("ERRORUUIDNEP on Nep {}, expected {}", nep.getName(), portName); + } + if (nep.augmentation(OwnedNodeEdgePoint1.class) == null) { + LOG.info("checkCepOtsiRdmNode1211 No CEPList augmentation found for Nep UUID {}, {}", nepUuid, + nep.getName()); + return; + } + Map cepMap = new HashMap<>( + nep.augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()); + assertEquals(nepUuid, cepMap.entrySet().iterator().next().getValue().getParentNodeEdgePoint() + .getNodeEdgePointUuid(), "Cep parent NodeEdgePoint shall be the tested Nep"); + if (nepName.contains("OMS")) { + assertEquals(1, cepMap.size(), "OMS nep of RDM infra node should support only 1 OMS cep"); + assertEquals(LayerProtocolName.PHOTONICMEDIA, cepMap.entrySet().iterator().next().getValue() + .getLayerProtocolName(), "OMS cep LPN shall be PHOTONIC_MEDIA"); + assertEquals(PHOTONICLAYERQUALIFIEROMS.VALUE, cepMap.entrySet().iterator().next().getValue() + .getLayerProtocolQualifier(), "OMS cep LPQ shall be PHOTONIC_MEDIA_OMS"); + } else if (nepName.contains("OTS")) { + assertEquals(1, cepMap.size(), "OTS nep of RDM infra node should support only 1 OTS cep"); + assertEquals(LayerProtocolName.PHOTONICMEDIA, cepMap.entrySet().iterator().next().getValue() + .getLayerProtocolName(), "OTS cep LPN shall be PHOTONIC_MEDIA"); + assertEquals(PHOTONICLAYERQUALIFIEROTS.VALUE, cepMap.entrySet().iterator().next().getValue() + .getLayerProtocolQualifier(), "OTS cep LPQ shall be PHOTONIC_MEDIA_OTS"); + OtsMediaConnectionEndPointSpec otsMcSpec = cepMap.entrySet().iterator().next().getValue() + .augmentationOrElseThrow(ConnectionEndPoint2.class).getOtsMediaConnectionEndPointSpec(); + + List iroIngress = otsMcSpec.getOtsImpairments().stream() + .filter(imp -> imp.getIngressDirection()).collect(Collectors.toList()) + .iterator().next().getImpairmentRouteEntry(); + assertEquals(9999, iroIngress.iterator().next().getOtsConcentratedLoss().getConcentratedLoss() + .doubleValue(), "OTS-media-CEP-spec shall be present with 9999 concentrated loss"); + assertEquals(0.0, iroIngress.iterator().next().getOtsFiberSpanImpairments().getConnectorIn().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 connectorInLoss loss"); + assertEquals(0.0, iroIngress.iterator().next().getOtsFiberSpanImpairments().getConnectorOut().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 connectorOutLoss loss"); + assertEquals(9999, iroIngress.iterator().next().getOtsFiberSpanImpairments().getLength().intValue(), + "OTS-media-CEP-spec shall be present with 9999 length"); + assertEquals(0, iroIngress.iterator().next().getOtsFiberSpanImpairments().getPmd().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 pmd"); + assertEquals(9999.0, iroIngress.iterator().next().getOtsFiberSpanImpairments().getTotalLoss().doubleValue(), + "OTS-media-CEP-spec shall be present with 9999 Total loss"); + + List iroEgress = otsMcSpec.getOtsImpairments().stream() + .filter(imp -> !imp.getIngressDirection()).collect(Collectors.toList()) + .iterator().next().getImpairmentRouteEntry(); + assertEquals(9999, iroEgress.iterator().next().getOtsConcentratedLoss().getConcentratedLoss() + .doubleValue(), "OTS-media-CEP-spec shall be present with 9999 concentrated loss"); + assertEquals(0.0, iroEgress.iterator().next().getOtsFiberSpanImpairments().getConnectorIn().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 connectorInLoss loss"); + assertEquals(0.0, iroEgress.iterator().next().getOtsFiberSpanImpairments().getConnectorOut().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 connectorOutLoss loss"); + assertEquals(9999, iroEgress.iterator().next().getOtsFiberSpanImpairments().getLength().intValue(), + "OTS-media-CEP-spec shall be present with 9999 length"); + assertEquals(0, iroEgress.iterator().next().getOtsFiberSpanImpairments().getPmd().doubleValue(), + "OTS-media-CEP-spec shall be present with 0 pmd"); + assertEquals(9999.0, iroEgress.iterator().next().getOtsFiberSpanImpairments().getTotalLoss().doubleValue(), + "OTS-media-CEP-spec shall be present with 9999 concentrated loss"); + } +// checkCommonPartOfNep(nep, withSip); +//>>>>>>> 381b4f2d (Consolidate ConnectivityUtils) } private void rawCheckNep(List lpqList, LayerProtocolName lpn, boolean anyInList, @@ -924,8 +1112,41 @@ public class ConvertORTopoToFullTapiTopoTest extends AbstractTest { "link-port-role of client nep should be SYMMETRIC"); } - private void checkOmsLink( - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link, + private void checkPhotPartOfNep(OwnedNodeEdgePoint nep) { + + var onep1 = nep.augmentation( + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1.class); + + Map supSpectrum = onep1.getPhotonicMediaNodeEdgePointSpec() + .getSpectrumCapabilityPac().getSupportableSpectrum(); + + double naz = 0.01; + assertEquals(supSpectrum.entrySet().stream().findFirst().orElseThrow().getValue().getLowerFrequency() + .doubleValue(), (Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + naz))).doubleValue(), + "Lower Freq of supportable spectrum shall be 191.325 THz"); + assertEquals(supSpectrum.entrySet().stream().findFirst().orElseThrow().getValue().getUpperFrequency() + .doubleValue(), (Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09 + naz))).doubleValue(), + "Higher Freq of supportable spectrum shall be 196.100 THz"); + + Map availSpectrum = onep1.getPhotonicMediaNodeEdgePointSpec() + .getSpectrumCapabilityPac().getAvailableSpectrum(); + assertEquals(availSpectrum.entrySet().stream().findFirst().orElseThrow().getValue().getLowerFrequency() + .doubleValue(), (Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + naz))).doubleValue(), + "In absence of service provisionning Lower Freq of available spectrum shall be 191.325 THz"); + assertEquals(availSpectrum.entrySet().stream().findFirst().orElseThrow().getValue().getUpperFrequency() + .doubleValue(), (Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E12 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09 + naz))).doubleValue(), + "In absence of service provisionning Higher Freq of available spectrum shall be 191.325 THz"); + + Map occSpectrum = onep1.getPhotonicMediaNodeEdgePointSpec() + .getSpectrumCapabilityPac().getOccupiedSpectrum(); + assertEquals(occSpectrum, null, + "In absence of service provisionning occupied spectrum shall be null"); + + } + + private void checkOmsLink(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) { assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link"); linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid); diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiTopoTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiTopoTest.java index c5a10f497..900e9e53c 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiTopoTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiTopoTest.java @@ -35,6 +35,7 @@ import org.opendaylight.transportpce.common.InstanceIdentifiers; import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.utils.TapiContext; import org.opendaylight.transportpce.tapi.utils.TapiLink; import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl; import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils; @@ -178,7 +179,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest { topologyUuid = new Uuid( UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8"))).toString()); networkTransactionService = new NetworkTransactionImpl(getDataBroker()); - tapiLink = new TapiLinkImpl(networkTransactionService); + tapiLink = new TapiLinkImpl(networkTransactionService, new TapiContext(networkTransactionService)); LOG.info("TEST SETUP READY"); } diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java index 427b63757..83c30c19b 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java @@ -119,13 +119,15 @@ public class TapiTopologyImplTest extends AbstractTest { TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(), TapiTopologyDataUtils.PORTMAPPING_FILE); networkTransactionService = new NetworkTransactionImpl(getDataBroker()); - tapiLink = new TapiLinkImpl(networkTransactionService); + tapiLink = new TapiLinkImpl(networkTransactionService, new TapiContext(networkTransactionService)); serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker()); tapiContext = new TapiContext(networkTransactionService); topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(), tapiLink); connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext, - networkTransactionService); + networkTransactionService, + new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)) + .toString())); tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils, tapiContext, serviceDataStoreOperations); tapiInitialORMapping.performTopoInitialMapping(); -- 2.36.6