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.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OtnDeviceRenderingTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackProcessor;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.OtnServicePathInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.OtnServicePathOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
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.device.rev200128.OtnServicePathInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathOutput;
-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.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.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.otn.common.types.rev200327.ODU4;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTUCn;
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.rev210705.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) {
case Service: case RoadmLine: // This takes into account of Ethernet 100G, 1G, 10G and ODU4
LOG.info("RPC implementation for {}", input.getConnectionType());
if (((input.getServiceAEnd().getServiceRate() != null)
- && (input.getServiceAEnd().getServiceRate().intValue() == 100))
+ && ((input.getServiceAEnd().getServiceRate().intValue() == 100))
+ || (input.getServiceAEnd().getServiceRate().intValue() == 400))
&& ((input.getServiceAEnd().getServiceFormat().getName().equals("Ethernet"))
|| (input.getServiceAEnd().getServiceFormat().getName().equals("OC")))) {
LOG.info("Service format for {} is {} and rate is {}", input.getServiceName(),
OPERATION_FAILED);
}
} else { // This implies, service-rate is 1 or 10G
- // This includes the lower-order odu (1G, 10G) and this is A-Z side
+ // This includes the lower-order odu (1G, 10G, 100G) and this is A-Z side
LOG.info("RPC implementation for LO-ODU");
String serviceRate = ""; // Assuming service at A-side and Z-side has same service rate
if (input.getServiceAEnd().getServiceRate() != null) {
OPERATION_FAILED);
}
LOG.info("OTN rendering result size {}", otnRenderingResults.size());
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL);
}
break;
case Infrastructure:
LOG.info("RPC implementation for {}", input.getConnectionType());
- if ((input.getServiceAEnd().getOtuServiceRate() != null)
- && (input.getServiceAEnd().getOtuServiceRate().equals(OTU4.class))) {
- // For the service of OTU4 infrastructure
- // First create the OCH and OTU interfaces
- String serviceRate = "100G"; // For OtnDeviceRendererServiceImpl
- if (!createServicepathInput(input)) {
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
+ if (input.getServiceAEnd().getOtuServiceRate() != null) {
+ if ((input.getServiceAEnd().getOtuServiceRate().equals(OTU4.class))
+ || (input.getServiceAEnd().getOtuServiceRate().equals(OTUCn.class))) {
+ // For the service of OTU4 or OTUCn infrastructure
+ // Create the OCH and OTU interfaces for OTU4 class
+ // Create OTSi, OTSi-group and OTUCn interface
+ if (!createServicepathInput(input)) {
+ return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
+ }
}
}
- 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
+ if (input.getServiceAEnd().getOduServiceRate() != null) {
+ String serviceRate = null;
+ if (input.getServiceAEnd().getOduServiceRate().equals(ODU4.class)) {
+ // For the service of OTU4 infrastructure
+ serviceRate = "100G"; // For OtnDeviceRendererServiceImpl
+ }
+ else if (input.getServiceAEnd().getOduServiceRate().equals(ODUCn.class)) {
+ // For the service of OTUCn infrastructure
+ // TODO: what happens if split-lambda where to be used? We will have ODUC2 rate,
+ // TODO: which case service-rate would be 200
+ // TODO: in that case it would be 200G?? Need to understand more
+ serviceRate = "400G"; // For OtnDeviceRendererServiceImpl
+ }
LOG.info("Service format for {} is {} and rate is {}", input.getServiceName(),
input.getServiceAEnd().getOduServiceRate(), serviceRate);
- // Now start rendering ODU4 interface
+ // Now start rendering ODU4 or ODUC4 interface
// This is A-Z side
OtnServicePathInput otnServicePathInputAtoZ = ModelMappingUtils
.rendererCreateOtnServiceInput(input.getServiceName(),
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();
case Service:
if ((ServiceFormat.Ethernet.equals(service.getServiceAEnd().getServiceFormat())
|| ServiceFormat.OC.equals(service.getServiceAEnd().getServiceFormat()))
- && Uint32.valueOf("100").equals(service.getServiceAEnd().getServiceRate())) {
+ && (Uint32.valueOf("100").equals(service.getServiceAEnd().getServiceRate())
+ || Uint32.valueOf("400").equals(service.getServiceAEnd().getServiceRate()))) {
if (!manageServicePathDeletion(serviceName, pathDescription)) {
return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
OPERATION_FAILED);
"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;
}
private boolean manageOtnServicePathDeletion(String serviceName, PathDescription pathDescription,
Services service) {
OtnServicePathInput ospi = null;
- if (ConnectionType.Infrastructure.equals(service.getConnectionType())) {
- ospi = ModelMappingUtils.rendererCreateOtnServiceInput(
- serviceName, service.getServiceAEnd().getServiceFormat().getName(), "100G", pathDescription, true);
- } else if (ConnectionType.Service.equals(service.getConnectionType())) {
- ospi = ModelMappingUtils.rendererCreateOtnServiceInput(serviceName,
+ ospi = ModelMappingUtils.rendererCreateOtnServiceInput(serviceName,
service.getServiceAEnd().getServiceFormat().getName(),
service.getServiceAEnd().getServiceRate().toString() + "G", pathDescription, true);
- }
LOG.info("Deleting otn-service path {} via renderer", serviceName);
sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Pending,
"Deleting otn-service path via renderer");
OtnServicePathOutput result = otnDeviceRenderer.deleteOtnServicePath(ospi);
- if (result.isSuccess()) {
- sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Successful,
- OPERATION_SUCCESSFUL);
+ if (result.getSuccess()) {
+ 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();
+ }
+ }
+
}