Merge "Refactor TAPI Connectivity Utils"
authorGilles Thouenon <gilles.thouenon@orange.com>
Thu, 29 Feb 2024 14:00:13 +0000 (14:00 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 29 Feb 2024 14:00:13 +0000 (14:00 +0000)
64 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
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/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/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/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
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/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/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/listeners/TapiPceNotificationHandler.java

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 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..f89cff96c2fb16b8e2c1808285d23831091119e0 100644 (file)
@@ -20,11 +20,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;
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..b5d77ac89a51f75c7faaa23e9a7812abfb8f2208 100644 (file)
@@ -30,7 +30,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;
index 537d3022cc72baf0eeab067a9182052a7049245e..56186777dce03378ff5167ec5273091a8de82ed0 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;
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..8bac0a20993faf532ceebdb35c40dbe6977033c3 100644 (file)
@@ -29,8 +29,8 @@ 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.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;
index dfb27b28f3b936f51c4bf6854fd2eadb317922ae..395693ff9487bb92b0a0d45cd7fc31fecaabdd90 100644 (file)
@@ -21,7 +21,7 @@ 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.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;
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..11721f5
--- /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.rev230925.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..6d36d82
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * 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.rev230925.PathComputationRequestInput;
+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.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 final String 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 8d7616c1207af670b23815d75bd51c3a9804f49a..cbf5ba570e8fcaf20034a45b49eaafc39d8f0db0 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;
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;
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..34ebb5c
--- /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.rev230925.PathComputationRequestInput;
+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.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..35056af2e94731a395b2867a5deefd6ba0cc5354 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;
@@ -346,7 +346,7 @@ 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))
@@ -375,7 +375,7 @@ public final class PceTestData {
                                         .build())
                                 .build())
                         .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()
                         .setServiceFormat(ServiceFormat.Ethernet)
                         .setServiceRate(Uint32.valueOf(0))
@@ -587,13 +587,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)
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;
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 b051192ad21e54bcef1920f024a38ab371cdcda0..cca076fa691a1650fea5b79820bfeba20706afea 100644 (file)
@@ -36,10 +36,14 @@ import org.opendaylight.transportpce.renderer.ServicePathInputData;
 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.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;
@@ -370,9 +374,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(
@@ -382,7 +389,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);
@@ -403,16 +411,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;
+    }
+}
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 63e347868f6cf6dd6ae3fb91136a1007e0772fbc..fe1973618c1953c37a4386b1d65ac46f92c51d9b 100644 (file)
@@ -101,7 +101,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());
@@ -113,7 +113,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();
@@ -126,7 +126,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());
@@ -138,7 +138,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());
@@ -150,7 +150,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());
@@ -167,7 +167,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
@@ -247,7 +247,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,
@@ -263,7 +263,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());
@@ -277,7 +277,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());
@@ -298,7 +298,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 f11a4c23809d8fd10b8a30624b67e9c4f4270a8e..2ea5077a6be795d34f43843a66cf6865dd94abde 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;
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 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;