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 = this.rendererServiceOperations
151 .serviceImplementation(serviceImplementationRequest);
152 if (ResponseCodes.RESPONSE_OK
153 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
154 String message = "Service rendered successfully !";
156 operationResult = this.serviceDataStoreOperations.modifyService(input.getServiceName(), State.InService,
158 if (!operationResult.isSuccess()) {
159 LOG.warn("Service status not updated in datastore !");
161 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
162 ResponseCodes.RESPONSE_OK);
164 String message = "Service rendering has failed !";
167 OperationResult deleteServicePathOperationResult =
168 this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
169 if (!deleteServicePathOperationResult.isSuccess()) {
170 LOG.warn("Service path was not removed from datastore!");
173 OperationResult deleteServiceOperationResult =
174 this.serviceDataStoreOperations.deleteService(input.getServiceName());
175 if (!deleteServiceOperationResult.isSuccess()) {
176 LOG.warn("Service was not removed from datastore!");
179 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
180 ResponseCodes.RESPONSE_FAILED);
185 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
186 LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName());
190 * Upon receipt of service-deleteService RPC, service header and sdnc-request
191 * header compliancy are verified.
193 LOG.info("checking Service Compliancy ...");
194 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
195 input.getServiceDeleteReqInfo().getServiceName(),
196 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
197 if (serviceHandlerCheckResult.hasPassed()) {
198 LOG.info("Service compliant !");
200 LOG.info("Service is not compliant !");
201 return ModelMappingUtils
202 .createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
203 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
206 //Check presence of service to be deleted
207 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
208 LOG.info("serviceName : {}", serviceName);
210 Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
211 if (!service.isPresent()) {
212 message = "Service '" + serviceName + "' does not exist in datastore";
214 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
215 message, ResponseCodes.RESPONSE_FAILED);
217 } catch (NullPointerException e) {
218 LOG.info("failed to get service '{}' from datastore : ", serviceName, e);
221 LOG.debug("Service '{}' present in datastore !", serviceName);
222 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
223 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
224 new ServiceInput(input));
225 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
226 .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
228 if (!ResponseCodes.RESPONSE_OK
229 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
230 message = "Service delete failed!";
231 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
232 ResponseCodes.RESPONSE_FAILED);
235 OperationResult deleteServicePathOperationResult =
236 this.serviceDataStoreOperations.deleteServicePath(input.getServiceDeleteReqInfo().getServiceName());
237 if (!deleteServicePathOperationResult.isSuccess()) {
238 LOG.warn("Service path was not removed from datastore!");
241 OperationResult deleteServiceOperationResult =
242 this.serviceDataStoreOperations.deleteService(input.getServiceDeleteReqInfo().getServiceName());
243 if (!deleteServiceOperationResult.isSuccess()) {
244 LOG.warn("Service was not removed from datastore!");
247 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
248 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
252 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
253 ServiceFeasibilityCheckInput input) {
254 throw new UnsupportedOperationException("Not implemented yet");
258 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
259 throw new UnsupportedOperationException("Not implemented yet");
263 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
264 throw new UnsupportedOperationException("Not implemented yet");
268 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
269 equipmentNotification(EquipmentNotificationInput input) {
270 // TODO Auto-generated method stub
275 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
276 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
277 // TODO Auto-generated method stub
282 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
283 LOG.info("RPC service reroute received");
286 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
287 if (servicesObject.isPresent()) {
288 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
289 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
290 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
291 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
292 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
293 .setServiceName(input.getServiceName()).setDueDate(datetime)
294 .setTailRetention(TailRetention.No).build());
295 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder();
296 sdncBuilder.setNotificationUrl(servicesObject.get().getSdncRequestHeader().getNotificationUrl());
297 sdncBuilder.setRequestId(servicesObject.get().getSdncRequestHeader().getRequestId());
298 sdncBuilder.setRequestSystemId(servicesObject.get().getSdncRequestHeader().getRequestSystemId());
299 sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
300 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
301 // Calling delete service
302 ServiceDeleteOutput serviceDeleteOutput = serviceDelete(deleteInputBldr.build()).get().getResult();
303 // Calling create request now
304 if (!ResponseCodes.RESPONSE_OK
305 .equals(serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode())) {
306 message = "Service delete failed!";
307 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
308 message, RpcStatus.Failed);
310 ServiceCreateInputBuilder serviceCreateBldr = new ServiceCreateInputBuilder();
311 serviceCreateBldr.setServiceName(input.getServiceName() + 2);
312 serviceCreateBldr.setCommonId(servicesObject.get().getCommonId());
313 serviceCreateBldr.setConnectionType(servicesObject.get().getConnectionType());
314 serviceCreateBldr.setCustomer(servicesObject.get().getCustomer());
315 serviceCreateBldr.setCustomerContact(servicesObject.get().getCustomerContact());
316 serviceCreateBldr.setDueDate(servicesObject.get().getDueDate());
317 serviceCreateBldr.setEndDate(servicesObject.get().getEndDate());
318 serviceCreateBldr.setHardConstraints(servicesObject.get().getHardConstraints());
319 serviceCreateBldr.setNcCode(servicesObject.get().getNcCode());
320 serviceCreateBldr.setNciCode(servicesObject.get().getNciCode());
321 serviceCreateBldr.setOperatorContact(servicesObject.get().getOperatorContact());
322 serviceCreateBldr.setSdncRequestHeader(servicesObject.get().getSdncRequestHeader());
323 serviceCreateBldr.setSecondaryNciCode(servicesObject.get().getSecondaryNciCode());
324 ServiceAEndBuilder serviceAendBuilder = new ServiceAEndBuilder(servicesObject.get().getServiceAEnd());
325 serviceCreateBldr.setServiceAEnd(serviceAendBuilder.build());
326 ServiceZEndBuilder serviceZendBuilder = new ServiceZEndBuilder(servicesObject.get().getServiceZEnd());
327 serviceCreateBldr.setServiceZEnd(serviceZendBuilder.build());
328 serviceCreateBldr.setSoftConstraints(servicesObject.get().getSoftConstraints());
329 ServiceCreateOutput serviceCreateOutput = serviceCreate(serviceCreateBldr.build()).get().getResult();
330 if (!ResponseCodes.RESPONSE_OK
331 .equals(serviceCreateOutput.getConfigurationResponseCommon().getResponseCode())) {
332 message = "Service create failed!";
333 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
334 message, RpcStatus.Failed);
336 message = "Service reroute successfully !";
337 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
338 message, RpcStatus.Successful);
340 LOG.error("Service '{}' is not present", input.getServiceName());
341 message = "Service '" + input.getServiceName() + "' is not present";
343 } catch (InterruptedException | ExecutionException e) {
344 LOG.info("Exception caught" , e);
346 ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
347 .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage(message);
348 return RpcResultBuilder.success(output).buildFuture();
352 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
353 // TODO Auto-generated method stub
358 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
359 // TODO Auto-generated method stub
364 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
365 networkReOptimization(NetworkReOptimizationInput input) {
366 // TODO Auto-generated method stub
371 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
372 LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
376 * Upon receipt of service-deleteService RPC, service header and sdnc-request
377 * header compliancy are verified.
379 LOG.info("checking Service Compliancy ...");
380 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
381 null, null, RpcActions.ServiceDelete, false, false);
382 if (serviceHandlerCheckResult.hasPassed()) {
383 LOG.info("Service compliant !");
385 LOG.info("Service is not compliant !");
386 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
387 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
390 //Check presence of service to be deleted
391 String commonId = input.getCommonId();
392 LOG.info("service common-id : {}", commonId);
394 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
395 .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
396 if (!service.isPresent()) {
397 message = "Service '" + commonId + "' does not exist in datastore";
399 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
400 message, ResponseCodes.RESPONSE_FAILED);
402 } catch (NullPointerException e) {
403 LOG.info("failed to get service '{}' from datastore : ", commonId, e);
406 LOG.debug("Service '{}' present in datastore !", commonId);
407 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
408 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
409 new ServiceInput(input));
410 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
411 .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
413 if (!ResponseCodes.RESPONSE_OK
414 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
415 message = "Service delete failed!";
416 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
417 ResponseCodes.RESPONSE_FAILED);
420 OperationResult deleteServicePathOperationResult =
421 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
422 if (!deleteServicePathOperationResult.isSuccess()) {
423 LOG.warn("Service path was not removed from datastore!");
426 OperationResult deleteServiceOperationResult =
427 this.serviceDataStoreOperations.deleteTempService(input.getCommonId());
428 if (!deleteServiceOperationResult.isSuccess()) {
429 LOG.warn("Service was not removed from datastore!");
432 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
433 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
437 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
438 LOG.info("RPC temp service creation received");
440 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
441 new ServiceInput(input), RpcActions.TempServiceCreate);
442 if (! validationResult.isSuccess()) {
443 LOG.warn("Aborting service create because validation of service create request failed: {}",
444 validationResult.getResultMessage());
445 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
446 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
449 // Starting service create operation
450 LOG.info("Commencing PCE");
451 //TODO: createService service status into datastore
452 PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
453 String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
454 if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
455 LOG.info("PCE calculation failed {}", pceResponseCode);
456 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
457 pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
460 LOG.info("PCE calculation done OK {}", pceResponseCode);
462 OperationResult operationResult = this.serviceDataStoreOperations.createTempService(input, pceResponse);
463 if (!operationResult.isSuccess()) {
464 String message = "Service status not updated in datastore !";
466 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
467 ResponseCodes.RESPONSE_FAILED);
470 OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
471 new ServiceInput(input), pceResponse);
472 if (!operationServicePathSaveResult.isSuccess()) {
473 String message = "Service Path not updated in datastore !";
475 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
476 ResponseCodes.RESPONSE_FAILED);
479 ServiceImplementationRequestInput serviceImplementationRequest =
480 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
481 ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
482 .serviceImplementation(serviceImplementationRequest);
483 if (ResponseCodes.RESPONSE_OK
484 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
485 String message = "Service rendered successfully !";
487 operationResult = this.serviceDataStoreOperations.modifyTempService(input.getCommonId(), State.InService,
489 if (!operationResult.isSuccess()) {
490 LOG.warn("Service status not updated in datastore !");
492 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
493 ResponseCodes.RESPONSE_OK);
495 String message = "Service rendering has failed !";
498 OperationResult deleteServicePathOperationResult =
499 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
500 if (!deleteServicePathOperationResult.isSuccess()) {
501 LOG.warn("Service path was not removed from datastore!");
504 OperationResult deleteServiceOperationResult =
505 this.serviceDataStoreOperations.deleteService(input.getCommonId());
506 if (!deleteServiceOperationResult.isSuccess()) {
507 LOG.warn("Service was not removed from datastore!");
510 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
511 ResponseCodes.RESPONSE_FAILED);