Update Servicehandler checks
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / RendererServiceOperationsImpl.java
index aa781606fdc7c2fe04ead0f5dd8d5b62fe8d2cc4..df4d6624dd0ec1f4b025933c2a10381b8ae22e30 100644 (file)
@@ -49,7 +49,6 @@ 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.portmapping.rev220114.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;
@@ -129,6 +128,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                 sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
                         RpcStatusEx.Pending, "Service compliant, submitting service implementation Request ...");
                 Uint32 serviceRate = getServiceRate(input);
+                LOG.info("Using {}G rate", serviceRate);
                 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes
                     mappingNode = portMapping.isNodeExist(input.getServiceAEnd().getNodeId())
                         ? portMapping.getNode(input.getServiceAEnd().getNodeId())
@@ -149,6 +149,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                     case StringConstants.SERVICE_TYPE_100GE_T:
                     case StringConstants.SERVICE_TYPE_400GE:
                     case StringConstants.SERVICE_TYPE_OTU4:
+                    case StringConstants.SERVICE_TYPE_OTUC2:
+                    case StringConstants.SERVICE_TYPE_OTUC3:
                     case StringConstants.SERVICE_TYPE_OTUC4:
                         if (!manageServicePathCreation(input, serviceType)) {
                             return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
@@ -160,6 +162,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                     case StringConstants.SERVICE_TYPE_100GE_M:
                     case StringConstants.SERVICE_TYPE_100GE_S:
                     case StringConstants.SERVICE_TYPE_ODU4:
+                    case StringConstants.SERVICE_TYPE_ODUC2:
+                    case StringConstants.SERVICE_TYPE_ODUC3:
                     case StringConstants.SERVICE_TYPE_ODUC4:
                         if (!manageOtnServicePathCreation(input, serviceType, serviceRate)) {
                             return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
@@ -199,14 +203,23 @@ 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(), mapping);
+                String serviceType =
+                    ServiceTypes.getServiceType(
+                        service.getServiceAEnd().getServiceFormat().getName(),
+                        service.getServiceAEnd().getServiceRate(),
+                        service.getServiceAEnd().getTxDirection() == null
+                                || service.getServiceAEnd().getTxDirection().getPort() == null
+                                || service.getServiceAEnd().getTxDirection().getPort().getPortName() == null
+                            ? null
+                            : portMapping.getMapping(
+                                    service.getServiceAEnd().getNodeId().getValue(),
+                                    service.getServiceAEnd().getTxDirection().getPort().getPortName()));
                 switch (serviceType) {
                     case StringConstants.SERVICE_TYPE_100GE_T:
                     case StringConstants.SERVICE_TYPE_400GE:
                     case StringConstants.SERVICE_TYPE_OTU4:
+                    case StringConstants.SERVICE_TYPE_OTUC2:
+                    case StringConstants.SERVICE_TYPE_OTUC3:
                     case StringConstants.SERVICE_TYPE_OTUC4:
                         if (!manageServicePathDeletion(serviceName, pathDescription, serviceType)) {
                             return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
@@ -218,6 +231,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                     case StringConstants.SERVICE_TYPE_100GE_M:
                     case StringConstants.SERVICE_TYPE_100GE_S:
                     case StringConstants.SERVICE_TYPE_ODU4:
+                    case StringConstants.SERVICE_TYPE_ODUC2:
+                    case StringConstants.SERVICE_TYPE_ODUC3:
                     case StringConstants.SERVICE_TYPE_ODUC4:
                         if (!manageOtnServicePathDeletion(serviceName, pathDescription, service, serviceType)) {
                             return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
@@ -245,6 +260,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
         if (input.getServiceAEnd().getServiceRate() != null) {
             return input.getServiceAEnd().getServiceRate();
         }
+        LOG.warn("Input should have rate if you are using 200 or 300G");
+        // TODO: missing 200, and 300G rates here, OTUCn cannot always be 400G
         Map<ServiceFormat, Map<String, Uint32>> formatRateMap  = Map.of(
                 ServiceFormat.OTU, Map.of(
                     "OTUCn", Uint32.valueOf(400),