Add notification support for service-rpc-result 24/106124/6
authorBalagangadhar (Bala) Bathula <bb4341@att.com>
Mon, 22 May 2023 14:31:00 +0000 (10:31 -0400)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 5 Jun 2023 07:09:25 +0000 (09:09 +0200)
- This RPC allows to notify the results of the path-computation
  such as assigned frequency, width, operational-mode-id,
  power range, GSNR and OSNR
- Applicable only for temp-service-create RPC
- Use-cases include IP-over-WDM and alien wavelength
- For IP-over-WDM or alien wavlength use case

JIRA: TRNSPRTPCE-743
Change-Id: I80258fad0b7ff3fc484203c9000a825e3565ea26
Signed-off-by: Balagangadhar (Bala) Bathula <bb4341@att.com>
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java

index af32ba11e098e18dc55a0917134771c2b9b07f94..e2e648cc2e15665800a14f7e57999aefbfdf684e 100644 (file)
@@ -28,7 +28,12 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.serviceha
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
 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.common.service.types.rev211210.ServiceNotificationTypes;
 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.rev211210.ServiceRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRpcResultBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.rpc.result.PathComputationResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.rpc.result.path.computation.result.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.rpc.result.path.computation.result.ZToABuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
@@ -169,7 +174,6 @@ public class RendererListenerImpl implements TransportpceRendererListener, Rende
         }
 
         updateOtnTopology(notification, false);
         }
 
         updateOtnTopology(notification, false);
-
         PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder()
                 .setServiceName(input.getServiceName())
                 .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
         PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder()
                 .setServiceName(input.getServiceName())
                 .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
@@ -182,6 +186,7 @@ public class RendererListenerImpl implements TransportpceRendererListener, Rende
             operationResult = this.serviceDataStoreOperations.modifyTempService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
             serviceTemp = "Temp ";
             operationResult = this.serviceDataStoreOperations.modifyTempService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
             serviceTemp = "Temp ";
+            LOG.info("Sending notification to the service-RPC-result");
         } else {
             operationResult = this.serviceDataStoreOperations.modifyService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
         } else {
             operationResult = this.serviceDataStoreOperations.modifyService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
@@ -194,6 +199,9 @@ public class RendererListenerImpl implements TransportpceRendererListener, Rende
                     .build());
             if (!tempService) {
                 sendServiceHandlerNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
                     .build());
             if (!tempService) {
                 sendServiceHandlerNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
+            } else {
+                LOG.info("For the Temp service, sending notification on service-result-rpc");
+                sendServiceRpcResultNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
             }
         } else {
             LOG.warn("{}Service status not updated in datastore !", serviceTemp);
             }
         } else {
             LOG.warn("{}Service status not updated in datastore !", serviceTemp);
@@ -230,6 +238,50 @@ public class RendererListenerImpl implements TransportpceRendererListener, Rende
         }
     }
 
         }
     }
 
+    private void sendServiceRpcResultNotification(RendererRpcResultSp notification, ServiceNotificationTypes type) {
+        try {
+            ServiceRpcResult serviceRpcResult = new ServiceRpcResultBuilder()
+                    .setServiceName(notification.getServiceName())
+                    .setNotificationType(type)
+                    .setStatusMessage(notification.getStatusMessage())
+                    .setCommonId(notification.getCommonId())
+                    .setPathComputationResult(new PathComputationResultBuilder()
+                            .setAToZ(new AToZBuilder()
+                                            .setFrequency(notification
+                                                            .getAToZDirection()
+                                                            .getCentralFrequency())
+                                            .setWidth(notification
+                                                            .getAToZDirection()
+                                                            .getWidth())
+                                            // TODO: here the optical operational mode should be set
+                                            // TODO: also set the GNSR, OSNR, power values
+                                            .setOpticalOperationalMode("test")
+                                            .build())
+                            .setZToA(new ZToABuilder()
+                                            .setFrequency(notification
+                                                            .getZToADirection()
+                                                            .getCentralFrequency())
+                                            .setWidth(notification
+                                                            .getZToADirection()
+                                                            .getWidth())
+                                            // TODO: here the optical operational mode should be set
+                                            // TODO: also set the GNSR, OSNR, power values
+                                            .setOpticalOperationalMode("test")
+                                            .build())
+                            .build())
+                    .build();
+            LOG.info("Sending the notification for service-rpc-result {}", serviceRpcResult);
+            notificationPublishService.putNotification(
+                    serviceRpcResult);
+        } catch (InterruptedException e) {
+            LOG.warn("Something went wrong while sending notification for service {}",
+                    serviceRpcResultSp.getServiceName(), e);
+            Thread.currentThread().interrupt();
+        }
+    }
+
+
+
     /**
      * Process failed service implementation for serviceName.
      * @param serviceName String
     /**
      * Process failed service implementation for serviceName.
      * @param serviceName String