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;
17 import org.opendaylight.mdsal.binding.api.DataBroker;
18 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
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.DowngradeConstraints;
25 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
26 import org.opendaylight.transportpce.servicehandler.ServiceInput;
27 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
28 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
29 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
30 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
31 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
32 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
33 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
34 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
35 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestOutput;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommon;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev190531.RpcStatus;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraints;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraints;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationOutput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationOutput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestInput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteOutput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo.TailRetention;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
86 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
87 import org.opendaylight.yangtools.yang.common.RpcResult;
88 import org.slf4j.Logger;
89 import org.slf4j.LoggerFactory;
93 * Top level service interface providing main OpenROADM controller services.
95 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
97 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
99 private DataBroker db;
100 private ServiceDataStoreOperations serviceDataStoreOperations;
101 private PCEServiceWrapper pceServiceWrapper;
102 private RendererServiceWrapper rendererServiceWrapper;
103 private PceListenerImpl pceListenerImpl;
104 private RendererListenerImpl rendererListenerImpl;
106 //TODO: remove private request fields as they are in global scope
108 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
109 RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
110 PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
111 NetworkModelWavelengthService networkModelWavelengthService) {
112 this.db = databroker;
113 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
114 this.serviceDataStoreOperations.initialize();
115 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
116 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
117 this.pceListenerImpl = pceListenerImpl;
118 this.rendererListenerImpl = rendererListenerImpl;
122 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
123 LOG.info("RPC service creation received");
125 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
126 new ServiceInput(input), RpcActions.ServiceCreate);
127 if (! validationResult.isSuccess()) {
128 LOG.warn("Aborting service create because validation of service create request failed: {}",
129 validationResult.getResultMessage());
130 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
131 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
133 this.pceListenerImpl.setInput(new ServiceInput(input));
134 this.pceListenerImpl.setServiceReconfigure(false);
135 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
136 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
137 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
138 LOG.info("Commencing PCE");
139 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
140 if (output != null) {
141 LOG.info("Service compliant, serviceCreate in progress...");
142 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
143 return ModelMappingUtils.createCreateServiceReply(input, common.getAckFinalIndicator(),
144 common.getResponseMessage(), common.getResponseCode());
146 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
147 "PCE calculation failed", ResponseCodes.RESPONSE_FAILED);
152 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
153 LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName());
157 * Upon receipt of service-deleteService RPC, service header and sdnc-request
158 * header compliancy are verified.
160 LOG.info("checking Service Compliancy ...");
161 ComplianceCheckResult serviceHandlerCheckResult =
162 ServicehandlerCompliancyCheck.check(
163 input.getServiceDeleteReqInfo().getServiceName(),
164 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
165 if (serviceHandlerCheckResult.hasPassed()) {
166 LOG.info("Service compliant !");
168 LOG.info("Service is not compliant !");
169 return ModelMappingUtils
170 .createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
171 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
174 //Check presence of service to be deleted
175 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
176 LOG.info("serviceName : {}", serviceName);
178 Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
179 if (!service.isPresent()) {
180 message = "Service '" + serviceName + "' does not exist in datastore";
182 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
183 message, ResponseCodes.RESPONSE_FAILED);
185 } catch (NullPointerException e) {
186 LOG.error("failed to get service '{}' from datastore : ", serviceName, e);
187 message = "Service '" + serviceName + "' does not exist in datastore";
189 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
190 ResponseCodes.RESPONSE_FAILED);
192 LOG.info("Service '{}' present in datastore !", serviceName);
193 this.pceListenerImpl.setInput(new ServiceInput(input));
194 this.pceListenerImpl.setServiceReconfigure(false);
195 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
196 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
197 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
198 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
199 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
200 new ServiceInput(input));
201 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
202 this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
203 ServiceNotificationTypes.ServiceDeleteResult);
204 if (output != null) {
205 LOG.info("Service present in datastore, service-delete in progress...");
206 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
207 return ModelMappingUtils.createDeleteServiceReply(input, common.getAckFinalIndicator(),
208 common.getResponseMessage(), common.getResponseCode());
210 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
211 "Renderer service delete failed !", ResponseCodes.RESPONSE_FAILED);
216 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
217 ServiceFeasibilityCheckInput input) {
218 LOG.info("RPC service feasibility check received");
220 ServiceInput serviceInput = new ServiceInput(input);
221 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
222 RpcActions.ServiceFeasibilityCheck);
223 if (! validationResult.isSuccess()) {
224 LOG.warn("Aborting service feasibility check because validation of service create request failed: {}",
225 validationResult.getResultMessage());
226 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
227 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
229 this.pceListenerImpl.setInput(new ServiceInput(input));
230 this.pceListenerImpl.setServiceReconfigure(false);
231 this.pceListenerImpl.setServiceFeasiblity(true);
232 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
233 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
234 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
235 LOG.info("Commencing PCE");
236 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
237 if (output != null) {
238 LOG.info("Service compliant, serviceFeasibilityCheck in progress...");
239 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
240 return ModelMappingUtils.createCreateServiceReply(input, common.getAckFinalIndicator(),
241 common.getResponseMessage(), common.getResponseCode());
243 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
244 "PCE calculation failed", ResponseCodes.RESPONSE_FAILED);
249 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
250 LOG.info("RPC service reconfigure received");
252 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
253 if (servicesObject.isPresent()) {
254 LOG.info("Service '{}' is present", input.getServiceName());
255 OperationResult validationResult = ServiceCreateValidation
256 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
257 if (!validationResult.isSuccess()) {
258 LOG.warn("Aborting service reconfigure because validation of service create request failed: {}",
259 validationResult.getResultMessage());
260 return ModelMappingUtils.createCreateServiceReply(input, validationResult.getResultMessage(),
263 this.pceListenerImpl.setInput(new ServiceInput(input));
264 this.pceListenerImpl.setServiceReconfigure(true);
265 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
266 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
267 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
268 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
269 .ServiceDeleteInput serviceDeleteInput =
270 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
271 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
272 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
273 ServiceNotificationTypes.ServiceDeleteResult);
274 if (output != null) {
275 LOG.info("Service compliant, service reconfigure in progress...");
276 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
277 return ModelMappingUtils.createCreateServiceReply(input, common.getResponseMessage(),
278 RpcStatus.Successful);
280 return ModelMappingUtils.createCreateServiceReply(input, "Renderer service delete failed !",
281 RpcStatus.Successful);
284 LOG.error("Service '{}' is not present", input.getServiceName());
285 message = "Service '" + input.getServiceName() + "' is not present";
286 return ModelMappingUtils.createCreateServiceReply(input, message, RpcStatus.Failed);
291 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
292 LOG.info("RPC service restoration received");
294 String serviceName = input.getServiceName();
295 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
296 if (servicesObject.isPresent()) {
297 Services service = servicesObject.get();
298 State state = service.getOperationalState();
299 if (state != State.InService) {
300 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
301 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
302 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
303 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
304 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
305 .setServiceName(serviceName).setDueDate(datetime)
306 .setTailRetention(TailRetention.No).build());
307 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
308 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
309 .setRequestId(service.getSdncRequestHeader().getRequestId())
310 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
311 .setRpcAction(RpcActions.ServiceDelete);
312 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
313 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
314 serviceInput.setServiceAEnd(service.getServiceAEnd());
315 serviceInput.setServiceZEnd(service.getServiceZEnd());
316 serviceInput.setConnectionType(service.getConnectionType());
317 HardConstraints hardConstraints = service.getHardConstraints();
318 if (hardConstraints != null) {
319 SoftConstraints softConstraints = service.getSoftConstraints();
320 if (softConstraints != null) {
321 LOG.info("converting hard constraints to soft constraints ...");
322 serviceInput.setSoftConstraints(
323 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
324 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
326 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
327 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
328 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
331 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
333 this.pceListenerImpl.setInput(serviceInput);
334 this.pceListenerImpl.setServiceReconfigure(true);
335 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
336 this.rendererListenerImpl.setServiceInput(serviceInput);
337 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
338 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
339 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
340 new ServiceInput(deleteInputBldr.build()));
341 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
342 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
343 ServiceNotificationTypes.ServiceDeleteResult);
344 if (output != null) {
345 LOG.info("Service present in datastore, service-restore in progress...");
346 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
347 return ModelMappingUtils.createRestoreServiceReply(common.getResponseMessage(),
348 RpcStatus.Successful);
350 return ModelMappingUtils.createRestoreServiceReply("Renderer service delete failed !",
354 LOG.error("Service '{}' is in 'inService' state", input.getServiceName());
355 message = "Service '" + input.getServiceName() + "' is in 'inService' state";
356 return ModelMappingUtils.createRestoreServiceReply(message, RpcStatus.Failed);
359 LOG.error("Service '{}' is not present", input.getServiceName());
360 message = "Service '" + input.getServiceName() + "' is not present";
361 return ModelMappingUtils.createRestoreServiceReply(message, RpcStatus.Failed);
366 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
367 equipmentNotification(EquipmentNotificationInput input) {
368 // TODO Auto-generated method stub
373 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
374 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
375 // TODO Auto-generated method stub
380 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
381 LOG.info("RPC service reroute received");
383 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
384 if (servicesObject.isPresent()) {
385 Services service = servicesObject.get();
386 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
387 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
388 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
389 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
390 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
391 .setServiceName(input.getServiceName()).setDueDate(datetime)
392 .setTailRetention(TailRetention.No).build());
393 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
394 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
395 .setRequestId(service.getSdncRequestHeader().getRequestId())
396 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
397 .setRpcAction(RpcActions.ServiceDelete);
398 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
399 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
400 serviceInput.setServiceAEnd(service.getServiceAEnd());
401 serviceInput.setServiceZEnd(service.getServiceZEnd());
402 serviceInput.setConnectionType(service.getConnectionType());
403 this.pceListenerImpl.setInput(serviceInput);
404 this.pceListenerImpl.setServiceReconfigure(true);
405 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
406 this.rendererListenerImpl.setServiceInput(serviceInput);
407 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
408 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
409 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
410 new ServiceInput(deleteInputBldr.build()));
411 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
412 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
413 ServiceNotificationTypes.ServiceDeleteResult);
414 if (output != null) {
415 LOG.info("Service present in datastore, service-reroute in progress...");
416 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
417 return ModelMappingUtils.createRerouteServiceReply(input, common.getAckFinalIndicator(),
418 common.getResponseMessage(), RpcStatus.Successful);
420 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
421 "Renderer service delete failed !", RpcStatus.Failed);
424 LOG.error("Service '{}' is not present", input.getServiceName());
425 message = "Service '" + input.getServiceName() + "' is not present";
426 return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_NO, message,
432 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
433 // TODO Auto-generated method stub
438 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
439 // TODO Auto-generated method stub
444 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
445 networkReOptimization(NetworkReOptimizationInput input) {
446 // TODO Auto-generated method stub
451 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
452 LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
456 * Upon receipt of service-deleteService RPC, service header and sdnc-request
457 * header compliancy are verified.
459 LOG.info("checking Service Compliancy ...");
460 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
461 null, null, RpcActions.ServiceDelete, false, false);
462 if (serviceHandlerCheckResult.hasPassed()) {
463 LOG.info("Service compliant !");
465 LOG.info("Service is not compliant !");
466 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
467 "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
470 //Check presence of service to be deleted
471 String commonId = input.getCommonId();
472 LOG.info("service common-id : {}", commonId);
474 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list
475 .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
476 if (!service.isPresent()) {
477 message = "Service '" + commonId + "' does not exist in datastore";
479 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
480 message, ResponseCodes.RESPONSE_FAILED);
482 } catch (NullPointerException e) {
483 LOG.info("failed to get service '{}' from datastore : ", commonId, e);
486 LOG.info("Service '{}' present in datastore !", commonId);
487 this.pceListenerImpl.setInput(new ServiceInput(input));
488 this.pceListenerImpl.setServiceReconfigure(false);
489 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
490 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
491 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
492 this.rendererListenerImpl.setTempService(true);
493 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
494 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
495 if (output != null) {
496 LOG.info("Temp Service present in datastore, service-delete in progress...");
497 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
498 return ModelMappingUtils.createDeleteServiceReply(input, common.getAckFinalIndicator(),
499 common.getResponseMessage(), common.getResponseCode());
501 return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
502 "Renderer service delete failed !", ResponseCodes.RESPONSE_FAILED);
507 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
508 LOG.info("RPC temp service creation received");
510 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
511 new ServiceInput(input), RpcActions.TempServiceCreate);
512 if (! validationResult.isSuccess()) {
513 LOG.warn("Aborting service create because validation of service create request failed: {}",
514 validationResult.getResultMessage());
515 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
516 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
519 // Starting service create operation
520 LOG.info("Commencing PCE");
521 this.pceListenerImpl.setInput(new ServiceInput(input));
522 this.pceListenerImpl.setServiceReconfigure(false);
523 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
524 this.pceListenerImpl.setTempService(true);
525 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
526 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
527 this.rendererListenerImpl.setTempService(true);
528 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
529 if (output != null) {
530 LOG.info("Service compliant, temp serviceCreate in progress...");
531 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
532 return ModelMappingUtils.createCreateServiceReply(input, common.getAckFinalIndicator(),
533 common.getResponseMessage(), common.getResponseCode());
535 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
536 "PCE calculation failed", ResponseCodes.RESPONSE_FAILED);
541 public ListenableFuture<RpcResult<
542 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
543 ServiceDeleteComplexResultNotificationRequestInput input) {
544 // TODO Auto-generated method stub
549 public ListenableFuture<RpcResult<
550 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
551 ServiceCreateResultNotificationRequestInput input) {
552 // TODO Auto-generated method stub
557 public ListenableFuture<RpcResult<
558 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
559 ServiceDeleteResultNotificationRequestInput input) {
560 // TODO Auto-generated method stub
565 public ListenableFuture<RpcResult<
566 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
567 ServiceCreateComplexResultNotificationRequestInput input) {
568 // TODO Auto-generated method stub
573 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
574 ServiceFeasibilityCheckBulkInput input) {
575 // TODO Auto-generated method stub