X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FRendererServiceOperationsImpl.java;h=154c8fa0220e247e3cdec576337ce1608797305a;hb=26c22f3f96ad697ddcc3bcce508922b10d7ac9ff;hp=5f276cee8de6b49551f344e4ed6e51e91becb824;hpb=b627cc7efe46068a1ab813ce7fd4ed84e5e31592;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java index 5f276cee8..154c8fa02 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java @@ -21,6 +21,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.ReadTransaction; @@ -39,8 +40,8 @@ import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetu 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.rev210618.Action; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.OtnServicePathInput; +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.olm.rev210618.GetPmInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput; @@ -48,16 +49,17 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.RendererRpcResultSp; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.RendererRpcResultSpBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceImplementationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceImplementationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.link._for.notif.ATerminationBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.link._for.notif.ZTerminationBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.renderer.rpc.result.sp.Link; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.renderer.rpc.result.sp.LinkBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping; +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.renderer.rev210915.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput; +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.ServiceImplementationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.link._for.notif.ATerminationBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.link._for.notif.ZTerminationBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.LinkBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; 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; @@ -72,6 +74,7 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.link.tp.LinkTp; import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.olm.get.pm.input.ResourceIdentifierBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.Nodes; +import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -126,11 +129,15 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), RpcStatusEx.Pending, "Service compliant, submitting service implementation Request ..."); Uint32 serviceRate = getServiceRate(input); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.network.Nodes + mappingNode = portMapping.isNodeExist(input.getServiceAEnd().getNodeId()) + ? portMapping.getNode(input.getServiceAEnd().getNodeId()) + : null; String serviceType = ServiceTypes.getServiceType( input.getServiceAEnd().getServiceFormat().getName(), serviceRate, - (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId()) - .getNodeInfo().getNodeType()) + (mappingNode != null + && NodeTypes.Xpdr.equals(mappingNode.getNodeInfo().getNodeType()) && input.getServiceAEnd().getTxDirection() != null && input.getServiceAEnd().getTxDirection().getPort() != null && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null) @@ -151,6 +158,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations case StringConstants.SERVICE_TYPE_1GE: case StringConstants.SERVICE_TYPE_10GE: case StringConstants.SERVICE_TYPE_100GE_M: + case StringConstants.SERVICE_TYPE_100GE_S: case StringConstants.SERVICE_TYPE_ODU4: case StringConstants.SERVICE_TYPE_ODUC4: if (!manageOtnServicePathCreation(input, serviceType, serviceRate)) { @@ -191,8 +199,10 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations OPERATION_FAILED); } PathDescription pathDescription = pathDescriptionOpt.get(); + Mapping mapping = portMapping.getMapping(service.getServiceAEnd().getNodeId().getValue(), + service.getServiceAEnd().getTxDirection().getPort().getPortName()); String serviceType = ServiceTypes.getServiceType(service.getServiceAEnd().getServiceFormat().getName(), - service.getServiceAEnd().getServiceRate(), null); + service.getServiceAEnd().getServiceRate(), mapping); switch (serviceType) { case StringConstants.SERVICE_TYPE_100GE_T: case StringConstants.SERVICE_TYPE_400GE: @@ -206,6 +216,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations case StringConstants.SERVICE_TYPE_1GE: case StringConstants.SERVICE_TYPE_10GE: case StringConstants.SERVICE_TYPE_100GE_M: + case StringConstants.SERVICE_TYPE_100GE_S: case StringConstants.SERVICE_TYPE_ODU4: case StringConstants.SERVICE_TYPE_ODUC4: if (!manageOtnServicePathDeletion(serviceName, pathDescription, service, serviceType)) { @@ -345,19 +356,19 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private List otnDeviceRendering(RollbackProcessor rollbackProcessor, - OtnServicePathInput otnServicePathAtoZ, OtnServicePathInput otnServicePathZtoA) { + OtnServicePathInput otnServicePathAtoZ, OtnServicePathInput otnServicePathZtoA, String serviceType) { LOG.info(RENDERING_DEVICES_A_Z_MSG); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, otnServicePathAtoZ.getServiceName(), RpcStatusEx.Pending, RENDERING_DEVICES_A_Z_MSG); ListenableFuture atozrenderingFuture = - this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathAtoZ)); - LOG.info("Rendering devices Z-A"); + this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathAtoZ, serviceType)); + LOG.info(RENDERING_DEVICES_Z_A_MSG); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, otnServicePathZtoA.getServiceName(), RpcStatusEx.Pending, RENDERING_DEVICES_Z_A_MSG); ListenableFuture ztoarenderingFuture = - this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathZtoA)); + this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathZtoA, serviceType)); ListenableFuture> renderingCombinedFuture = Futures.allAsList(atozrenderingFuture, ztoarenderingFuture); List otnRenderingResults = new ArrayList<>(2); @@ -514,7 +525,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations RollbackProcessor rollbackProcessor = new RollbackProcessor(); List renderingResults = deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA); - if (rollbackProcessor.rollbackAllIfNecessary() > 0) { + if (rollbackProcessor.rollbackAllIfNecessary() > 0 || renderingResults.isEmpty()) { sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG); return false; @@ -561,7 +572,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription(), - notifLink, serviceType); + notifLink, null, serviceType); return true; } @@ -614,7 +625,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations Link notifLink = createLinkForNotif(otnLinkTerminationPoints); sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete, - serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, serviceType); + serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, null, serviceType); return true; } @@ -638,7 +649,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations // Rollback should be same for all conditions, so creating a new one RollbackProcessor rollbackProcessor = new RollbackProcessor(); List renderingResults = - otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA); + otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA, serviceType); if (rollbackProcessor.rollbackAllIfNecessary() > 0) { rollbackProcessor.rollbackAll(); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, @@ -648,10 +659,12 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations List otnLinkTerminationPoints = new ArrayList<>(); renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps())); Link notifLink = createLinkForNotif(otnLinkTerminationPoints); + List allSupportLinks = ModelMappingUtils.getLinksFromServicePathDescription(input.getPathDescription()); + List supportedLinks = getSupportedLinks(allSupportLinks, serviceType); sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription(), - notifLink, serviceType); + notifLink, supportedLinks, serviceType); return true; } @@ -678,14 +691,17 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations RollbackProcessor rollbackProcessor = new RollbackProcessor(); List renderingResults = - otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA); + otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA, serviceType); List otnLinkTerminationPoints = new ArrayList<>(); renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps())); Link notifLink = createLinkForNotif(otnLinkTerminationPoints); + List allSupportLinks = ModelMappingUtils.getLinksFromServicePathDescription(pathDescription); + List supportedLinks = getSupportedLinks(allSupportLinks, serviceType); sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete, - serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, serviceType); + serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, supportedLinks, + serviceType); return true; } @@ -699,7 +715,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx, String message) { Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message, - null, null, null); + null, null, null, null); send(notification); } @@ -713,9 +729,9 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations */ private void sendNotificationsWithPathDescription(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription, - Link notifLink, String serviceType) { + Link notifLink, List supportedLinks, String serviceType) { Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message, - pathDescription, notifLink, serviceType); + pathDescription, notifLink, supportedLinks, serviceType); send(notification); } @@ -730,7 +746,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations */ private RendererRpcResultSp buildNotification(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription, - Link notifLink, String serviceType) { + Link notifLink, List supportedLinks, String serviceType) { RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder() .setNotificationType(servicePathNotificationTypes).setServiceName(serviceName).setStatus(rpcStatusEx) .setStatusMessage(message) @@ -742,6 +758,9 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations if (notifLink != null) { builder.setLink(notifLink); } + if (supportedLinks != null) { + builder.setLinkId(supportedLinks); + } return builder.build(); } @@ -774,4 +793,25 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations .build()) .build(); } + + private List getSupportedLinks(List allSupportLinks, String serviceType) { + switch (serviceType) { + case StringConstants.SERVICE_TYPE_10GE: + case StringConstants.SERVICE_TYPE_1GE: + return allSupportLinks.stream() + .filter(lk -> lk.startsWith(OtnLinkType.ODTU4.getName())).collect(Collectors.toList()); + case StringConstants.SERVICE_TYPE_100GE_M: + return allSupportLinks.stream() + .filter(lk -> lk.startsWith(OtnLinkType.ODUC4.getName())).collect(Collectors.toList()); + case StringConstants.SERVICE_TYPE_ODU4: + case StringConstants.SERVICE_TYPE_100GE_S: + return allSupportLinks.stream() + .filter(lk -> lk.startsWith(OtnLinkType.OTU4.getName())).collect(Collectors.toList()); + case StringConstants.SERVICE_TYPE_ODUC4: + return allSupportLinks.stream() + .filter(lk -> lk.startsWith(OtnLinkType.OTUC4.getName())).collect(Collectors.toList()); + default: + return null; + } + } }