+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private boolean createServicepathInput(ServiceImplementationRequestInput input) {
+ ServicePathInputData servicePathInputDataAtoZ = ModelMappingUtils
+ .rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription());
+ ServicePathInputData servicePathInputDataZtoA = ModelMappingUtils
+ .rendererCreateServiceInputZToA(input.getServiceName(), input.getPathDescription());
+ // Rollback should be same for all conditions, so creating a new one
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<DeviceRenderingResult> renderingResults =
+ deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
+ sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
+ return false;
+ }
+ ServicePowerSetupInput olmPowerSetupInputAtoZ =
+ ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(0).getOlmList(), input);
+ ServicePowerSetupInput olmPowerSetupInputZtoA =
+ ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input);
+ olmPowerSetup(rollbackProcessor, olmPowerSetupInputAtoZ, olmPowerSetupInputZtoA);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
+ sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Failed, OLM_ROLL_BACK_MSG);
+ return false;
+ }
+ // run service activation test twice - once on source node and once on
+ // destination node
+ List<Nodes> nodes = servicePathInputDataAtoZ.getServicePathInput().getNodes();
+ if ((nodes == null) || (nodes.isEmpty())) {
+ return false;
+ }
+
+ Nodes sourceNode = nodes.get(0);
+ Nodes destNode = nodes.get(nodes.size() - 1);
+ String srcNetworkTp;
+ String dstNetowrkTp;
+ if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
+ srcNetworkTp = sourceNode.getDestTp();
+ } else {
+ srcNetworkTp = sourceNode.getSrcTp();
+ }
+ if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
+ dstNetowrkTp = destNode.getDestTp();
+ } else {
+ dstNetowrkTp = destNode.getSrcTp();
+ }
+ if (!isServiceActivated(sourceNode.getNodeId(), srcNetworkTp)
+ || !isServiceActivated(destNode.getNodeId(), dstNetowrkTp)) {
+ rollbackProcessor.rollbackAll();
+ sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Failed,
+ "Service activation test failed.");
+ return false;
+ }
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(), RpcStatusEx.Successful, OPERATION_SUCCESSFUL, input.getPathDescription());
+ 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) {
+ ServicePathInputData servicePathInputDataAtoZ =
+ ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription);
+ ServicePathInputData servicePathInputDataZtoA =
+ ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription);
+ // OLM turn down power
+ try {
+ LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
+ sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName,
+ RpcStatusEx.Pending, TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
+ ServicePowerTurndownOutput atozPowerTurndownOutput = olmPowerTurndown(servicePathInputDataAtoZ);
+ // TODO add some flag rather than string
+ if (FAILED.equals(atozPowerTurndownOutput.getResult())) {
+ LOG.error("Service power turndown failed on A-to-Z path for service {}!", serviceName);
+ sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Failed,
+ "Service power turndown failed on A-to-Z path for service");
+ return false;
+ }
+ LOG.debug("Turning down power on Z-to-A path");
+ sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Pending,
+ "Turning down power on Z-to-A path");
+ ServicePowerTurndownOutput ztoaPowerTurndownOutput = olmPowerTurndown(servicePathInputDataZtoA);
+ // TODO add some flag rather than string
+ if (FAILED.equals(ztoaPowerTurndownOutput.getResult())) {
+ LOG.error("Service power turndown failed on Z-to-A path for service {}!", serviceName);
+ sendNotifications(ServicePathNotificationTypes.ServiceDelete, serviceName, RpcStatusEx.Failed,
+ "Service power turndown failed on Z-to-A path for service");
+ return false;
+ }
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.error("Error while turning down power!", e);
+ return false;
+ }
+ // delete service path with renderer
+ 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());
+ sendNotificationsWithPathDescription(ServicePathNotificationTypes.ServiceDelete,
+ serviceName, RpcStatusEx.Successful, OPERATION_SUCCESSFUL,pathDescription);
+ return true;
+ }
+
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ 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,
+ 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.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();
+ }
+ }
+