Merge changes Ib0dab687,Ia7e45116,I6839ad8b
authorGuillaume Lambert <guillaume.lambert@orange.com>
Tue, 12 Mar 2024 10:23:12 +0000 (10:23 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 12 Mar 2024 10:23:12 +0000 (10:23 +0000)
* changes:
  Turn down OLM power AtoZ and ZtoA in parallel
  Refactor RendererServiceOperationsImpl notify
  Olm Power Down Task

78 files changed:
api/src/main/yang/service_path/transportpce-pce@2024-02-05.yang [moved from api/src/main/yang/service_path/transportpce-pce@2023-09-25.yang with 95% similarity]
karaf/src/main/assembly/ressources/post_install_for_tests.sh
lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/TpceNetwork.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceComplianceCheck.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java
pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsCalc.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/GnpyServiceImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/GnpyUtilitiesImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java
pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceCalculation.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreference.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Factory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/NoPreference.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Preference.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationService.java
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java
pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/PceCalculationTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNodeTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreferenceTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactoryTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/utils/PceTestData.java
pce/src/test/java/org/opendaylight/transportpce/pce/utils/PceTestUtils.java
pce/src/test/resources/spectrum-filling-rule1.json [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererService.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/NetworkDeviceRenderingRollbackTask.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/OlmPowerSetupRollbackTask.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/ResultMessage.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/RollbackResultMessage.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Connection.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterface.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Transaction.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Delete.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteService.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteSubscriber.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/FailedRollbackResult.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Result.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Subscriber.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/History.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/NonStickHistoryMemory.java [new file with mode: 0644]
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistory.java [new file with mode: 0644]
renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplTest.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/ConnectionTest.java [new file with mode: 0644]
renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterfaceTest.java [new file with mode: 0644]
renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistoryTest.java [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererNotificationHandler.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperations.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtilsTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapperTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ModelMappingUtils.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiPceNotificationHandler.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java
tests/sample_configs/openroadm/7.1/oper-ROADMA.xml
tests/sample_configs/openroadm/7.1/oper-ROADMB.xml
tests/sample_configs/openroadm/7.1/oper-ROADMC.xml

similarity index 95%
rename from api/src/main/yang/service_path/transportpce-pce@2023-09-25.yang
rename to api/src/main/yang/service_path/transportpce-pce@2024-02-05.yang
index 0fe9e897451624975285833fba24816c67a3e0fe..cecc2b99290807f511e134195be8c12701e6fb41 100644 (file)
@@ -54,16 +54,21 @@ module transportpce-pce {
       POSSIBILITY OF SUCH DAMAGE";
 
 
+  revision 2024-02-05 {
+      description
+        "Add customer-name to path-computation-request input to check in controller-customization if the customer's
+        services need specific handling";
+  }
   revision 2023-09-25 {
       description
         "Add pce-constraint-mode enum to be able to disinguish the way to manage node include constraints inside the
          PCE module";
-    }
+  }
   revision 2022-08-08 {
       description
         "Implement the RPC path-computation-reroute-request (only for reroute purposes) that computes a service path of
         an existing service in order to reroute it";
-    }
+  }
   revision 2022-06-15 {
     description
       "change fraction digits from 2 to 6 for accumulative-value leaf, from 2 to 6 to be compliant with Gnpy";
@@ -183,6 +188,13 @@ module transportpce-pce {
            e.g., CLFI, CLCI, etc. This is reported against the service, but
            may not get reflected in the service in the network.";
       }
+      leaf customer-name {
+        type string;
+        description
+          "name of the customer that may be declared in controller-customization,
+          to define a specific way to handle constraints associated with this
+          customer.";
+      }
       leaf resource-reserve {
         type boolean;
         mandatory true;
index 86e32826dce2b780300d393239928aa3d55fe20e..40f3545d0d92314fcdd9b713e4787ed3d0abedba 100755 (executable)
@@ -8,6 +8,8 @@ sed 's/8181/ODL_RESTCONF_PORT/' ../etc/jetty.xml > jetty_template.xml
 sed 's/8101/ODL_SHELL_PORT/' ../etc/org.apache.karaf.shell.cfg > org.apache.karaf.shell._template.cfg
 sed -e 's/1099/ODL_RMI_REGISTRY_PORT/' -e 's/44444/ODL_RMI_SERVER_PORT/' ../etc/org.apache.karaf.management.cfg > org.apache.karaf.management._template.cfg
 
+sed 's/^#persistent=true/persistent=false/' ../system/org/opendaylight/controller/sal-clustering-config/*/sal-clustering-config-*-datastore.cfg > ../etc/org.opendaylight.controller.cluster.datastore.cfg
+
 sed -i'_' -e '1 a\
 \
 . \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\
index 9d8344d8ace77c21e968fb54ab300c69aa1a26be..e75bdb1f741b9532864f4bf6e5cf21a7a7229349 100644 (file)
@@ -291,7 +291,7 @@ public final class TPCEUtils {
                     .getInstance(),
             org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.$YangModuleInfoImpl
                     .getInstance(),
-            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.$YangModuleInfoImpl
+            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.$YangModuleInfoImpl
                     .getInstance(),
             org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.$YangModuleInfoImpl
                     .getInstance(),
index a8818bcb44931a3bacf3939506d882c3244e760c..a19a8636f27c1f4d43674543fb1e946dc72e4b64 100644 (file)
@@ -49,7 +49,7 @@ public class TpceNetwork {
             Network network = createNetwork(networkId);
             InstanceIdentifier.Builder<Network> nwIID = InstanceIdentifier.builder(Networks.class).child(Network.class,
                 new NetworkKey(new NetworkId(networkId)));
-            networkTransactionService.put(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network);
+            networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network);
             this.networkTransactionService.commit().get(1, TimeUnit.SECONDS);
             LOG.info("{} network layer created successfully.", networkId);
         } catch (ExecutionException | TimeoutException | InterruptedException e) {
index cbfc365ad44d1b19df8dcd969c66eee1b6aef862..dda3592b2009a2f8af1404e7c4385e8dd87de256 100644 (file)
@@ -197,8 +197,8 @@ public class PowerMgmtImpl implements PowerMgmt {
 
                     LOG.info("Spanloss TX is {}", spanLossTx);
                     // TODO: The span-loss limits should be obtained from optical specifications
-                    if (spanLossTx == null || spanLossTx.intValue() <= 0 || spanLossTx.intValue() > 27) {
-                        LOG.error("Power Value is null: spanLossTx null or out of openROADM range ]0,27] {}",
+                    if (spanLossTx == null || spanLossTx.intValue() < 0 || spanLossTx.intValue() > 27) {
+                        LOG.error("Power Value is null: spanLossTx null or out of openROADM range [0,27] {}",
                             spanLossTx);
                         return false;
                     }
index cfc15403ba5f43258f84cd8ada2444134c48c195..72476971b1dc4ddd7e83e85594d760a3f6194796 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.transportpce.pce;
 
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index f819daad548d89ed89883ced69c4566dc999a3ec..08b46d744edc30a86cd5ff183a7b0ea1cb0421c2 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.transportpce.pce;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.pce.constraints.OperatorConstraints;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
 import org.opendaylight.transportpce.pce.gnpy.GnpyException;
@@ -20,11 +21,11 @@ import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer;
 import org.opendaylight.transportpce.pce.graph.PceGraph;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceCalculation;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.Endpoints;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PceConstraintMode;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.Endpoints;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraints;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
@@ -121,10 +122,11 @@ public class PceSendingPceRPCs {
             LOG.error("In pathComputationWithConstraints, nwAnalizer: result = {}", rc);
             return;
         }
+        OperatorConstraints opConstraints = new OperatorConstraints(networkTransaction);
         LOG.info("PceGraph ...");
         PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), nwAnalizer.getzendPceNode(),
                 nwAnalizer.getAllPceNodes(), nwAnalizer.getAllPceLinks(), hardConstraints,
-                rc, serviceType, networkTransaction, mode);
+                rc, serviceType, networkTransaction, mode, opConstraints.getBitMapConstraint(input.getCustomerName()));
         graph.calcPath();
         rc = graph.getReturnStructure();
         if (!rc.getStatus()) {
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java b/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java
new file mode 100644 (file)
index 0000000..7e0048f
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright Â© 2024 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.pce.constraints;
+
+import java.util.BitSet;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.fixedflex.GridUtils;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.SpectrumFilling;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.spectrum.filling.SpectrumFillingRules;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.spectrum.filling.SpectrumFillingRulesKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ControllerBehaviourSettings;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * Class to handle Operator Constraints associated with Specific Engineering rules
+ * as they are defined in the controller-behaviour-settings container of the service
+ * Data-Store.
+ *
+ */
+
+public class OperatorConstraints {
+
+    /* Logging. */
+    private static final Logger LOG = LoggerFactory.getLogger(OperatorConstraints.class);
+    private static final String SPECTRUM_LOG_MSG =
+        "Specific Spectrum filling Rules have been defined for {} the spectrum range {} - {}";
+    private NetworkTransactionService networkTransaction;
+
+    public OperatorConstraints(NetworkTransactionService networkTransaction) {
+
+        this.networkTransaction = networkTransaction;
+
+    }
+
+    public BitSet getBitMapConstraint(String customerName) {
+        BitSet referenceBitSet = new BitSet(GridConstant.EFFECTIVE_BITS);
+        referenceBitSet.set(0, GridConstant.EFFECTIVE_BITS, true);
+        InstanceIdentifier<SpectrumFilling> sfIID =
+            InstanceIdentifier
+                .builder(ControllerBehaviourSettings.class)
+                .child(SpectrumFilling.class)
+                .build();
+
+        try {
+            if (networkTransaction.read(LogicalDatastoreType.CONFIGURATION, sfIID).get().isPresent()) {
+                SpectrumFilling spectrumConstraint = networkTransaction
+                    .read(LogicalDatastoreType.CONFIGURATION, sfIID)
+                    .get().orElseThrow();
+                if (spectrumConstraint.getSpectrumFillingRules().isEmpty()) {
+                    return referenceBitSet;
+                }
+                if (customerName == null) {
+                    for (Map.Entry<SpectrumFillingRulesKey, SpectrumFillingRules> rule:
+                            spectrumConstraint.getSpectrumFillingRules().entrySet()) {
+                        var spectrumRangeOfAppl = rule.getValue().getSpectrumRangeOfAppliance();
+                        var dedicatedCustomer = spectrumRangeOfAppl.getDedicatedCustomer();
+                        if (dedicatedCustomer == null || dedicatedCustomer.isEmpty()) {
+                            continue;
+                        }
+                        // Spectrum portion is dedicated to some customers that do not include this one
+                        FrequencyTHz startFreq = spectrumRangeOfAppl.getStartEdgeFrequency();
+                        FrequencyTHz stopFreq = spectrumRangeOfAppl.getStopEdgeFrequency();
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()),
+                            false);
+                        LOG.info(SPECTRUM_LOG_MSG,
+                            "other customers, preventing the customer from using", startFreq, stopFreq);
+                    }
+                    return referenceBitSet;
+                }
+
+                for (Map.Entry<SpectrumFillingRulesKey, SpectrumFillingRules> rule:
+                        spectrumConstraint.getSpectrumFillingRules().entrySet()) {
+                    var spectrumRangeOfAppl = rule.getValue().getSpectrumRangeOfAppliance();
+                    FrequencyTHz startFreq = spectrumRangeOfAppl.getStartEdgeFrequency();
+                    FrequencyTHz stopFreq = spectrumRangeOfAppl.getStopEdgeFrequency();
+                    var nonAuthorizedCustomer = spectrumRangeOfAppl.getNonAuthorizedCustomer();
+                    if (nonAuthorizedCustomer != null && nonAuthorizedCustomer.contains(customerName)) {
+                        //Customer shall not be put in this spectrum portion
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()),
+                            false);
+                        LOG.info(SPECTRUM_LOG_MSG,
+                            "customer " + customerName + ", exluding it from", startFreq, stopFreq);
+                        continue;
+                    }
+                    var dedicatedCustomer = spectrumRangeOfAppl.getDedicatedCustomer();
+                    if (dedicatedCustomer == null || dedicatedCustomer.isEmpty()) {
+                        continue;
+                    }
+                    if (dedicatedCustomer.contains(customerName)) {
+                        // Spectrum portion is dedicated to customers including this one
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()),
+                            true);
+                        LOG.info(SPECTRUM_LOG_MSG,
+                            "customer " + customerName + ", to dedicate", startFreq, stopFreq + " to it");
+                        continue;
+                    }
+                    // Spectrum portion is dedicated to some customers that do not include this one
+                    referenceBitSet.set(
+                        GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                        GridUtils.getIndexFromFrequency(stopFreq.getValue()),
+                        false);
+                    LOG.info(SPECTRUM_LOG_MSG,
+                        "other customers, preventing the customer from using", startFreq, stopFreq);
+                }
+                return referenceBitSet;
+            }
+        } catch (InterruptedException | ExecutionException e1) {
+            LOG.error("Exception caught handling Spectrum filling Rules ", e1.getCause());
+        }
+        LOG.info("Did not succeed finding any Specific Spectrum filling Rules defined in Configuration Datastore");
+        return referenceBitSet;
+    }
+}
index f09e94bca14a40a7d41fd8a8a774137c5cf4beba..6db7c9b2c3a1d711506f7ab26ae6449bd4ff62a3 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints.ResourcePair;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.Constraints;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.CoRouting;
index 792d52b8a16804953f121b74df0df30423305091..9208f61519af988658f095bd0d112185f4a920db 100644 (file)
@@ -56,7 +56,7 @@ import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.Syn
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.SynchronizationBuilder;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.synchronization.Svec;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.synchronization.SvecBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
index 98b3783017d500bf36586078065da80655ceb01d..9ae44120c060c63cb3a6702951564bf43db9e254 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.Result;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathRouteObjects;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.service.PathRequest;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.Synchronization;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraints;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
index 81656f3f8e254bb7ef4517171ea929479760731e..994d3256fcbdce825275437c91d2357e60b176f2 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.transportpce.pce.graph;
 
 import java.util.ArrayList;
+import java.util.BitSet;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -30,7 +31,7 @@ import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult.LocalCause;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PceConstraintMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 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;
@@ -54,6 +55,7 @@ public class PceGraph {
     private Double margin = null;
     PceConstraints pceHardConstraints;
     private PceConstraintMode pceConstraintMode;
+    private BitSet spectrumConstraint;
 
     // results
     private PceResult pceResult = null;
@@ -68,7 +70,7 @@ public class PceGraph {
 
     public PceGraph(PceNode aendNode, PceNode zendNode, Map<NodeId, PceNode> allPceNodes,
             Map<LinkId, PceLink> allPceLinks, PceConstraints pceHardConstraints,PceResult pceResult, String serviceType,
-            NetworkTransactionService networkTransactionService, PceConstraintMode mode) {
+            NetworkTransactionService networkTransactionService, PceConstraintMode mode, BitSet spectrumConstraint) {
         super();
         this.apceNode = aendNode;
         this.zpceNode = zendNode;
@@ -79,6 +81,7 @@ public class PceGraph {
         this.serviceType = serviceType;
         this.networkTransactionService = networkTransactionService;
         this.pceConstraintMode = mode;
+        this.spectrumConstraint = spectrumConstraint;
 
         LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode, zendNode);
         LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes);
@@ -102,7 +105,7 @@ public class PceGraph {
         for (Entry<Integer, GraphPath<String, PceGraphEdge>> entry : allWPaths.entrySet()) {
             GraphPath<String, PceGraphEdge> path = entry.getValue();
             LOG.info("validating path n° {} - {}", entry.getKey(), path.getVertexList());
-            PostAlgoPathValidator papv = new PostAlgoPathValidator(networkTransactionService);
+            PostAlgoPathValidator papv = new PostAlgoPathValidator(networkTransactionService, spectrumConstraint);
             pceResult = papv.checkPath(
                     path, allPceNodes, allPceLinks, pceResult, pceHardConstraints, serviceType, pceConstraintMode);
             this.margin = papv.getTpceCalculatedMargin();
index 537d3022cc72baf0eeab067a9182052a7049245e..53353aeae0415acfb29aa9867e4f4d2de734be67 100644 (file)
@@ -38,9 +38,9 @@ import org.opendaylight.transportpce.pce.constraints.PceConstraints.ResourcePair
 import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.SpectrumAssignment;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.SpectrumAssignmentBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PceConstraintMode;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.SpectrumAssignment;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.SpectrumAssignmentBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1;
 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.OpenroadmNodeType;
@@ -61,9 +61,11 @@ public class PostAlgoPathValidator {
 
     private Double tpceCalculatedMargin = 0.0;
     private final NetworkTransactionService networkTransactionService;
+    private final BitSet spectrumConstraint;
 
-    public PostAlgoPathValidator(NetworkTransactionService networkTransactionService) {
+    public PostAlgoPathValidator(NetworkTransactionService networkTransactionService, BitSet spectrumConstraint) {
         this.networkTransactionService = networkTransactionService;
+        this.spectrumConstraint = spectrumConstraint;
     }
 
     @SuppressWarnings("fallthrough")
@@ -1048,6 +1050,10 @@ public class PostAlgoPathValidator {
                 pceNode.getNodeId(), pceNodeVersion, sltWdthGran, ctralFreqGran);
             isFlexGrid = false;
         }
+        if (spectrumConstraint != null) {
+            result.and(spectrumConstraint);
+        }
+
         LOG.debug("Bitset result {}", result);
         return computeBestSpectrumAssignment(result, spectralWidthSlotNumber, isFlexGrid);
     }
index 1b2163a2bb919aa8928dca42eb1e9566c11c85ad..a299875e80f0d3b6f1d7337ff6c28e55943e1be6 100644 (file)
@@ -12,16 +12,16 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserve;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.TransportpcePceService;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserve;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.TransportpcePceService;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.opendaylight.yangtools.yang.common.RpcResult;
index e90a27006b19fa43a906a206d50ef28eb377da5e..0afc9bca8a196d40f9d2821c215f31b8ec8d6d54 100644 (file)
@@ -29,8 +29,11 @@ import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.common.service.ServiceTypes;
 import org.opendaylight.transportpce.pce.PceComplianceCheck;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.Endpoints;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.Factory;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.Preference;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.PreferenceFactory;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.Endpoints;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mc.capabilities.McCapabilities;
 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.Node1;
@@ -293,9 +296,11 @@ public class PceCalculation {
             case StringConstants.SERVICE_TYPE_OTUC2:
             case StringConstants.SERVICE_TYPE_OTUC3:
             case  StringConstants.SERVICE_TYPE_OTUC4:
+                Factory portPreferenceFactory = new PreferenceFactory();
+                Preference portPreference = portPreferenceFactory.portPreference(input);
                 // 100GE service and OTU4 service are handled at the openroadm-topology layer
                 for (Node node : allNodes) {
-                    validateNode(node);
+                    validateNode(node, portPreference);
                 }
 
                 LOG.debug("analyzeNw: allPceNodes size {}", allPceNodes.size());
@@ -439,7 +444,7 @@ public class PceCalculation {
         }
     }
 
-    private void validateNode(Node node) {
+    private void validateNode(Node node, Preference portPreference) {
         LOG.debug("validateNode: node {} ", node);
         // PceNode will be used in Graph algorithm
         Node1 node1 = node.augmentation(Node1.class);
@@ -478,7 +483,7 @@ public class PceCalculation {
             return;
         }
 
-        if (endPceNode(nodeType, pceNode.getNodeId(), pceNode)) {
+        if (endPceNode(nodeType, pceNode.getNodeId(), pceNode, portPreference)) {
             if (this.aendPceNode == null && isAZendPceNode(this.serviceFormatA, pceNode, anodeId, "A")) {
                 // Added to ensure A-node has a addlink in the topology
                 List<Link> links = this.allLinks.stream()
@@ -625,10 +630,11 @@ public class PceCalculation {
         }
     }
 
-    private Boolean endPceNode(OpenroadmNodeType openroadmNodeType, NodeId nodeId, PceOpticalNode pceNode) {
+    private Boolean endPceNode(OpenroadmNodeType openroadmNodeType, NodeId nodeId, PceOpticalNode pceNode,
+                               Preference portPreference) {
         switch (openroadmNodeType) {
             case SRG:
-                pceNode.initSrgTps();
+                pceNode.initSrgTps(portPreference);
                 this.azSrgs.add(nodeId);
                 break;
             case XPONDER:
index dfb27b28f3b936f51c4bf6854fd2eadb317922ae..611263d68a3f43e490abc0af1ab034a9146faa65 100644 (file)
@@ -21,7 +21,8 @@ import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.pce.SortPortsByName;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.Endpoints;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.Preference;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.Endpoints;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
@@ -102,7 +103,7 @@ public class PceOpticalNode implements PceNode {
         }
     }
 
-    public void initSrgTps() {
+    public void initSrgTps(Preference portPreference) {
         this.availableSrgPp.clear();
         this.availableSrgCp.clear();
         if (!isValid()) {
@@ -141,6 +142,10 @@ public class PceOpticalNode implements PceNode {
                 case SRGTXPP:
                 case SRGTXRXPP:
                     LOG.debug("initSrgTpList: SRG-PP tp = {} found", tp.getTpId().getValue());
+                    if (!portPreference.isPreferredPort(nodeId.getValue(), tp.getTpId().getValue())) {
+                        LOG.warn("initSrgTpList: SRG-PP tp = {} is rejected by the client", tp.getTpId().getValue());
+                        break;
+                    }
                     if (isTerminationPointAvailable(nttp1)) {
                         LOG.debug("initSrgTpList: adding SRG-PP tp '{}'", tp.getTpId().getValue());
                         this.availableSrgPp.put(tp.getTpId().getValue(), cntp1.getTpType());
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreference.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreference.java
new file mode 100644 (file)
index 0000000..d3749c3
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+import java.util.Map;
+import java.util.Set;
+
+public class ClientPreference implements Preference {
+
+    Map<String, Set<String>> nodePortPreference;
+
+    public ClientPreference(Map<String, Set<String>> nodePortPreference) {
+        this.nodePortPreference = nodePortPreference;
+    }
+
+    @Override
+    public boolean isPreferredPort(String node, String portName) {
+
+        //If there is no preferred port registered for the node, it means
+        //the client has no preference regarding the node.
+        //Therefore, we'll treat the node as it was preferred to
+        //prevent it from NOT being used.
+        return !nodePortPreference.containsKey(node) || nodePortPreference.get(node).contains(portName);
+
+    }
+
+}
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Factory.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Factory.java
new file mode 100644 (file)
index 0000000..82da45d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+
+public interface Factory {
+
+    /**
+     * Extracting preferred ports from pathComputationRequestInput.
+     *
+     * <p>
+     * This is the recommended method of determining if a node/port combination
+     * is preferred by the client.
+     *
+     * <p>
+     * Pseudocode example:
+     * <pre>
+     *     Factory.portPreference(PCRI).preferredPort("ROADM-B-SRG1", "SRG1-PP1-TXRX");
+     * </pre>
+     *
+     * @return Client port preference
+     */
+    Preference portPreference(PathComputationRequestInput pathComputationRequestInput);
+
+}
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/NoPreference.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/NoPreference.java
new file mode 100644 (file)
index 0000000..5b96ca0
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+/**
+ * This class represents a state where the client has no port preference.
+ * In essence, all ports on all nodes will therefore be treated as 'preferred'
+ * when queried.
+ *
+ * <p>
+ * Usage of this class is of sorts the 'backwards compatible' approach. Meaning,
+ * intended to offer a path for the application to behave as it did
+ * prior to implementing client port preference.
+ */
+public class NoPreference implements Preference {
+    @Override
+    public boolean isPreferredPort(String node, String portName) {
+        return true;
+    }
+}
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Preference.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/Preference.java
new file mode 100644 (file)
index 0000000..3d1acb8
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+public interface Preference {
+
+    /**
+     * Return true if the portName is among the ports preferred by the client.
+     */
+    boolean isPreferredPort(String node, String portName);
+
+}
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactory.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactory.java
new file mode 100644 (file)
index 0000000..1d62e18
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.Port;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.TxDirection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PreferenceFactory implements Factory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PreferenceFactory.class);
+
+    private String portNamePattern;
+
+    public PreferenceFactory() {
+        this.portNamePattern = "(?i)SRG\\d+-PP\\d+-(TXRX|TX|RX)";
+    }
+
+    @Override
+    public Preference portPreference(PathComputationRequestInput pathComputationRequestInput) {
+
+        Map<String, Set<String>> map = nodePortMap(pathComputationRequestInput);
+
+        if (map.isEmpty()) {
+            LOG.debug("No port preference found in path computation request.");
+            return new NoPreference();
+        }
+
+        LOG.debug("Port preference in path computation request: {}." , map);
+        return new ClientPreference(map);
+    }
+
+    /**
+     * Create a key value mapper from PCRI where key is the node and the value is
+     * a unique list of port names.
+     *
+     * @return Client port preference map
+     */
+    Map<String, Set<String>> nodePortMap(PathComputationRequestInput pathComputationRequestInput) {
+
+        Map<String, Set<String>> mapper = new HashMap<>();
+
+        ServiceAEnd serviceAEnd = pathComputationRequestInput.getServiceAEnd();
+        if (serviceAEnd != null) {
+
+            RxDirection rxAzDirection = serviceAEnd.getRxDirection();
+            if (rxAzDirection != null) {
+
+                Port rxAZport = rxAzDirection.getPort();
+                if (rxAZport != null) {
+                    add(rxAZport.getPortDeviceName(), rxAZport.getPortName(), mapper);
+                }
+            }
+
+            TxDirection txAzDirection = serviceAEnd.getTxDirection();
+            if (txAzDirection != null) {
+
+                Port txAZport = txAzDirection.getPort();
+                if (txAZport != null) {
+                    add(txAZport.getPortDeviceName(), txAZport.getPortName(), mapper);
+                }
+            }
+        }
+
+        ServiceZEnd serviceZEnd = pathComputationRequestInput.getServiceZEnd();
+        if (serviceZEnd != null) {
+
+            RxDirection rxZaDirection = serviceZEnd.getRxDirection();
+            if (rxZaDirection != null) {
+
+                Port rxZAport = rxZaDirection.getPort();
+                if (rxZAport != null) {
+                    add(rxZAport.getPortDeviceName(), rxZAport.getPortName(), mapper);
+                }
+            }
+
+            TxDirection txZaDirection = serviceZEnd.getTxDirection();
+            if (txZaDirection != null) {
+
+                Port txZAport = txZaDirection.getPort();
+                if (txZAport != null) {
+                    add(txZAport.getPortDeviceName(), txZAport.getPortName(), mapper);
+                }
+            }
+        }
+
+        return mapper;
+    }
+
+    /**
+     * Add node/port name to key value map. Mutable method, modifies the argument nodePortMap.
+     */
+    boolean add(String node, String port, Map<String, Set<String>> nodePortMap) {
+
+        if (node == null || port == null) {
+            return false;
+        }
+
+        String nodeTrimmed = node.trim();
+        String portTrimmed = port.trim();
+
+        if (nodeTrimmed.isEmpty() || portTrimmed.isEmpty()) {
+            return false;
+        }
+
+        if (!portTrimmed.matches(portNamePattern)) {
+            LOG.warn("Preferred port name '{}' on node {} doesn't match pattern '{}'",
+                portTrimmed,
+                nodeTrimmed,
+                portNamePattern
+            );
+        }
+
+        if (nodePortMap.containsKey(nodeTrimmed)) {
+            boolean added = nodePortMap.get(nodeTrimmed).add(portTrimmed);
+            if (added) {
+                LOG.debug("Preferred port '{}' for node '{}' registered.", portTrimmed, nodeTrimmed);
+            } else {
+                LOG.debug("Failed registering port '{}' for node '{}'.", portTrimmed, nodeTrimmed);
+            }
+            return added;
+        }
+
+        nodePortMap.put(nodeTrimmed, new HashSet<>(Arrays.asList(portTrimmed)));
+
+        return true;
+    }
+}
index 6c85e968a914559fee47cc61387e687506d02c64..0de1fbf2d3cebce0ec797bc8879b9ead142d6ad3 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.transportpce.pce.service;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
 
 /**
  * Path Computation Service.
index 5c0ab8ebb858104f7599651b7c60707651d0458b..523ad31f9b8101b7a6a74e438364fb7093245fb2 100644 (file)
@@ -25,29 +25,29 @@ import org.opendaylight.transportpce.pce.PceSendingPceRPCs;
 import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
 import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.Response;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResultBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.gnpy.GnpyResponse;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.gnpy.GnpyResponseBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.gnpy.gnpy.response.response.type.NoPathCaseBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.gnpy.gnpy.response.response.type.PathCaseBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.performance.PathPropertiesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.performance.path.properties.PathMetric;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.performance.path.properties.PathMetricBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.gnpy.GnpyResponse;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.gnpy.GnpyResponseBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.gnpy.gnpy.response.response.type.NoPathCaseBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.gnpy.gnpy.response.response.type.PathCaseBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.performance.PathPropertiesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.performance.path.properties.PathMetric;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.performance.path.properties.PathMetricBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
index 3ade493bb58e3774a66aa8a663f4e163df04671f..bcc21d6f370f1c48f835bc26acc199c05c1ae80c 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.transportpce.pce;
 
-
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.when;
 
+import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -27,7 +27,6 @@ import org.opendaylight.transportpce.pce.gnpy.JerseyServer;
 import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer;
 import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumerImpl;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
-import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 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.MappingBuilder;
@@ -38,6 +37,7 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmappi
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 
+
 @ExtendWith(MockitoExtension.class)
 public class PceSendingPceRPCsTest extends AbstractTest {
 
@@ -54,10 +54,9 @@ public class PceSendingPceRPCsTest extends AbstractTest {
 
 
     @BeforeEach
-    void setUp() {
+    void setUp() throws InterruptedException, ExecutionException {
         this.dataBroker = getNewDataBroker();
         networkTransaction = new NetworkTransactionImpl(this.dataBroker);
-        PceTestUtils.writeNetworkInDataStore(this.dataBroker);
         gnpyConsumer = new GnpyConsumerImpl(
             "http://localhost:9998", "mylogin", "mypassword", getDataStoreContextUtil().getBindingDOMCodecServices());
         pceSendingPceRPCs = new PceSendingPceRPCs(
@@ -94,6 +93,7 @@ public class PceSendingPceRPCsTest extends AbstractTest {
         assertNull(pceSendingPceRPCs.getMessage());
     }
 
+
     @Test
     void responseCodeTest() {
         assertNull(pceSendingPceRPCs.getResponseCode());
diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java
new file mode 100644 (file)
index 0000000..4fbab35
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright Â© 2024 Orange Labs, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.pce.constraints;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.BitSet;
+import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
+import org.opendaylight.transportpce.pce.graph.PceGraphTest;
+import org.opendaylight.transportpce.pce.utils.PceTestUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.transportpce.test.converter.DataObjectConverter;
+import org.opendaylight.transportpce.test.converter.JSONDataObjectConverter;
+//import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters
+//.SpectrumFilling;
+//import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters
+//.spectrum.filling.SpectrumFillingRules;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ControllerBehaviourSettings;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@ExtendWith(MockitoExtension.class)
+public class OperatorConstraintsTest extends AbstractTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PceGraphTest.class);
+    private NetworkTransactionImpl networkTransaction;
+    private static final String SPEC_FILLING_FILE = "src/test/resources/spectrum-filling-rule1.json";
+//    private static SpectrumFillingRules sfRule;
+    private static ControllerBehaviourSettings cbSettings;
+    private OperatorConstraints opConstraints;
+    @Mock
+    private BindingDOMCodecServices bindingDOMCodecServices;
+    private DataBroker dataBroker;
+
+    @BeforeEach
+    void setUp() throws InterruptedException, ExecutionException {
+        this.dataBroker = getNewDataBroker();
+        networkTransaction = new NetworkTransactionImpl(this.dataBroker);
+        opConstraints = new OperatorConstraints(networkTransaction);
+        PceTestUtils.writeNetworkInDataStore(this.dataBroker);
+        DataObjectConverter dataObjectConverter = JSONDataObjectConverter
+            .createWithDataStoreUtil(getDataStoreContextUtil());
+        // The Spectrum filling rules associated with CustomerProfileLamda1 is populated from a file in the Data Store
+        try (Reader reader = new FileReader(SPEC_FILLING_FILE, StandardCharsets.UTF_8)) {
+            NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).orElseThrow();
+            cbSettings = (ControllerBehaviourSettings) getDataStoreContextUtil()
+                .getBindingDOMCodecServices()
+                .fromNormalizedNode(
+                    YangInstanceIdentifier.of(ControllerBehaviourSettings.QNAME), normalizedNode)
+                .getValue();
+            InstanceIdentifier<ControllerBehaviourSettings> sfIID =
+                InstanceIdentifier
+                    .builder(ControllerBehaviourSettings.class)
+//                    .child(SpectrumFilling.class)
+//                    .child(SpectrumFillingRules.class)
+                    .build();
+            @NonNull
+            WriteTransaction newWriteOnlyTransaction = dataBroker.newWriteOnlyTransaction();
+            newWriteOnlyTransaction.put(LogicalDatastoreType.CONFIGURATION, sfIID, cbSettings);
+            newWriteOnlyTransaction.commit().get();
+        } catch (IOException e) {
+            LOG.error("Cannot load Spectrum-Filling-Rules in Service DS ", e);
+            fail("Cannot load Spectrum-Filling-Rules");
+        }
+    }
+
+
+    @Test
+    void checkSpecttrumFilling() {
+        BitSet referenceBitSet = new BitSet(GridConstant.EFFECTIVE_BITS);
+        referenceBitSet.set(0, GridConstant.EFFECTIVE_BITS, false);
+        referenceBitSet.set(0, 8, true);
+        assertEquals(referenceBitSet, opConstraints.getBitMapConstraint("CustomerProfileLamda1"));
+        referenceBitSet.set(8, GridConstant.EFFECTIVE_BITS, true);
+        referenceBitSet.set(0, 8, false);
+        assertEquals(referenceBitSet, opConstraints.getBitMapConstraint("otherCustomer"));
+    }
+
+}
index 8d7616c1207af670b23815d75bd51c3a9804f49a..d85efa20c81a25fc668a1960331c71a0b90382f7 100644 (file)
@@ -56,11 +56,11 @@ import org.opendaylight.transportpce.test.converter.DataObjectConverter;
 import org.opendaylight.transportpce.test.converter.JSONDataObjectConverter;
 import org.opendaylight.transportpce.test.stub.MountPointServiceStub;
 import org.opendaylight.transportpce.test.stub.MountPointStub;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PceConstraintMode;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PceConstraintMode;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEndBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev230526.OpenroadmVersionType;
@@ -249,7 +249,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
     }
@@ -262,7 +262,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.1559963686478447));
     }
@@ -275,7 +275,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.3351048800367167));
     }
@@ -288,7 +288,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), false);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
     }
@@ -301,7 +301,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
     }
@@ -314,7 +314,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
     }
@@ -327,7 +327,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
     }
@@ -340,7 +340,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
     }
@@ -354,7 +354,7 @@ public class PceGraphTest extends AbstractTest {
         pceHardConstraints.setPceMetrics(PceMetric.PropagationDelay);
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         pceGraph.setConstrains(pceHardConstraints);
 
         assertEquals(pceGraph.calcPath(), true);
@@ -417,7 +417,7 @@ public class PceGraphTest extends AbstractTest {
             new NodeId("optical"), pceOtnNode,
             new NodeId("optical2"), pceOtnNode2);
         return new PceGraph(pceOtnNode, pceOtnNode2, allPceNodes, allPceLinks, pceHardConstraints,
-                new PceResult(), type, null, PceConstraintMode.Loose);
+                new PceResult(), type, null, PceConstraintMode.Loose, null);
     }
 
     private void saveOpenRoadmNetwork(Network network, String networkId)
index 0d43206a3c33ea83090ca8fd926aeb8a0119fc78..f727565746af27765200baa1f976f08ecb9b59c8 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.transportpce.pce.utils.PceTestData;
 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInputBuilder;
 
 @ExtendWith(MockitoExtension.class)
 public class PceServiceRPCImplTest extends AbstractTest {
index 13a871385d1fc5dbf7d76f4e5f924b2bb4ce75ed..c0efabcc335acedb64fc3ddcc6540d7fcf7176bd 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.transportpce.pce.utils.PceTestData;
 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
 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.MappingBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes;
index 733ba20885a41253c1ccd37521321efe096e96af..876dcd9d8dbcd1d5e381ed2e3dd01aeca055118a 100644 (file)
@@ -26,6 +26,8 @@ import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.NoPreference;
+import org.opendaylight.transportpce.pce.networkanalyzer.port.Preference;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1Builder;
@@ -76,6 +78,7 @@ public class PceOpticalNodeTest extends AbstractTest {
     private String serviceType = "100GE";
     @Mock
     private PortMapping portMapping;
+    private final Preference portPreference = new NoPreference();
 
     @BeforeEach
     void setUp() {
@@ -100,7 +103,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         pceOpticalNode.initXndrTps(ServiceFormat.OMS);
         pceOpticalNode.initFrequenciesBitSet();
         assertFalse(pceOpticalNode.isValid());
@@ -163,7 +166,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         assertNull(pceOpticalNode.getRdmSrgClient("7", StringConstants.SERVICE_DIRECTION_AZ));
         assertFalse(pceOpticalNode.isValid());
         assertNull(pceOpticalNode.getBitSetData());
@@ -177,7 +180,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(null, null, null, specificNode,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         pceOpticalNode.initFrequenciesBitSet();
         pceOpticalNode.initXndrTps(ServiceFormat.OMS);
         assertNull(pceOpticalNode.getRdmSrgClient("7" ,StringConstants.SERVICE_DIRECTION_AZ));
@@ -191,7 +194,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.DEGREE, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         assertNull(pceOpticalNode.getRdmSrgClient("7" ,StringConstants.SERVICE_DIRECTION_AZ));
         assertFalse(pceOpticalNode.isValid());
         assertNull(pceOpticalNode.getBitSetData());
@@ -205,7 +208,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(null, null, null, specificNode,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         assertFalse(pceOpticalNode.isValid());
         assertNull(pceOpticalNode.getBitSetData());
         assertTrue(pceOpticalNode.checkTP("testTP"));
@@ -219,7 +222,7 @@ public class PceOpticalNodeTest extends AbstractTest {
         pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
                 GridConstant.SLOT_WIDTH_50, GridConstant.SLOT_WIDTH_50);
-        pceOpticalNode.initSrgTps();
+        pceOpticalNode.initSrgTps(portPreference);
         assertNull(pceOpticalNode.getRdmSrgClient("2" ,StringConstants.SERVICE_DIRECTION_AZ));
         assertFalse(pceOpticalNode.isValid());
         assertNull(pceOpticalNode.getBitSetData());
diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreferenceTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/ClientPreferenceTest.java
new file mode 100644 (file)
index 0000000..2466221
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ClientPreferenceTest {
+
+    @Test
+    void preferredPort_returnTrue() {
+
+        Map<String, Set<String>> nodePortPreference = new HashMap<>();
+        nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+        Preference clientPreference = new ClientPreference(nodePortPreference);
+
+        Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP1-TXRX"));
+    }
+
+    /**
+     * The client prefer to use SRG1-PP1-TXRX on ROADM-B-SRG1.
+     * Therefore, preferredPort returns false on SRG1-PP2-TXRX.
+     */
+    @Test
+    void nonPreferredPort_returnFalse() {
+
+        Map<String, Set<String>> nodePortPreference = new HashMap<>();
+        nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+        Preference clientPreference = new ClientPreference(nodePortPreference);
+
+        Assertions.assertFalse(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP2-TXRX"));
+    }
+
+    /**
+     * In this scenario ROADM-A-SRG1 is missing from the client preferred list.
+     * We treat this as the client has no opinion on what port
+     * to use on ROADM-A-SRG1. Meaning, as far as the client goes, all
+     * ports on ROADM-A-SRG1 are fine.
+     */
+    @Test
+    void nodeMissingInPreferredList_returnTrue() {
+
+        Map<String, Set<String>> nodePortPreference = new HashMap<>();
+        nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+        Preference clientPreference = new ClientPreference(nodePortPreference);
+
+        Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-A-SRG1", "SRG1-PP2-TXRX"));
+
+    }
+}
\ No newline at end of file
diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactoryTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/port/PreferenceFactoryTest.java
new file mode 100644 (file)
index 0000000..818bbf6
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.networkanalyzer.port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.TxDirection;
+
+class PreferenceFactoryTest {
+
+    @Test
+    void emptyPathComputationRequest_returnEmptyHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceAEndRxDirectionWithoutDeviceAndPort_returnEmptyHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+        RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+        Mockito.when(rxDirection.getPort()).thenReturn(new PortBuilder().build());
+        Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+        Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceAEndRxDirectionWithoutPort_returnEmptyHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+        RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+        Mockito.when(rxDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .build()
+        );
+        Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+        Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceAEndRxDirectionTxRx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+        RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+        Mockito.when(rxDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-TXRX")
+                .build()
+        );
+        Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+        Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceAEndRxDirectionTx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+        RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+        Mockito.when(rxDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-TX")
+                .build()
+        );
+        Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+        Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceAEndRxDirectionRx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-RX")
+                .build()
+        );
+        Mockito.when(serviceAEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-RX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceZEndRx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+        Mockito.when(rxDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-TXRX")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getRxDirection()).thenReturn(rxDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceZEndTxDirectionTxRx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-TXRX")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceZEndTxDirectionTx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-TX")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathComputationRequestServiceZEndTxDirectionRx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("SRG1-PP1-RX")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-RX"));
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathEmptyComputationRequestServiceZEndTx_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName(" ")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void pathUnexpectedPortName_returnHashmap() {
+
+        PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+        ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+        TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+        Mockito.when(txDirection.getPort()).thenReturn(
+            new PortBuilder()
+                .setPortDeviceName("ROADM-B-SRG1")
+                .setPortName("FUBAR")
+                .build()
+        );
+        Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+        Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+        Map<String, Set<String>> expected = new HashMap<>();
+        expected.put("ROADM-B-SRG1", Set.of("FUBAR"));
+
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+        Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+    }
+
+    @Test
+    void addingMultiplePort() {
+
+        PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+        Map<String, Set<String>> mapper = new HashMap<>();
+
+        //New ports
+        Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP1-TXRX", mapper));
+        Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP2-TXRX", mapper));
+        Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP3-RX", mapper));
+        Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP3-TX", mapper));
+
+        //This port already exists, should return false.
+        Assertions.assertFalse(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP2-TXRX", mapper));
+
+        Assertions.assertEquals(
+            Set.of("SRG1-PP1-TXRX", "SRG1-PP2-TXRX", "SRG1-PP3-RX", "SRG1-PP3-TX"),
+            mapper.get("ROADM-B-SRG1")
+        );
+    }
+}
\ No newline at end of file
index 4c37ae5ec98ba0be0864cb3a26ea023f99cadee8..c394a928ae2618faa05fab8a118b816a7a23deb7 100644 (file)
@@ -11,15 +11,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.transportpce.common.ResponseCodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.EndpointsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.EndpointsBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
@@ -238,8 +238,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
@@ -247,8 +247,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
@@ -323,8 +323,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
@@ -332,8 +332,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
@@ -346,88 +346,86 @@ public final class PceTestData {
                 .setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
                         .setRequestId("request1")
                         .build())
-                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                         .path.computation.reroute.request.input.ServiceAEndBuilder()
-                        .setServiceFormat(ServiceFormat.Ethernet)
-                        .setServiceRate(Uint32.valueOf(100))
-                        .setClli("clli11")
-                        .setNodeId("XPONDER-2-2")
-                        .setTxDirection(new TxDirectionBuilder()
-                                .setPort(new PortBuilder()
-                                        .setPortDeviceName("Some port-device-name")
-                                        .setPortType("Some port-type")
-                                        .setPortName("Some port-name")
-                                        .setPortRack("Some port-rack")
-                                        .setPortShelf("Some port-shelf")
-                                        .setPortSlot("Some port-slot")
-                                        .setPortSubSlot("Some port-sub-slot")
-                                        .build())
-                                .build())
-                        .setRxDirection(new RxDirectionBuilder()
-                                .setPort(new PortBuilder()
-                                        .setPortDeviceName("Some port-device-name")
-                                        .setPortType("Some port-type")
-                                        .setPortName("Some port-name")
-                                        .setPortRack("Some port-rack")
-                                        .setPortShelf("Some port-shelf")
-                                        .setPortSlot("Some port-slot")
-                                        .setPortSubSlot("Some port-sub-slot")
-                                        .build())
-                                .build())
-                        .build())
-                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+                    .setServiceFormat(ServiceFormat.Ethernet)
+                    .setServiceRate(Uint32.valueOf(100))
+                    .setClli("clli11")
+                    .setNodeId("XPONDER-2-2")
+                    .setTxDirection(new TxDirectionBuilder()
+                            .setPort(new PortBuilder()
+                                    .setPortDeviceName("Some port-device-name")
+                                    .setPortType("Some port-type")
+                                    .setPortName("Some port-name")
+                                    .setPortRack("Some port-rack")
+                                    .setPortShelf("Some port-shelf")
+                                    .setPortSlot("Some port-slot")
+                                    .setPortSubSlot("Some port-sub-slot")
+                                    .build())
+                            .build())
+                    .setRxDirection(new RxDirectionBuilder()
+                            .setPort(new PortBuilder()
+                                    .setPortDeviceName("Some port-device-name")
+                                    .setPortType("Some port-type")
+                                    .setPortName("Some port-name")
+                                    .setPortRack("Some port-rack")
+                                    .setPortShelf("Some port-shelf")
+                                    .setPortSlot("Some port-slot")
+                                    .setPortSubSlot("Some port-sub-slot")
+                                    .build())
+                            .build())
+                    .build())
+                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                         .path.computation.reroute.request.input.ServiceZEndBuilder()
-                        .setServiceFormat(ServiceFormat.Ethernet)
-                        .setServiceRate(Uint32.valueOf(0))
-                        .setClli("Some clli11")
-                        .setNodeId("XPONDER-1-2")
-                        .setTxDirection(new TxDirectionBuilder()
-                                .setPort(new PortBuilder()
-                                        .setPortDeviceName("Some port-device-name")
-                                        .setPortType("Some port-type")
-                                        .setPortName("Some port-name")
-                                        .setPortRack("Some port-rack")
-                                        .setPortShelf("Some port-shelf")
-                                        .setPortSlot("Some port-slot")
-                                        .setPortSubSlot("Some port-sub-slot")
-                                        .build())
-                                .build())
-                        .setRxDirection(new RxDirectionBuilder()
-                                .setPort(new PortBuilder()
-                                        .setPortDeviceName("Some port-device-name")
-                                        .setPortType("Some port-type")
-                                        .setPortName("Some port-name")
-                                        .setPortRack("Some port-rack")
-                                        .setPortShelf("Some port-shelf")
-                                        .setPortSlot("Some port-slot")
-                                        .setPortSubSlot("Some port-sub-slot")
-                                        .build())
-                                .build())
-                        .build())
+                    .setServiceFormat(ServiceFormat.Ethernet)
+                    .setServiceRate(Uint32.valueOf(0))
+                    .setClli("Some clli11")
+                    .setNodeId("XPONDER-1-2")
+                    .setTxDirection(new TxDirectionBuilder()
+                            .setPort(new PortBuilder()
+                                    .setPortDeviceName("Some port-device-name")
+                                    .setPortType("Some port-type")
+                                    .setPortName("Some port-name")
+                                    .setPortRack("Some port-rack")
+                                    .setPortShelf("Some port-shelf")
+                                    .setPortSlot("Some port-slot")
+                                    .setPortSubSlot("Some port-sub-slot")
+                                    .build())
+                            .build())
+                    .setRxDirection(new RxDirectionBuilder()
+                            .setPort(new PortBuilder()
+                                    .setPortDeviceName("Some port-device-name")
+                                    .setPortType("Some port-type")
+                                    .setPortName("Some port-name")
+                                    .setPortRack("Some port-rack")
+                                    .setPortShelf("Some port-shelf")
+                                    .setPortSlot("Some port-slot")
+                                    .setPortSubSlot("Some port-sub-slot")
+                                    .build())
+                            .build())
+                    .build())
                 .setHardConstraints(new HardConstraintsBuilder()
-                        .setCustomerCode(Set.of("Some customer-code"))
-                        .setCoRouting(new CoRoutingBuilder()
-                                .setServiceIdentifierList(Map.of(
-                                        new org.opendaylight.yang.gen.v1
-                                                .http.org.openroadm.routing.constraints.rev221209
-                                                .constraints.co.routing.ServiceIdentifierListKey("test"),
-                                        new ServiceIdentifierListBuilder().setServiceIdentifier("test").build()))
-                                .build())
+                    .setCustomerCode(Set.of("Some customer-code"))
+                    .setCoRouting(new CoRoutingBuilder()
+                        .setServiceIdentifierList(Map.of(
+                                new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                        .constraints.co.routing.ServiceIdentifierListKey("test"),
+                                new ServiceIdentifierListBuilder().setServiceIdentifier("test").build()))
                         .build())
+                    .build())
                 .setSoftConstraints(new SoftConstraintsBuilder()
-                        .setCustomerCode(Set.of("Some customer-code"))
-                        .setCoRouting(new CoRoutingBuilder()
-                                .setServiceIdentifierList(Map.of(
-                                        new org.opendaylight.yang.gen.v1
-                                                .http.org.openroadm.routing.constraints.rev221209
-                                                .constraints.co.routing.ServiceIdentifierListKey("test"),
-                                        new ServiceIdentifierListBuilder().setServiceIdentifier("test").build()))
-                                .build())
+                    .setCustomerCode(Set.of("Some customer-code"))
+                    .setCoRouting(new CoRoutingBuilder()
+                        .setServiceIdentifierList(Map.of(
+                                new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                        .constraints.co.routing.ServiceIdentifierListKey("test"),
+                                new ServiceIdentifierListBuilder().setServiceIdentifier("test").build()))
                         .build())
+                    .build())
                 .setEndpoints(new EndpointsBuilder()
-                        .setAEndTp("AendTP")
-                        .setZEndTp("ZendTP")
-                        .build())
+                    .setAEndTp("AendTP")
+                    .setZEndTp("ZendTP")
+                    .build())
                 .build();
     }
 
@@ -587,13 +585,13 @@ public final class PceTestData {
                         .setRequestId("request 1")
                         .build())
                 .setPceRoutingMetric(PceMetric.HopCount)
-                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                         .path.computation.reroute.request.input.ServiceAEndBuilder()
                         .setServiceRate(Uint32.valueOf(100))
                         .setServiceFormat(ServiceFormat.Ethernet)
                         .setNodeId("XPONDER-1-2")
                         .build())
-                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                         .path.computation.reroute.request.input.ServiceZEndBuilder()
                         .setServiceRate(Uint32.valueOf(0))
                         .setServiceFormat(ServiceFormat.Ethernet)
@@ -802,8 +800,8 @@ public final class PceTestData {
                 .setDiversity(new DiversityBuilder()
                     .setServiceIdentifierList(Map.of(
                         new ServiceIdentifierListKey(base.getServiceName()),
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.diversity
-                                .existing.service.constraints.ServiceIdentifierListBuilder()
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .diversity.existing.service.constraints.ServiceIdentifierListBuilder()
                             .setServiceIdentifier(base.getServiceName())
                             .setServiceApplicability(new ServiceApplicabilityBuilder()
                                 .setNode(true)
@@ -821,40 +819,40 @@ public final class PceTestData {
             .setCustomer("Customer")
             .setServiceName("service 1")
             .setServiceAEnd(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
-                        .ServiceAEndBuilder()
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526
+                        .service.create.input.ServiceAEndBuilder()
                     .setClli("clli")
                     .setServiceRate(Uint32.valueOf(0))
                     .setNodeId(new NodeIdType("XPONDER-1-2"))
                     .setTxDirection(Map.of(
                         new TxDirectionKey(Uint8.ZERO),
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
-                                .endpoint.TxDirectionBuilder()
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                                .service.endpoint.TxDirectionBuilder()
                             .setPort(new PortBuilder().build())
                             .build()))
                     .setRxDirection(Map.of(
                         new RxDirectionKey(Uint8.ZERO),
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
-                                .endpoint.RxDirectionBuilder()
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                                .service.endpoint.RxDirectionBuilder()
                             .setPort(new PortBuilder().build())
                             .build()))
                     .build())
             .setServiceZEnd(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
-                        .ServiceZEndBuilder()
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526
+                        .service.create.input.ServiceZEndBuilder()
                     .setClli("clli")
                     .setServiceRate(Uint32.valueOf(0))
                     .setNodeId(new NodeIdType("XPONDER-3-2"))
                     .setTxDirection(Map.of(
                         new TxDirectionKey(Uint8.ZERO),
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
-                                .endpoint.TxDirectionBuilder()
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                                .service.endpoint.TxDirectionBuilder()
                             .setPort(new PortBuilder().build())
                             .build()))
                     .setRxDirection(Map.of(
                         new RxDirectionKey(Uint8.ZERO),
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
-                                .endpoint.RxDirectionBuilder()
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                                .service.endpoint.RxDirectionBuilder()
                             .setPort(new PortBuilder().build())
                             .build()))
                     .build())
@@ -931,8 +929,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
@@ -940,8 +938,8 @@ public final class PceTestData {
                 .setCustomerCode(Set.of("Some customer-code"))
                 .setCoRouting(new CoRoutingBuilder()
                     .setServiceIdentifierList(Map.of(
-                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co
-                                .routing.ServiceIdentifierListKey("Some existing-service"),
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209
+                                .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
                         new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service").build()))
                     .build())
                 .build())
index 4567ec832fc154c9f2b6a885076aea53db25786a..d0e9afa23dfa25b98c9d8add8b536951c29bb7f9 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.test.DataStoreContext;
 import org.opendaylight.transportpce.test.converter.DataObjectConverter;
 import org.opendaylight.transportpce.test.converter.XMLDataObjectConverter;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node;
diff --git a/pce/src/test/resources/spectrum-filling-rule1.json b/pce/src/test/resources/spectrum-filling-rule1.json
new file mode 100644 (file)
index 0000000..dfb0c83
--- /dev/null
@@ -0,0 +1,38 @@
+{
+    "controller-behaviour-settings": {
+        "spectrum-filling": {
+          "spectrum-filling-rules": [
+            {
+              "rule-id": 1,
+              "priority": 1,
+              "RMSA-policy": "maximize-capacity",
+              "spectrum-range-of-appliance": {
+                "dedicated-signal-bandwidth-multiple": 50,
+                "spectrum-portion-id": 0,
+                "start-edge-frequency": 191.325,
+                "stop-edge-frequency": 191.375,
+                "dedicated-customer": [
+                  "CustomerProfileLamda1"
+                ],
+                "non-authorized-customer": [
+                  "All-other"
+                ]
+              }
+            },
+            {
+              "rule-id": 2,
+              "priority": 1,
+              "RMSA-policy": "maximize-capacity",
+              "spectrum-range-of-appliance": {
+                "spectrum-portion-id": 1,
+                "start-edge-frequency": 191.375,
+                "stop-edge-frequency": 196.125,
+                "non-authorized-customer": [
+                  "CustomerProfileLamda1"
+                ]
+              }
+            }
+          ]
+        }
+    }
+}
index a242147bdcdfffe2e4cb4d15a8fa7addc3e097d6..049247b45dc17f8e0d8a541c92a26f5de9a6c88d 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.transportpce.renderer.provisiondevice;
 
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsOutput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackInput;
@@ -44,6 +45,35 @@ public interface DeviceRendererService {
      */
     ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction);
 
+    /**
+     * This method set's wavelength path based on following steps.
+     *
+     * <p>
+     * For each node:
+     * 1. Create Och interface on source termination point.
+     * 2. Create Och interface on destination termination point.
+     * 3. Create cross connect between source and destination tps created in step 1
+     *    and 2.
+     *
+     * Naming convention used for OCH interfaces name : tp-wavenumber Naming
+     * convention used for cross connect name : src-dest-wavenumber
+     * </p>
+     *
+     * @param input
+     *            Input parameter from the service-path yang model
+     * @param direction
+     *            Service Path direction
+     * @param transactionHistory
+     *            Object tracking created interface(s) and connection(s).
+     *
+     * @return Result list of all nodes if request successful otherwise specific
+     *         reason of failure.
+     */
+    ServicePathOutput setupServicePath(
+            ServicePathInput input,
+            ServicePathDirection direction,
+            History transactionHistory);
+
     /**
      * This method removes wavelength path based on following steps.
      *
@@ -72,6 +102,14 @@ public interface DeviceRendererService {
      */
     RendererRollbackOutput rendererRollback(RendererRollbackInput input);
 
+    /**
+     * Rollback created interfaces and cross connects specified by transaction history.
+     *
+     * @param transactionHistory The transaction history in need of rollback.
+     * @return Success flag and nodes which failed to rollback
+     */
+    RendererRollbackOutput rendererRollback(History transactionHistory);
+
     /**
      * This method creates the basis of ots and oms interfaces on a specific ROADM degree.
      *
index 836282c44a8ae4fab4c9c9827c007c728b7b11e2..a38b848b414f1888ada468153a571145659cb762 100644 (file)
@@ -49,6 +49,15 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Connection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.DeleteService;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.DeleteSubscriber;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.FailedRollbackResult;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Result;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Subscriber;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.NonStickHistoryMemory;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
@@ -113,12 +122,21 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(mappingUtils, portMapping, openRoadmInterfaces);
     }
 
+    @Override
+    public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
+        return setupServicePath(input, direction, new NonStickHistoryMemory());
+    }
+
     @SuppressWarnings("rawtypes")
     // FIXME check if the ForkJoinTask raw type can be avoided
     // Raw types use are discouraged since they lack type safety.
     // Resulting Problems are observed at run time and not at compile time
     @Override
-    public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
+    public ServicePathOutput setupServicePath(
+            ServicePathInput input,
+            ServicePathDirection direction,
+            History transactionHistory
+    ) {
         LOG.info("setup service path for input {} and direction {}", input, direction);
         List<Nodes> nodes = new ArrayList<>();
         if (input.getNodes() != null) {
@@ -164,10 +182,14 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                         crossConnectFlag++;
                         String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
                                 nodeId, destTp, spectrumInformation);
+                        transactionHistory.add(new DeviceInterface(nodeId, supportingOchInterface));
+
                         // Split the string based on # pass the last element as the supported Interface
                         // This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH
                         String[] listOfSuppOchInf = supportingOchInterface.split("#");
                         List<String> createdOchInf = Arrays.asList(listOfSuppOchInf);
+                        transactionHistory.addInterfaces(nodeId, listOfSuppOchInf);
+
                         createdOchInterfaces.addAll(createdOchInf);
                         LOG.info("DEST all otsi interfaces {}", createdOchInterfaces);
                         // Taking the last element
@@ -176,6 +198,8 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                                 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface, apiInfoA,
                                         apiInfoZ);
                         createdOtuInterfaces.add(supportingOtuInterface);
+                        transactionHistory.add(new DeviceInterface(nodeId, supportingOtuInterface));
+
                         LOG.info("all dest otu interfaces {}", createdOtuInterfaces);
                         if (srcTp == null) {
                             otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(destTp).build());
@@ -183,23 +207,32 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                             // If src and dest tp contains the network token, then it is regenerator
                             LOG.info("Create the ODUCn for regen on the dest-tp");
                             // Here we first create ODUCn interface for the Regen
-                            createdOduInterfaces.add(this.openRoadmInterfaceFactory
-                                    .createOpenRoadmOducn(nodeId, destTp));
+                            String openRoadmOducn = this.openRoadmInterfaceFactory
+                                    .createOpenRoadmOducn(nodeId, destTp);
+                            createdOduInterfaces.add(openRoadmOducn);
+                            transactionHistory.addInterfaces(nodeId, openRoadmOducn);
+
                             LOG.info("all dest odu interfaces {}", createdOduInterfaces);
                         } else {
                             // This is needed for 7.1 device models for 400GE, since we have ODUC4 and ODUflex
                             // are combined
-                            createdOduInterfaces = Set.of(this.openRoadmInterfaceFactory
-                                .createOpenRoadmOdu4HOInterface(
-                                    nodeId, destTp, false, apiInfoA, apiInfoZ, PT_07).split("#"));
+                            String[] oduInterfaces = this.openRoadmInterfaceFactory
+                                    .createOpenRoadmOdu4HOInterface(
+                                            nodeId, destTp, false, apiInfoA, apiInfoZ, PT_07).split("#");
+                            createdOduInterfaces.addAll(Arrays.asList(oduInterfaces));
+                            transactionHistory.addInterfaces(nodeId, oduInterfaces);
+
                         }
                     }
                     if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
                         LOG.info("Adding supporting EThernet interface for node {}, src tp {}", nodeId, srcTp);
                         crossConnectFlag++;
                         // create OpenRoadm Xponder Client Interfaces
-                        createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
-                                nodeId, srcTp));
+                        String openRoadmEthInterface = this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+                                nodeId, srcTp);
+                        createdEthInterfaces.add(openRoadmEthInterface);
+                        transactionHistory.add(new DeviceInterface(nodeId, openRoadmEthInterface));
+
                     }
                     if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
                         LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
@@ -208,10 +241,14 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                         // create OpenRoadm Xponder Line Interfaces
                         String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
                                 nodeId, srcTp, spectrumInformation);
+                        transactionHistory.add(new DeviceInterface(nodeId, supportingOchInterface));
+
                         // createdOchInterfaces.add(supportingOchInterface);
                         // Split the string based on # pass the last element as the supported Interface
                         // This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH
                         String[] listOfSuppOchInf = supportingOchInterface.split("#");
+                        transactionHistory.addInterfaces(nodeId, listOfSuppOchInf);
+
                         List<String> tmpCreatedOchInterfaces = Arrays.asList(listOfSuppOchInf);
                         createdOchInterfaces.addAll(tmpCreatedOchInterfaces);
                         // Taking the last element
@@ -219,40 +256,53 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                         String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
                                 nodeId, srcTp, supportingOchInterface, apiInfoA, apiInfoZ);
                         createdOtuInterfaces.add(supportingOtuInterface);
+                        transactionHistory.add(new DeviceInterface(nodeId, supportingOtuInterface));
+
                         if (destTp == null) {
                             otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(srcTp).build());
                         } else if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
                             // If the src and dest tp have network-token, then it is a regen
                             LOG.info("Create the regen-interfaces on the src-tp");
                             // Here we first create ODUCn interface for the Regen
-                            createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOducn(nodeId,
-                                    srcTp));
+                            String openRoadmOducn = this.openRoadmInterfaceFactory.createOpenRoadmOducn(nodeId,
+                                    srcTp);
+                            createdOduInterfaces.add(openRoadmOducn);
+                            transactionHistory.add(new DeviceInterface(nodeId, openRoadmOducn));
+
                             LOG.info("all src odu interfaces {}", createdOduInterfaces);
                         } else {
-                            createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
-                                    nodeId, srcTp, false, apiInfoA, apiInfoZ, PT_07));
+                            String openRoadmOdu4HOInterface = this.openRoadmInterfaceFactory
+                                    .createOpenRoadmOdu4HOInterface(nodeId, srcTp, false, apiInfoA, apiInfoZ, PT_07);
+                            createdOduInterfaces.add(openRoadmOdu4HOInterface);
+                            transactionHistory.add(new DeviceInterface(nodeId, openRoadmOdu4HOInterface));
                         }
                     }
                     if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
                         LOG.info("Adding supporting EThernet interface for node {}, dest tp {}", nodeId, destTp);
                         crossConnectFlag++;
                         // create OpenRoadm Xponder Client Interfaces
-                        createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
-                                nodeId, destTp));
+                        String openRoadmEthInterface = this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+                                nodeId, destTp);
+                        createdEthInterfaces.add(openRoadmEthInterface);
+                        transactionHistory.add(new DeviceInterface(nodeId, openRoadmEthInterface));
                     }
                     if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
                             || srcTp.contains(StringConstants.PP_TOKEN))) {
                         LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
                                 nodeId, srcTp, spectrumInformation);
-                        createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
-                                nodeId, srcTp, spectrumInformation));
+                        List<String> openRoadmOchInterfaces = this.openRoadmInterfaceFactory
+                                .createOpenRoadmOchInterfaces(nodeId, srcTp, spectrumInformation);
+                        createdOchInterfaces.addAll(openRoadmOchInterfaces);
+                        transactionHistory.addInterfaces(nodeId, openRoadmOchInterfaces);
                     }
                     if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
                             || destTp.contains(StringConstants.PP_TOKEN))) {
                         LOG.info("Adding supporting OCH interface for node {}, dest tp {}, spectrumInformation {}",
                                 nodeId, destTp, spectrumInformation);
-                        createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
-                                nodeId, destTp, spectrumInformation));
+                        List<String> openRoadmOchInterfaces = this.openRoadmInterfaceFactory
+                                .createOpenRoadmOchInterfaces(nodeId, destTp, spectrumInformation);
+                        createdOchInterfaces.addAll(openRoadmOchInterfaces);
+                        transactionHistory.addInterfaces(nodeId, openRoadmOchInterfaces);
                     }
                     if (crossConnectFlag < 1) {
                         LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
@@ -261,7 +311,9 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                                 this.crossConnect.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
                         if (connectionNameOpt.isPresent()) {
                             nodesProvisioned.add(nodeId);
-                            createdConnections.add(connectionNameOpt.orElseThrow());
+                            String connectionName = connectionNameOpt.orElseThrow();
+                            createdConnections.add(connectionName);
+                            transactionHistory.add(new Connection(nodeId, connectionName, false));
                         } else {
                             processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
                                     results);
@@ -558,6 +610,26 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                 .build();
     }
 
+    @Override
+    public RendererRollbackOutput rendererRollback(History transactionHistory) {
+        LOG.info("Rolling back...");
+
+        Result rollbackResult = new FailedRollbackResult();
+        Subscriber deleteSubscriber = new DeleteSubscriber(rollbackResult);
+
+        transactionHistory.rollback(
+                new DeleteService(
+                        crossConnect,
+                        openRoadmInterfaces,
+                        deleteSubscriber
+                )
+        );
+
+        LOG.info("Rollback done!");
+
+        return rollbackResult.renderRollbackOutput();
+    }
+
     private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
         Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
                 .nodelist.nodelist.NodesKey,
index 0fdf79e0493878256a95c632da61127a0014fec9..a4053de0fe45d665c529fa0682e0b34f2277cf0b 100644 (file)
@@ -36,11 +36,15 @@ import org.opendaylight.transportpce.renderer.provisiondevice.notification.Notif
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingRollbackTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingTask;
+import org.opendaylight.transportpce.renderer.provisiondevice.tasks.NetworkDeviceRenderingRollbackTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupRollbackTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerTurnDownTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OtnDeviceRenderingTask;
 import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackProcessor;
+import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackResultMessage;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.TransactionHistory;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.Action;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType;
@@ -353,9 +357,12 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
             servicePathDataAtoZ.getServicePathInput().getServiceName(),
             RpcStatusEx.Pending,
             RENDERING_DEVICES_A_Z_MSG);
+
+        History transactionHistory = new TransactionHistory();
         ListenableFuture<DeviceRenderingResult> atozrenderingFuture =
             this.executor.submit(
-                new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z));
+                new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z,
+                        transactionHistory));
 
         LOG.info(RENDERING_DEVICES_Z_A_MSG);
         sendNotifications(
@@ -365,7 +372,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
             RENDERING_DEVICES_Z_A_MSG);
         ListenableFuture<DeviceRenderingResult> ztoarenderingFuture =
             this.executor.submit(
-                new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A));
+                new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A,
+                        transactionHistory));
 
         ListenableFuture<List<DeviceRenderingResult>> renderingCombinedFuture =
             Futures.allAsList(atozrenderingFuture, ztoarenderingFuture);
@@ -386,16 +394,15 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
         }
 
         rollbackProcessor.addTask(
-            new DeviceRenderingRollbackTask(
-                "AtoZDeviceTask",
-                ! renderingResults.get(0).isSuccess(),
-                renderingResults.get(0).getRenderedNodeInterfaces(),
-                this.deviceRenderer));
-        rollbackProcessor.addTask(
-                new DeviceRenderingRollbackTask("ZtoADeviceTask",
-                ! renderingResults.get(1).isSuccess(),
-                renderingResults.get(1).getRenderedNodeInterfaces(),
-                this.deviceRenderer));
+            new NetworkDeviceRenderingRollbackTask(
+                "RollbackTransactionHistoryTask",
+                transactionHistory,
+                ! (renderingResults.get(0).isSuccess() && renderingResults.get(1).isSuccess()),
+                deviceRenderer,
+                new RollbackResultMessage()
+            )
+        );
+
         return renderingResults;
     }
 
index 6a30f950d7f00efc5d24eb19c638e32a57b364b5..4b2d7fbed1364662aacf5d3b0a11d54ef4f3adf7 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.transportpce.renderer.ServicePathInputData;
 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.Nodes;
 import org.slf4j.Logger;
@@ -26,12 +27,14 @@ public class DeviceRenderingTask implements Callable<DeviceRenderingResult> {
     private final DeviceRendererService deviceRenderer;
     private final ServicePathInputData servicePathInputData;
     private final ServicePathDirection direction;
+    private final History transactionHistory;
 
     public DeviceRenderingTask(DeviceRendererService deviceRenderer, ServicePathInputData servicePathInputData,
-            ServicePathDirection direction) {
+            ServicePathDirection direction, History transactionHistory) {
         this.deviceRenderer = deviceRenderer;
         this.servicePathInputData = servicePathInputData;
         this.direction = direction;
+        this.transactionHistory = transactionHistory;
     }
 
     @Override
@@ -43,7 +46,7 @@ public class DeviceRenderingTask implements Callable<DeviceRenderingResult> {
             case Create:
                 operation = "setup";
                 output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(),
-                    this.direction);
+                    this.direction, transactionHistory);
                 olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
                 break;
             case Delete:
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/NetworkDeviceRenderingRollbackTask.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/NetworkDeviceRenderingRollbackTask.java
new file mode 100644 (file)
index 0000000..4c1faa1
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.tasks;
+
+import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class NetworkDeviceRenderingRollbackTask extends RollbackTask {
+
+    private final History transactionHistory;
+
+    private final boolean isRollbackNecessary;
+
+    private final DeviceRendererService deviceRendererService;
+
+    private final ResultMessage message;
+
+    private static final Logger LOG = LoggerFactory.getLogger(NetworkDeviceRenderingRollbackTask.class);
+
+    public NetworkDeviceRenderingRollbackTask(String id, History transactionHistory,
+                                              boolean isRollbackNecessary,
+                                              DeviceRendererService deviceRendererService, ResultMessage message) {
+        super(id);
+        this.transactionHistory = transactionHistory;
+        this.isRollbackNecessary = isRollbackNecessary;
+        this.deviceRendererService = deviceRendererService;
+        this.message = message;
+    }
+
+    @Override
+    public boolean isRollbackNecessary() {
+        return isRollbackNecessary;
+    }
+
+    @Override
+    public Void call() throws Exception {
+
+        RendererRollbackOutput rollbackOutput = deviceRendererService.rendererRollback(transactionHistory);
+
+        if (! rollbackOutput.getSuccess()) {
+            LOG.warn("Device rendering rollback of {} was not successful! Failed rollback on {}.", this.getId(),
+                    message.createErrorMessage(rollbackOutput.nonnullFailedToRollback().values()));
+        } else {
+            LOG.info("Device rollback of {} successful.", this.getId());
+        }
+
+        return null;
+    }
+}
index f0cc4b6137a776210605123a77e633ea74d60aec..fbd70782e1bc1c62919fbcd1ac7e1cb3a29984c4 100644 (file)
@@ -44,6 +44,8 @@ public class OlmPowerSetupRollbackTask extends RollbackTask {
                 .setNodes(this.powerSetupInput.getNodes())
                 .setServiceName(this.powerSetupInput.getServiceName())
                 .setWaveNumber(this.powerSetupInput.getWaveNumber())
+                .setLowerSpectralSlotNumber(this.powerSetupInput.getLowerSpectralSlotNumber())
+                .setHigherSpectralSlotNumber(this.powerSetupInput.getHigherSpectralSlotNumber())
                 .build();
 
         Future<RpcResult<ServicePowerTurndownOutput>> powerTurndownResultFuture =
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/ResultMessage.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/ResultMessage.java
new file mode 100644 (file)
index 0000000..d1540ca
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.tasks;
+
+import java.util.Collection;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+
+public interface ResultMessage {
+
+    /**
+     * Build an error message for a failed rollback.
+     */
+    String createErrorMessage(Collection<FailedToRollback> failedRollbacks);
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/RollbackResultMessage.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/RollbackResultMessage.java
new file mode 100644 (file)
index 0000000..7fae4c9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.tasks;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+
+public class RollbackResultMessage implements ResultMessage {
+
+    @Override
+    public String createErrorMessage(Collection<FailedToRollback> failedRollbacks) {
+        List<String> failedRollbackNodes = new ArrayList<>();
+
+        failedRollbacks.forEach(failedRollback -> {
+            var intf = failedRollback.getInterface();
+
+            failedRollbackNodes.add(
+                failedRollback.getNodeId()
+                    + ": "
+                    + intf == null ? "" : String.join(", ", intf)
+            );
+        });
+
+        return String.join(System.lineSeparator(), failedRollbackNodes);
+    }
+
+}
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Connection.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Connection.java
new file mode 100644 (file)
index 0000000..ad04ae7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Connection transaction.
+ *
+ * <p>
+ * i.e. a class tracking a connection.
+ */
+public class Connection implements Transaction {
+
+    private static final Logger LOG = LoggerFactory.getLogger(Connection.class);
+    private final String deviceId;
+    private final String connectionNumber;
+    private final boolean isOtn;
+
+    public Connection(String deviceId, String connectionNumber, boolean isOtn) {
+        this.deviceId = deviceId;
+        this.connectionNumber = connectionNumber;
+        this.isOtn = isOtn;
+    }
+
+    @Override
+    public boolean rollback(Delete delete) {
+        List<String> supportingInterfaces = delete.deleteCrossConnect(deviceId, connectionNumber, isOtn);
+
+        if (supportingInterfaces == null || supportingInterfaces.size() == 0) {
+            return false;
+        }
+
+        LOG.info("Supporting interfaces {} affected by rollback on {} {}",
+                String.join(", ", supportingInterfaces), deviceId, connectionNumber);
+
+        return true;
+
+    }
+
+    @Override
+    public String description() {
+        return String.format("Connection %s connection number %s isOtn %s", deviceId,
+                connectionNumber, isOtn);
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+        if (!(object instanceof Connection)) {
+            return false;
+        }
+        Connection that = (Connection) object;
+        return isOtn == that.isOtn && Objects.equals(deviceId, that.deviceId)
+                && Objects.equals(connectionNumber, that.connectionNumber);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(deviceId, connectionNumber, isOtn);
+    }
+}
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterface.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterface.java
new file mode 100644 (file)
index 0000000..8bcc2c1
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
+
+import java.util.Objects;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+public class DeviceInterface implements Transaction {
+
+    private final String nodeId;
+
+    private final String interfaceId;
+
+    public DeviceInterface(String nodeId, String interfaceId) {
+        this.nodeId = nodeId;
+        this.interfaceId = interfaceId;
+    }
+
+    @Override
+    public boolean rollback(Delete delete) {
+        return delete.deleteInterface(nodeId, interfaceId);
+    }
+
+    @Override
+    public String description() {
+        return String.format("Node: %s interface id: %s", nodeId, interfaceId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(nodeId, interfaceId);
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+        if (!(object instanceof DeviceInterface)) {
+            return false;
+        }
+        DeviceInterface that = (DeviceInterface) object;
+        return Objects.equals(nodeId, that.nodeId) && Objects.equals(interfaceId,
+                that.interfaceId);
+    }
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Transaction.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/Transaction.java
new file mode 100644 (file)
index 0000000..d1300e3
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
+
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+/**
+ * Any class wishing to keep track of transactions
+ * may implement this interface.
+ */
+public interface Transaction {
+
+    /**
+     * Rollback this transaction.
+     */
+    boolean rollback(Delete delete);
+
+    String description();
+
+    int hashCode();
+
+    boolean equals(Object object);
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Delete.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Delete.java
new file mode 100644 (file)
index 0000000..95fcdff
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+import java.util.List;
+
+/**
+ * A class capable of deleting service connections/interfaces
+ * may implement this interface.
+ */
+public interface Delete {
+
+    /**
+     * Delete cross connection.
+     * Typically, deleted before interfaces.
+     */
+    List<String> deleteCrossConnect(String deviceId, String connectionNumber, boolean isOtn);
+
+    /**
+     * Delete an interface.
+     * Typically, deleted after the cross connection.
+     */
+    boolean deleteInterface(String nodeId, String interfaceId);
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteService.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteService.java
new file mode 100644 (file)
index 0000000..62af4bf
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeleteService implements Delete {
+
+    private final CrossConnect crossConnect;
+    private final OpenRoadmInterfaces openRoadmInterfaces;
+
+    private final Subscriber subscriber;
+
+    private static final Logger LOG = LoggerFactory.getLogger(DeleteService.class);
+
+    public DeleteService(
+            CrossConnect crossConnect,
+            OpenRoadmInterfaces openRoadmInterfaces,
+            Subscriber subscriber) {
+        this.crossConnect = crossConnect;
+        this.openRoadmInterfaces = openRoadmInterfaces;
+        this.subscriber = subscriber;
+    }
+
+    @Override
+    public @NonNull List<String> deleteCrossConnect(String deviceId, String connectionNumber,
+                                                    boolean isOtn) {
+        List<String> result = crossConnect.deleteCrossConnect(deviceId, connectionNumber, isOtn);
+
+        if (result == null) {
+            subscriber.result(false, deviceId, connectionNumber);
+            return new ArrayList<>();
+        }
+
+        subscriber.result(true, deviceId, connectionNumber);
+
+        return result;
+    }
+
+    @Override
+    public boolean deleteInterface(String nodeId, String interfaceId) {
+        try {
+            openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
+
+            subscriber.result(true, nodeId, interfaceId);
+            return true;
+        } catch (OpenRoadmInterfaceException e) {
+            LOG.error("Failed rolling back {} {}", nodeId, interfaceId);
+            subscriber.result(false, nodeId, interfaceId);
+            return false;
+        }
+    }
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteSubscriber.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/DeleteSubscriber.java
new file mode 100644 (file)
index 0000000..886b459
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+public class DeleteSubscriber implements Subscriber {
+
+    private final Result result;
+
+    public DeleteSubscriber(Result result) {
+        this.result = result;
+    }
+
+    @Override
+    public void result(Boolean success, String nodeId, String interfaceId) {
+
+        result.add(success, nodeId, interfaceId);
+
+    }
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/FailedRollbackResult.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/FailedRollbackResult.java
new file mode 100644 (file)
index 0000000..5637879
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollbackBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollbackKey;
+
+public class FailedRollbackResult implements Result {
+
+    private final Map<String, Set<String>> failedRollback = Collections.synchronizedMap(
+            new HashMap<>());
+
+    @Override
+    public boolean add(boolean success, String nodeId, String interfaceId) {
+
+        if (success) {
+            return false;
+        }
+
+        if (!failedRollback.containsKey(nodeId)) {
+            failedRollback.put(nodeId, new LinkedHashSet<>());
+        }
+
+        return failedRollback.get(nodeId).add(interfaceId);
+    }
+
+    @Override
+    public RendererRollbackOutput renderRollbackOutput() {
+
+        Map<FailedToRollbackKey, FailedToRollback> failedToRollbackList = new HashMap<>();
+
+        for (Entry<String, Set<String>> entry : failedRollback.entrySet()) {
+
+            FailedToRollback failedToRollack = new FailedToRollbackBuilder()
+                    .withKey(new FailedToRollbackKey(entry.getKey()))
+                    .setNodeId(entry.getKey())
+                    .setInterface(entry.getValue())
+                    .build();
+
+            failedToRollbackList.put(failedToRollack.key(), failedToRollack);
+
+        }
+
+        return new RendererRollbackOutputBuilder()
+                .setSuccess(failedRollback.isEmpty())
+                .setFailedToRollback(failedToRollbackList)
+                .build();
+
+    }
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Result.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Result.java
new file mode 100644 (file)
index 0000000..fb77027
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+
+public interface Result {
+
+    boolean add(boolean success, String nodeId, String interfaceId);
+
+    RendererRollbackOutput renderRollbackOutput();
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Subscriber.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/delete/Subscriber.java
new file mode 100644 (file)
index 0000000..8e83d16
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete;
+
+public interface Subscriber {
+
+    void result(Boolean success, String nodeId, String interfaceId);
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/History.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/History.java
new file mode 100644 (file)
index 0000000..fd2646a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+public interface History {
+
+    /**
+     * Add transaction.
+     *
+     * <p>
+     * Only accepts the transaction if this History
+     * object doesn't already contain the object.
+     *
+     * @return true if the transaction was added.
+     */
+    boolean add(Transaction transaction);
+
+    /**
+     * A list of transactions.
+     *
+     * <p>
+     * Will only accept unique transactions.
+     * @return true if all transactions was added. false if one or more transactions was rejected.
+     */
+    boolean add(List<Transaction> transactions);
+
+    /**
+     * Add an array of interface transactions.
+     *
+     * <p>
+     * Duplicate interface ids, null or empty strings
+     * are silently ignored.
+     * @return may return false
+     */
+    boolean addInterfaces(String nodeId, String interfaceId);
+
+    /**
+     * Add an array of interface transactions.
+     *
+     * <p>
+     * Duplicate interface ids, null or empty strings
+     * are silently ignored.
+     * @return may return false
+     */
+    boolean addInterfaces(String nodeId, String[] interfaceIds);
+
+    /**
+     * Add a list of interface transactions.
+     *
+     * <p>
+     * Duplicate interface ids, null or empty strings
+     * are silently ignored.
+     */
+    boolean addInterfaces(String nodeId, List<String> interfaceIds);
+
+    /**
+     * Rollback all transactions.
+     *
+     * <p>
+     * Typically, the transactions are rolled back in reverse
+     * order, but the implementing class may choose a different
+     * logic.
+     */
+    boolean rollback(Delete delete);
+
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/NonStickHistoryMemory.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/NonStickHistoryMemory.java
new file mode 100644 (file)
index 0000000..71d8f74
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Goldfish implementation of the History interface.
+ *
+ * <p>
+ * This implementation simply doesn't track anything.
+ * Most useful for backwards compatibility reasons.
+ */
+public class NonStickHistoryMemory implements History {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NonStickHistoryMemory.class);
+
+    @Override
+    public boolean add(Transaction transaction) {
+        LOG.warn("Transaction history disabled. Ignoring '{}'.", transaction.description());
+        return false;
+    }
+
+    @Override
+    public boolean add(List<Transaction> transactions) {
+        LOG.warn("Transaction history disabled. No rollback executed.");
+        return false;
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, String interfaceId) {
+        LOG.warn("Transaction history disabled.");
+        return false;
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, String[] interfaceIds) {
+        LOG.warn("Transaction history disabled.");
+        return false;
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, List<String> interfaceIds) {
+        LOG.warn("Transaction history disabled.");
+        return false;
+    }
+
+    @Override
+    public boolean rollback(Delete delete) {
+        LOG.warn("Transaction history disabled. No rollback executed.");
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistory.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistory.java
new file mode 100644 (file)
index 0000000..a1565fc
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.history;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A class keeping track of transaction history.
+ *
+ * <p>
+ * A transaction can be something like an interface or a roadm connection, that may need to be
+ * rolled back in the future.
+ */
+public class TransactionHistory implements History {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TransactionHistory.class);
+    Set<Transaction> transactionHistory = Collections.synchronizedSet(new LinkedHashSet<>());
+
+    @Override
+    public boolean add(Transaction transaction) {
+
+        boolean result = transactionHistory.add(transaction);
+
+        if (result) {
+            LOG.info("Adding {}", transaction.description());
+        } else {
+            LOG.warn("Transaction {} not added.", transaction.description());
+        }
+
+        return result;
+    }
+
+    @Override
+    public boolean add(List<Transaction> transactions) {
+        Set<Boolean> results = new HashSet<>(transactions.size());
+
+        for (Transaction transaction : transactions) {
+            results.add(add(transaction));
+        }
+
+        return results.stream().allMatch(i -> (i.equals(Boolean.TRUE)));
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, String interfaceId) {
+        return addInterfaces(nodeId, Collections.singletonList(interfaceId));
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, String[] interfaceIds) {
+
+        return addInterfaces(nodeId, Arrays.asList(interfaceIds));
+
+    }
+
+    @Override
+    public boolean addInterfaces(String nodeId, List<String> interfaceIds) {
+
+        Set<Boolean> results = new HashSet<>();
+        Set<String> unique = new LinkedHashSet<>();
+
+        for (String interfaceId : interfaceIds) {
+            if (interfaceId != null && !interfaceId.trim().isEmpty()) {
+                unique.add(interfaceId.trim());
+            }
+        }
+
+        for (String interfaceId : unique) {
+            results.add(this.add(new DeviceInterface(nodeId, interfaceId)));
+        }
+
+        return results.stream().allMatch(i -> (i.equals(Boolean.TRUE)));
+
+    }
+
+    @Override
+    public boolean rollback(Delete delete) {
+
+        LOG.info("History contains {} items. Rolling them back in reverse order.",
+                transactionHistory.size());
+
+        List<Transaction> reverse = new ArrayList<>(transactionHistory);
+
+        Collections.reverse(reverse);
+
+        boolean success = true;
+
+        for (Transaction transaction : reverse) {
+            LOG.info("Rolling back {}", transaction.description());
+            if (!transaction.rollback(delete)) {
+                success = false;
+            }
+        }
+
+        return success;
+
+    }
+}
\ No newline at end of file
index cb17336b6ecbf19222627c3fc00154db7b104cef..6df33027a2248a124ebac183c2096b70d6489513 100644 (file)
@@ -102,7 +102,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN);
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result =
                 this.rendererServiceOperations.serviceImplementation(input, false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -114,7 +114,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN);
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService).servicePowerSetup(any());
         ServiceImplementationRequestOutput result =
                 this.rendererServiceOperations.serviceImplementation(input, false).get();
@@ -127,7 +127,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.PP_TOKEN);
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
                 false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -139,7 +139,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
                 false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -151,7 +151,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.CLIENT_TOKEN);
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
                 false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -168,7 +168,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
 
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("failed")
             .setSuccess(false);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
 
         for (String tpToken : interfaceTokens) {
             ServiceImplementationRequestInput input = ServiceDataUtils
@@ -248,7 +248,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
         when(this.olmService.getPm(eq(getPmInputA))).thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestInput input = ServiceDataUtils
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
@@ -264,7 +264,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
         when(this.olmService.getPm(any())).thenReturn(RpcResultBuilder.success(getPmOutput1).buildFuture());
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
                 false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -278,7 +278,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
         when(this.olmService.getPm(any())).thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
                 false).get();
         assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
@@ -299,7 +299,7 @@ public class RendererServiceOperationsImplTest extends AbstractTest {
         doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService).getPm(any());
         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
             .setSuccess(true);
-        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+        doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
         ServiceImplementationRequestInput input = ServiceDataUtils
             .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/ConnectionTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/ConnectionTest.java
new file mode 100644 (file)
index 0000000..a3ba1e7
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class ConnectionTest {
+
+    @Test
+    void rollback() {
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+                .thenReturn(List.of("Interface1"));
+
+        Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+        Assert.assertTrue(n1.rollback(delete));
+
+        Mockito.verify(delete, Mockito.times(1))
+                .deleteCrossConnect("ROADM-A", "DEG1", false);
+    }
+
+    @Test
+    void testTwoObjectsWithSameInformationIsEqual() {
+        Connection n1 = new Connection("ROADM-A", "DEG1", false);
+        Connection n2 = new Connection("ROADM-A", "DEG1", false);
+
+        Assert.assertTrue(n1.equals(n2));
+    }
+
+    @Test
+    void testTwoObjectsWithDifferentInformationIsNotEqual() {
+        Connection n1 = new Connection("ROADM-A", "DEG1", true);
+        Connection n2 = new Connection("ROADM-A", "DEG1", false);
+
+        Assert.assertFalse(n1.equals(n2));
+    }
+
+    @Test
+    void testTwoDifferentRoadmNodesAreNotEqual() {
+        Connection n1 = new Connection("ROADM-A", "DEG1", false);
+        Connection n2 = new Connection("ROADM-B", "DEG1", false);
+
+        Assert.assertFalse(n1.equals(n2));
+    }
+
+
+    @Test
+    void deleteReturnNull() {
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+                .thenReturn(null);
+
+        Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+        Assert.assertFalse(n1.rollback(delete));
+
+        Mockito.verify(delete, Mockito.times(1))
+                .deleteCrossConnect("ROADM-A", "DEG1", false);
+    }
+
+    @Test
+    void deleteReturnEmptyList() {
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+                .thenReturn(new ArrayList<>());
+
+        Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+        Assert.assertFalse(n1.rollback(delete));
+
+        Mockito.verify(delete, Mockito.times(1))
+                .deleteCrossConnect("ROADM-A", "DEG1", false);
+    }
+}
\ No newline at end of file
diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterfaceTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/DeviceInterfaceTest.java
new file mode 100644 (file)
index 0000000..d0481ae
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
+
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class DeviceInterfaceTest {
+
+    @Test
+    void rollback() {
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        Assert.assertTrue(n1.rollback(delete));
+
+        Mockito.verify(delete, Mockito.times(1)).deleteInterface("ROADM-A", "DEG1");
+    }
+
+    @Test
+    void testTwoInterfacesAreEqual() {
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        DeviceInterface n2 = new DeviceInterface("ROADM-A", "DEG1");
+
+        Assert.assertTrue(n1.equals(n2));
+    }
+
+    @Test
+    void testTwoInterfacesAreNotEqual() {
+        DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+        DeviceInterface n2 = new DeviceInterface("ROADM-B", "DEG1");
+
+        Assert.assertFalse(n1.equals(n2));
+    }
+}
\ No newline at end of file
diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistoryTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/transaction/history/TransactionHistoryTest.java
new file mode 100644 (file)
index 0000000..0adf418
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright Â© 2024 Smartoptics and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class TransactionHistoryTest {
+
+    @Test
+    void add() {
+        Transaction transaction = Mockito.mock(Transaction.class);
+        History history = new TransactionHistory();
+
+        Assert.assertTrue(history.add(transaction));
+    }
+
+    @Test
+    void testDuplicateTransactionIsIgnored() {
+
+        Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+        Transaction t2 = new DeviceInterface("ROADM-A", "DEG1");
+
+        History history = new TransactionHistory();
+
+        history.add(t1);
+        Assert.assertFalse(history.add(t2));
+    }
+
+    @Test
+    void testAddCollectionOfUniqueTransactions() {
+        Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+        Transaction t2 = new DeviceInterface("ROADM-A", "DEG2");
+
+        List<Transaction> transactions = List.of(t1, t2);
+
+        History history = new TransactionHistory();
+
+        Assert.assertTrue(history.add(transactions));
+    }
+
+    @Test
+    void testAddCollectionOfDuplicateTransactions() {
+        Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+        Transaction t2 = new DeviceInterface("ROADM-A", "DEG1");
+
+        List<Transaction> transactions = List.of(t1, t2);
+
+        History history = new TransactionHistory();
+
+        Assert.assertFalse(history.add(transactions));
+    }
+
+    @Test
+    void testAddUniqueStringOfInterfaceIds() {
+        String nodeId = "ROADM-A";
+        String[] interfaces = new String[]{"DEG1", "DEG2"};
+
+        History history = new TransactionHistory();
+
+        Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+    }
+
+    @Test
+    void testAddDuplicateStringOfInterfaceIds() {
+        String nodeId = "ROADM-A";
+        String[] interfaces = new String[]{"DEG1", "DEG1"};
+
+        History history = new TransactionHistory();
+
+        Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+
+    }
+
+    @Test
+    void testAddDuplicateListOfInterfaceIds() {
+        String nodeId = "ROADM-A";
+        List<String> interfaces = List.of("DEG1", "DEG1");
+
+        History history = new TransactionHistory();
+
+        Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+
+    }
+
+    @Test
+    void rollbackOneInterface() {
+
+        String nodeId = "ROADM-A";
+        List<String> interfaces = List.of("DEG1", "DEG1");
+
+        History history = new TransactionHistory();
+        history.addInterfaces(nodeId, interfaces);
+
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+
+        Assert.assertTrue(history.rollback(delete));
+
+        //Although the same interface was added twice, we only rollback once.
+        Mockito.verify(delete, Mockito.times(1))
+                .deleteInterface("ROADM-A", "DEG1");
+    }
+
+    @Test
+    void rollbackTwoInterfacesInReverseOrderTheyWereAdded() {
+
+        String nodeId = "ROADM-A";
+
+        //Note DEG1 is added before DEG2
+        List<String> interfaces = List.of("DEG1", "DEG2");
+
+        History history = new TransactionHistory();
+        history.addInterfaces(nodeId, interfaces);
+
+        Delete delete = Mockito.mock(Delete.class);
+        Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+        Mockito.when(delete.deleteInterface("ROADM-A", "DEG2")).thenReturn(true);
+
+        Assert.assertTrue(history.rollback(delete));
+
+        //The rollback occurs in the reverse order.
+        // i.e. DEG2 before DEG1.
+        InOrder inOrder = Mockito.inOrder(delete);
+        inOrder.verify(delete, Mockito.times(1))
+                .deleteInterface("ROADM-A", "DEG2");
+        inOrder.verify(delete, Mockito.times(1))
+                .deleteInterface("ROADM-A", "DEG1");
+
+    }
+}
\ No newline at end of file
index 22ad0c0f9bc9dfad44d7ea9c3721d6487617deab..1ecb8114021a4174bac5b45031fa7fcf6504f933 100644 (file)
@@ -12,12 +12,12 @@ import com.google.common.util.concurrent.ListenableFuture;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.HashMap;
 import java.util.Map;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInputBuilder;
@@ -280,9 +280,9 @@ public final class ModelMappingUtils {
             .build();
     }
 
-    public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+    public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
             .path.computation.reroute.request.input.ServiceAEnd createServiceAEndReroute(ServiceEndpoint serviceAEnd) {
-        return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+        return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                     .path.computation.reroute.request.input.ServiceAEndBuilder()
                 .setClli(serviceAEnd.getClli())
                 .setNodeId(serviceAEnd.getNodeId().getValue())
@@ -306,9 +306,9 @@ public final class ModelMappingUtils {
             .build();
     }
 
-    public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+    public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
             .path.computation.reroute.request.input.ServiceZEnd createServiceZEndReroute(ServiceEndpoint serviceZEnd) {
-        return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+        return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                     .path.computation.reroute.request.input.ServiceZEndBuilder()
                 .setClli(serviceZEnd.getClli())
                 .setNodeId(serviceZEnd.getNodeId().getValue())
index 0529f832aa35e8b28c15a80f966af04001356a2a..d880d40f64ea394e4a91b505abf6c62510defbc5 100644 (file)
@@ -36,9 +36,9 @@ import org.opendaylight.transportpce.servicehandler.validation.CatalogValidation
 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.EndpointsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.EndpointsBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceNotificationTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
index cc66c0b6bc872b8ae2a159a7d00522195e7b6c57..6cb4540aad398a19123de5109979cb032aed520f 100644 (file)
@@ -18,10 +18,10 @@ import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
 import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services;
index be3eef2a43e1861b7510bfda535cda356897cced..ae723eb6c3fce489b8f7602e4a0fa4e147ab2498 100644 (file)
@@ -364,7 +364,7 @@ public class RendererNotificationHandler implements RendererListener {
         } else {
             deleteServiceOperationResult = this.serviceDataStoreOperations.deleteService(serviceName);
         }
-        if (deleteServiceOperationResult.isSuccess()) {
+        if (!deleteServiceOperationResult.isSuccess()) {
             LOG.warn("{}Service was not removed from datastore!", serviceType);
         }
     }
index f11a4c23809d8fd10b8a30624b67e9c4f4270a8e..7eb2e29c1ba6ab7b6474fdfec907a77194340f04 100644 (file)
@@ -18,20 +18,20 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.Endpoints;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.reroute.request.input.EndpointsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.Endpoints;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.reroute.request.input.EndpointsBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultShBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceEndpoint;
@@ -78,7 +78,8 @@ public class PCEServiceWrapper {
             return performPCE(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints(),
                     serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader(),
                     serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    serviceCreateInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -91,7 +92,8 @@ public class PCEServiceWrapper {
             return performPCE(tempServiceCreateInput.getHardConstraints(), tempServiceCreateInput.getSoftConstraints(),
                     tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader(),
                     tempServiceCreateInput.getServiceAEnd(), tempServiceCreateInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    tempServiceCreateInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -106,7 +108,8 @@ public class PCEServiceWrapper {
                     serviceFeasibilityCheckInput.getSoftConstraints(), serviceFeasibilityCheckInput.getCommonId(),
                     serviceFeasibilityCheckInput.getSdncRequestHeader(), serviceFeasibilityCheckInput.getServiceAEnd(),
                     serviceFeasibilityCheckInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    serviceFeasibilityCheckInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -114,7 +117,8 @@ public class PCEServiceWrapper {
 
     private PathComputationRequestOutput performPCE(HardConstraints hardConstraints, SoftConstraints softConstraints,
             String serviceName, SdncRequestHeader sdncRequestHeader, ServiceEndpoint serviceAEnd,
-            ServiceEndpoint serviceZEnd, ServiceNotificationTypes notifType, boolean reserveResource) {
+            ServiceEndpoint serviceZEnd, ServiceNotificationTypes notifType, boolean reserveResource,
+            String customerName) {
         LOG.info("Calling path computation.");
         notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
                 .setStatus(RpcStatusEx.Pending)
@@ -127,7 +131,7 @@ public class PCEServiceWrapper {
         FutureCallback<PathComputationRequestOutput> pceCallback =
                 new PathComputationRequestOutputCallback(notifType, serviceName);
         PathComputationRequestInput pathComputationRequestInput = createPceRequestInput(serviceName, sdncRequestHeader,
-                hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd);
+                hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd, customerName);
         ListenableFuture<PathComputationRequestOutput> pce = this.pathComputationService
                 .pathComputationRequest(pathComputationRequestInput);
         Futures.addCallback(pce, pceCallback, executor);
@@ -173,7 +177,7 @@ public class PCEServiceWrapper {
     private PathComputationRequestInput createPceRequestInput(String serviceName,
             SdncRequestHeader serviceHandler, HardConstraints hardConstraints,
             SoftConstraints softConstraints, Boolean reserveResource, ServiceEndpoint serviceAEnd,
-            ServiceEndpoint serviceZEnd) {
+            ServiceEndpoint serviceZEnd, String customerName) {
         LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
                 + "requests");
         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
@@ -187,6 +191,7 @@ public class PCEServiceWrapper {
             .setHardConstraints(hardConstraints)
             .setSoftConstraints(softConstraints)
             .setPceRoutingMetric(PceMetric.TEMetric)
+            .setCustomerName(customerName)
             .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceAEnd))
             .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceZEnd))
             .build();
index 005d014cc76c3b60489d16d7efb752086e25feb7..dbf2099399297699b40abc27a86d7d56cf562e31 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.transportpce.servicehandler.service;
 import java.util.Optional;
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.servicehandler.ServiceInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
 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.service.rev230526.ServiceCreateInput;
@@ -128,7 +128,7 @@ public interface ServiceDataStoreOperations {
      * @return result of createTempService operation
      */
     OperationResult createTempService(TempServiceCreateInput tempServiceCreateInput,
-                                      org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+                                      org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                                               .service.path.rpc.result.PathDescription pathDescription);
 
     Optional<ServicePathList> getServicePaths();
index 5a7386ffa9ed05f0fdce1c0250e3f343e89af651..4704950da306a21e473494a3755a03c56ccce294 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
 import org.opendaylight.transportpce.servicehandler.ServiceInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
 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.service.rev230526.ServiceCreateInput;
@@ -90,7 +90,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         try {
             LOG.info("initializing service registry");
             WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
-            transaction.put(
+            transaction.merge(
                 LogicalDatastoreType.OPERATIONAL,
                 InstanceIdentifier.create(ServiceList.class),
                 new ServiceListBuilder().build());
@@ -105,7 +105,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         try {
             LOG.info("initializing temp service registry");
             WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
-            transaction.put(
+            transaction.merge(
                 LogicalDatastoreType.OPERATIONAL,
                 InstanceIdentifier.create(TempServiceList.class),
                 new TempServiceListBuilder().build());
@@ -284,7 +284,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
     @Override
     public OperationResult createTempService(
             TempServiceCreateInput tempServiceCreateInput,
-            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925
+            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205
                     .service.path.rpc.result.PathDescription pathDescription) {
         LOG.debug("Writing '{}' Temp Service", tempServiceCreateInput.getCommonId());
         try {
index 911370a9a0246d739ede1da118192ffc1873128c..387c7c6fcb9b48586cbe13ddd6db23bf68b9b993 100644 (file)
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder;
index d5b858eb67f496128b5c0a57e578fb175d8b5a3f..61141a07c0271b6d024ab72e0fe70011e776b803 100644 (file)
@@ -50,9 +50,9 @@ import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOper
 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
index 2ed9ad4dd613c29c1b0a07abcf478894c6677a47..30f8bb9e55a1a33f8a058dac0de08d706949c49c 100644 (file)
@@ -25,12 +25,12 @@ import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.CancelResourceReserveOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceNotificationTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
index 70981716f45ac879ba0ef567a8cfea46a9cd8e58..0f40f3842918b3d4e1f637d808e421ba558678ff 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
index dedaa6a79dad2368d326971b5707666afbaeff25..557d43dc4782c9b37a47ae9d565dfbb4d4acbe88 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.transportpce.servicehandler.utils;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.transportpce.servicehandler.ServiceInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInputBuilder;
index c3808c53fb59e22eeb3de24fc3425d55f7e30502..a9df0ed95617547121c5dd26c8dee3c5bb217edd 100644 (file)
@@ -17,12 +17,12 @@ import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResultBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSpBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
index 2f5780910211da57185efd187e885db9e0994006..fe1e2eb2de021f37924a871951ca5b75db7c5217 100644 (file)
@@ -86,7 +86,6 @@ 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.connection.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;
@@ -113,7 +112,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.no
 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.SupportedCepLayerProtocolQualifierInstances;
 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;
@@ -129,17 +127,18 @@ 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 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 ServiceDataStoreOperations serviceDataStoreOperations;
     private final TapiContext tapiContext;
     private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
+    // this variable is for complete connection objects
     private final Map<
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
-        connectionFullMap; // this variable is for complete connection objects
+            connectionFullMap;
     private final NetworkTransactionService networkTransactionService;
     private Connection topConnRdmRdm;
     private Connection topConnXpdrXpdrPhtn;
@@ -173,56 +172,65 @@ public final class ConnectivityUtils {
             .setServiceName("service test")
             .setServiceAEnd(serviceAEnd)
             .setServiceZEnd(serviceZEnd)
-            .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
-                .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
-                    "appname")
-                .build())
+            .setSdncRequestHeader(
+                new SdncRequestHeaderBuilder()
+                    .setRequestId("request-1")
+                    .setRpcAction(RpcActions.ServiceCreate)
+                    .setNotificationUrl("notification url")
+                    .setRequestSystemId("appname")
+                    .build())
             .build();
     }
 
-    public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
-                                               String txPortName, String rxPortDeviceName, String rxPortName) {
+    public static ServiceAEnd buildServiceAEnd(
+            String nodeid, String clli, String txPortDeviceName,
+            String txPortName, String rxPortDeviceName, String rxPortName) {
         return new ServiceAEndBuilder()
             .setClli(clli)
             .setNodeId(new NodeIdType(nodeid))
             .setOpticType(OpticTypes.Gray)
             .setServiceFormat(ServiceFormat.Ethernet)
             .setServiceRate(Uint32.valueOf(100))
-            .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
-                .setPort(new PortBuilder()
-                    .setPortDeviceName(txPortDeviceName)
-                    .setPortName(txPortName)
-                    .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
-                    .setPortShelf("00")
-                    .setPortType(TapiStringConstants.PORT_TYPE)
-                    .build())
-                .setLgx(new LgxBuilder()
-                    .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
-                    .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
-                    .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
-                    .setLgxPortShelf("00")
-                    .build())
-                .build()))
-            .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
-                .setPort(new PortBuilder()
-                    .setPortDeviceName(rxPortDeviceName)
-                    .setPortName(rxPortName)
-                    .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
-                    .setPortShelf("00")
-                    .setPortType(TapiStringConstants.PORT_TYPE)
-                    .build())
-                .setLgx(new LgxBuilder()
-                    .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
-                    .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
-                    .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
-                    .setLgxPortShelf("00")
-                    .build())
-                .build()))
+            .setTxDirection(Map.of(
+                new TxDirectionKey(Uint8.ZERO),
+                new TxDirectionBuilder()
+                    .setPort(new PortBuilder()
+                        .setPortDeviceName(txPortDeviceName)
+                        .setPortName(txPortName)
+                        .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
+                        .setPortShelf("00")
+                        .setPortType(TapiStringConstants.PORT_TYPE)
+                        .build())
+                    .setLgx(new LgxBuilder()
+                        .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
+                        .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
+                        .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
+                        .setLgxPortShelf("00")
+                        .build())
+                    .build()))
+            .setRxDirection(Map.of(
+                new RxDirectionKey(Uint8.ZERO),
+                new RxDirectionBuilder()
+                    .setPort(new PortBuilder()
+                        .setPortDeviceName(rxPortDeviceName)
+                        .setPortName(rxPortName)
+                        .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
+                        .setPortShelf("00")
+                        .setPortType(TapiStringConstants.PORT_TYPE)
+                        .build())
+                    .setLgx(new LgxBuilder()
+                        .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
+                        .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
+                        .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
+                        .setLgxPortShelf("00")
+                        .build())
+                    .build()))
             .build();
     }
 
-    public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
-                                               String txPortName, String rxPortDeviceName, String rxPortName) {
+    public static ServiceZEnd buildServiceZEnd(
+            String nodeid, String clli, String txPortDeviceName,
+            String txPortName, String rxPortDeviceName, String rxPortName) {
         return  new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
             .setOpticType(OpticTypes.Gray)
             .setServiceFormat(ServiceFormat.Ethernet)
@@ -269,31 +277,28 @@ public final class ConnectivityUtils {
         LOG.info("Service = {}", service);
         Optional<ServicePaths> optServicePaths =
             this.serviceDataStoreOperations.getServicePath(service.getServiceName());
-        if (!optServicePaths.isPresent()) {
+        if (optServicePaths.isEmpty()) {
             LOG.error("No service path found for service {}", service.getServiceName());
             return null;
         }
-        ServicePaths servicePaths = optServicePaths.orElseThrow();
-        PathDescription pathDescription = servicePaths.getPathDescription();
+        PathDescription pathDescription = optServicePaths.orElseThrow().getPathDescription();
         LOG.info("Path description of service = {}", pathDescription);
-        org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd
-            service.getServiceAEnd();
+        org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd =
+            service.getServiceAEnd();
         // Endpoint creation
         EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
-        org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd serviceZEnd
-            = service.getServiceZEnd();
-        EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
-        Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
-        endPointMap.put(endPoint1.key(), endPoint1);
-        endPointMap.put(endPoint2.key(), endPoint2);
+        EndPoint endPoint2 = mapServiceZEndPoint(service.getServiceZEnd(), pathDescription);
+        Map<EndPointKey, EndPoint> endPointMap = new HashMap<>(Map.of(
+                endPoint1.key(), endPoint1,
+                endPoint2.key(), endPoint2));
         LOG.info("EndPoints of connectivity services = {}", endPointMap);
         // Services Names
-        Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
-            .build();
+        Name name =
+            new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName()).build();
         // Connection creation
         Map<ConnectionKey, Connection> connMap =
             createConnectionsFromService(pathDescription, mapServiceLayerToAend(serviceAEnd));
-        LOG.debug("connectionMap for service {} = {} ", name.toString(), connMap.toString());
+        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...
@@ -301,8 +306,8 @@ public final class ConnectivityUtils {
             .setAdministrativeState(AdministrativeState.UNLOCKED)
             .setOperationalState(OperationalState.ENABLED)
             .setLifecycleState(LifecycleState.INSTALLED)
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8))
-                .toString()))
+            .setUuid(new Uuid(
+                UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8)).toString()))
             .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
             .setConnectivityConstraint(conConstr)
             .setDirection(ForwardingDirection.BIDIRECTIONAL)
@@ -312,8 +317,8 @@ public final class ConnectivityUtils {
             .build();
     }
 
-    public Map<ConnectionKey, Connection> createConnectionsFromService(PathDescription pathDescription,
-            LayerProtocolName lpn) {
+    public Map<ConnectionKey, Connection> createConnectionsFromService(
+            PathDescription pathDescription, LayerProtocolName lpn) {
         Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
         // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
         //  and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
@@ -326,7 +331,7 @@ public final class ConnectivityUtils {
         List<String> rdmNodelist = new ArrayList<>();
         List<String> xpdrNodelist = new ArrayList<>();
         for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
-            .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
+                .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
             resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
             switch (resourceType) {
                 case TapiStringConstants.TP:
@@ -413,10 +418,10 @@ public final class ConnectivityUtils {
                 // - 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
-                connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
-                    edgeRoadm1, edgeRoadm2));
+                connectionServMap.putAll(
+                    createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
                 if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
-                    .contains("ROADM")) {
+                        .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));
@@ -436,14 +441,15 @@ public final class ConnectivityUtils {
                 // Check if OC, OTU and ODU are created
                 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
                     LOG.info("WDM ETH service");
-                    connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
-                        edgeRoadm1, edgeRoadm2));
+                    connectionServMap.putAll(
+                        createRoadmCepsAndConnections(
+                            rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
                     connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
                     this.topConnRdmRdm = null;
                     xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
                     LOG.info("Associated client ports = {}", xpdrClientTplist);
-                    connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
-                        connectionServMap));
+                    connectionServMap.putAll(
+                        createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist, connectionServMap));
                     this.topConnXpdrXpdrPhtn = null;
                 }
                 break;
@@ -456,21 +462,21 @@ public final class ConnectivityUtils {
                     // 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(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
-                        xpdrNodelist));
+                    connectionServMap.putAll(
+                        createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
                     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));
+                    connectionServMap.putAll(
+                        createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
                     this.topConnXpdrXpdrOdu = null;
                 }
                 break;
             default:
                 LOG.error("Service type format not supported");
         }
-        LOG.debug("CONNSERVERMAP = {}", connectionServMap.toString());
+        LOG.debug("CONNSERVERMAP = {}", connectionServMap);
         return connectionServMap;
     }
 
@@ -485,19 +491,18 @@ public final class ConnectivityUtils {
             .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
             .build();
         try {
-            Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
-                LogicalDatastoreType.OPERATIONAL, onepIID).get();
+            Optional<OwnedNodeEdgePoint> optionalOnep =
+                this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
             if (optionalOnep.isPresent()) {
                 LOG.error("ONEP is already present in datastore");
                 return;
             }
             // merge in datastore
-            this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
-                onep);
+            this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onep);
             this.networkTransactionService.commit().get();
-            LOG.info("NEP {} added successfully.", onep.getName().toString());
+            LOG.info("NEP {} added successfully.", onep.getName());
         } catch (InterruptedException | ExecutionException e) {
-            LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName().toString(), e);
+            LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName(), e);
         }
     }
 
@@ -510,16 +515,17 @@ public final class ConnectivityUtils {
 
     public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
         // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
-        Map<org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
-            org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint>
-            endPointMap = input.getEndPoint();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPointKey,
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPoint> endPointMap = input.getEndPoint();
         ConnectionType connType = null;
         ServiceFormat serviceFormat = null;
-        String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
+        String nodeAid = String.join("+",
+            endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
             TapiStringConstants.XPDR);
-        String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
+        String nodeZid = String.join("+",
+            endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
             TapiStringConstants.XPDR);
         LOG.info("NodeAid = {}", nodeAid);
         LOG.info("NodeZid = {}", nodeZid);
@@ -554,10 +560,12 @@ public final class ConnectivityUtils {
         Uint64 capacity = Uint64.valueOf(Math.abs(
             input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
         // map endpoints into service end points. Map the type of service from TAPI to OR
-        ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
+        ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(
+            endPointMap.values().stream().findFirst().orElseThrow(),
             serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
-        ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
-                .orElseThrow(), serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
+        ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(
+            endPointMap.values().stream().skip(1).findFirst().orElseThrow(),
+            serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
         if (serviceAEnd == null || serviceZEnd == null) {
             LOG.error("Couldnt map endpoints to service end");
             return null;
@@ -601,8 +609,8 @@ public final class ConnectivityUtils {
     }
 
     private LayerProtocolName mapServiceLayerToAend(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
-            serviceAEnd) {
+            org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                .service.ServiceAEnd serviceAEnd) {
         ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
         switch (serviceFormat) {
             case OC:
@@ -611,8 +619,10 @@ public final class ConnectivityUtils {
             case ODU:
                 return LayerProtocolName.ODU;
             case Ethernet:
-                if (getOpenroadmType(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
-                        .getPortDeviceName()).equals(OpenroadmNodeType.TPDR)) {
+                if (getOpenroadmType(
+                            serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()
+                                .getPort().getPortDeviceName())
+                        .equals(OpenroadmNodeType.TPDR)) {
                     return LayerProtocolName.ETH;
                 }
                 return LayerProtocolName.DSR;
@@ -642,23 +652,23 @@ public final class ConnectivityUtils {
         }
         return null;
     }
+    //TODO factorize these two similar methods
 
     private OpenroadmNodeType getOpenroadmType(String nodeName) {
         LOG.info("Node name = {}", nodeName);
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.XPDR))
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode
-            = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
-        if (tapiNode != null) {
-            return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
-                .getValue());
-        }
-        return null;
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode =
+            this.tapiContext.getTapiNode(
+                this.tapiTopoUuid,
+                new Uuid(UUID.nameUUIDFromBytes(
+                        (String.join("+",nodeName, TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
+                    .toString()));
+        return tapiNode == null
+            ? null
+            : OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type")).getValue());
     }
 
-    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
-                                                                           List<String> xpdrNodelist,
-                                                                           Map<ConnectionKey, Connection> lowerConn) {
+    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(
+            List<String> xpdrClientTplist, List<String> xpdrNodelist, Map<ConnectionKey, Connection> lowerConn) {
         // TODO: do we need to create cross connection between iODU and eODU??
         // add the lower connections of the previous steps for this kind of service
         Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
@@ -666,48 +676,44 @@ public final class ConnectivityUtils {
             LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
             xcMap.put(conn.key(), conn);
         }
-        Map<ConnectionKey, Connection> connServMap = new HashMap<>();
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-            ConnectionEndPoint> cepMapDsr = new HashMap<>();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
         // Create 1 cep per Xpdr in the CLIENT
         // 1 top connection DSR between the CLIENT xpdrs
         for (String xpdr:xpdrNodelist) {
             LOG.info("Creating ceps and xc for xpdr {}", xpdr);
-            String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
-                .orElseThrow();
-            ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
-                LayerProtocolName.DSR);
-            putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR,
-                TapiStringConstants.XPDR, netCep1);
-
+            String spcXpdrClient =
+                xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+            ConnectionEndPoint netCep1 =
+                createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
+            putXpdrCepInTopologyContext(
+                xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, netCep1);
             cepMapDsr.put(netCep1.key(), netCep1);
         }
-        String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(0))).findFirst().orElseThrow();
-        String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-
         // DSR top connection between edge xpdr CLIENT DSR
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
-            LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection connectionDsr =
+            createTopConnection(
+                //spcXpdr1,
+                xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+                    .findFirst().orElseThrow(),
+                //spcXpdr2,
+                xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+                    .findFirst().orElseThrow(),
+                cepMapDsr, TapiStringConstants.DSR, LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
         this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
-
         // DSR top connection that will be added to the service object
         Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
-        connServMap.put(conn1.key(), conn1);
-
-        return connServMap;
+        return new HashMap<>(Map.of(conn1.key(), conn1));
     }
 
-    private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
-                                                                          List<String> xpdrNetworkTplist,
-                                                                          List<String> xpdrNodelist) {
+    private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(
+            List<String> xpdrClientTplist, List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
         Map<ConnectionKey, Connection> connServMap = new HashMap<>();
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-            ConnectionEndPoint> cepMapDsr = new HashMap<>();
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-            ConnectionEndPoint> cepMapOdu = new HashMap<>();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapOdu = new HashMap<>();
         // 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<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
@@ -716,27 +722,26 @@ public final class ConnectivityUtils {
         // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
         for (String xpdr:xpdrNodelist) {
             LOG.info("Creating ceps and xc for xpdr {}", xpdr);
-            String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
-                .orElseThrow();
-            ConnectionEndPoint clientCep1 = createCepXpdr(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);
-            putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR,
-                clientCep2);
-
-            String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
-            ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
-
+            String spcXpdrClient =
+                xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+            ConnectionEndPoint clientCep1 =
+                createCepXpdr(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);
+            putXpdrCepInTopologyContext(
+                xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, clientCep2);
             cepMapDsr.put(clientCep1.key(), clientCep1);
             cepMapOdu.put(clientCep2.key(), clientCep2);
+
+            String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
             // Create x connection between I_ODU and E_ODU within xpdr
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-                connection = createXCBetweenCeps(clientCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
-                TapiStringConstants.ODU, LayerProtocolName.ODU);
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                    .connectivity.context.Connection connection =
+                createXCBetweenCeps(
+                    clientCep2, getAssociatediODUCep(spcXpdrNetwork),
+                     spcXpdrClient, spcXpdrNetwork, TapiStringConstants.ODU, LayerProtocolName.ODU);
             this.connectionFullMap.put(connection.key(), connection);
 
             // Create X connection that will be added to the service object
@@ -745,14 +750,18 @@ public final class ConnectivityUtils {
         }
 
         // DSR top connection between edge xpdr CLIENT DSR
-        String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(0))).findFirst().orElseThrow();
-        String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
-            LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
+        String spcXpdr1 =
+            xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+                .findFirst().orElseThrow();
+        String spcXpdr2 =
+            xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+                .findFirst().orElseThrow();
+
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection connectionOdu =
+            createTopConnection(
+                spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
+                LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
         this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
 
         // ODU top connection that will be added to the service object
@@ -761,62 +770,60 @@ public final class ConnectivityUtils {
         LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
         xcMap.put(lowerConn.key(), lowerConn);
 
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
-            LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection connectionDsr =
+            createTopConnection(
+                spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
+                LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
         this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
-
         // DSR top connection that will be added to the service object
         Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
         connServMap.put(conn1.key(), conn1);
-
         return connServMap;
     }
 
-    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
-                                                                           List<String> xpdrNodelist) {
+    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(
+            List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
         Map<ConnectionKey, Connection> connServMap = new HashMap<>();
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-            ConnectionEndPoint> cepMap = new HashMap<>();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
         // 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<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
-
         // 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);
-            String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
-                .orElseThrow();
-            ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
-                TapiStringConstants.XPDR, LayerProtocolName.ODU);
-            putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR,
-                netCep1);
-
+            String spcXpdrNetwork =
+                xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+            ConnectionEndPoint netCep1 =
+                createCepXpdr(
+                    spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
+            putXpdrCepInTopologyContext(
+                xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, netCep1);
             cepMap.put(netCep1.key(), netCep1);
         }
-
         // ODU top connection between edge xpdr i_ODU
-        String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(0))).findFirst().orElseThrow();
-        String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
-            LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
+        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(),
+                cepMap, TapiStringConstants.I_ODU,
+                LayerProtocolName.ODU, new HashMap<>(), this.topConnXpdrXpdrPhtn);
         this.connectionFullMap.put(connection.key(), connection);
-
         // ODU top connection that will be added to the service object
         Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
         connServMap.put(conn.key(), conn);
         this.topConnXpdrXpdrOdu = conn;
-
         return connServMap;
     }
 
-    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
-                                                                           List<String> xpdrNodelist) {
-
+    private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(
+                List<String> xpdrNetworkTplist, List<String> 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<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
@@ -824,64 +831,62 @@ public final class ConnectivityUtils {
         // create ceps and x connections within xpdr
         for (String xpdr:xpdrNodelist) {
             LOG.info("Creating ceps and xc for xpdr {}", xpdr);
-            String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
-                .orElseThrow();
+            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(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
-                TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
-            putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
-                TapiStringConstants.XPDR, netCep1);
-            ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.OTSI_MC,
-                TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
-            putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR,
-                netCep2);
+            ConnectionEndPoint netCep1 = createCepXpdr(
+                    spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
+                    TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
+            putXpdrCepInTopologyContext(
+                xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, netCep1);
+            ConnectionEndPoint netCep2 = createCepXpdr(
+                    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);
 
         }
-
         // OTSi top connection between edge OTSI_MC Xpdr
-        Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
-        String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(0))).findFirst().orElseThrow();
-        String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
-            .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.OTSI_MC,
-            LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
+        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(),
+                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
-        Map<ConnectionKey, Connection> connServMap = new HashMap<>();
+        // OTSi top connection that will be added to the service object
         Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
-        connServMap.put(conn.key(), conn);
         this.topConnXpdrXpdrPhtn = conn;
-
-        return connServMap;
+        return new HashMap<>(Map.of(conn.key(), conn));
     }
 
-    private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
-                                                                         List<String> rdmDegTplist,
-                                                                         List<String> rdmNodelist,
-                                                                         String edgeRoadm1, String edgeRoadm2) {
+    private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(
+            List<String> rdmAddDropTplist, List<String> rdmDegTplist, List<String> rdmNodelist,
+            String edgeRoadm1, String edgeRoadm2) {
         // TODO: will need to check if things exist already or not
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-            ConnectionEndPoint> cepMap = new HashMap<>();
+        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
         // create ceps and x connections within roadm
         Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
         for (String roadm : rdmNodelist) {
             LOG.info("Creating ceps and xc for roadm {}", roadm);
             if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
                 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
-                String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
-                    .orElseThrow();
+                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
@@ -917,16 +922,18 @@ public final class ConnectivityUtils {
 
                 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,
+                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                        .connectivity.context.Connection connection1 =
+                    createXCBetweenCeps(
+                        adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
                         LayerProtocolName.PHOTONICMEDIA);
-                LOG.info("Cross connection 1 created = {}", connection1.toString());
-                org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
-                    = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
-                    LayerProtocolName.PHOTONICMEDIA);
-                LOG.info("Cross connection 2 created = {}", connection2.toString());
+                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,
+                        LayerProtocolName.PHOTONICMEDIA);
+                LOG.info("Cross connection 2 created = {}", connection2);
                 this.connectionFullMap.put(connection1.key(), connection1);
                 this.connectionFullMap.put(connection2.key(), connection2);
 
@@ -954,8 +961,8 @@ public final class ConnectivityUtils {
                 cepMap.put(deg1Cep2.key(), deg1Cep2);
                 cepMap.put(deg1Cep3.key(), deg1Cep3);
 
-                String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
-                    .orElseThrow();
+                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);
@@ -973,24 +980,25 @@ public final class ConnectivityUtils {
 
                 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,
-                    TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
-                LOG.info("Cross connection 1 created = {}", connection1.toString());
-                org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
-                    = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
-                    TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
+                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                        .connectivity.context.Connection connection1 =
+                    createXCBetweenCeps(
+                        deg1Cep2, deg2Cep2, 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,
+                        TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
                 LOG.info("Cross connection 2 created = {}", connection2.toString());
                 this.connectionFullMap.put(connection1.key(), connection1);
                 this.connectionFullMap.put(connection2.key(), connection2);
 
                 // Create X connections that will be added to the service object
                 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
-                LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
-
                 xcLowerMap.put(conn1.key(), conn1);
+                LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
                 xcLowerMap.put(conn2.key(), conn2);
             }
         }
@@ -999,94 +1007,94 @@ public final class ConnectivityUtils {
         String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
         // MC top connection between edge roadms
         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,
-            LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection connection =
+            createTopConnection(
+                spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
+                LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
         this.connectionFullMap.put(connection.key(), connection);
-        LOG.info("Top connection created = {}", connection.toString());
+        LOG.info("Top connection created = {}", connection);
 
-        Map<ConnectionKey, Connection> connServMap = new HashMap<>();
-        // OTSiMC top connections that will be added to the service object
-        Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
-        connServMap.put(conn.key(), conn);
         LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
-        Map<LowerConnectionKey, LowerConnection> topLowerMap = new HashMap<>();
-        topLowerMap.put(conn1.key(), conn1);
-
         // OTSiMC top connection between edge roadms
         LOG.info("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,
-            LayerProtocolName.PHOTONICMEDIA, topLowerMap, null);
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection connection1 =
+            createTopConnection(
+                spcRdmAD1, spcRdmAD2, 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.toString());
+        LOG.info("Top connection created = {}", connection1);
 
         // 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();
-        connServMap.put(conn2.key(), conn2);
         this.topConnRdmRdm = conn2;
-        return connServMap;
+        return new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2));
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            createTopConnection(String tp1, String tp2,
-                        Map<org.opendaylight.yang.gen.v1.urn
-                            .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
-                            ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
-                        Map<LowerConnectionKey, LowerConnection> xcMap, Connection additionalLowerConn) {
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection createTopConnection(
+            String tp1,
+            String tp2,
+            Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                    .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap,
+            String qual, LayerProtocolName topPortocol,
+            Map<LowerConnectionKey, LowerConnection> xcMap,
+            Connection additionalLowerConn) {
         // find cep for each AD MC of roadm 1 and 2
-        LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
+        String topConnName = String.join("+", "TOP", tp1, tp2, qual);
+        LOG.info("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())));
+            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);
-        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.connection.ConnectionEndPointBuilder()
+        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
+                    .connection.ConnectionEndPointBuilder()
                 .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
                 .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
                 .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
                 .setConnectionEndPointUuid(adCep1.getUuid())
                 .build();
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
-            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", tp2.split("\\+")[0],
-                        qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
-                    .toString())));
+            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", tp2.split("\\+")[0], qual, tp2.split("\\+")[1]))
+                            .getBytes(StandardCharsets.UTF_8)).toString())));
         LOG.info("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.connection.ConnectionEndPointBuilder()
+        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
+                    .connection.ConnectionEndPointBuilder()
                 .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
                 .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
                 .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
                 .setConnectionEndPointUuid(adCep1.getUuid())
                 .build();
-        Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
-        ceps.put(cep1.key(), cep1);
-        ceps.put(cep2.key(), cep2);
         Name connName = new NameBuilder()
             .setValueName("Connection name")
-            .setValue(String.join("+", "TOP", tp1, tp2, qual))
+            .setValue(topConnName)
             .build();
         // TODO: lower connection, supported link.......
         if (additionalLowerConn != null) {
             xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
                 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
         }
-        return new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
-                .getBytes(StandardCharsets.UTF_8)).toString()))
+        return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.ConnectionBuilder()
+            .setUuid(new Uuid(UUID.nameUUIDFromBytes(topConnName.getBytes(StandardCharsets.UTF_8)).toString()))
             .setName(Map.of(connName.key(), connName))
-            .setConnectionEndPoint(ceps)
+            .setConnectionEndPoint(new HashMap<>(Map.of(cep1.key(), cep1, cep2.key(), cep2)))
             .setOperationalState(OperationalState.ENABLED)
             .setLayerProtocolName(topPortocol)
             .setLifecycleState(LifecycleState.INSTALLED)
@@ -1095,46 +1103,43 @@ public final class ConnectivityUtils {
             .build();
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
-            createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
-                        LayerProtocolName xcProtocol) {
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.Connection createXCBetweenCeps(
+            ConnectionEndPoint cep1, ConnectionEndPoint cep2,
+            String tp1, String tp2, String qual, LayerProtocolName xcProtocol) {
+        String crossConnName = String.join("+", "XC", tp1, tp2, qual);
         LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
-        LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
-        LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint().toString());
-        LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint().toString());
-        org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ1 =
-            new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
-            .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
-            .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
-            .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
-            .setConnectionEndPointUuid(cep1.getUuid())
-            .build();
-        org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ2 =
-            new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
-            .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
-            .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
-            .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
-            .setConnectionEndPointUuid(cep2.getUuid())
-            .build();
-        Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
-        ceps.put(cepServ1.key(), cepServ1);
-        ceps.put(cepServ2.key(), cepServ2);
+        LOG.info("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
+                .connection.ConnectionEndPoint cepServ1 =
+            new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                    .connection.ConnectionEndPointBuilder()
+                .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
+                .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
+                .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
+                .setConnectionEndPointUuid(cep1.getUuid())
+                .build();
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connection.ConnectionEndPoint cepServ2 =
+            new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                    .connection.ConnectionEndPointBuilder()
+                .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
+                .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
+                .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
+                .setConnectionEndPointUuid(cep2.getUuid())
+                .build();
         Name connName = new NameBuilder()
             .setValueName("Connection name")
-            .setValue(String.join("+", "XC", tp1, tp2, qual))
+            .setValue(crossConnName)
             .build();
         // TODO: lower connection, supported link.......
-        return new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
-                .getBytes(StandardCharsets.UTF_8)).toString()))
+        return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .connectivity.context.ConnectionBuilder()
+            .setUuid(new Uuid(UUID.nameUUIDFromBytes(crossConnName.getBytes(StandardCharsets.UTF_8)).toString()))
             .setName(Map.of(connName.key(), connName))
-            .setConnectionEndPoint(ceps)
+            .setConnectionEndPoint(new HashMap<>(Map.of(cepServ1.key(), cepServ1, cepServ2.key(), cepServ2)))
             .setOperationalState(OperationalState.ENABLED)
             .setLayerProtocolName(xcProtocol)
             .setLifecycleState(LifecycleState.INSTALLED)
@@ -1143,21 +1148,23 @@ public final class ConnectivityUtils {
     }
 
     private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
-        LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+        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(String.join("+", id.split("\\+")[0], qualifier,
-                id.split("\\+")[1]))
+            .setValue(nepId)
             .build();
         ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
-            .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
-                    qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
+            .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+                    nepId.getBytes(StandardCharsets.UTF_8))
+                .toString()))
+            .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
+                    nodeNepId.getBytes(StandardCharsets.UTF_8))
                 .toString()))
-            .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
-                    TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
+            .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
+                    TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
                 .toString()))
-            .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-                .getBytes(StandardCharsets.UTF_8)).toString()))
             .build();
         String clientQualifier = "";
         switch (qualifier) {
@@ -1178,25 +1185,27 @@ public final class ConnectivityUtils {
                     TapiStringConstants.OTSI_MC, onepOTSiMC);
                 break;
             default:
-                LOG.debug("not currently handling client NEP for OTSiMC CEP {}",
-                    String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+                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))
+            .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
+                        .getBytes(StandardCharsets.UTF_8))
                 .toString()))
-            .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
-                    TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
+            .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()))
-            .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))
+            .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))
@@ -1205,28 +1214,27 @@ public final class ConnectivityUtils {
             .setOperationalState(OperationalState.ENABLED)
             .setLifecycleState(LifecycleState.INSTALLED)
             .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
-        if (!(TapiStringConstants.OTSI_MC.equals(qualifier))) {
-            cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
-        }
-        return cepBldr.build();
+        return TapiStringConstants.OTSI_MC.equals(qualifier)
+            ? cepBldr.build()
+            : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
     }
 
-    private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
-                                             LayerProtocolName cepProtocol) {
+    private ConnectionEndPoint createCepXpdr(
+            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);
         Name cepName = new NameBuilder()
             .setValueName("ConnectionEndPoint name")
-            .setValue(String.join("+", id.split("\\+")[0], qualifier,
-                id.split("\\+")[1]))
+            .setValue(nepId)
             .build();
         ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
-            .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
-                    qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
-                .toString()))
-            .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
-                    TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
-                .toString()))
-            .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-                .getBytes(StandardCharsets.UTF_8)).toString()))
+            .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()))
             .build();
         String clientQualifier = "";
         String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA;
@@ -1243,26 +1251,25 @@ public final class ConnectivityUtils {
                 clientNodeLayer = TapiStringConstants.DSR;
                 break;
             default :
-                LOG.debug("no client CEP for DSR NEP {}",
-                    String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+                LOG.debug("no client CEP for DSR NEP {}", 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((String.join("+",id.split("\\+")[0],
-                    TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
-                .toString()))
-            .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-                .getBytes(StandardCharsets.UTF_8)).toString()))
+            .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
+                    .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()))
             .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()))
+            .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)
@@ -1270,15 +1277,14 @@ public final class ConnectivityUtils {
             .setOperationalState(OperationalState.ENABLED)
             .setLifecycleState(LifecycleState.INSTALLED)
             .setLayerProtocolName(cepProtocol);
-        if (!(TapiStringConstants.DSR.equals(qualifier))) {
-            cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
-        }
-        return cepBldr.build();
+        return TapiStringConstants.DSR.equals(qualifier)
+            ? cepBldr.build()
+            : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
     }
 
     private EndPoint mapServiceZEndPoint(
-        org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd
-            serviceZEnd, PathDescription pathDescription) {
+            org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                .service.ServiceZEnd serviceZEnd, PathDescription pathDescription) {
         EndPointBuilder endPointBuilder = new EndPointBuilder();
         // 1. Service Format: ODU, OTU, ETH
         ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
@@ -1302,13 +1308,11 @@ public final class ConnectivityUtils {
             default:
                 LOG.error("Service Format not supported");
         }
+        var portZEnd = serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
             new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
                 .setValueName("OpenROADM info")
-                .setValue(String.join("-", serviceZEnd.getClli(),
-                    serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
-                        .getPortDeviceName(),
-                    serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
+                .setValue(String.join("-", serviceZEnd.getClli(), portZEnd.getPortDeviceName(), portZEnd.getPortName()))
                 .build();
         return endPointBuilder
             .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
@@ -1325,12 +1329,11 @@ public final class ConnectivityUtils {
                     .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
                     .setUnit(CAPACITYUNITGBPS.VALUE)
                     .build())
-//                .setBandwidthProfile(new BandwidthProfileBuilder().build())
+//                .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
                 .build())
             .setProtectionRole(ProtectionRole.WORK)
             .setRole(PortRole.SYMMETRIC)
-            .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()
-                .getPort().getPortDeviceName())
+            .setLocalId(portZEnd.getPortDeviceName())
             .build();
     }
 
@@ -1360,13 +1363,11 @@ public final class ConnectivityUtils {
             default:
                 LOG.error("Service Format not supported");
         }
+        var portAEnd = serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
             new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
                 .setValueName("OpenROADM info")
-                .setValue(String.join("-", serviceAEnd.getClli(),
-                    serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
-                        .getPortDeviceName(),
-                    serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
+                .setValue(String.join("-", serviceAEnd.getClli(), portAEnd.getPortDeviceName(), portAEnd.getPortName()))
                 .build();
         return endPointBuilder
             .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
@@ -1393,203 +1394,217 @@ public final class ConnectivityUtils {
     }
 
     private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
-        Uuid zendUuid = null;
         if (serviceNodeId.contains("ROADM")) {
             // Service from ROADM to ROADM
             // AddDrop-AddDrop ports --> MC layer SIPs
-            ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
-                    .orElseThrow();
+            ZToA firstElement =
+                mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
             TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
-            Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
-                    tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
-                .toString());
+            Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
+                    .getBytes(StandardCharsets.UTF_8)).toString());
             LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
             for (ServiceInterfacePoint sip:this.sipMap.values()) {
-                if (!sip.getUuid().equals(sipUuid)) {
-                    LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
-                    continue;
+                if (sip.getUuid().equals(sipUuid)) {
+                    return sip.getUuid();
                 }
-                zendUuid = sip.getUuid();
-                break;
-            }
-        } else {
-            // Service from XPDR to XPDR
-            ZToA firstElement;
-            TerminationPoint tp;
-            Uuid sipUuid;
-            switch (serviceFormat) {
-                case ODU:
-                    firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
-                        tp.getTpId()));
-                    break;
-                case OTU:
-                    firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Network-Network ports --> iOTSi layer SIPs
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
-                        tp.getTpId()));
-                    break;
-                case Ethernet:
-                    LOG.info("Elements ZA = {}", mapztoa.values().toString());
-                    firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Client-client ports --> DSR layer SIPs
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
-                        tp.getTpId()));
-                    break;
-                default:
-                    sipUuid = null;
-                    LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+                LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
             }
-            for (ServiceInterfacePoint sip:this.sipMap.values()) {
-                if (!sip.getUuid().equals(sipUuid)) {
-                    LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
-                    continue;
-                }
-                zendUuid = sip.getUuid();
+            return null;
+        }
+        // Service from XPDR to XPDR
+        ZToA firstElement;
+        TerminationPoint tp;
+        Uuid sipUuid;
+        switch (serviceFormat) {
+            case ODU:
+                firstElement =
+                    mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
+                break;
+            case OTU:
+                firstElement =
+                    mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Network-Network ports --> iOTSi layer SIPs
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
+                break;
+            case Ethernet:
+                LOG.info("Elements ZA = {}", mapztoa.values());
+                firstElement =
+                    mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Client-client ports --> DSR layer SIPs
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
                 break;
+            default:
+                sipUuid = null;
+                LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+        }
+        for (ServiceInterfacePoint sip:this.sipMap.values()) {
+            if (sip.getUuid().equals(sipUuid)) {
+                return sip.getUuid();
             }
+            LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
         }
-        return zendUuid;
+        return null;
     }
 
     private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
-        Uuid aendUuid = null;
         LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
         LOG.info("Map a to z = {}", mapatoz);
         if (serviceNodeId.contains("ROADM")) {
             // Service from ROADM to ROADM
             // AddDrop-AddDrop ports --> MC layer SIPs
-            AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
-                    .orElseThrow();
+            AToZ firstElement =
+                mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
             LOG.info("First element of service path = {}", firstElement.getResource().getResource());
             TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
-            Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
-                    tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
-                .toString());
-            LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
-                tp.getTpId()));
+            Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
+                    .getBytes(StandardCharsets.UTF_8)).toString());
+            LOG.info("ROADM SIP name = {}",
+                String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
             for (ServiceInterfacePoint sip:this.sipMap.values()) {
-                if (!sip.getUuid().equals(sipUuid)) {
-                    LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
-                    continue;
+                if (sip.getUuid().equals(sipUuid)) {
+                    return sip.getUuid();
                 }
-                aendUuid = sip.getUuid();
-                break;
-            }
-        } else {
-            // Service from XPDR to XPDR
-            AToZ firstElement;
-            TerminationPoint tp;
-            Uuid sipUuid;
-            switch (serviceFormat) {
-                case ODU:
-                    firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
-                        TapiStringConstants.I_ODU, tp.getTpId()));
-                    break;
-                case OTU:
-                    firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Network-Network ports --> iOTSi layer SIPs
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
-                        TapiStringConstants.I_OTSI, tp.getTpId()));
-                    break;
-                case Ethernet:
-                    LOG.info("Elements AZ = {}", mapatoz.values().toString());
-                    firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
-                            .orElseThrow();
-                    tp = (TerminationPoint) firstElement.getResource().getResource();
-                    // Client-client ports --> DSR layer SIPs
-                    sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
-                            TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
-                    LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
-                        TapiStringConstants.DSR, tp.getTpId()));
-                    break;
-                default:
-                    sipUuid = null;
-                    LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+                LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
             }
-            for (ServiceInterfacePoint sip:this.sipMap.values()) {
-                if (!sip.getUuid().equals(sipUuid)) {
-                    LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
-                    continue;
-                }
-                aendUuid = sip.getUuid();
+            return null;
+        }
+        // Service from XPDR to XPDR
+        AToZ firstElement;
+        TerminationPoint tp;
+        Uuid sipUuid;
+        switch (serviceFormat) {
+            case ODU:
+                firstElement =
+                    mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("ODU XPDR SIP name = {}",
+                    String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
+                break;
+            case OTU:
+                firstElement =
+                    mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Network-Network ports --> iOTSi layer SIPs
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("OTU XPDR SIP name = {}",
+                    String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
                 break;
+            case Ethernet:
+                LOG.info("Elements AZ = {}", mapatoz.values());
+                firstElement =
+                    mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
+                tp = (TerminationPoint) firstElement.getResource().getResource();
+                // Client-client ports --> DSR layer SIPs
+                sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
+                        .getBytes(StandardCharsets.UTF_8)).toString());
+                LOG.info("DSR XPDR SIP name = {}",
+                    String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
+                break;
+            default:
+                sipUuid = null;
+                LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+        }
+        for (ServiceInterfacePoint sip:this.sipMap.values()) {
+            if (sip.getUuid().equals(sipUuid)) {
+                return sip.getUuid();
             }
+            LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
         }
-        return aendUuid;
+        return null;
     }
 
     private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
-        LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
-        LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
+        String nepId = String.join("+", node, qual, spcRdmAD.split("\\+")[1]);
+        String nodeNepId = String.join("+", node, TapiStringConstants.PHTNC_MEDIA);
+        LOG.info("NEP id before Merge = {}", nepId);
+        LOG.info("Node of NEP id before Merge = {}", nodeNepId);
         // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
-        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
+        this.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);
     }
 
-    private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
-                                             ConnectionEndPoint cep) {
+    private void putXpdrCepInTopologyContext(
+            String node, String spcXpdrNet, String qual, String nodeLayer, ConnectionEndPoint cep) {
         // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
-        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
+        this.tapiContext.updateTopologyWithCep(
+            //topoUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                    TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
+                .toString()),
+            //nodeUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                    String.join("+", node, nodeLayer).getBytes(StandardCharsets.UTF_8))
+                .toString()),
+            //nepUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                    String.join("+", node, qual, spcXpdrNet.split("\\+")[1]).getBytes(StandardCharsets.UTF_8))
+                .toString()),
+            cep);
     }
 
 
     private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
-        LOG.info("NEP id before Merge = {}", String.join("+", orNodeId, qual, orTpId));
-        LOG.info("Node of NEP id before Merge = {}", String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA));
+        String nepId = String.join("+", orNodeId, qual, orTpId);
+        String nepNodeId = String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA);
+        LOG.info("NEP id before Merge = {}", nepId);
+        LOG.info("Node of NEP id before Merge = {}", nepNodeId);
         // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
-        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-            .getBytes(Charset.forName("UTF-8"))).toString());
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)
-            .getBytes(Charset.forName("UTF-8"))).toString());
-        Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, qual, orTpId)
-            .getBytes(Charset.forName("UTF-8"))).toString());
-        updateTopologyWithNep(topoUuid, nodeUuid, nepUuid, onep);
+        updateTopologyWithNep(
+            //topoUuid,
+             new Uuid(UUID.nameUUIDFromBytes(
+                    TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+                 .toString()),
+            //nodeUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                    nepNodeId.getBytes(Charset.forName("UTF-8")))
+                .toString()),
+            //nepUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                    nepId.getBytes(Charset.forName("UTF-8")))
+                .toString()),
+            onep);
     }
 
     private String getIdBasedOnModelVersion(String nodeid) {
-        return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
-            nodeid.split("-")[1]) : nodeid.split("-")[0];
+        return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")
+            ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
+            : nodeid.split("-")[0];
     }
 
     private ServiceZEnd tapiEndPointToServiceZPoint(
-        org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
-        ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPoint endPoint,
+            ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
         // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
         //  Not the rest which is needed in the txPortDeviceName.
         //  It could be obtained from the SIP which has the NEP and includes all the OR name.
@@ -1606,10 +1621,8 @@ public final class ConnectivityUtils {
         //  connection is between 2 CLIENT ports. Otherwise it will not work...
         OwnedNodeEdgePoint nep = null;
         for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
-            if (onep.getMappedServiceInterfacePoint() == null) {
-                continue;
-            }
-            if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
+            if (onep.getMappedServiceInterfacePoint() != null
+                    && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
                 nep = onep;
                 break;
             }
@@ -1619,8 +1632,9 @@ public final class ConnectivityUtils {
             return null;
         }
         String nodeName = "";
-        for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
-                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
+        for (Map.Entry<
+                    org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
+                    org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
                 endPoint.getName().entrySet()) {
             if (!("Node Type").equals(entry.getValue().getValueName())) {
                 nodeName = entry.getValue().getValue();
@@ -1688,21 +1702,22 @@ public final class ConnectivityUtils {
         if (serviceFormat.equals(ServiceFormat.OTU)) {
             serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
         }
-        if (!serviceLayer.equals(LayerProtocolName.ETH)) {
-            serviceZEndBuilder
-                .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
+        return serviceLayer.equals(LayerProtocolName.ETH)
+            ? serviceZEndBuilder.build()
+            : serviceZEndBuilder
+                .setEthernetAttributes(new EthernetAttributesBuilder()
+                    .setSubrateEthSla(new SubrateEthSlaBuilder()
                         .setCommittedBurstSize(Uint16.valueOf(64))
                         .setCommittedInfoRate(Uint32.valueOf(100000))
                         .build())
-                    .build());
-        }
-        return serviceZEndBuilder.build();
+                    .build())
+                .build();
     }
 
     private ServiceAEnd tapiEndPointToServiceAPoint(
-        org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
-        ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPoint endPoint,
+            ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
         // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
         //  Not the rest which is needed in the txPortDeviceName.
         //  It could be obtained from the SIP which has the NEP and includes all the OR name.
@@ -1720,10 +1735,8 @@ public final class ConnectivityUtils {
         //  connection is between 2 CLIENT ports. Otherwise it will not work...
         OwnedNodeEdgePoint nep = null;
         for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
-            if (onep.getMappedServiceInterfacePoint() == null) {
-                continue;
-            }
-            if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
+            if (onep.getMappedServiceInterfacePoint() != null
+                    && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
                 nep = onep;
                 break;
             }
@@ -1733,9 +1746,10 @@ public final class ConnectivityUtils {
             return null;
         }
         String nodeName = "";
-        for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
+        for (Map.Entry<
+                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
-                endPoint.getName().entrySet()) {
+                    endPoint.getName().entrySet()) {
             if (!("Node Type").equals(entry.getValue().getValueName())) {
                 nodeName = entry.getValue().getValue();
             }
@@ -1760,8 +1774,8 @@ public final class ConnectivityUtils {
             .setServiceFormat(serviceFormat)
             .setServiceRate(Uint32.valueOf(capacity))
             .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
-                    new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth
-                        .sla.SubrateEthSlaBuilder()
+                    new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+                            .subrate.eth.sla.SubrateEthSlaBuilder()
                         .setCommittedBurstSize(Uint16.valueOf(64))
                         .setCommittedInfoRate(Uint32.valueOf(100000))
                         .build())
@@ -1803,49 +1817,64 @@ public final class ConnectivityUtils {
         } else if (serviceFormat.equals(ServiceFormat.OTU)) {
             serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
         }
-        if (!serviceLayer.equals(LayerProtocolName.ETH)) {
-            serviceAEndBuilder
-                .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
+        return serviceLayer.equals(LayerProtocolName.ETH)
+            ? serviceAEndBuilder.build()
+            : serviceAEndBuilder
+                .setEthernetAttributes(new EthernetAttributesBuilder()
+                    .setSubrateEthSla(new SubrateEthSlaBuilder()
                         .setCommittedBurstSize(Uint16.valueOf(64))
                         .setCommittedInfoRate(Uint32.valueOf(100000))
                         .build())
-                    .build());
-        }
-        return serviceAEndBuilder.build();
+                    .build())
+                .build();
     }
 
-    private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
-        if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
-                .anyMatch(name -> name.getValue().contains("ROADM")))) {
+    private ConnectionType getConnectionTypePhtnc(
+            Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPoint> endPoints) {
+        return endPoints.stream()
+                .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
             // EndPoints are ROADMs
-            return ConnectionType.RoadmLine;
-        }
-        // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
-        return ConnectionType.Infrastructure;
+            ? ConnectionType.RoadmLine
+            // EndPoints are not ROADMs -> XPDR, MUXPDR, SWTICHPDR
+            : ConnectionType.Infrastructure;
     }
 
-    private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
-            .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
-        if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
-                .anyMatch(name -> name.getValue().contains("ROADM")))) {
+    private ServiceFormat getServiceFormatPhtnc(
+            Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+                .create.connectivity.service.input.EndPoint> endPoints) {
+        return endPoints.stream()
+                .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
             // EndPoints are ROADMs
-            return ServiceFormat.OC;
-        }
-        // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
-        return ServiceFormat.OTU;
+            ? ServiceFormat.OC
+            // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
+            : ServiceFormat.OTU;
     }
 
     private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
-            TapiStringConstants.XPDR).getBytes(StandardCharsets.UTF_8))).toString());
-        Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
-                TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8)))
-            .toString());
-        Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
-            spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
+        return this.tapiContext.getTapiCEP(
+            this.tapiTopoUuid,
+            //nodeUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+",
+                        spcXpdrNetwork.split("\\+")[0],
+                        TapiStringConstants.XPDR)
+                    .getBytes(StandardCharsets.UTF_8))).toString()),
+            //nepUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+",
+                        spcXpdrNetwork.split("\\+")[0],
+                        TapiStringConstants.I_ODU,
+                        spcXpdrNetwork.split("\\+")[1])
+                    .getBytes(StandardCharsets.UTF_8))).toString()),
+            //cepUuid,
+            new Uuid(UUID.nameUUIDFromBytes(
+                (String.join("+",
+                        "CEP",
+                        spcXpdrNetwork.split("\\+")[0],
+                        TapiStringConstants.I_ODU,
+                        spcXpdrNetwork.split("\\+")[1]))
+                    .getBytes(StandardCharsets.UTF_8)).toString()));
     }
 
     private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
@@ -1860,21 +1889,23 @@ public final class ConnectivityUtils {
     private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
         List<String> clientPortList = new ArrayList<>();
         for (String networkPort:xpdrNetworkTplist) {
-            String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
+            String nodeId = String.join("-",
+                networkPort.split("\\+")[0].split("-")[0],
                 networkPort.split("\\+")[0].split("-")[1]);
             String tpId = networkPort.split("\\+")[1];
             InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
                 .child(Nodes.class, new NodesKey(nodeId))
                 .child(Mapping.class, new MappingKey(tpId)).build();
             try {
-                Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
-                    mapIID).get();
-                if (!optMapping.isPresent()) {
+                Optional<Mapping> optMapping =
+                    this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, mapIID).get();
+                if (optMapping.isEmpty()) {
                     LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
                 }
                 Mapping mapping = optMapping.orElseThrow();
                 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
-                String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
+                String key = String.join("+",
+                    String.join("-", nodeId, tpId.split("\\-")[0]),
                     mapping.getConnectionMapLcp());
                 LOG.info("Key to be added to list = {}", key);
                 if (!clientPortList.contains(key)) {
@@ -1892,23 +1923,28 @@ public final class ConnectivityUtils {
     private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
         List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
         for (String xpdrNode:xpdrNodelist) {
-            Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.XPDR))
-                .getBytes(StandardCharsets.UTF_8)).toString());
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeIID = InstanceIdentifier.builder(
-                    Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.topology.rev221121.Context1.class).child(TopologyContext.class)
-                .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
-                .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
-                    new NodeKey(nodeUuid)).build();
+            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                    .topology.Node> nodeIID =
+                InstanceIdentifier.builder(Context.class)
+                    .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
+                    .child(TopologyContext.class)
+                    .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
+                    .child(
+                        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
+                        new NodeKey(
+                            //nodeUUID
+                            new Uuid(UUID.nameUUIDFromBytes(
+                                (String.join("+",xpdrNode, TapiStringConstants.XPDR))
+                                    .getBytes(StandardCharsets.UTF_8)).toString())))
+                    .build();
             try {
-                Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode
-                    this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
+                Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode =
+                    this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
                 if (optNode.isEmpty()) {
                     return null;
                 }
-                OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
-                    new NameKey("Node Type")).getValue());
+                OpenroadmNodeType openroadmNodeType =
+                    OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(new NameKey("Node Type")).getValue());
                 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
                     openroadmNodeTypeList.add(openroadmNodeType);
                 }
@@ -1918,47 +1954,41 @@ public final class ConnectivityUtils {
             }
         }
         // TODO for now check that there is only one type, otherwise error
-        if (openroadmNodeTypeList.size() != 1) {
-            LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
-            return null;
+        if (openroadmNodeTypeList.size() == 1) {
+            return openroadmNodeTypeList.get(0);
         }
-        return openroadmNodeTypeList.get(0);
+        LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
+        return null;
     }
 
-    private OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId,
-        boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
-
+    private OwnedNodeEdgePoint createRoadmNep(
+            String orNodeId, String tpId, boolean withSip,
+            OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
         //TODO : complete implementation with SIP
-        Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, nepPhotonicSublayer,
-                tpId)).getBytes(StandardCharsets.UTF_8)).toString());
         Name nepName = new NameBuilder()
                 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
                 .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
                 .build();
-        List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
-        if (TapiStringConstants.MC.equals(nepPhotonicSublayer)) {
-            sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE)
-                .setNumberOfCepInstances(Uint64.valueOf(1))
-                .build());
-        } else {
-            sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
-                .setNumberOfCepInstances(Uint64.valueOf(1))
-                .build());
-        }
-        OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
-            .setUuid(nepUuid)
+        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(sclpqiList)
+            .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();
-
-        return onep;
     }
-
 }
index 9fbabba9a5eabc90c3c1c5fea83d33755d7b2d61..3137fabb154cf7ad06e837fccf061da861efe1c1 100644 (file)
@@ -21,9 +21,9 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
index 3aaeeef7fd07e2d89807de58420cb8750a275f9e..c4f589036cddcca70f5ceaa2a5cee015dfaa24cf 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.PpAttributes;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.XpdrNetworkAttributes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
@@ -67,16 +66,13 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITAL
 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.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;
 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.OccupiedSpectrumBuilder;
 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.SupportableSpectrumBuilder;
 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.FORWARDINGRULEMAYFORWARDACROSSGROUP;
@@ -87,7 +83,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.no
 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.RiskParameterPac;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructure;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructureBuilder;
@@ -146,116 +141,102 @@ public class ConvertORToTapiTopology {
 
     public void convertNode(Node ietfNode, List<String> networkPorts) {
         this.ietfNodeId = ietfNode.getNodeId().getValue();
-        if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
-                == null) {
+        var ietfAug =
+            ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class);
+        if (ietfAug == null) {
             return;
         }
-        this.ietfNodeType = ietfNode.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
-        this.ietfNodeAdminState = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
-            .getAdministrativeState();
-        this.ietfNodeOperState = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
-            .getOperationalState();
-        this.oorNetworkPortList = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
-            .getTerminationPoint().values().stream()
+        this.ietfNodeType = ietfAug.getNodeType();
+        this.ietfNodeAdminState = ietfAug.getAdministrativeState();
+        this.ietfNodeOperState = ietfAug.getOperationalState();
+        var ietfAugTopo =
+            ietfNode.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
+        this.oorNetworkPortList = ietfAugTopo.getTerminationPoint().values().stream()
             .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                == OpenroadmTpType.XPONDERNETWORK.getIntValue()
+                    == OpenroadmTpType.XPONDERNETWORK.getIntValue()
                 && networkPorts.contains(tp.getTpId().getValue()))
             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
             .collect(Collectors.toList());
-        if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
-            this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
-                .values().stream().findFirst().orElseThrow();
-            this.oorClientPortList = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
-                .getTerminationPoint().values().stream()
-                .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                    == OpenroadmTpType.XPONDERCLIENT.getIntValue())
-                .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
-                .collect(Collectors.toList());
-        } else {
+        if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
             this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
             List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
                 .flatMap(nbl -> nbl.getTpList().stream())
                 .collect(Collectors.toList());
-            this.oorClientPortList = ietfNode.augmentation(
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
-                .getTerminationPoint().values().stream()
+            this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
                 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                    == OpenroadmTpType.XPONDERCLIENT.getIntValue() && tpList.contains(tp.getTpId()))
+                        == OpenroadmTpType.XPONDERCLIENT.getIntValue()
+                    && tpList.contains(tp.getTpId()))
                 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
                 .collect(Collectors.toList());
             this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
+        } else {
+            this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
+                .values().stream().findFirst().orElseThrow();
+            this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
+                .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
+                    == OpenroadmTpType.XPONDERCLIENT.getIntValue())
+                .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
+                .collect(Collectors.toList());
         }
 
         // node creation [DSR/ODU] ([DSR/ODU] and OTSI merged in R 2.4.X)
         LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
-            TapiStringConstants.XPDR)).getBytes(Charset.forName("UTF-8"))).toString());
-        this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR), nodeUuid);
-        Name nameDsr = new NameBuilder().setValueName("dsr/odu node name")
-            .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR)).build();
-        Name namePhot = new NameBuilder().setValueName("otsi node name")
-            .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR)).build();
-        Name nameNodeType = new NameBuilder().setValueName("Node Type")
-            .setValue(this.ietfNodeType.getName()).build();
-        Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
-            LayerProtocolName.DIGITALOTN,LayerProtocolName.PHOTONICMEDIA);
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
-            .Node dsrNode = createTapiNode(Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(),
-                nameNodeType), dsrLayerProtocols);
-        LOG.debug("XPDR Node {} should have {} NEPs and SIPs", this.ietfNodeId,
-            this.oorClientPortList.size() + this.oorNetworkPortList.size());
-        LOG.info("XPDR Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
-            dsrNode.getOwnedNodeEdgePoint().values().size(), dsrNode.getOwnedNodeEdgePoint().values().stream()
+        String nodeIdXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
+        this.uuidMap.put(nodeIdXpdr,
+                //nodeUuid
+                new Uuid(UUID.nameUUIDFromBytes(nodeIdXpdr.getBytes(Charset.forName("UTF-8"))).toString()));
+        Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(nodeIdXpdr).build();
+        Name namePhot = new NameBuilder().setValueName("otsi node name").setValue(nodeIdXpdr).build();
+        Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                .topology.Node dsrNode =
+            createTapiNode(
+                Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(), nameNodeType),
+                //dsrLayerProtocols
+                Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
+                       LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA));
+        LOG.debug("XPDR Node {} should have {} NEPs and SIPs",
+            this.ietfNodeId, this.oorClientPortList.size() + this.oorNetworkPortList.size());
+        LOG.info("XPDR Node {} has {} NEPs and {} SIPs",
+            this.ietfNodeId,
+            dsrNode.getOwnedNodeEdgePoint().values().size(),
+            dsrNode.getOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
         tapiNodes.put(dsrNode.key(), dsrNode);
     }
 
-    public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
-            String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
+    public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(
+            String topoType, Uuid nodeUuid, String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
-            nepMap = new HashMap<>();
+                nepMap = new HashMap<>();
         for (OwnedNodeEdgePoint onep : onepl) {
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
-                nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group
-                    .NodeEdgePointBuilder()
+            var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                    .node.rule.group.NodeEdgePointBuilder()
                 .setTopologyUuid(tapiTopoUuid)
                 .setNodeUuid(nodeUuid)
                 .setNodeEdgePointUuid(onep.key().getUuid())
                 .build();
             nepMap.put(nep.key(), nep);
         }
-        String rdmName =
-            topoType.equals("Abstracted")
-                ? "rdm infra node rule group"
-                : orNodeId + " node rule group";
-        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
-        Set<RuleType> ruleTypes = new HashSet<>();
-        ruleTypes.add(RuleType.FORWARDING);
-        Map<RuleKey, Rule> ruleList = new HashMap<>();
         Rule rule = new RuleBuilder()
             .setLocalId("forward")
             .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
-            .setRuleType(ruleTypes)
+            .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
             .build();
-        ruleList.put(rule.key(), rule);
         NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes((rdmName)
+            .setUuid(new Uuid(UUID.nameUUIDFromBytes((
+                    topoType.equals("Abstracted") ? "rdm infra node rule group" : orNodeId + " node rule group")
                 .getBytes(Charset.forName("UTF-8"))).toString()))
-            .setRule(ruleList)
+            .setRule(new HashMap<>(Map.of(rule.key(), rule)))
             .setNodeEdgePoint(nepMap)
             .build();
-        nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
-        return nodeRuleGroupMap;
+        return new HashMap<>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
     }
 
-    public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
-            LayerProtocolName layerProtocol, String tpId, String nodeid,
+    public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(
+            int nb, LayerProtocolName layerProtocol, String tpId, String nodeid,
             Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
             OperationalState operState, AdministrativeState adminState) {
         // add them to SIP context
@@ -264,13 +245,14 @@ public class ConvertORToTapiTopology {
             String sipName =
                 nb == 1
                     ? String.join("+", "SIP", nodeid, tpId)
-                    : String.join("+", "SIP", nodeid, tpId,"Nber", String.valueOf(i));
+                    : String.join("+", "SIP", nodeid, tpId, "Nber", String.valueOf(i));
             LOG.info("SIP = {}", sipName);
             Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(sipName.getBytes(Charset.forName("UTF-8"))).toString());
             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
-                .setServiceInterfacePointUuid(sipUuid).build();
-            ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability,
-                operState, adminState);
+                .setServiceInterfacePointUuid(sipUuid)
+                .build();
+            ServiceInterfacePoint sip =
+                createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability, operState, adminState);
             this.tapiSips.put(sip.key(), sip);
             msipl.put(msip.key(), msip);
             LOG.debug("SIP created {}", sip.getUuid());
@@ -279,8 +261,10 @@ public class ConvertORToTapiTopology {
         return msipl;
     }
 
-    public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(Boolean otsiProvisioned,
-            Collection<SupportedInterfaceCapability> sicList, List<OperationalModeKey> supportedOpModes) {
+    public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(
+            Boolean otsiProvisioned,
+            Collection<SupportedInterfaceCapability> sicList,
+            List<OperationalModeKey> supportedOpModes) {
         if (supportedOpModes == null || supportedOpModes.isEmpty()) {
             return null;
         }
@@ -304,24 +288,21 @@ public class ConvertORToTapiTopology {
                 nepRate = loopRate;
             }
         }
-        CapacityBuilder capBd = new CapacityBuilder()
-            .setUnit(CAPACITYUNITGBPS.VALUE);
         List<AvailablePayloadStructure> aps = new ArrayList<>();
-        Integer cepInstanceNber = 1;
-        if (otsiProvisioned) {
-            cepInstanceNber = 0;
-        }
+        Integer cepInstanceNber = otsiProvisioned ? 0 : 1;
         for (SupportedInterfaceCapability sic : sicList) {
-            String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
-            switch (ifCapType) {
+            switch (sic.getIfCapType().toString().split("\\{")[0]) {
                 case "IfOCHOTU4ODU4":
                 case "IfOCHOTU4ODU4Regen":
                 case "IfOCHOTU4ODU4Uniregen":
                     aps.add(new AvailablePayloadStructureBuilder()
                         .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
                         .setNumberOfCepInstances(Uint64.valueOf(cepInstanceNber))
-                        .setCapacity(capBd.setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
-                            .build())
+                        .setCapacity(
+                            new CapacityBuilder()
+                                .setUnit(CAPACITYUNITGBPS.VALUE)
+                                .setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
+                                .build())
                         .build());
                     break;
                 case "IfOCHOTUCnODUCn":
@@ -333,8 +314,10 @@ public class ConvertORToTapiTopology {
                             ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
                         .setNumberOfCepInstances(Uint64.valueOf(nepRate * cepInstanceNber))
                         .setCapacity(
-                            capBd.setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
-                            .build())
+                            new CapacityBuilder()
+                                .setUnit(CAPACITYUNITGBPS.VALUE)
+                                .setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
+                                .build())
                         .build());
                     break;
                 default:
@@ -369,8 +352,6 @@ public class ConvertORToTapiTopology {
                 nepRate = loopRate;
             }
         }
-        CapacityBuilder capBd = new CapacityBuilder()
-            .setUnit(CAPACITYUNITGBPS.VALUE);
         List<SupportedPayloadStructure> sps = new ArrayList<>();
         for (SupportedInterfaceCapability sic : sicList) {
             String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
@@ -381,7 +362,11 @@ public class ConvertORToTapiTopology {
                     sps.add(new SupportedPayloadStructureBuilder()
                         .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
                         .setNumberOfCepInstances(Uint64.valueOf(1))
-                        .setCapacity(capBd.setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN)).build())
+                        .setCapacity(
+                            new CapacityBuilder()
+                                .setUnit(CAPACITYUNITGBPS.VALUE)
+                                .setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN))
+                                .build())
                         .build());
                     break;
                 case "IfOCHOTUCnODUCn":
@@ -389,10 +374,15 @@ public class ConvertORToTapiTopology {
                 case "IfOCHOTUCnODUCnRegen":
                 case "IfOCHOTUCnODUCnUniregen":
                     sps.add(new SupportedPayloadStructureBuilder()
-                        .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
+                        .setMultiplexingSequence(Set.of(
+                            PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
                             ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
                         .setNumberOfCepInstances(Uint64.valueOf(nepRate))
-                        .setCapacity(capBd.setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN)).build())
+                        .setCapacity(
+                            new CapacityBuilder()
+                                .setUnit(CAPACITYUNITGBPS.VALUE)
+                                .setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN))
+                                .build())
                         .build());
                     break;
                 default:
@@ -406,15 +396,15 @@ public class ConvertORToTapiTopology {
         justification = "Voluntarily No break in switchcase where comment is inserted in following method")
     public List<SupportedCepLayerProtocolQualifierInstances> createSupportedCepLayerProtocolQualifier(
             Collection<SupportedInterfaceCapability> sicList, LayerProtocolName lpn) {
-        List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
         if (sicList == null) {
-            sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
-                .setNumberOfCepInstances(Uint64.valueOf(1))
-                .build());
-            return sclpqiList;
+            return new ArrayList<>(List.of(
+                new SupportedCepLayerProtocolQualifierInstancesBuilder()
+                    .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
+                    .setNumberOfCepInstances(Uint64.valueOf(1))
+                    .build()));
         }
         LOG.debug("SIC list = {}", sicList);
+        List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
         for (SupportedInterfaceCapability sic : sicList) {
             String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
             switch (lpn.getName()) {
@@ -561,122 +551,102 @@ public class ConvertORToTapiTopology {
     }
 
     public Map<Double, Double> getXpdrUsedWavelength(TerminationPoint tp) {
-        if (tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
-                    .TerminationPoint1.class) == null
-                || tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
-                    .network.topology.rev230526.TerminationPoint1.class).getXpdrNetworkAttributes()
-                == null) {
+        var tpAug = tp.augmentation(
+            org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
+        if (tpAug == null || tpAug.getXpdrNetworkAttributes() == null) {
             return null;
         }
-        XpdrNetworkAttributes xnatt = tp.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
-            .getXpdrNetworkAttributes();
-        Map<Double,Double> freqWidthMap = new HashMap<>();
-        if (xnatt.getWavelength() != null && xnatt.getWavelength().getFrequency() != null
-                && xnatt.getWavelength().getWidth() != null) {
-            freqWidthMap.put(xnatt.getWavelength().getFrequency().getValue().doubleValue(),
-                xnatt.getWavelength().getWidth().getValue().doubleValue());
-            return freqWidthMap;
-        }
-        return null;
+        var xnattWvlgth = tpAug.getXpdrNetworkAttributes().getWavelength();
+        return xnattWvlgth == null || xnattWvlgth.getFrequency() == null || xnattWvlgth.getWidth() == null
+            ? null
+            : new HashMap<>(Map.of(
+                xnattWvlgth.getFrequency().getValue().doubleValue(),
+                xnattWvlgth.getWidth().getValue().doubleValue()));
     }
 
     public Map<Double, Double> getPPUsedWavelength(TerminationPoint tp) {
         PpAttributes ppAtt = tp.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
+                org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
             .getPpAttributes();
-        if (ppAtt == null) {
-            return null;
-        }
-        Map<Double,Double> freqWidthMap = new HashMap<>();
-        if (ppAtt.getUsedWavelength() != null && ppAtt.getUsedWavelength().entrySet().iterator().next() != null) {
-            freqWidthMap.put(ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue()
-                .doubleValue(), ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
-                .getValue().doubleValue());
-            return freqWidthMap;
-        }
-        return null;
+        return ppAtt == null || ppAtt.getUsedWavelength() == null
+                || ppAtt.getUsedWavelength().entrySet().iterator().next() == null
+            ? null
+            : new HashMap<>(Map.of(
+            ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue().doubleValue(),
+            ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue().doubleValue()));
     }
 
-    public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(String nodeId,
-            Map<Double, Double> freqWidthMap, List<OperationalModeKey> operModeList,
+    public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(
+            String nodeId, Map<Double, Double> freqWidthMap, List<OperationalModeKey> operModeList,
             Collection<SupportedInterfaceCapability> sicColl, OwnedNodeEdgePointBuilder onepBldr, String keyword) {
-        if (String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
-                || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
-            //Creating OTS & OTSI_MC NEP specific attributes
-            onepBldr.setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(
-                sicColl,operModeList));
-            SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
-            OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
-            if (freqWidthMap == null || freqWidthMap.isEmpty()) {
-                ospecBd
-                    .setUpperFrequency(Uint64.valueOf(0))
-                    .setLowerFrequency(Uint64.valueOf(0));
-                onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
-                    false, sicColl,operModeList));
-                double naz = 0.01;
-                AvailableSpectrum  aspec = new AvailableSpectrumBuilder()
-                    .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
-                    .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                        + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
-                    .build();
-                Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
-                aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
-                    aspec.getUpperFrequency()), aspec);
-                spectrumPac.setAvailableSpectrum(aspecMap);
-            } else {
-                onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
-                    true, sicColl,operModeList));
-                ospecBd
-                    .setUpperFrequency(Uint64.valueOf(Math.round(
-                        freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
-                        + (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2)))
-                    .setLowerFrequency(Uint64.valueOf(Math.round(
-                        freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
-                        - (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2)));
-            }
-            OccupiedSpectrum ospec = ospecBd.build();
-            Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
-            ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(),
-                ospec.getUpperFrequency()), ospec);
-            spectrumPac.setOccupiedSpectrum(ospecMap);
-            double nazz = 0.01;
-            SupportableSpectrum  sspec = new SupportableSpectrumBuilder()
-                .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
-                .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                    + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
-                .build();
-            Map<SupportableSpectrumKey, SupportableSpectrum> 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);
+        if (!String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
+                && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
+            return onepBldr;
+        }
+        //Creating OTS & OTSI_MC NEP specific attributes
+        double naz = 0.01;
+        Uint64 supLoFreq = Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz));
+        Uint64 supUpFreq = Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
+                + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz));
+        boolean boolParam;
+        Uint64 upFreq;
+        Uint64 loFreq;
+        SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
+        if (freqWidthMap == null || freqWidthMap.isEmpty()) {
+            upFreq = Uint64.valueOf(0);
+            loFreq = Uint64.valueOf(0);
+            boolParam = false;
+            AvailableSpectrum  aspec =
+                new AvailableSpectrumBuilder().setUpperFrequency(supUpFreq).setLowerFrequency(supLoFreq).build();
+            spectrumPac.setAvailableSpectrum(new HashMap<>(Map.of(
+                new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec)));
+        } else {
+            upFreq = Uint64.valueOf(Math.round(
+                    freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
+                    + (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2));
+            loFreq = Uint64.valueOf(Math.round(
+                    freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
+                    - (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2));
+            boolParam = true;
         }
-        return onepBldr;
+        return onepBldr
+            .setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(sicColl, operModeList))
+            .setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(boolParam, sicColl,operModeList))
+            .addAugmentation(
+                new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
+                        .OwnedNodeEdgePoint1Builder()
+                    .setPhotonicMediaNodeEdgePointSpec(
+                        new PhotonicMediaNodeEdgePointSpecBuilder()
+                            .setSpectrumCapabilityPac(
+                                spectrumPac
+                                    .setOccupiedSpectrum(new HashMap<>(Map.of(
+                                        new OccupiedSpectrumKey(loFreq, upFreq),
+                                        new OccupiedSpectrumBuilder()
+                                            .setUpperFrequency(upFreq)
+                                            .setLowerFrequency(loFreq)
+                                            .build())))
+                                    .setSupportableSpectrum(new HashMap<>(Map.of(
+                                        new SupportableSpectrumKey(supLoFreq, supUpFreq),
+                                        new SupportableSpectrumBuilder()
+                                            .setUpperFrequency(supUpFreq)
+                                            .setLowerFrequency(supLoFreq)
+                                            .build())))
+                                    .build())
+                            .build())
+                    .build());
     }
 
     private OduSwitchingPools createOduSwitchingPoolForTp100G() {
         Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
         int count = 1;
         for (TerminationPoint tp : this.oorNetworkPortList) {
-            TpId tpid1 = tp.getTpId();
-            TpId tpid2 = tp.augmentation(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1.class)
-                .getAssociatedConnectionMapTp().iterator().next();
-            Set<TpId> tpList = new HashSet<>();
-            tpList.add(tpid1);
-            tpList.add(tpid2);
             NonBlockingList nbl = new NonBlockingListBuilder()
                 .setNblNumber(Uint16.valueOf(count))
-                .setTpList(tpList)
+                .setTpList(new HashSet<>(Set.of(
+                    tp.getTpId(),
+                    tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526
+                            .TerminationPoint1.class)
+                        .getAssociatedConnectionMapTp().iterator().next())))
                 .build();
             nblMap.put(nbl.key(), nbl);
             count++;
@@ -687,26 +657,23 @@ public class ConvertORToTapiTopology {
             .build();
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node
-            createTapiNode(Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createTapiNode(
+            Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
         Uuid nodeUuid = null;
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
-        Map<RuleKey, Rule> ruleList = new HashMap<>();
-        Set<RuleType> ruleTypes = new HashSet<>();
-        ruleTypes.add(RuleType.FORWARDING);
-        Rule rule = new RuleBuilder()
-            .setLocalId("forward")
-            .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
-            .setRuleType(ruleTypes)
-            .build();
-        ruleList.put(rule.key(), rule);
         if (layerProtocols.contains(LayerProtocolName.DSR)
                 || layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
-            nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, ruleList);
+            Rule rule = new RuleBuilder()
+                .setLocalId("forward")
+                .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
+                .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
+                .build();
+            nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, new HashMap<>(Map.of(rule.key(), rule)));
         } else {
-            LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(nodeNames.keySet().iterator().next())
-                .getValueName(), nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
+            LOG.error("Undefined LayerProtocolName for {} node {}",
+                nodeNames.get(nodeNames.keySet().iterator().next()).getValueName(),
+                nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
         }
      // Empty random creation of mandatory fields for avoiding errors....
         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
@@ -725,9 +692,6 @@ public class ConvertORToTapiTopology {
             .setRiskCharacteristicName("risk characteristic")
             .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
             .build();
-        RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
-            .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
-            .build();
         return new NodeBuilder()
             .setUuid(nodeUuid)
             .setName(nodeNames)
@@ -739,7 +703,10 @@ public class ConvertORToTapiTopology {
             .setNodeRuleGroup(nodeRuleGroupList)
             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
-            .setRiskParameterPac(riskParamPac)
+            .setRiskParameterPac(
+                new RiskParameterPacBuilder()
+                    .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+                    .build())
             .setErrorCharacteristic("error")
             .setLossCharacteristic("loss")
             .setRepeatDeliveryCharacteristic("repeat delivery")
@@ -749,111 +716,95 @@ public class ConvertORToTapiTopology {
             .build();
     }
 
-    private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
-                                 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
-        Uuid nodeUuid;
-        nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR));
+    private Uuid getNodeUuid4Dsr(
+            Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
+            Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
+            Map<RuleKey, Rule> ruleList) {
         // client NEP DSR creation on DSR/ODU node
         for (int i = 0; i < oorClientPortList.size(); i++) {
-            Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
-                (String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
-                    oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
-            LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
-                oorClientPortList.get(i).getTpId().getValue()), nepUuid);
-            this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
-                    oorClientPortList.get(i).getTpId().getValue()), nepUuid);
-            NameBuilder nameBldr = new NameBuilder().setValue(
-                String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
-                    oorClientPortList.get(i).getTpId().getValue()));
-            Name name;
-            if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
-                name = nameBldr.setValueName("100G-tpdr").build();
-            } else {
-                name = nameBldr.setValueName("NodeEdgePoint_C").build();
-            }
-
-            OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
-                LayerProtocolName.DSR, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
-                    TapiStringConstants.DSR));
+            String nodeIdDsr = String.join("+",
+                this.ietfNodeId, TapiStringConstants.DSR, oorClientPortList.get(i).getTpId().getValue());
+            Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdDsr.getBytes(Charset.forName("UTF-8"))).toString());
+            LOG.info("NEP = {} has Uuid {} ", nodeIdDsr, nepUuid);
+            this.uuidMap.put(nodeIdDsr, nepUuid);
+            Name name = new NameBuilder()
+                .setValue(nodeIdDsr)
+                .setValueName(OpenroadmNodeType.TPDR.equals(this.ietfNodeType) ? "100G-tpdr" : "NodeEdgePoint_C")
+                .build();
+            OwnedNodeEdgePoint onep = createNep(
+                oorClientPortList.get(i),
+                Map.of(name.key(), name),
+                LayerProtocolName.DSR, LayerProtocolName.DSR, true,
+                String.join("+", this.ietfNodeId, TapiStringConstants.DSR));
             onepl.put(onep.key(), onep);
         }
         // CLIENT NEP E_ODU creation on DSR/ODU node
         for (int i = 0; i < oorClientPortList.size(); i++) {
-            Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
-                (String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
-                    oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
-            LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
-                oorClientPortList.get(i).getTpId().getValue()), nepUuid1);
-            this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
-                oorClientPortList.get(i).getTpId().getValue()), nepUuid1);
+            String nodeIdEodu = String.join("+",
+                this.ietfNodeId, TapiStringConstants.E_ODU, oorClientPortList.get(i).getTpId().getValue());
+            Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdEodu.getBytes(Charset.forName("UTF-8"))).toString());
+            LOG.info("NEP = {} has Uuid {} ", nodeIdEodu, nepUuid1);
+            this.uuidMap.put(nodeIdEodu, nepUuid1);
             Name onedName = new NameBuilder()
                 .setValueName("eNodeEdgePoint_N")
-                .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
-                    oorClientPortList.get(i).getTpId().getValue()))
+                .setValue(nodeIdEodu)
                 .build();
-
-            OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(onedName.key(), onedName),
-                LayerProtocolName.ODU, LayerProtocolName.DSR, false, String.join("+", this.ietfNodeId,
-                    TapiStringConstants.E_ODU));
+            OwnedNodeEdgePoint onep = createNep(
+                oorClientPortList.get(i),
+                Map.of(onedName.key(), onedName),
+                LayerProtocolName.ODU, LayerProtocolName.DSR, false,
+                String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU));
             onepl.put(onep.key(), onep);
         }
         // NETWORK NEPs I_ODU creation on DSR/ODU node
         for (int i = 0; i < oorNetworkPortList.size(); i++) {
-            Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
-                (String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
-                    oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
-            LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
-            this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
+            String nodeIdIodu = String.join("+",
+                this.ietfNodeId, TapiStringConstants.I_ODU, oorNetworkPortList.get(i).getTpId().getValue());
+            Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdIodu.getBytes(Charset.forName("UTF-8"))).toString());
+            LOG.info("NEP = {} has Uuid {} ", nodeIdIodu, nepUuid1);
+            this.uuidMap.put(nodeIdIodu, nepUuid1);
             Name onedName = new NameBuilder()
                 .setValueName("iNodeEdgePoint_N")
-                .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
-                    oorNetworkPortList.get(i).getTpId().getValue()))
+                .setValue(nodeIdIodu)
                 .build();
-
-            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
-                LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
-                    TapiStringConstants.I_ODU));
+            OwnedNodeEdgePoint onep = createNep(
+                oorNetworkPortList.get(i),
+                Map.of(onedName.key(), onedName),
+                LayerProtocolName.ODU, LayerProtocolName.DSR, true,
+                String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU));
             onepl.put(onep.key(), onep);
         }
         // NETWORK NEP OTS network on DSR/ODU node
         for (int i = 0; i < oorNetworkPortList.size(); i++) {
-            Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
-                (String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
-                    oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
-                .toString());
-            LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
-            this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
+            String nodeIdPmOts = String.join("+",
+                this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS, oorNetworkPortList.get(i).getTpId().getValue());
+            Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(nodeIdPmOts.getBytes(Charset.forName("UTF-8"))).toString());
+            LOG.info("NEP = {} has Uuid {} ", nodeIdPmOts, nepUuid2);
+            this.uuidMap.put(nodeIdPmOts, nepUuid2);
             Name onedName = new NameBuilder()
                 .setValueName("eNodeEdgePoint")
-                .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
-                    oorNetworkPortList.get(i).getTpId().getValue()))
+                .setValue(nodeIdPmOts)
                 .build();
-
-            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
+            OwnedNodeEdgePoint onep = createNep(
+                oorNetworkPortList.get(i),
+                Map.of(onedName.key(), onedName),
                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
                 String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS));
             onepl.put(onep.key(), onep);
         }
         for (int i = 0; i < oorNetworkPortList.size(); i++) {
-            Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
-                (String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
-                    oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
-                .toString());
-            LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
-            this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
-                oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
+            String nodeIdOtMc = String.join("+",
+                this.ietfNodeId, TapiStringConstants.OTSI_MC, oorNetworkPortList.get(i).getTpId().getValue());
+            Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(nodeIdOtMc.getBytes(Charset.forName("UTF-8"))).toString());
+            LOG.info("NEP = {} has Uuid {} ", nodeIdOtMc, nepUuid3);
+            this.uuidMap.put(nodeIdOtMc, nepUuid3);
             Name onedName = new NameBuilder()
                 .setValueName("PhotMedNodeEdgePoint")
-                .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
-                    oorNetworkPortList.get(i).getTpId().getValue()))
+                .setValue(nodeIdOtMc)
                 .build();
-
-            OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
+            OwnedNodeEdgePoint onep = createNep(
+                oorNetworkPortList.get(i),
+                Map.of(onedName.key(), onedName),
                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
                 String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC));
             onepl.put(onep.key(), onep);
@@ -861,64 +812,56 @@ public class ConvertORToTapiTopology {
         // create NodeRuleGroup
         int count = 1;
         LOG.debug("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
+        String ietfXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
         for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
-                nepList = new HashMap<>();
+                    nepList = new HashMap<>();
             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
-                oduNepList = new HashMap<>();
+                    oduNepList = new HashMap<>();
             LOG.debug("UUidMap={}", this.uuidMap.keySet());
             LOG.debug("TP list = {}", nbl.getTpList());
             for (TpId tp : nbl.getTpList()) {
                 LOG.debug("TP={}", tp.getValue());
-                LOG.debug("UuidKey={}", String.join("+", this.ietfNodeId,
-                    TapiStringConstants.E_ODU, tp.getValue()));
-                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
-                        tp.getValue())) || this.uuidMap.containsKey(String.join(
-                        "+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue()))) {
-                    String qual = tp.getValue().contains("CLIENT") ? TapiStringConstants.DSR
-                        : TapiStringConstants.I_ODU;
-                    org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
-                            nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
-                            .node.rule.group.NodeEdgePointBuilder()
-                        .setTopologyUuid(tapiTopoUuid)
-                        .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
-                            TapiStringConstants.XPDR)))
-                        .setNodeEdgePointUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
-                            qual, tp.getValue())))
-                        .build();
+                String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue());
+                LOG.debug("UuidKey={}", ietfEoduTp);
+                String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue());
+                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tp.getValue()))
+                        || this.uuidMap.containsKey(ietfIoduTp)) {
+                    String qual = tp.getValue().contains("CLIENT")
+                        ? TapiStringConstants.DSR : TapiStringConstants.I_ODU;
+                    var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                                .node.rule.group.NodeEdgePointBuilder()
+                            .setTopologyUuid(tapiTopoUuid)
+                            .setNodeUuid(this.uuidMap.get(ietfXpdr))
+                            .setNodeEdgePointUuid(this.uuidMap.get(
+                                String.join("+", this.ietfNodeId, qual, tp.getValue())))
+                            .build();
                     nepList.put(nep.key(), nep);
                 }
-                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
-                        TapiStringConstants.E_ODU, tp.getValue()))) {
-                    org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
-                            nep1 = new org.opendaylight.yang.gen.v1.urn
-                            .onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder()
-                        .setTopologyUuid(tapiTopoUuid)
-                        .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
-                            TapiStringConstants.XPDR)))
-                        .setNodeEdgePointUuid(this.uuidMap.get(String.join(
-                            "+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue())))
-                        .build();
+                if (this.uuidMap.containsKey(ietfEoduTp)) {
+                    var nep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                                .node.rule.group.NodeEdgePointBuilder()
+                            .setTopologyUuid(tapiTopoUuid)
+                            .setNodeUuid(this.uuidMap.get(ietfXpdr))
+                            .setNodeEdgePointUuid(this.uuidMap.get(ietfEoduTp))
+                            .build();
                     oduNepList.put(nep1.key(), nep1);
                 }
-                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
-                        TapiStringConstants.I_ODU, tp.getValue()))) {
-                    org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
-                            nep2 = new org.opendaylight.yang.gen.v1.urn
-                            .onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder()
-                        .setTopologyUuid(tapiTopoUuid)
-                        .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
-                            TapiStringConstants.XPDR)))
-                        .setNodeEdgePointUuid(this.uuidMap.get(String.join(
-                            "+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue())))
-                        .build();
+                if (this.uuidMap.containsKey(ietfIoduTp)) {
+                // TODO already checked with DSR above -> potential factorization ?
+                    var nep2 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                                .node.rule.group.NodeEdgePointBuilder()
+                            .setTopologyUuid(tapiTopoUuid)
+                            .setNodeUuid(this.uuidMap.get(ietfXpdr))
+                            .setNodeEdgePointUuid(this.uuidMap.get(ietfIoduTp))
+                            .build();
                     oduNepList.put(nep2.key(), nep2);
                 }
             }
-            LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList.toString());
-            LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList.toString());
+            LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList);
+            LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList);
             // Empty random creation of mandatory fields for avoiding errors....
             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
                 .setCostAlgorithm("Restricted Shortest Path - RSP")
@@ -958,35 +901,35 @@ public class ConvertORToTapiTopology {
             nodeRuleGroupList.put(nodeRuleGroup2.key(), nodeRuleGroup2);
             count++;
         }
-        return nodeUuid;
+        return this.uuidMap.get(ietfXpdr);
     }
 
     private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
             LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
-        String key = String.join("+", keyword, oorTp.getTpId().getValue());
-        AdministrativeState adminState = (oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() != null)
-            ? transformAsToTapiAdminState(oorTp.augmentation(TerminationPoint1.class).getAdministrativeState()
-                .getName())
-            : null;
-        OperationalState operState = (oorTp.augmentation(TerminationPoint1.class).getOperationalState() != null)
-            ? transformOsToTapiOperationalState(oorTp.augmentation(TerminationPoint1.class).getOperationalState()
-                .getName())
-            : null;
-        org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1 tp1 =
-            oorTp.augmentation(org.opendaylight.yang.gen.v1.http
-                .org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
+        var tp1 = oorTp.augmentation(
+            org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
         if (tp1.getTpSupportedInterfaces() == null) {
             LOG.warn("Tp supported interface doesnt exist on TP {}", oorTp.getTpId().getValue());
             return null;
         }
-        Collection<SupportedInterfaceCapability> sicColl = tp1.getTpSupportedInterfaces()
-            .getSupportedInterfaceCapability().values();
+        AdministrativeState adminState =
+            oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() == null
+                ? null
+                : transformAsToTapiAdminState(
+                    oorTp.augmentation(TerminationPoint1.class).getAdministrativeState().getName());
+        OperationalState operState =
+            oorTp.augmentation(TerminationPoint1.class).getOperationalState() == null
+                ? null
+                : transformOsToTapiOperationalState(
+                    oorTp.augmentation(TerminationPoint1.class).getOperationalState().getName());
+        Collection<SupportedInterfaceCapability> sicColl =
+            tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values();
         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
-            .setUuid(this.uuidMap.get(key))
+            .setUuid(this.uuidMap.get(String.join("+", keyword, oorTp.getTpId().getValue())))
             .setLayerProtocolName(nepProtocol)
-            .setName(nepNames);
-        onepBldr.setSupportedCepLayerProtocolQualifierInstances(createSupportedCepLayerProtocolQualifier(sicColl,
-                nepProtocol))
+            .setName(nepNames)
+            .setSupportedCepLayerProtocolQualifierInstances(
+                createSupportedCepLayerProtocolQualifier(sicColl, nepProtocol))
             .setDirection(Direction.BIDIRECTIONAL)
             .setLinkPortRole(PortRole.SYMMETRIC)
             .setAdministrativeState(adminState)
@@ -996,33 +939,28 @@ public class ConvertORToTapiTopology {
             onepBldr.setMappedServiceInterfacePoint(
                 createMSIP(1, nepProtocol, oorTp.getTpId().getValue(), keyword, sicColl, operState, adminState));
         }
-        List<OperationalModeKey> opModeList = new ArrayList<>();
         if (oorTp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
-            if (oorTp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
-                        .TerminationPoint1.class) == null
-                    || oorTp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
-                        .network.topology.rev230526.TerminationPoint1.class).getXpdrNetworkAttributes()
-                    == null) {
+            List<OperationalModeKey> opModeList = new ArrayList<>();
+            var tp11 = oorTp.augmentation(
+                org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
+            if (tp11 == null || tp11.getXpdrNetworkAttributes() == null) {
                 for (SupportedInterfaceCapability sic : sicColl) {
                     String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
                     if (("IfOCHOTUCnODUCn").equals(ifCapType) || ("IfOCHOTUCnODUCnUniregen").equals(ifCapType)
                             || ("IfOCHOTUCnODUCnRegen").equals(ifCapType)) {
                         opModeList.add(new OperationalModeKey("400G"));
-                        LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId().toString());
+                        LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId());
                         break;
                     }
                 }
                 opModeList.add(new OperationalModeKey("100G"));
-                LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId().toString());
+                LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId());
             } else {
-                opModeList = oorTp.augmentation(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
-                    .getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode().keySet().stream()
-                    .toList();
+                opModeList = tp11.getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode()
+                    .keySet().stream().toList();
             }
-            Map<Double, Double> freqWidthMap = getXpdrUsedWavelength(oorTp);
-            onepBldr = addPayloadStructureAndPhotSpecToOnep(this.ietfNodeId, freqWidthMap, opModeList, sicColl,
-                onepBldr, keyword);
+            onepBldr = addPayloadStructureAndPhotSpecToOnep(
+                this.ietfNodeId, getXpdrUsedWavelength(oorTp), opModeList, sicColl, onepBldr, keyword);
         }
         return onepBldr.build();
     }
@@ -1036,7 +974,6 @@ public class ConvertORToTapiTopology {
             .setValueName("SIP name")
             .setValue(String.join("+", nodeid, tpId))
             .build();
-
         return new ServiceInterfacePointBuilder()
             .setUuid(sipUuid)
             .setName(Map.of(sipName.key(), sipName))
@@ -1054,20 +991,18 @@ public class ConvertORToTapiTopology {
     @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "SF_SWITCH_FALLTHROUGH",
         justification = "Voluntarily No break in switchcase where comment is inserted in following method")
     private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
-            .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
-            createSipSupportedLayerProtocolQualifier(
-            Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
-            LayerProtocolName lpn) {
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
-            .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
+                .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
+             createSipSupportedLayerProtocolQualifier(
+                Collection<SupportedInterfaceCapability> supportedInterfaceCapability, LayerProtocolName lpn) {
         if (supportedInterfaceCapability == null) {
-            sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
-                .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
+            return new ArrayList<>(List.of(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
+                    .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
                 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
                 .setNumberOfCepInstances(Uint64.valueOf(1))
-                .build());
-            return sclpqiList;
+                .build()));
         }
+        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
+            .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
         for (SupportedInterfaceCapability sic : supportedInterfaceCapability) {
             String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
             switch (lpn.getName()) {
@@ -1242,20 +1177,18 @@ public class ConvertORToTapiTopology {
     }
 
     public AdministrativeState transformAsToTapiAdminState(String adminState) {
-        if (adminState == null) {
-            return null;
-        }
-        return adminState.equals(AdminStates.InService.getName())
-            || adminState.equals(AdministrativeState.UNLOCKED.getName()) ? AdministrativeState.UNLOCKED
-                : AdministrativeState.LOCKED;
+        return adminState == null
+            ? null
+            : adminState.equals(AdminStates.InService.getName())
+                    || adminState.equals(AdministrativeState.UNLOCKED.getName())
+                ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
     }
 
     public OperationalState transformOsToTapiOperationalState(String operState) {
-        if (operState == null) {
-            return null;
-        }
-        return operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
-            ? OperationalState.ENABLED : OperationalState.DISABLED;
+        return operState == null
+            ? null
+            : operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
+                ? OperationalState.ENABLED : OperationalState.DISABLED;
     }
 
     public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
index 9e83c91e6bac4b0c899f7d3e23241befe10d13e0..ca5d57cdd1325bc4531cd1311b91d9caa9b3b2b9 100644 (file)
@@ -44,9 +44,7 @@ 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.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.RiskParameterPac;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
 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.risk.parameter.pac.RiskCharacteristic;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
@@ -84,51 +82,47 @@ public class ConvertORTopoToTapiFullTopo {
         this.tapiLink = tapiLink;
     }
 
-    public void convertRdmToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link> rdmTordmLinkList) {
+    public void convertRdmToRdmLinks(
+            List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> rdmTordmLinkList) {
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-            .Link link : rdmTordmLinkList) {
+        for (var link : rdmTordmLinkList) {
             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                        .ietf.network.topology.rev180226.networks.network.Link oppositeLink = rdmTordmLinkList.stream()
+                var oppositeLink = rdmTordmLinkList.stream()
                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink()))
                     .findAny().orElse(null);
-
                 AdminStates oppLnkAdmState = null;
                 State oppLnkOpState = null;
                 if (oppositeLink != null) {
                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
                 }
-                String adminState =
-                    link.augmentation(Link1.class).getAdministrativeState() == null
-                        || oppLnkAdmState == null
-                    ? null
-                    : this.tapiLink.setTapiAdminState(
-                        link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
-                String operState =
-                    link.augmentation(Link1.class).getOperationalState() == null
-                        || oppLnkOpState == null
-                    ? null
-                    : this.tapiLink.setTapiOperationalState(
-                        link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
 
-                Link tapLink = this.tapiLink.createTapiLink(String.join("-",
+                Link tapLink = this.tapiLink.createTapiLink(
+                    String.join("-",
                         link.getSource().getSourceNode().getValue().split("-")[0],
                         link.getSource().getSourceNode().getValue().split("-")[1]),
-                    link.getSource().getSourceTp().getValue(), String.join("-",
+                    link.getSource().getSourceTp().getValue(),
+                    String.join("-",
                         link.getDestination().getDestNode().getValue().split("-")[0],
                         link.getDestination().getDestNode().getValue().split("-")[1]),
                     link.getDestination().getDestTp().getValue(), TapiStringConstants.OMS_RDM_RDM_LINK,
                     TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA,
-                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState, operState,
+                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+                    //adminState,
+                    link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+                        ? null
+                        : this.tapiLink.setTapiAdminState(
+                            link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+                    //operState,
+                    link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+                        ? null
+                        : this.tapiLink.setTapiOperationalState(
+                            link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
                     Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
                     this.tapiTopoUuid);
-                linksToNotConvert.add(link
-                    .augmentation(Link1.class)
-                    .getOppositeLink().getValue());
+                linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
                 tapiLinks.put(tapLink.key(), tapLink);
             }
         }
@@ -137,7 +131,8 @@ public class ConvertORTopoToTapiFullTopo {
     public void convertRoadmNode(Node roadm, Network openroadmTopo) {
         this.ietfNodeId = roadm.getNodeId().getValue();
         this.ietfNodeType = roadm.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
+                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+            .getNodeType();
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
         // 1. Get degree and srg nodes to map TPs into NEPs
         if (openroadmTopo.getNode() == null) {
@@ -148,24 +143,24 @@ public class ConvertORTopoToTapiFullTopo {
         int numSips = 0;
         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
         for (Node node:nodeList) {
-            if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
-                .equals(this.ietfNodeId))) {
-                LOG.debug("Abstracted node {} is not part of {}",
-                    node.getNodeId().getValue(), this.ietfNodeId);
+            if (node.getSupportingNode().values().stream()
+                    .noneMatch(sp -> sp.getNodeRef().getValue().equals(this.ietfNodeId))) {
+                LOG.debug("Abstracted node {} is not part of {}", node.getNodeId().getValue(), this.ietfNodeId);
                 continue;
             }
             if (node.augmentation(Node1.class) == null
-                && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                .ietf.network.topology.rev180226.Node1.class) == null) {
+                    && node.augmentation(
+                            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                        .Node1.class) == null) {
                 LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
                     node.getNodeId().getValue());
                 continue;
             }
-            OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
-                .org.openroadm.common.network.rev230526.Node1.class).getNodeType();
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
-                node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.Node1.class);
+            OpenroadmNodeType nodeType = node.augmentation(
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+                .getNodeType();
+            var node1 = node.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
             LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
             switch (nodeType.getIntValue()) {
                 case 11:
@@ -173,11 +168,11 @@ public class ConvertORTopoToTapiFullTopo {
                     // Get only external TPs of the degree
                     List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
+                                == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREERXTTP.getIntValue()
+                                == OpenroadmTpType.DEGREERXTTP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREETXTTP.getIntValue())
+                                == OpenroadmTpType.DEGREETXTTP.getIntValue())
                         .collect(Collectors.toList());
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Degree port List: {}", degPortList);
@@ -191,11 +186,11 @@ public class ConvertORTopoToTapiFullTopo {
                     // Get only external TPs of the srg
                     List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGTXRXPP.getIntValue()
+                                == OpenroadmTpType.SRGTXRXPP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGRXPP.getIntValue()
+                                == OpenroadmTpType.SRGRXPP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGTXPP.getIntValue())
+                                == OpenroadmTpType.SRGTXPP.getIntValue())
                         .collect(Collectors.toList());
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Srg port List: {}", srgPortList);
@@ -209,33 +204,30 @@ public class ConvertORTopoToTapiFullTopo {
         }
         // create tapi Node
         // UUID
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
-            TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
-        LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid.toString());
+        String nodeIdPhMed = String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA);
+        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdPhMed.getBytes(Charset.forName("UTF-8"))).toString());
+        LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid);
         // Names
-        Name nodeNames =  new NameBuilder().setValueName("roadm node name")
-            .setValue(String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA)).build();
-        Name nameNodeType = new NameBuilder().setValueName("Node Type")
-            .setValue(this.ietfNodeType.getName()).build();
+        Name nodeNames =  new NameBuilder().setValueName("roadm node name").setValue(nodeIdPhMed).build();
+        Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
         // Protocol Layer
         Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
         // Build tapi node
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
-            .Node roadmNode = createRoadmTapiNode(nodeUuid,
-            Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
+        var roadmNode = createRoadmTapiNode(
+            nodeUuid, Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
         // TODO add states corresponding to device config
         LOG.info("ROADM node {} should have {} NEPs and {} SIPs", roadm.getNodeId().getValue(), numNeps, numSips);
-        LOG.info("ROADM node {} has {} NEPs and {} SIPs", roadm.getNodeId().getValue(),
+        LOG.info("ROADM node {} has {} NEPs and {} SIPs",
+            roadm.getNodeId().getValue(),
             roadmNode.nonnullOwnedNodeEdgePoint().values().size(),
             roadmNode.nonnullOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
-
         tapiNodes.put(roadmNode.key(), roadmNode);
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node
-             createRoadmTapiNode(Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
-             Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createRoadmTapiNode(
+            Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
+            Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
         // Empty random creation of mandatory fields for avoiding errors....
         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
             .setCostAlgorithm("Restricted Shortest Path - RSP")
@@ -253,9 +245,6 @@ public class ConvertORTopoToTapiFullTopo {
             .setRiskCharacteristicName("risk characteristic")
             .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
             .build();
-        RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
-            .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
-            .build();
         return new NodeBuilder()
             .setUuid(nodeUuid)
             .setName(nameMap)
@@ -268,7 +257,10 @@ public class ConvertORTopoToTapiFullTopo {
                 .createNodeRuleGroupForRdmNode("Full",nodeUuid, this.ietfNodeId, oneplist.values()))
             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
-            .setRiskParameterPac(riskParamPac)
+            .setRiskParameterPac(
+                new RiskParameterPacBuilder()
+                    .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+                    .build())
             .setErrorCharacteristic("error")
             .setLossCharacteristic("loss")
             .setRepeatDeliveryCharacteristic("repeat delivery")
@@ -278,43 +270,39 @@ public class ConvertORTopoToTapiFullTopo {
             .build();
     }
 
-    private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(List<TerminationPoint> tpList,
-            boolean withSip, String nepPhotonicSublayer) {
+    private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(
+            List<TerminationPoint> tpList, boolean withSip, String nepPhotonicSublayer) {
         // create neps for MC and OTSiMC and Photonic Media
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
         for (TerminationPoint tp:tpList) {
-            // Admin and oper state common for all tps
-            AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
-            State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
             // PHOTONIC MEDIA nep
-            LOG.info("PHOTO NEP = {}", String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                tp.getTpId().getValue()));
+            String nodeIdNepTp = String.join("+", this.ietfNodeId, nepPhotonicSublayer, tp.getTpId().getValue());
+            LOG.info("PHOTO NEP = {}", nodeIdNepTp);
             Name nepName = new NameBuilder()
                 .setValueName(nepPhotonicSublayer + "NodeEdgePoint")
-                .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                    tp.getTpId().getValue()))
+                .setValue(nodeIdNepTp)
                 .build();
-
-            List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
-            sclpqiList.add(
-                new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                    .setLayerProtocolQualifier(
-                        TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
-                            ? PHOTONICLAYERQUALIFIEROMS.VALUE
-                            : PHOTONICLAYERQUALIFIEROTS.VALUE)
-                    .setNumberOfCepInstances(Uint64.valueOf(1))
-                    .build());
             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
-                .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
-                    nepPhotonicSublayer, tp.getTpId().getValue()))
-                    .getBytes(Charset.forName("UTF-8"))).toString()))
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes(nodeIdNepTp.getBytes(Charset.forName("UTF-8"))).toString()))
                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
                 .setName(Map.of(nepName.key(), nepName))
-                .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
+                .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()))
+                .setAdministrativeState(this.tapiLink.setTapiAdminState(
+                    // Admin state common for all tps
+                    tp.augmentation(TerminationPoint1.class).getAdministrativeState().getName()))
+                .setOperationalState(this.tapiLink.setTapiOperationalState(
+                    // Oper state common for all tps
+                    tp.augmentation(TerminationPoint1.class).getOperationalState().getName()))
                 .setLifecycleState(LifecycleState.INSTALLED)
                 .build();
             onepMap.put(onep.key(), onep);
@@ -322,55 +310,50 @@ public class ConvertORTopoToTapiFullTopo {
         return onepMap;
     }
 
-    public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
+    public void convertXpdrToRdmLinks(
+            List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> xpdrRdmLinkList) {
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
         // LOG.info("Link list = {}", xpdrRdmLinkList.toString());
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
+        for (var link:xpdrRdmLinkList) {
             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.networks.network.Link oppositeLink = xpdrRdmLinkList.stream()
+                var oppositeLink = xpdrRdmLinkList.stream()
                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink())).findAny()
                     .orElse(null);
-
                 AdminStates oppLnkAdmState = null;
                 State oppLnkOpState = null;
                 if (oppositeLink != null) {
                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
                 }
-                String adminState =
-                    link.augmentation(Link1.class).getAdministrativeState() == null
-                        || oppLnkAdmState == null
-                    ? null
-                    : this.tapiLink.setTapiAdminState(
-                        link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
-                String operState =
-                    link.augmentation(Link1.class).getOperationalState() == null
-                        || oppLnkOpState == null
-                    ? null
-                    : this.tapiLink.setTapiOperationalState(
-                        link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
-
-                String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
-                    ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
-                    : link.getSource().getSourceNode().getValue();
-                String sourceTp = link.getSource().getSourceTp().getValue();
-                String sourceNodeQual = sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
-                    : TapiStringConstants.XPDR;
-                String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
-                    ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
-                    : link.getDestination().getDestNode().getValue();
-                String destTp = link.getDestination().getDestTp().getValue();
-                String destNodeQual = destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
-                    : TapiStringConstants.XPDR;
-                Link tapLink = this.tapiLink.createTapiLink(sourceNode, sourceTp, destNode, destTp,
-                    TapiStringConstants.OMS_XPDR_RDM_LINK, sourceNodeQual, destNodeQual,
-                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState,
-                    operState, Set.of(LayerProtocolName.PHOTONICMEDIA),
-                    Set.of(LayerProtocolName.PHOTONICMEDIA.getName()), this.tapiTopoUuid);
+                String sourceNode =
+                    link.getSource().getSourceNode().getValue().contains("ROADM")
+                        ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
+                        : link.getSource().getSourceNode().getValue();
+                String destNode =
+                    link.getDestination().getDestNode().getValue().contains("ROADM")
+                        ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
+                        : link.getDestination().getDestNode().getValue();
+                Link tapLink = this.tapiLink.createTapiLink(
+                    sourceNode, link.getSource().getSourceTp().getValue(),
+                    destNode, link.getDestination().getDestTp().getValue(),
+                    TapiStringConstants.OMS_XPDR_RDM_LINK,
+                    sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+                    destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+                    //adminState,
+                    link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+                        ? null
+                        : this.tapiLink.setTapiAdminState(
+                            link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+                    //operState,
+                    link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+                        ? null
+                        : this.tapiLink.setTapiOperationalState(
+                            link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
+                    Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
+                    this.tapiTopoUuid);
                 linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
                 this.tapiLinks.put(tapLink.key(), tapLink);
             }
@@ -387,7 +370,6 @@ public class ConvertORTopoToTapiFullTopo {
         }
     }
 
-
     public void setTapiNodes(Map<NodeKey,
             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap) {
         this.tapiNodes.putAll(nodeMap);
index 2b99e3aef97770f664f43385655cc38edc7d6d8c..656b07c6777f2a5be7023497a5b6c67c3fde39d0 100644 (file)
   </current-pm-entry>
   </current-pm-list>
 
+  <current-pm-description xmlns="http://honeynode-simulator/pm-handling">
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+  </current-pm-description>
+
  </data>
index d09d3906706dead55083c48289efad162aee4d4a..26b766ddf9dd61bb321002597052b6e7ee4ff718 100644 (file)
       </connection-ports>
     </degree>
   </org-openroadm-device>
- </data>
+
+  <current-pm-list xmlns="http://org/openroadm/pm">
+  <current-pm-entry>
+    <pm-resource-instance xmlns:d="http://org/openroadm/device">/d:org-openroadm-device/d:interface[d:name='OTS-DEG1-TTP-TXRX']</pm-resource-instance>
+    <pm-resource-type>interface</pm-resource-type>
+    <pm-resource-type-extension></pm-resource-type-extension>
+    <retrieval-time>2018-06-07T13:22:58+00:00</retrieval-time>
+    <current-pm>
+      <type>opticalPowerOutput</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>tx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>2.5</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>2.23</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+    <current-pm>
+      <type>opticalPowerInput</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>rx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>-21.1</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>-49.3</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+    <current-pm>
+      <type>opticalReturnLoss</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>rx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>40</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>44</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+  </current-pm-entry>
+  <current-pm-entry>
+    <pm-resource-instance xmlns:d="http://org/openroadm/device">/d:org-openroadm-device/d:interface[d:name='OTS-DEG2-TTP-TXRX']</pm-resource-instance>
+    <pm-resource-type>interface</pm-resource-type>
+    <pm-resource-type-extension></pm-resource-type-extension>
+    <retrieval-time>2018-06-07T13:22:58+00:00</retrieval-time>
+    <current-pm>
+      <type>opticalPowerOutput</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>tx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>2.5</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>2.23</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+    <current-pm>
+      <type>opticalPowerInput</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>rx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>-21.1</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>-49.3</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+    <current-pm>
+      <type>opticalReturnLoss</type>
+      <extension></extension>
+      <location>nearEnd</location>
+      <direction>rx</direction>
+      <measurement>
+        <granularity>15min</granularity>
+        <pmParameterValue>40</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+      <measurement>
+        <granularity>24Hour</granularity>
+        <pmParameterValue>44</pmParameterValue>
+        <pmParameterUnit>dBm</pmParameterUnit>
+        <validity>complete</validity>
+      </measurement>
+    </current-pm>
+  </current-pm-entry>
+  </current-pm-list>
+
+  <current-pm-description xmlns="http://honeynode-simulator/pm-handling">
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+  </current-pm-description>
+
+</data>
index bbd709d524c2fe57ae536236b969dad3d273a39d..47f8f1e367f4267c29013b273cdf9365d9b55cf7 100644 (file)
   </current-pm-entry>
   </current-pm-list>
 
- </data>
+  <current-pm-description xmlns="http://honeynode-simulator/pm-handling">
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:opticalTransport</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerOutput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of the first NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[TX/TXRX]-[frequency]-->
+      <!--Its value will be changed as additional NMC are created-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>0</default-current-value>
+      <max-value>21.82</max-value>
+      <min-value>-9.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>5</evolution-range>
+    </pm-generation-rules>
+    <pm-generation-rules>
+      <triggering-interface xmlns:org-openroadm-interfaces="http://org/openroadm/interfaces">org-openroadm-interfaces:openROADMOpticalMultiplex</triggering-interface>
+      <pm-name-prefix>opticalPowerInput</pm-name-prefix>
+      <!--This PM is generated on ROADMs on creation of a NMC (MediaChannel) interface nmc-ttp-DEGX-TTP-[RX/TXRX]-[frequency]-->
+      <analog>true</analog>
+      <!--Default value is purely indicative, the value shall be set trough pm-interact RPC according to a value calculated from span loss and Power mask -->
+      <!--The value set through the RPC will be the value to keep as a reference out of any forced mode use to simulate a failure -->
+      <default-current-value>-17.0</default-current-value>
+      <max-value>-9.0</max-value>
+      <min-value>-25.0</min-value>
+      <!--Evolution range is a percentage of the min max range expressed in dB-->
+      <evolution-range>10</evolution-range>
+    </pm-generation-rules>
+  </current-pm-description>
+
+</data>