import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.renderer.ModelMappingUtils;
-import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
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.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.TransportpceOlmService;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceImplementationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceRpcResultSp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceRpcResultSpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.RendererRpcResultSp;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.RendererRpcResultSpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceImplementationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.OTU4;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity;
import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201126.PathDescription;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.RpcStatusEx;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.ServicePathNotificationTypes;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.olm.get.pm.input.ResourceIdentifierBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.olm.renderer.input.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.olm.get.pm.input.ResourceIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.olm.renderer.input.Nodes;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
private final DataBroker dataBroker;
private final NotificationPublishService notificationPublishService;
private ListeningExecutorService executor;
- private NetworkModelWavelengthService networkModelWavelengthService;
- private ServiceRpcResultSp notification = null;
public RendererServiceOperationsImpl(DeviceRendererService deviceRenderer,
OtnDeviceRendererService otnDeviceRenderer, TransportpceOlmService olmService,
- DataBroker dataBroker, NetworkModelWavelengthService networkModelWavelengthService,
- NotificationPublishService notificationPublishService) {
+ DataBroker dataBroker, NotificationPublishService notificationPublishService) {
this.deviceRenderer = deviceRenderer;
this.otnDeviceRenderer = otnDeviceRenderer;
this.olmService = olmService;
this.dataBroker = dataBroker;
- this.networkModelWavelengthService = networkModelWavelengthService;
this.notificationPublishService = notificationPublishService;
this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
}
- private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName,
- RpcStatusEx rpcStatusEx, String message) {
- this.notification = new ServiceRpcResultSpBuilder()
- .setNotificationType(servicePathNotificationTypes)
- .setServiceName(serviceName)
- .setStatus(rpcStatusEx)
- .setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(this.notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected: ", e);
- }
- }
-
@Override
public ListenableFuture<ServiceImplementationRequestOutput>
serviceImplementation(ServiceImplementationRequestInput input) {
OPERATION_FAILED);
}
LOG.info("OTN rendering result size {}", otnRenderingResults.size());
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL);
}
break;
case Infrastructure:
if ((input.getServiceAEnd().getOduServiceRate() != null)
&& (input.getServiceAEnd().getOduServiceRate().equals(ODU4.class))) {
// For the service of OTU4 infrastructure
- // First create the OCH and OTU interfaces
String serviceRate = "100G"; // For OtnDeviceRendererServiceImpl
LOG.info("Service format for {} is {} and rate is {}", input.getServiceName(),
input.getServiceAEnd().getOduServiceRate(), serviceRate);
OPERATION_FAILED);
}
LOG.info("OTN rendering result size {}", otnRenderingResults.size());
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL);
}
break;
default:
LOG.warn("Unsupported connection type {}", input.getConnectionType());
}
+ sendNotificationsWithPathDescription(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL,
+ input.getPathDescription());
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_OK,
OPERATION_SUCCESSFUL);
}
});
}
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public OperationResult reserveResource(PathDescription pathDescription) {
-
- try {
- LOG.info("Reserving resources in network model");
- networkModelWavelengthService.useWavelengths(pathDescription);
- } catch (Exception e) {
- LOG.warn("Reserving resources in network model failed");
- return OperationResult.failed("Resources reserve failed in network model");
- }
- return OperationResult.ok("Resources reserved successfully in network model");
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public OperationResult freeResource(PathDescription pathDescription) {
-
- try {
- networkModelWavelengthService.freeWavelengths(pathDescription);
- } catch (Exception e) {
- return OperationResult.failed("Resources reserve failed in network model");
- }
- return OperationResult.ok("Resources reserved successfully in network model");
- }
-
@Override
public ListenableFuture<ServiceDeleteOutput> serviceDelete(ServiceDeleteInput input, Services service) {
String serviceName = input.getServiceName();
"Service activation test failed.");
return false;
}
- // If Service activation is success update Network ModelMappingUtils
- networkModelWavelengthService.useWavelengths(input.getPathDescription());
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL);
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription());
return true;
}
"Deleting service path via renderer");
deviceRenderer.deleteServicePath(servicePathInputDataAtoZ.getServicePathInput());
deviceRenderer.deleteServicePath(servicePathInputDataZtoA.getServicePathInput());
- networkModelWavelengthService.freeWavelengths(pathDescription);
- sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Successful,
- OPERATION_SUCCESSFUL);
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
+ serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL,pathDescription);
return true;
}
"Deleting otn-service path via renderer");
OtnServicePathOutput result = otnDeviceRenderer.deleteOtnServicePath(ospi);
if (result.isSuccess()) {
- sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Successful,
- OPERATION_SUCCESSFUL);
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
+ serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription);
return true;
} else {
return false;
}
}
+ /**
+ * Send renderer notification.
+ * @param servicePathNotificationTypes ServicePathNotificationTypes
+ * @param serviceName String
+ * @param rpcStatusEx RpcStatusEx
+ * @param message String
+ */
+ private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName,
+ RpcStatusEx rpcStatusEx, String message) {
+ Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message,
+ null);
+ send(notification);
+ }
+
+ /**
+ * Send renderer notification with path description information.
+ * @param servicePathNotificationTypes ServicePathNotificationTypes
+ * @param serviceName String
+ * @param rpcStatusEx RpcStatusEx
+ * @param message String
+ * @param pathDescription PathDescription
+ */
+ private void sendNotificationsWithPathDescription(ServicePathNotificationTypes servicePathNotificationTypes,
+ String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) {
+ Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message,
+ pathDescription);
+ send(notification);
+ }
+
+ /**
+ * Build notification containing path description information.
+ * @param servicePathNotificationTypes ServicePathNotificationTypes
+ * @param serviceName String
+ * @param rpcStatusEx RpcStatusEx
+ * @param message String
+ * @param pathDescription PathDescription
+ * @return notification with RendererRpcResultSp type.
+ */
+ private RendererRpcResultSp buildNotification(ServicePathNotificationTypes servicePathNotificationTypes,
+ String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) {
+ RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder()
+ .setNotificationType(servicePathNotificationTypes).setServiceName(serviceName).setStatus(rpcStatusEx)
+ .setStatusMessage(message);
+ if (pathDescription != null) {
+ builder.setAToZDirection(pathDescription.getAToZDirection())
+ .setZToADirection(pathDescription.getZToADirection());
+ }
+ return builder.build();
+ }
+
+ /**
+ * Send renderer notification.
+ * @param notification Notification
+ */
+ private void send(Notification notification) {
+ try {
+ LOG.info("Sending notification {}", notification);
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info("notification offer rejected: ", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
}