+ public ListenableFuture<ServiceImplementationRequestOutput>
+ serviceImplementation(ServiceImplementationRequestInput input) {
+ return executor.submit(new Callable<ServiceImplementationRequestOutput>() {
+ @Override
+ public ServiceImplementationRequestOutput call() {
+ LOG.info("serviceImplementation request ...");
+ String serviceName = input.getServiceName();
+ RpcStatusEx rpcStatusEx = RpcStatusEx.Pending;
+ ServiceRpcResultSp notification = new ServiceRpcResultSpBuilder()
+ .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
+ .setServiceName(serviceName).setStatus(rpcStatusEx)
+ .setStatusMessage("Service compliant, submitting serviceImplementation Request ...").build();
+ sendNotifications(notification);
+ String message = "";
+ String responseCode = null;
+ ConfigurationResponseCommonBuilder configurationResponseCommon = null;
+ ServiceImplementationRequestOutput output = null;
+ try {
+ LOG.info("Wait for 5s til beginning the Renderer serviceImplementation request");
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ message = "renderer failed !";
+ rpcStatusEx = RpcStatusEx.Failed;
+ responseCode = ResponseCodes.RESPONSE_FAILED;
+ LOG.error(message);
+ notification = new ServiceRpcResultSpBuilder()
+ .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
+ .setServiceName(serviceName).setStatus(rpcStatusEx).setStatusMessage(message).build();
+ sendNotifications(notification);
+ configurationResponseCommon =
+ new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode).setResponseMessage(message);
+ output = new ServiceImplementationRequestOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build()).build();
+ return output;
+ }
+ if (rendererFailed) {
+ LOG.info("forcing renderer to fail");
+ message = "renderer failed !";
+ rpcStatusEx = RpcStatusEx.Failed;
+ LOG.error(message);
+ responseCode = ResponseCodes.RESPONSE_FAILED;
+ } else {
+ if (isnetworkModelWlService) {
+ networkModelWavelengthService.useWavelengths(input.getPathDescription());
+ } else {
+ LOG.warn("No need to execute networkModelWavelengthService...");
+ }
+ message = "service implemented !";
+ rpcStatusEx = RpcStatusEx.Successful;
+ LOG.info(message);
+ responseCode = ResponseCodes.RESPONSE_OK;
+ }
+ PathTopology pathTopology = new PathTopologyBuilder().build();
+ notification = new ServiceRpcResultSpBuilder()
+ .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
+ .setServiceName(serviceName).setStatus(rpcStatusEx)
+ .setStatusMessage(message).setPathTopology(pathTopology).build();
+ sendNotifications(notification);
+ responseCode = ResponseCodes.RESPONSE_OK;
+ configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode)
+ .setResponseMessage(message);
+ output = new ServiceImplementationRequestOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build())
+ .build();
+ return output;
+ }
+ });
+ }
+
+ @Override
+ public ListenableFuture<ServiceDeleteOutput> serviceDelete(ServiceDeleteInput input) {
+ return executor.submit(new Callable<ServiceDeleteOutput>() {
+ @Override
+ public ServiceDeleteOutput call() {
+ LOG.info("ServiceDelete request ...");
+ String serviceName = input.getServiceName();
+ RpcStatusEx rpcStatusEx = RpcStatusEx.Pending;
+ ServiceRpcResultSp notification =
+ new ServiceRpcResultSpBuilder().setNotificationType(ServicePathNotificationTypes.ServiceDelete)
+ .setServiceName(serviceName).setStatus(rpcStatusEx)
+ .setStatusMessage("Service compliant, submitting serviceDelete Request ...").build();
+ sendNotifications(notification);
+ String message = "";
+ String responseCode = null;
+ ConfigurationResponseCommonBuilder configurationResponseCommon = null;
+ ServiceDeleteOutput output = null;
+ try {
+ LOG.info("Wait for 5s til beginning the Renderer serviceDelete request");
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ message = "deleting service failed !";
+ LOG.error("deleting service failed !", e);
+ responseCode = ResponseCodes.RESPONSE_FAILED;
+ rpcStatusEx = RpcStatusEx.Failed;
+ notification = new ServiceRpcResultSpBuilder()
+ .setNotificationType(ServicePathNotificationTypes.ServiceDelete).setServiceName(serviceName)
+ .setStatus(rpcStatusEx).setStatusMessage(message).build();
+ sendNotifications(notification);
+ configurationResponseCommon =
+ new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode).setResponseMessage(message);
+ output = new ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build()).build();
+ }
+ if (rendererFailed) {
+ LOG.info("forcing renderer to fail");
+ message = "renderer failed !";
+ rpcStatusEx = RpcStatusEx.Failed;
+ LOG.error(message);
+ responseCode = ResponseCodes.RESPONSE_FAILED;
+ } else {
+ if (isnetworkModelWlService) {
+ // Obtain path description
+ Optional<PathDescription> pathDescriptionOpt = getPathDescriptionFromDatastore(serviceName);
+ PathDescription pathDescription;
+ if (pathDescriptionOpt.isPresent()) {
+ pathDescription = pathDescriptionOpt.get();
+ networkModelWavelengthService.freeWavelengths(pathDescription);
+ } else {
+ LOG.warn("failed to get pathDescription for service : {}", serviceName);
+ }
+ } else {
+ LOG.warn("No need to execute networkModelWavelengthService...");
+ }
+ message = "service deleted !";
+ rpcStatusEx = RpcStatusEx.Successful;
+ LOG.info(message);
+ responseCode = ResponseCodes.RESPONSE_OK;
+ }
+ notification = new ServiceRpcResultSpBuilder()
+ .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
+ .setServiceName(serviceName).setStatus(rpcStatusEx)
+ .setStatusMessage(message).build();
+ sendNotifications(notification);
+ responseCode = ResponseCodes.RESPONSE_OK;
+ configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode)
+ .setResponseMessage(message);
+ output = new ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build())
+ .build();
+ return output;
+ }
+ });
+ }
+
+ private Optional<PathDescription> getPathDescriptionFromDatastore(String serviceName) {
+ InstanceIdentifier<PathDescription> pathDescriptionIID = InstanceIdentifier.create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceName)).child(PathDescription.class);
+ ReadTransaction pathDescReadTx = this.dataBroker.newReadOnlyTransaction();