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.provisiondevice.RendererServiceOperations;
23 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
24 import org.opendaylight.transportpce.servicehandler.ServiceInput;
25 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
26 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
27 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
28 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
29 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
30 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationInput;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationOutput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationInput;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationOutput;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmOutput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceAEndBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceZEndBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo.TailRetention;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
73 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
74 import org.opendaylight.yangtools.yang.common.RpcResult;
75 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
81 * Top level service interface providing main OpenROADM controller services.
83 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
85 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
87 private DataBroker db;
88 private ServiceDataStoreOperations serviceDataStoreOperations;
89 private RendererServiceOperations rendererServiceOperations;
90 private PCEServiceWrapper pceServiceWrapper;
92 //TODO: remove private request fields as they are in global scope
94 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
95 RendererServiceOperations rendererServiceOperations) {
97 this.rendererServiceOperations = rendererServiceOperations;
98 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
99 this.serviceDataStoreOperations.initialize();
100 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
104 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
105 LOG.info("RPC service creation received");
107 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
108 new ServiceInput(input), RpcActions.ServiceCreate);
109 if (! validationResult.isSuccess()) {
110 LOG.warn("Aborting service create because validation of service create request failed: {}",
111 validationResult.getResultMessage());
112 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
113 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
116 // Starting service create operation
117 LOG.info("Commencing PCE");
118 //TODO: createService service status into datastore
119 PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
120 String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
121 if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
122 LOG.info("PCE calculation failed {}", pceResponseCode);
123 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
124 pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
127 LOG.info("PCE calculation done OK {}", pceResponseCode);
129 OperationResult operationResult = this.serviceDataStoreOperations.createService(input, pceResponse);
130 if (!operationResult.isSuccess()) {
131 String message = "Service status not updated in datastore !";
133 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
134 ResponseCodes.RESPONSE_FAILED);
137 OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
138 new ServiceInput(input), pceResponse);
139 if (!operationServicePathSaveResult.isSuccess()) {
140 String message = "Service Path not updated in datastore !";
142 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
143 ResponseCodes.RESPONSE_FAILED);
146 ServiceImplementationRequestInput serviceImplementationRequest =
147 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
148 ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
149 .serviceImplementation(serviceImplementationRequest);
150 if (ResponseCodes.RESPONSE_OK
151 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
152 String message = "Service rendered successfully !";
154 operationResult = this.serviceDataStoreOperations.modifyService(input.getServiceName(), State.InService,
156 if (!operationResult.isSuccess()) {
157 LOG.warn("Service status not updated in datastore !");
159 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
160 ResponseCodes.RESPONSE_OK);
162 String message = "Service rendering has failed !";
165 OperationResult deleteServicePathOperationResult =
166 this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
167 if (!deleteServicePathOperationResult.isSuccess()) {
168 LOG.warn("Service path was not removed from datastore!");
171 OperationResult deleteServiceOperationResult =
172 this.serviceDataStoreOperations.deleteService(input.getServiceName());
173 if (!deleteServiceOperationResult.isSuccess()) {
174 LOG.warn("Service was not removed from datastore!");
177 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
178 ResponseCodes.RESPONSE_FAILED);
183 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
184 LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName());
188 * Upon receipt of service-deleteService RPC, service header and sdnc-request
189 * header compliancy are verified.
191 LOG.info("checking Service Compliancy ...");
192 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
193 input.getServiceDeleteReqInfo().getServiceName(),
194 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
195 if (serviceHandlerCheckResult.hasPassed()) {
196 LOG.info("Service compliant !");
198 LOG.info("Service is not compliant !");
199 return ModelMappingUtils
200 .createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
201 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
204 //Check presence of service to be deleted
205 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
206 LOG.info("serviceName : {}", serviceName);
208 Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
209 if (!service.isPresent()) {
210 message = "Service '" + serviceName + "' does not exist in datastore";
212 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
213 message, ResponseCodes.RESPONSE_FAILED);
215 } catch (NullPointerException e) {
216 LOG.info("failed to get service '{}' from datastore : ", serviceName, e);
219 LOG.debug("Service '{}' present in datastore !", serviceName);
220 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
221 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
222 new ServiceInput(input));
223 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
224 .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
226 if (!ResponseCodes.RESPONSE_OK
227 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
228 message = "Service delete failed!";
229 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
230 ResponseCodes.RESPONSE_FAILED);
233 OperationResult deleteServicePathOperationResult =
234 this.serviceDataStoreOperations.deleteServicePath(input.getServiceDeleteReqInfo().getServiceName());
235 if (!deleteServicePathOperationResult.isSuccess()) {
236 LOG.warn("Service path was not removed from datastore!");
239 OperationResult deleteServiceOperationResult =
240 this.serviceDataStoreOperations.deleteService(input.getServiceDeleteReqInfo().getServiceName());
241 if (!deleteServiceOperationResult.isSuccess()) {
242 LOG.warn("Service was not removed from datastore!");
245 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
246 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
250 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
251 ServiceFeasibilityCheckInput input) {
252 throw new UnsupportedOperationException("Not implemented yet");
256 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
257 throw new UnsupportedOperationException("Not implemented yet");
261 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
262 throw new UnsupportedOperationException("Not implemented yet");
266 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
267 equipmentNotification(EquipmentNotificationInput input) {
268 // TODO Auto-generated method stub
273 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
274 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
275 // TODO Auto-generated method stub
280 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
281 LOG.info("RPC service reroute received");
284 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
285 if (servicesObject.isPresent()) {
286 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
287 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
288 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
289 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
290 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
291 .setServiceName(input.getServiceName()).setDueDate(datetime)
292 .setTailRetention(TailRetention.No).build());
293 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder();
294 sdncBuilder.setNotificationUrl(servicesObject.get().getSdncRequestHeader().getNotificationUrl());
295 sdncBuilder.setRequestId(servicesObject.get().getSdncRequestHeader().getRequestId());
296 sdncBuilder.setRequestSystemId(servicesObject.get().getSdncRequestHeader().getRequestSystemId());
297 sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
298 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
299 // Calling delete service
300 ServiceDeleteOutput serviceDeleteOutput = serviceDelete(deleteInputBldr.build()).get().getResult();
301 // Calling create request now
302 if (!ResponseCodes.RESPONSE_OK
303 .equals(serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode())) {
304 message = "Service delete failed!";
305 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
306 message, RpcStatus.Failed);
308 ServiceCreateInputBuilder serviceCreateBldr = new ServiceCreateInputBuilder();
309 serviceCreateBldr.setServiceName(input.getServiceName() + 2);
310 serviceCreateBldr.setCommonId(servicesObject.get().getCommonId());
311 serviceCreateBldr.setConnectionType(servicesObject.get().getConnectionType());
312 serviceCreateBldr.setCustomer(servicesObject.get().getCustomer());
313 serviceCreateBldr.setCustomerContact(servicesObject.get().getCustomerContact());
314 serviceCreateBldr.setDueDate(servicesObject.get().getDueDate());
315 serviceCreateBldr.setEndDate(servicesObject.get().getEndDate());
316 serviceCreateBldr.setHardConstraints(servicesObject.get().getHardConstraints());
317 serviceCreateBldr.setNcCode(servicesObject.get().getNcCode());
318 serviceCreateBldr.setNciCode(servicesObject.get().getNciCode());
319 serviceCreateBldr.setOperatorContact(servicesObject.get().getOperatorContact());
320 serviceCreateBldr.setSdncRequestHeader(servicesObject.get().getSdncRequestHeader());
321 serviceCreateBldr.setSecondaryNciCode(servicesObject.get().getSecondaryNciCode());
322 ServiceAEndBuilder serviceAendBuilder = new ServiceAEndBuilder(servicesObject.get().getServiceAEnd());
323 serviceCreateBldr.setServiceAEnd(serviceAendBuilder.build());
324 ServiceZEndBuilder serviceZendBuilder = new ServiceZEndBuilder(servicesObject.get().getServiceZEnd());
325 serviceCreateBldr.setServiceZEnd(serviceZendBuilder.build());
326 serviceCreateBldr.setSoftConstraints(servicesObject.get().getSoftConstraints());
327 ServiceCreateOutput serviceCreateOutput = serviceCreate(serviceCreateBldr.build()).get().getResult();
328 if (!ResponseCodes.RESPONSE_OK
329 .equals(serviceCreateOutput.getConfigurationResponseCommon().getResponseCode())) {
330 message = "Service create failed!";
331 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
332 message, RpcStatus.Failed);
334 message = "Service reroute successfully !";
335 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
336 message, RpcStatus.Successful);
338 LOG.error("Service '{}' is not present", input.getServiceName());
339 message = "Service '" + input.getServiceName() + "' is not present";
341 } catch (InterruptedException | ExecutionException e) {
342 LOG.info("Exception caught" , e);
344 ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
345 .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage(message);
346 return RpcResultBuilder.success(output).buildFuture();
350 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
351 // TODO Auto-generated method stub
356 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
357 // TODO Auto-generated method stub
362 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
363 networkReOptimization(NetworkReOptimizationInput input) {
364 // TODO Auto-generated method stub
369 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
370 LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
374 * Upon receipt of service-deleteService RPC, service header and sdnc-request
375 * header compliancy are verified.
377 LOG.info("checking Service Compliancy ...");
378 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
379 null, null, RpcActions.ServiceDelete, false, false);
380 if (serviceHandlerCheckResult.hasPassed()) {
381 LOG.info("Service compliant !");
383 LOG.info("Service is not compliant !");
384 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
385 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
388 //Check presence of service to be deleted
389 String commonId = input.getCommonId();
390 LOG.info("service common-id : {}", commonId);
392 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
393 .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
394 if (!service.isPresent()) {
395 message = "Service '" + commonId + "' does not exist in datastore";
397 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
398 message, ResponseCodes.RESPONSE_FAILED);
400 } catch (NullPointerException e) {
401 LOG.info("failed to get service '{}' from datastore : ", commonId, e);
404 LOG.debug("Service '{}' present in datastore !", commonId);
405 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
406 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
407 new ServiceInput(input));
408 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
409 .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
411 if (!ResponseCodes.RESPONSE_OK
412 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
413 message = "Service delete failed!";
414 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
415 ResponseCodes.RESPONSE_FAILED);
418 OperationResult deleteServicePathOperationResult =
419 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
420 if (!deleteServicePathOperationResult.isSuccess()) {
421 LOG.warn("Service path was not removed from datastore!");
424 OperationResult deleteServiceOperationResult =
425 this.serviceDataStoreOperations.deleteTempService(input.getCommonId());
426 if (!deleteServiceOperationResult.isSuccess()) {
427 LOG.warn("Service was not removed from datastore!");
430 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
431 "Service delete was successful!", ResponseCodes.RESPONSE_OK);
435 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
436 LOG.info("RPC temp service creation received");
438 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
439 new ServiceInput(input), RpcActions.TempServiceCreate);
440 if (! validationResult.isSuccess()) {
441 LOG.warn("Aborting service create because validation of service create request failed: {}",
442 validationResult.getResultMessage());
443 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
444 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
447 // Starting service create operation
448 LOG.info("Commencing PCE");
449 //TODO: createService service status into datastore
450 PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
451 String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
452 if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
453 LOG.info("PCE calculation failed {}", pceResponseCode);
454 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
455 pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
458 LOG.info("PCE calculation done OK {}", pceResponseCode);
460 OperationResult operationResult = this.serviceDataStoreOperations.createTempService(input, pceResponse);
461 if (!operationResult.isSuccess()) {
462 String message = "Service status not updated in datastore !";
464 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
465 ResponseCodes.RESPONSE_FAILED);
468 OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
469 new ServiceInput(input), pceResponse);
470 if (!operationServicePathSaveResult.isSuccess()) {
471 String message = "Service Path not updated in datastore !";
473 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
474 ResponseCodes.RESPONSE_FAILED);
477 ServiceImplementationRequestInput serviceImplementationRequest =
478 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
479 ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
480 .serviceImplementation(serviceImplementationRequest);
481 if (ResponseCodes.RESPONSE_OK
482 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
483 String message = "Service rendered successfully !";
485 operationResult = this.serviceDataStoreOperations.modifyTempService(input.getCommonId(), State.InService,
487 if (!operationResult.isSuccess()) {
488 LOG.warn("Service status not updated in datastore !");
490 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
491 ResponseCodes.RESPONSE_OK);
493 String message = "Service rendering has failed !";
496 OperationResult deleteServicePathOperationResult =
497 this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
498 if (!deleteServicePathOperationResult.isSuccess()) {
499 LOG.warn("Service path was not removed from datastore!");
502 OperationResult deleteServiceOperationResult =
503 this.serviceDataStoreOperations.deleteService(input.getCommonId());
504 if (!deleteServiceOperationResult.isSuccess()) {
505 LOG.warn("Service was not removed from datastore!");
508 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
509 ResponseCodes.RESPONSE_FAILED);