import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.service.ServiceTypes;
import org.opendaylight.transportpce.renderer.ModelMappingUtils;
import org.opendaylight.transportpce.renderer.ServicePathInputData;
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
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.ServicePowerTurndownInputBuilder;
-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.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.rev200327.ODU4;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
+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.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;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInputBuilder;
+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.rev210426.mapping.Mapping;
+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.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;
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.rev201210.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.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.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.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
private final TransportpceOlmService olmService;
private final DataBroker dataBroker;
private final NotificationPublishService notificationPublishService;
+ private final PortMapping portMapping;
private ListeningExecutorService executor;
public RendererServiceOperationsImpl(DeviceRendererService deviceRenderer,
OtnDeviceRendererService otnDeviceRenderer, TransportpceOlmService olmService,
- DataBroker dataBroker, NotificationPublishService notificationPublishService) {
+ DataBroker dataBroker, NotificationPublishService notificationPublishService, PortMapping portMapping) {
this.deviceRenderer = deviceRenderer;
this.otnDeviceRenderer = otnDeviceRenderer;
this.olmService = olmService;
this.dataBroker = dataBroker;
this.notificationPublishService = notificationPublishService;
+ this.portMapping = portMapping;
this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
}
public ServiceImplementationRequestOutput call() throws Exception {
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
RpcStatusEx.Pending, "Service compliant, submitting service implementation Request ...");
- // Here is the switch statement that distinguishes on the connection-type
- LOG.info("Connection-type is {} for {}", input.getConnectionType(), input.getServiceName());
- switch (input.getConnectionType()) {
- 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().getServiceFormat().getName().equals("Ethernet"))
- || (input.getServiceAEnd().getServiceFormat().getName().equals("OC")))) {
- LOG.info("Service format for {} is {} and rate is {}", input.getServiceName(),
- input.getServiceAEnd().getServiceFormat(), input.getServiceAEnd().getServiceRate());
- if (!createServicepathInput(input)) {
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
- 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
- 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) {
- serviceRate = input.getServiceAEnd().getServiceRate().toString() + "G";
- }
- LOG.info("Start rendering for {} service with {} rate and {} format",
- input.getServiceName(), serviceRate,
- input.getServiceAEnd().getServiceFormat());
- // This is A-Z side
- OtnServicePathInput otnServicePathInputAtoZ = ModelMappingUtils
- .rendererCreateOtnServiceInput(input.getServiceName(),
- input.getServiceAEnd().getServiceFormat().getName(),
- serviceRate, (PathDescription) input.getPathDescription(), true);
- // Rollback should be same for all conditions, so creating a new one
- RollbackProcessor rollbackProcessor = new RollbackProcessor();
- List<OtnDeviceRenderingResult> otnRenderingResults = otnDeviceRendering(rollbackProcessor,
- otnServicePathInputAtoZ, null);
- if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
- LOG.info("OTN rendering result size {}", otnRenderingResults.size());
+ Uint32 serviceRate = getServiceRate(input);
+ String serviceType;
+ if (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId())
+ .getNodeInfo().getNodeType())
+ && input.getServiceAEnd().getTxDirection() != null
+ && input.getServiceAEnd().getTxDirection().getPort() != null
+ && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null) {
+ Mapping mapping = portMapping.getMapping(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getTxDirection().getPort().getPortName());
+ serviceType = ServiceTypes.getServiceType(input.getServiceAEnd().getServiceFormat().getName(),
+ serviceRate, mapping);
+ } else {
+ serviceType = ServiceTypes.getServiceType(input.getServiceAEnd().getServiceFormat().getName(),
+ serviceRate, null);
+ }
+
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_100GE_T:
+ case StringConstants.SERVICE_TYPE_400GE:
+ case StringConstants.SERVICE_TYPE_OTU4:
+ case StringConstants.SERVICE_TYPE_OTUC4:
+ if (!manageServicePathCreation(input, serviceType)) {
+ return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
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().getOduServiceRate() != null)
- && (input.getServiceAEnd().getOduServiceRate().equals(ODU4.class))) {
- // For the service of OTU4 infrastructure
- String serviceRate = "100G"; // For OtnDeviceRendererServiceImpl
- LOG.info("Service format for {} is {} and rate is {}", input.getServiceName(),
- input.getServiceAEnd().getOduServiceRate(), serviceRate);
- // Now start rendering ODU4 interface
- // This is A-Z side
- OtnServicePathInput otnServicePathInputAtoZ = ModelMappingUtils
- .rendererCreateOtnServiceInput(input.getServiceName(),
- input.getServiceAEnd().getServiceFormat().getName(),
- serviceRate,
- input.getPathDescription(), true);
- // This is Z-A side
- OtnServicePathInput otnServicePathInputZtoA = ModelMappingUtils
- .rendererCreateOtnServiceInput(input.getServiceName(),
- input.getServiceZEnd().getServiceFormat().getName(),
- serviceRate,
- input.getPathDescription(), false);
- // Rollback should be same for all conditions, so creating a new one
- RollbackProcessor rollbackProcessor = new RollbackProcessor();
- List<OtnDeviceRenderingResult> otnRenderingResults = otnDeviceRendering(rollbackProcessor,
- otnServicePathInputAtoZ, otnServicePathInputZtoA);
- if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
- LOG.info("OTN rendering result size {}", otnRenderingResults.size());
+ case StringConstants.SERVICE_TYPE_1GE:
+ case StringConstants.SERVICE_TYPE_10GE:
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ case StringConstants.SERVICE_TYPE_ODU4:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ if (!manageOtnServicePathCreation(input, serviceType, serviceRate)) {
+ return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
break;
default:
- LOG.warn("Unsupported connection type {}", input.getConnectionType());
+ LOG.error("unsupported service-type");
+ break;
}
- sendNotificationsWithPathDescription(
- ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL,
- input.getPathDescription());
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_OK,
OPERATION_SUCCESSFUL);
}
return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
OPERATION_FAILED);
}
- switch (service.getConnectionType()) {
- case RoadmLine:
- case Service:
- if ((ServiceFormat.Ethernet.equals(service.getServiceAEnd().getServiceFormat())
- || ServiceFormat.OC.equals(service.getServiceAEnd().getServiceFormat()))
- && Uint32.valueOf("100").equals(service.getServiceAEnd().getServiceRate())) {
- if (!manageServicePathDeletion(serviceName, pathDescription)) {
- return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
- }
- if (ServiceFormat.Ethernet.equals(service.getServiceAEnd().getServiceFormat())
- && (Uint32.valueOf("10").equals(service.getServiceAEnd().getServiceRate())
- || Uint32.valueOf("1").equals(service.getServiceAEnd().getServiceRate()))) {
- if (!manageOtnServicePathDeletion(serviceName, pathDescription, service)) {
- return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
+ String serviceType = ServiceTypes.getServiceType(service.getServiceAEnd().getServiceFormat().getName(),
+ service.getServiceAEnd().getServiceRate(), null);
+ switch (serviceType) {
+ case StringConstants.SERVICE_TYPE_100GE_T:
+ case StringConstants.SERVICE_TYPE_400GE:
+ case StringConstants.SERVICE_TYPE_OTU4:
+ case StringConstants.SERVICE_TYPE_OTUC4:
+ if (!manageServicePathDeletion(serviceName, pathDescription, serviceType)) {
+ return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
break;
- case Infrastructure:
- if (ServiceFormat.OTU.equals(service.getServiceAEnd().getServiceFormat())) {
- if (!manageServicePathDeletion(serviceName, pathDescription)) {
- return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
- } else if (ServiceFormat.ODU.equals(service.getServiceAEnd().getServiceFormat())) {
- if (!manageOtnServicePathDeletion(serviceName, pathDescription, service)) {
- return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
- OPERATION_FAILED);
- }
+ case StringConstants.SERVICE_TYPE_1GE:
+ case StringConstants.SERVICE_TYPE_10GE:
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ case StringConstants.SERVICE_TYPE_ODU4:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ if (!manageOtnServicePathDeletion(serviceName, pathDescription, service, serviceType)) {
+ return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED,
+ OPERATION_FAILED);
}
break;
default:
- LOG.error("Unmanaged connection-type for deletion of service {}", serviceName);
+ LOG.error("unsupported service-type");
break;
- }
+ }
return ModelMappingUtils.createServiceDeleteResponse(ResponseCodes.RESPONSE_OK, OPERATION_SUCCESSFUL);
}
});
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private Uint32 getServiceRate(ServiceImplementationRequestInput input) {
+ if (input.getServiceAEnd() == null) {
+ LOG.warn("Unable to get service-rate for service {}", input.getServiceName());
+ return Uint32.ZERO;
+ }
+ if (input.getServiceAEnd().getServiceRate() != null) {
+ return input.getServiceAEnd().getServiceRate();
+ }
+ if (ServiceFormat.OTU.equals(input.getServiceAEnd().getServiceFormat())
+ && input.getServiceAEnd().getOtuServiceRate() != null) {
+ switch (input.getServiceAEnd().getOtuServiceRate().getSimpleName()) {
+ case "OTUCn":
+ return Uint32.valueOf(400);
+ case "OTU4":
+ return Uint32.valueOf(100);
+ case "OTU2":
+ case "OTU2e":
+ return Uint32.valueOf(10);
+ default:
+ LOG.warn("otu-service-rate {} not managed yet", input.getServiceAEnd().getOtuServiceRate()
+ .getSimpleName());
+ return Uint32.ZERO;
+ }
+ } else if (ServiceFormat.ODU.equals(input.getServiceAEnd().getServiceFormat())
+ && input.getServiceAEnd().getOduServiceRate() != null) {
+ switch (input.getServiceAEnd().getOduServiceRate().getSimpleName()) {
+ case "ODUCn":
+ return Uint32.valueOf(400);
+ case "ODU4":
+ return Uint32.valueOf(100);
+ case "ODU2":
+ case "ODU2e":
+ return Uint32.valueOf(10);
+ case "ODU0":
+ return Uint32.valueOf(1);
+ default:
+ LOG.warn("odu-service-rate {} not managed yet", input.getServiceAEnd().getOduServiceRate()
+ .getSimpleName());
+ return Uint32.ZERO;
+ }
+ } else {
+ LOG.warn("Unable to get service-rate for service {} - otu-service-rate should not be null",
+ input.getServiceName());
+ return Uint32.ZERO;
+ }
+ }
+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
RENDERING_DEVICES_A_Z_MSG);
ListenableFuture<OtnDeviceRenderingResult> atozrenderingFuture =
this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathAtoZ));
- ListenableFuture<List<OtnDeviceRenderingResult>> renderingCombinedFuture;
- if (otnServicePathZtoA != null) {
- LOG.info("Rendering devices Z-A");
- sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
- otnServicePathZtoA.getServiceName(), RpcStatusEx.Pending,
- RENDERING_DEVICES_Z_A_MSG);
- ListenableFuture<OtnDeviceRenderingResult> ztoarenderingFuture =
- this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathZtoA));
- renderingCombinedFuture = Futures.allAsList(atozrenderingFuture, ztoarenderingFuture);
- } else {
- renderingCombinedFuture = Futures.allAsList(atozrenderingFuture);
- }
+ LOG.info("Rendering devices Z-A");
+ sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
+ otnServicePathZtoA.getServiceName(), RpcStatusEx.Pending,
+ RENDERING_DEVICES_Z_A_MSG);
+ ListenableFuture<OtnDeviceRenderingResult> ztoarenderingFuture =
+ this.executor.submit(new OtnDeviceRenderingTask(this.otnDeviceRenderer, otnServicePathZtoA));
+ ListenableFuture<List<OtnDeviceRenderingResult>> renderingCombinedFuture =
+ Futures.allAsList(atozrenderingFuture, ztoarenderingFuture);
List<OtnDeviceRenderingResult> otnRenderingResults = new ArrayList<>(2);
try {
LOG.info("Waiting for A-Z and Z-A device renderers ...");
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
- private boolean createServicepathInput(ServiceImplementationRequestInput input) {
+ private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType) {
ServicePathInputData servicePathInputDataAtoZ = ModelMappingUtils
- .rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription());
+ .rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription(), Action.Create);
ServicePathInputData servicePathInputDataZtoA = ModelMappingUtils
- .rendererCreateServiceInputZToA(input.getServiceName(), input.getPathDescription());
+ .rendererCreateServiceInputZToA(input.getServiceName(), input.getPathDescription(), Action.Create);
// Rollback should be same for all conditions, so creating a new one
RollbackProcessor rollbackProcessor = new RollbackProcessor();
List<DeviceRenderingResult> renderingResults =
"Service activation test failed.");
return false;
}
+ List<LinkTp> otnLinkTerminationPoints = new ArrayList<>();
+ renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps()));
+ Link notifLink = createLinkForNotif(otnLinkTerminationPoints);
+
sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest,
- input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription());
+ input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription(),
+ notifLink, serviceType);
return true;
}
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
- private boolean manageServicePathDeletion(String serviceName, PathDescription pathDescription) {
+ private boolean manageServicePathDeletion(String serviceName, PathDescription pathDescription, String serviceType)
+ throws InterruptedException {
ServicePathInputData servicePathInputDataAtoZ =
- ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription);
+ ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription, Action.Delete);
ServicePathInputData servicePathInputDataZtoA =
- ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription);
+ ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription, Action.Delete);
// OLM turn down power
try {
LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
LOG.info("Deleting service path via renderer");
sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Pending,
"Deleting service path via renderer");
- deviceRenderer.deleteServicePath(servicePathInputDataAtoZ.getServicePathInput());
- deviceRenderer.deleteServicePath(servicePathInputDataZtoA.getServicePathInput());
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<DeviceRenderingResult> renderingResults =
+ deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA);
+ List<LinkTp> otnLinkTerminationPoints = new ArrayList<>();
+ renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps()));
+ Link notifLink = createLinkForNotif(otnLinkTerminationPoints);
+
sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
- serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL,pathDescription);
+ serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, serviceType);
+ return true;
+ }
+
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private boolean manageOtnServicePathCreation(ServiceImplementationRequestInput input, String serviceType,
+ Uint32 serviceRate) {
+ // This is A-Z side
+ OtnServicePathInput otnServicePathInputAtoZ = ModelMappingUtils
+ .rendererCreateOtnServiceInput(input.getServiceName(), Action.Create,
+ input.getServiceAEnd().getServiceFormat().getName(),
+ serviceRate,
+ input.getPathDescription(), true);
+ // This is Z-A side
+ OtnServicePathInput otnServicePathInputZtoA = ModelMappingUtils
+ .rendererCreateOtnServiceInput(input.getServiceName(), Action.Create,
+ input.getServiceZEnd().getServiceFormat().getName(),
+ serviceRate,
+ input.getPathDescription(), false);
+ // Rollback should be same for all conditions, so creating a new one
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<OtnDeviceRenderingResult> renderingResults =
+ otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
+ rollbackProcessor.rollbackAll();
+ sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
+ return false;
+ }
+ List<LinkTp> otnLinkTerminationPoints = new ArrayList<>();
+ renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps()));
+ Link notifLink = createLinkForNotif(otnLinkTerminationPoints);
+
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription(),
+ notifLink, serviceType);
return true;
}
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
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,
+ Services service, String serviceType) {
+ // This is A-Z side
+ OtnServicePathInput otnServicePathInputAtoZ = ModelMappingUtils
+ .rendererCreateOtnServiceInput(serviceName, Action.Delete,
service.getServiceAEnd().getServiceFormat().getName(),
- service.getServiceAEnd().getServiceRate().toString() + "G", pathDescription, true);
- }
+ service.getServiceAEnd().getServiceRate(),
+ pathDescription, true);
+ // This is Z-A side
+ OtnServicePathInput otnServicePathInputZtoA = ModelMappingUtils
+ .rendererCreateOtnServiceInput(serviceName, Action.Delete,
+ service.getServiceZEnd().getServiceFormat().getName(),
+ service.getServiceAEnd().getServiceRate(),
+ pathDescription, false);
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.getSuccess()) {
- sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
- serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription);
- return true;
- } else {
- return false;
- }
+
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<OtnDeviceRenderingResult> renderingResults =
+ otnDeviceRendering(rollbackProcessor, otnServicePathInputAtoZ, otnServicePathInputZtoA);
+
+ List<LinkTp> otnLinkTerminationPoints = new ArrayList<>();
+ renderingResults.forEach(rr -> otnLinkTerminationPoints.addAll(rr.getOtnLinkTps()));
+ Link notifLink = createLinkForNotif(otnLinkTerminationPoints);
+
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
+ serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL, pathDescription, notifLink, serviceType);
+ return true;
}
/**
private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName,
RpcStatusEx rpcStatusEx, String message) {
Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message,
- null);
+ null, null, null);
send(notification);
}
* @param pathDescription PathDescription
*/
private void sendNotificationsWithPathDescription(ServicePathNotificationTypes servicePathNotificationTypes,
- String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) {
+ String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription,
+ Link notifLink, String serviceType) {
Notification notification = buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message,
- pathDescription);
+ pathDescription, notifLink, serviceType);
send(notification);
}
* @return notification with RendererRpcResultSp type.
*/
private RendererRpcResultSp buildNotification(ServicePathNotificationTypes servicePathNotificationTypes,
- String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) {
+ String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription,
+ Link notifLink, String serviceType) {
RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder()
.setNotificationType(servicePathNotificationTypes).setServiceName(serviceName).setStatus(rpcStatusEx)
- .setStatusMessage(message);
+ .setStatusMessage(message)
+ .setServiceType(serviceType);
if (pathDescription != null) {
builder.setAToZDirection(pathDescription.getAToZDirection())
- .setZToADirection(pathDescription.getZToADirection());
+ .setZToADirection(pathDescription.getZToADirection());
+ }
+ if (notifLink != null) {
+ builder.setLink(notifLink);
}
return builder.build();
}
}
}
+ private Link createLinkForNotif(List<LinkTp> otnLinkTerminationPoints) {
+ if (otnLinkTerminationPoints.size() != 2 || otnLinkTerminationPoints.isEmpty()) {
+ return null;
+ } else {
+ return new LinkBuilder()
+ .setATermination(new ATerminationBuilder()
+ .setNodeId(otnLinkTerminationPoints.get(0).getNodeId())
+ .setTpId(otnLinkTerminationPoints.get(0).getTpId())
+ .build())
+ .setZTermination(new ZTerminationBuilder()
+ .setNodeId(otnLinkTerminationPoints.get(1).getNodeId())
+ .setTpId(otnLinkTerminationPoints.get(1).getTpId())
+ .build())
+ .build();
+ }
+ }
}