2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.servicehandler.impl;
10 import com.google.common.util.concurrent.ListenableFuture;
12 import java.time.OffsetDateTime;
13 import java.time.ZoneOffset;
14 import java.time.format.DateTimeFormatter;
15 import java.util.Optional;
16 import java.util.concurrent.ExecutionException;
18 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
19 import org.opendaylight.transportpce.common.OperationResult;
20 import org.opendaylight.transportpce.common.ResponseCodes;
21 import org.opendaylight.transportpce.pce.service.PathComputationService;
22 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
23 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
24 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
25 import org.opendaylight.transportpce.servicehandler.ServiceInput;
26 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
27 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
28 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
29 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
30 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
31 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationInput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationOutput;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationInput;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationOutput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionInput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceAEndBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceZEndBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo.TailRetention;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
74 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
75 import org.opendaylight.yangtools.yang.common.RpcResult;
76 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
82 * Top level service interface providing main OpenROADM controller services.
84 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
86 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
88 private DataBroker db;
89 private ServiceDataStoreOperations serviceDataStoreOperations;
90 private RendererServiceOperations rendererServiceOperations;
91 private PCEServiceWrapper pceServiceWrapper;
93 //TODO: remove private request fields as they are in global scope
95 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
96 RendererServiceOperations rendererServiceOperations,
97 NetworkModelWavelengthService networkModelWavelengthService) {
99 this.rendererServiceOperations = rendererServiceOperations;
100 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
101 this.serviceDataStoreOperations.initialize();
102 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
106 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
107 LOG.info("RPC service creation received");
109 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
110 new ServiceInput(input), RpcActions.ServiceCreate);
111 if (! validationResult.isSuccess()) {
112 LOG.warn("Aborting service create because validation of service create request failed: {}",
113 validationResult.getResultMessage());
114 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
115 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
118 // Starting service create operation
119 LOG.info("Commencing PCE");
120 //TODO: createService service status into datastore
121 PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
122 String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
123 if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
124 LOG.info("PCE calculation failed {}", pceResponseCode);
125 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
126 pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
129 LOG.info("PCE calculation done OK {}", pceResponseCode);
131 OperationResult operationResult = this.serviceDataStoreOperations.createService(input, pceResponse);
132 if (!operationResult.isSuccess()) {
133 String message = "Service status not updated in datastore !";
135 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
136 ResponseCodes.RESPONSE_FAILED);
139 OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
140 new ServiceInput(input), pceResponse);
141 if (!operationServicePathSaveResult.isSuccess()) {
142 String message = "Service Path not updated in datastore !";
144 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
145 ResponseCodes.RESPONSE_FAILED);
148 ServiceImplementationRequestInput serviceImplementationRequest =
149 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
150 ServiceImplementationRequestOutput serviceImplementationRequestOutput = null;
152 serviceImplementationRequestOutput =
153 this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest).get();
154 } catch (InterruptedException | ExecutionException e) {
155 LOG.error("Renderer Service implementation failed !");
157 if (ResponseCodes.RESPONSE_OK
158 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
159 String message = "Service rendered successfully !";
161 operationResult = this.serviceDataStoreOperations.modifyService(input.getServiceName(), State.InService,
163 if (!operationResult.isSuccess()) {
164 LOG.warn("Service status not updated in datastore !");
166 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
167 ResponseCodes.RESPONSE_OK);
169 String message = "Service rendering has failed !";
172 OperationResult deleteServicePathOperationResult =
173 this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
174 if (!deleteServicePathOperationResult.isSuccess()) {
175 LOG.warn("Service path was not removed from datastore!");
178 OperationResult deleteServiceOperationResult =
179 this.serviceDataStoreOperations.deleteService(input.getServiceName());
180 if (!deleteServiceOperationResult.isSuccess()) {
181 LOG.warn("Service was not removed from datastore!");
184 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
185 ResponseCodes.RESPONSE_FAILED);
190 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
191 LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName());
195 * Upon receipt of service-deleteService RPC, service header and sdnc-request
196 * header compliancy are verified.
198 LOG.info("checking Service Compliancy ...");
199 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
200 input.getServiceDeleteReqInfo().getServiceName(),
201 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
202 if (serviceHandlerCheckResult.hasPassed()) {
203 LOG.info("Service compliant !");
205 LOG.info("Service is not compliant !");
206 return ModelMappingUtils
207 .createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
208 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
211 //Check presence of service to be deleted
212 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
213 LOG.info("serviceName : {}", serviceName);
215 Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
216 if (!service.isPresent()) {
217 message = "Service '" + serviceName + "' does not exist in datastore";
219 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
220 message, ResponseCodes.RESPONSE_FAILED);
222 } catch (NullPointerException e) {
223 LOG.info("failed to get service '{}' from datastore : ", serviceName, e);
226 LOG.debug("Service '{}' present in datastore !", serviceName);
227 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
228 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
229 new ServiceInput(input));
230 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
231 .ServiceDeleteOutput output = null;
233 output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput).get();
234 } catch (InterruptedException | ExecutionException e) {
235 LOG.error("Renderer Service delete failed !");
238 if (!ResponseCodes.RESPONSE_OK
239 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
240 message = "Service delete failed!";
241 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
242 ResponseCodes.RESPONSE_FAILED);
245 OperationResult deleteServicePathOperationResult =
246 this.serviceDataStoreOperations.deleteServicePath(input.getServiceDeleteReqInfo().getServiceName());
247 if (!deleteServicePathOperationResult.isSuccess()) {
248 LOG.warn("Service path was not removed from datastore!");
251 OperationResult deleteServiceOperationResult =
252 this.serviceDataStoreOperations.deleteService(input.getServiceDeleteReqInfo().getServiceName());
253 if (!deleteServiceOperationResult.isSuccess()) {
254 LOG.warn("Service was not removed from datastore!");
257 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
258 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
262 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
263 ServiceFeasibilityCheckInput input) {
264 throw new UnsupportedOperationException("Not implemented yet");
268 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
269 throw new UnsupportedOperationException("Not implemented yet");
273 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
274 throw new UnsupportedOperationException("Not implemented yet");
278 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
279 equipmentNotification(EquipmentNotificationInput input) {
280 // TODO Auto-generated method stub
285 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
286 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
287 // TODO Auto-generated method stub
292 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
293 LOG.info("RPC service reroute received");
296 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
297 if (servicesObject.isPresent()) {
298 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
299 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
300 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
301 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
302 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
303 .setServiceName(input.getServiceName()).setDueDate(datetime)
304 .setTailRetention(TailRetention.No).build());
305 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder();
306 sdncBuilder.setNotificationUrl(servicesObject.get().getSdncRequestHeader().getNotificationUrl());
307 sdncBuilder.setRequestId(servicesObject.get().getSdncRequestHeader().getRequestId());
308 sdncBuilder.setRequestSystemId(servicesObject.get().getSdncRequestHeader().getRequestSystemId());
309 sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
310 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
311 // Calling delete service
312 ServiceDeleteOutput serviceDeleteOutput = serviceDelete(deleteInputBldr.build()).get().getResult();
313 // Calling create request now
314 if (!ResponseCodes.RESPONSE_OK
315 .equals(serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode())) {
316 message = "Service delete failed!";
317 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
318 message, RpcStatus.Failed);
320 ServiceCreateInputBuilder serviceCreateBldr = new ServiceCreateInputBuilder();
321 serviceCreateBldr.setServiceName(input.getServiceName() + 2);
322 serviceCreateBldr.setCommonId(servicesObject.get().getCommonId());
323 serviceCreateBldr.setConnectionType(servicesObject.get().getConnectionType());
324 serviceCreateBldr.setCustomer(servicesObject.get().getCustomer());
325 serviceCreateBldr.setCustomerContact(servicesObject.get().getCustomerContact());
326 serviceCreateBldr.setDueDate(servicesObject.get().getDueDate());
327 serviceCreateBldr.setEndDate(servicesObject.get().getEndDate());
328 serviceCreateBldr.setHardConstraints(servicesObject.get().getHardConstraints());
329 serviceCreateBldr.setNcCode(servicesObject.get().getNcCode());
330 serviceCreateBldr.setNciCode(servicesObject.get().getNciCode());
331 serviceCreateBldr.setOperatorContact(servicesObject.get().getOperatorContact());
332 serviceCreateBldr.setSdncRequestHeader(servicesObject.get().getSdncRequestHeader());
333 serviceCreateBldr.setSecondaryNciCode(servicesObject.get().getSecondaryNciCode());
334 ServiceAEndBuilder serviceAendBuilder = new ServiceAEndBuilder(servicesObject.get().getServiceAEnd());
335 serviceCreateBldr.setServiceAEnd(serviceAendBuilder.build());
336 ServiceZEndBuilder serviceZendBuilder = new ServiceZEndBuilder(servicesObject.get().getServiceZEnd());
337 serviceCreateBldr.setServiceZEnd(serviceZendBuilder.build());
338 serviceCreateBldr.setSoftConstraints(servicesObject.get().getSoftConstraints());
339 ServiceCreateOutput serviceCreateOutput = serviceCreate(serviceCreateBldr.build()).get().getResult();
340 if (!ResponseCodes.RESPONSE_OK
341 .equals(serviceCreateOutput.getConfigurationResponseCommon().getResponseCode())) {
342 message = "Service create failed!";
343 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
344 message, RpcStatus.Failed);
346 message = "Service reroute successfully !";
347 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
348 message, RpcStatus.Successful);
350 LOG.error("Service '{}' is not present", input.getServiceName());
351 message = "Service '" + input.getServiceName() + "' is not present";
353 } catch (InterruptedException | ExecutionException e) {
354 LOG.info("Exception caught" , e);
356 ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
357 .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage(message);
358 return RpcResultBuilder.success(output).buildFuture();
362 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
363 // TODO Auto-generated method stub
368 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
369 // TODO Auto-generated method stub
374 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
375 networkReOptimization(NetworkReOptimizationInput input) {
376 // TODO Auto-generated method stub
381 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
382 LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
386 * Upon receipt of service-deleteService RPC, service header and sdnc-request
387 * header compliancy are verified.
389 LOG.info("checking Service Compliancy ...");
390 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
391 null, null, RpcActions.ServiceDelete, false, false);
392 if (serviceHandlerCheckResult.hasPassed()) {
393 LOG.info("Service compliant !");
395 LOG.info("Service is not compliant !");
396 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
397 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
400 //Check presence of service to be deleted
401 String commonId = input.getCommonId();
402 LOG.info("service common-id : {}", commonId);
404 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
405 .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
406 if (!service.isPresent()) {
407 message = "Service '" + commonId + "' does not exist in datastore";
409 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
410 message, ResponseCodes.RESPONSE_FAILED);
412 } catch (NullPointerException e) {
413 LOG.info("failed to get service '{}' from datastore : ", commonId, e);
416 LOG.debug("Service '{}' present in datastore !", commonId);
417 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
418 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
419 new ServiceInput(input));
420 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
421 .ServiceDeleteOutput output = null;
423 output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput).get();
424 } catch (InterruptedException | ExecutionException e) {
425 LOG.error("Renderer Service delete failed ! ");
428 if (!ResponseCodes.RESPONSE_OK
429 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
430 message = "Service delete failed!";
431 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
432 ResponseCodes.RESPONSE_FAILED);
435 OperationResult deleteServicePathOperationResult =
436 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
437 if (!deleteServicePathOperationResult.isSuccess()) {
438 LOG.warn("Service path was not removed from datastore!");
441 OperationResult deleteServiceOperationResult =
442 this.serviceDataStoreOperations.deleteTempService(input.getCommonId());
443 if (!deleteServiceOperationResult.isSuccess()) {
444 LOG.warn("Service was not removed from datastore!");
447 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
448 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
452 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
453 LOG.info("RPC temp service creation received");
455 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
456 new ServiceInput(input), RpcActions.TempServiceCreate);
457 if (! validationResult.isSuccess()) {
458 LOG.warn("Aborting service create because validation of service create request failed: {}",
459 validationResult.getResultMessage());
460 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
461 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
464 // Starting service create operation
465 LOG.info("Commencing PCE");
466 //TODO: createService service status into datastore
467 PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
468 String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
469 if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
470 LOG.info("PCE calculation failed {}", pceResponseCode);
471 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
472 pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
475 LOG.info("PCE calculation done OK {}", pceResponseCode);
477 OperationResult operationResult = this.serviceDataStoreOperations.createTempService(input, pceResponse);
478 if (!operationResult.isSuccess()) {
479 String message = "Service status not updated in datastore !";
481 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
482 ResponseCodes.RESPONSE_FAILED);
485 OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
486 new ServiceInput(input), pceResponse);
487 if (!operationServicePathSaveResult.isSuccess()) {
488 String message = "Service Path not updated in datastore !";
490 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
491 ResponseCodes.RESPONSE_FAILED);
494 ServiceImplementationRequestInput serviceImplementationRequest =
495 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
496 ServiceImplementationRequestOutput serviceImplementationRequestOutput = null;
498 serviceImplementationRequestOutput =
499 this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest).get();
500 } catch (InterruptedException | ExecutionException e) {
501 LOG.error("Renderer service implementation failed !");
503 if (ResponseCodes.RESPONSE_OK
504 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
505 String message = "Service rendered successfully !";
507 operationResult = this.serviceDataStoreOperations.modifyTempService(input.getCommonId(), State.InService,
509 if (!operationResult.isSuccess()) {
510 LOG.warn("Service status not updated in datastore !");
512 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
513 ResponseCodes.RESPONSE_OK);
515 String message = "Service rendering has failed !";
518 OperationResult deleteServicePathOperationResult =
519 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
520 if (!deleteServicePathOperationResult.isSuccess()) {
521 LOG.warn("Service path was not removed from datastore!");
524 OperationResult deleteServiceOperationResult =
525 this.serviceDataStoreOperations.deleteService(input.getCommonId());
526 if (!deleteServiceOperationResult.isSuccess()) {
527 LOG.warn("Service was not removed from datastore!");
530 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
531 ResponseCodes.RESPONSE_FAILED);