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;
11 import java.time.OffsetDateTime;
12 import java.time.ZoneOffset;
13 import java.time.format.DateTimeFormatter;
14 import java.util.Optional;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
17 import org.opendaylight.transportpce.common.OperationResult;
18 import org.opendaylight.transportpce.common.ResponseCodes;
19 import org.opendaylight.transportpce.pce.service.PathComputationService;
20 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
21 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
22 import org.opendaylight.transportpce.servicehandler.DowngradeConstraints;
23 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
24 import org.opendaylight.transportpce.servicehandler.ServiceInput;
25 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
26 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
27 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
28 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
29 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
30 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
31 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
32 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
33 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestOutput;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommon;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev190531.RpcStatus;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraints;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraints;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationInput;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationOutput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationOutput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestOutput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkInput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo.TailRetention;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
84 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
85 import org.opendaylight.yangtools.yang.common.RpcResult;
86 import org.slf4j.Logger;
87 import org.slf4j.LoggerFactory;
91 * Top level service interface providing main OpenROADM controller services.
93 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
95 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
97 private DataBroker db;
98 private ServiceDataStoreOperations serviceDataStoreOperations;
99 private PCEServiceWrapper pceServiceWrapper;
100 private RendererServiceWrapper rendererServiceWrapper;
101 private PceListenerImpl pceListenerImpl;
102 private RendererListenerImpl rendererListenerImpl;
104 //TODO: remove private request fields as they are in global scope
106 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
107 RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
108 PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
109 NetworkModelWavelengthService networkModelWavelengthService) {
110 this.db = databroker;
111 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
112 this.serviceDataStoreOperations.initialize();
113 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
114 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
115 this.pceListenerImpl = pceListenerImpl;
116 this.rendererListenerImpl = rendererListenerImpl;
120 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
121 public static final class LogMessages {
123 public static final String PCE_CALLING;
124 public static final String ABORT_PCE_FAILED;
125 public static final String PCE_FAILED;
126 public static final String ABORT_SERVICE_NON_COMPLIANT;
127 public static final String SERVICE_NON_COMPLIANT;
128 public static final String RENDERER_DELETE_FAILED;
129 public static final String ABORT_VALID_FAILED;
131 // Static blocks are generated once and spare memory.
133 PCE_CALLING = "Calling PCE";
134 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
135 PCE_FAILED = "PCE calculation failed";
136 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
137 SERVICE_NON_COMPLIANT = "non-compliant service";
138 RENDERER_DELETE_FAILED = "Renderer service delete failed";
139 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
142 public static String serviceNotInDS(String serviceName) {
143 return "Service '" + serviceName + "' does not exist in datastore";
146 public static String serviceInService(String serviceName) {
147 return "Service '" + serviceName + "' is in 'inService' state";
150 private LogMessages() {
155 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
156 LOG.info("RPC serviceCreate received");
158 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
159 new ServiceInput(input), RpcActions.ServiceCreate);
160 if (! validationResult.isSuccess()) {
161 LOG.warn("serviceCreate: {}", LogMessages.ABORT_VALID_FAILED);
162 return ModelMappingUtils.createCreateServiceReply(
163 input, ResponseCodes.FINAL_ACK_YES,
164 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
166 this.pceListenerImpl.setInput(new ServiceInput(input));
167 this.pceListenerImpl.setServiceReconfigure(false);
168 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
169 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
170 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
171 LOG.debug("serviceCreate: {}", LogMessages.PCE_CALLING);
172 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
173 if (output == null) {
174 LOG.warn("serviceCreate: {}", LogMessages.ABORT_PCE_FAILED);
175 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
176 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
178 LOG.info("RPC serviceCreate in progress...");
179 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
180 return ModelMappingUtils.createCreateServiceReply(
181 input, common.getAckFinalIndicator(),
182 common.getResponseMessage(), common.getResponseCode());
186 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
187 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
188 LOG.info("RPC serviceDelete request received for {}", serviceName);
191 * Upon receipt of service-deleteService RPC, service header and sdnc-request
192 * header compliance are verified.
194 ComplianceCheckResult serviceHandlerCheckResult =
195 ServicehandlerComplianceCheck.check(
196 input.getServiceDeleteReqInfo().getServiceName(),
197 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
198 if (!serviceHandlerCheckResult.hasPassed()) {
199 LOG.warn("serviceDelete: {}", LogMessages.ABORT_SERVICE_NON_COMPLIANT);
200 return ModelMappingUtils.createDeleteServiceReply(
201 input, ResponseCodes.FINAL_ACK_YES,
202 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
205 //Check presence of service to be deleted
206 //TODO check if an expected bug was justifying this NPE handling
208 Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
209 // } catch (NullPointerException e) {
210 // LOG.error("Something wrong when retrieving service '{}' from datastore : ", serviceName, e);
211 // return ModelMappingUtils.createDeleteServiceReply(
212 // input, ResponseCodes.FINAL_ACK_YES,
213 // LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
215 if (!service.isPresent()) {
216 LOG.warn("serviceDelete: {}", LogMessages.serviceNotInDS(serviceName));
217 return ModelMappingUtils.createDeleteServiceReply(
218 input, ResponseCodes.FINAL_ACK_YES,
219 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
221 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
222 this.pceListenerImpl.setInput(new ServiceInput(input));
223 this.pceListenerImpl.setServiceReconfigure(false);
224 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
225 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
226 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
227 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
228 .ServiceDeleteInput serviceDeleteInput =
229 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
230 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput output =
231 this.rendererServiceWrapper.performRenderer(
232 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult);
234 if (output == null) {
235 LOG.error("serviceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
236 return ModelMappingUtils.createDeleteServiceReply(
237 input, ResponseCodes.FINAL_ACK_YES,
238 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
241 LOG.debug("RPC serviceDelete in progress...");
242 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
243 return ModelMappingUtils.createDeleteServiceReply(
244 input, common.getAckFinalIndicator(),
245 common.getResponseMessage(), common.getResponseCode());
249 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
250 ServiceFeasibilityCheckInput input) {
251 LOG.info("RPC serviceFeasibilityCheck received");
253 ServiceInput serviceInput = new ServiceInput(input);
254 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
255 RpcActions.ServiceFeasibilityCheck);
256 if (! validationResult.isSuccess()) {
257 LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_VALID_FAILED);
258 return ModelMappingUtils.createCreateServiceReply(
259 input, ResponseCodes.FINAL_ACK_YES,
260 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
262 this.pceListenerImpl.setInput(new ServiceInput(input));
263 this.pceListenerImpl.setServiceReconfigure(false);
264 this.pceListenerImpl.setServiceFeasiblity(true);
265 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
266 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
267 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
268 LOG.debug("serviceFeasabilityCheck: {}", LogMessages.PCE_CALLING);
269 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
270 if (output == null) {
271 LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_PCE_FAILED);
272 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
273 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
275 LOG.info("RPC serviceFeasibilityCheck in progress...");
276 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
277 return ModelMappingUtils.createCreateServiceReply(
278 input, common.getAckFinalIndicator(),
279 common.getResponseMessage(), common.getResponseCode());
283 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
284 String serviceName = input.getServiceName();
285 LOG.info("RPC serviceReconfigure received for {}", serviceName);
286 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
287 if (!servicesObject.isPresent()) {
288 LOG.warn("serviceReconfigure: {}", LogMessages.serviceNotInDS(serviceName));
289 return ModelMappingUtils.createCreateServiceReply(
291 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
293 LOG.debug("Service '{}' found in datastore", serviceName);
294 OperationResult validationResult = ServiceCreateValidation
295 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
296 if (!validationResult.isSuccess()) {
297 LOG.warn("serviceReconfigure: {}", LogMessages.ABORT_VALID_FAILED);
298 return ModelMappingUtils.createCreateServiceReply(
300 validationResult.getResultMessage(), RpcStatus.Failed);
302 this.pceListenerImpl.setInput(new ServiceInput(input));
303 this.pceListenerImpl.setServiceReconfigure(true);
304 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
305 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
306 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
307 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
308 .ServiceDeleteInput serviceDeleteInput =
309 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
310 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
311 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
312 ServiceNotificationTypes.ServiceDeleteResult);
313 if (output == null) {
314 LOG.error("serviceReconfigure: {}", LogMessages.RENDERER_DELETE_FAILED);
315 return ModelMappingUtils.createCreateServiceReply(
317 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Successful);
318 //TODO check if RpcStatus.Successful is really expected here
320 LOG.info("RPC serviceReconfigure in progress...");
321 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
322 return ModelMappingUtils.createCreateServiceReply(
324 common.getResponseMessage(), RpcStatus.Successful);
328 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
329 String serviceName = input.getServiceName();
330 LOG.info("RPC serviceRestoration received for {}", serviceName);
331 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
333 if (!servicesObject.isPresent()) {
334 LOG.warn("serviceRestoration: {}", LogMessages.serviceNotInDS(serviceName));
335 return ModelMappingUtils.createRestoreServiceReply(
336 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
339 Services service = servicesObject.get();
340 State state = service.getOperationalState();
342 if (state == State.InService) {
343 LOG.error("serviceRestoration: {}", LogMessages.serviceInService(serviceName));
344 return ModelMappingUtils.createRestoreServiceReply(
345 LogMessages.serviceInService(serviceName), RpcStatus.Failed);
348 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
349 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
350 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
351 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
352 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
353 .setRequestId(service.getSdncRequestHeader().getRequestId())
354 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
355 .setRpcAction(RpcActions.ServiceDelete);
356 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
357 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
358 .setServiceName(serviceName)
359 .setDueDate(datetime)
360 .setTailRetention(TailRetention.No).build())
361 .setSdncRequestHeader(sdncBuilder.build());
362 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
363 serviceInput.setServiceAEnd(service.getServiceAEnd());
364 serviceInput.setServiceZEnd(service.getServiceZEnd());
365 serviceInput.setConnectionType(service.getConnectionType());
366 HardConstraints hardConstraints = service.getHardConstraints();
367 if (hardConstraints == null) {
368 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
370 SoftConstraints softConstraints = service.getSoftConstraints();
371 if (softConstraints == null) {
372 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
373 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
374 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
376 LOG.info("converting hard constraints to soft constraints ...");
377 serviceInput.setSoftConstraints(
378 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
379 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
382 this.pceListenerImpl.setInput(serviceInput);
383 this.pceListenerImpl.setServiceReconfigure(true);
384 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
385 this.rendererListenerImpl.setServiceInput(serviceInput);
386 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
387 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
388 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
389 new ServiceInput(deleteInputBldr.build()));
390 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
391 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
392 ServiceNotificationTypes.ServiceDeleteResult);
393 if (output == null) {
394 LOG.error("serviceRestoration: {}", LogMessages.RENDERER_DELETE_FAILED);
395 return ModelMappingUtils.createRestoreServiceReply(
396 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
398 LOG.info("RPC serviceRestore in progress...");
399 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
400 return ModelMappingUtils.createRestoreServiceReply(
401 common.getResponseMessage(), RpcStatus.Successful);
406 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
407 equipmentNotification(EquipmentNotificationInput input) {
408 // TODO Auto-generated method stub
413 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
414 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
415 // TODO Auto-generated method stub
420 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
421 String serviceName = input.getServiceName();
422 LOG.info("RPC serviceReroute received for {}", serviceName);
423 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
424 if (!servicesObject.isPresent()) {
425 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
426 return ModelMappingUtils.createRerouteServiceReply(
427 input, ResponseCodes.FINAL_ACK_NO,
428 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
430 Services service = servicesObject.get();
431 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
432 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
433 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
434 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
435 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
436 .setRequestId(service.getSdncRequestHeader().getRequestId())
437 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
438 .setRpcAction(RpcActions.ServiceDelete);
439 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
440 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
441 .setServiceName(serviceName).setDueDate(datetime)
442 .setTailRetention(TailRetention.No).build())
443 .setSdncRequestHeader(sdncBuilder.build());
444 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
445 serviceInput.setServiceAEnd(service.getServiceAEnd());
446 serviceInput.setServiceZEnd(service.getServiceZEnd());
447 serviceInput.setConnectionType(service.getConnectionType());
448 this.pceListenerImpl.setInput(serviceInput);
449 this.pceListenerImpl.setServiceReconfigure(true);
450 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
451 this.rendererListenerImpl.setServiceInput(serviceInput);
452 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
453 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
454 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
455 new ServiceInput(deleteInputBldr.build()));
456 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
457 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
458 ServiceNotificationTypes.ServiceDeleteResult);
459 if (output == null) {
460 LOG.error("serviceReroute: {}", LogMessages.RENDERER_DELETE_FAILED);
461 return ModelMappingUtils.createRerouteServiceReply(
462 input, ResponseCodes.FINAL_ACK_YES,
463 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
465 LOG.info("RPC ServiceReroute in progress...");
466 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
467 return ModelMappingUtils.createRerouteServiceReply(
468 input, common.getAckFinalIndicator(),
469 common.getResponseMessage(), RpcStatus.Successful);
473 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
474 // TODO Auto-generated method stub
479 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
480 // TODO Auto-generated method stub
485 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
486 networkReOptimization(NetworkReOptimizationInput input) {
487 // TODO Auto-generated method stub
492 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
493 String commonId = input.getCommonId();
494 LOG.info("RPC temp serviceDelete request received for {}", commonId);
497 * Upon receipt of service-deleteService RPC, service header and sdnc-request
498 * header compliancy are verified.
500 LOG.debug("checking Service Compliance ...");
501 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
502 commonId, null, null, RpcActions.ServiceDelete, false, false
504 if (!serviceHandlerCheckResult.hasPassed()) {
505 LOG.warn("tempServiceDelete: {}", LogMessages.ABORT_SERVICE_NON_COMPLIANT);
506 return ModelMappingUtils.createDeleteServiceReply(
507 input, ResponseCodes.FINAL_ACK_YES,
508 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
511 //Check presence of service to be deleted
512 LOG.debug("service common-id '{}' is compliant", commonId);
513 //TODO check if an expected bug was justifying this NPE handling
515 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list.Services>
517 this.serviceDataStoreOperations.getTempService(commonId);
518 // } catch (NullPointerException e) {
519 // LOG.info("failed to get service '{}' from datastore : ", commonId, e);
520 // return ModelMappingUtils.createDeleteServiceReply(
521 // input, ResponseCodes.FINAL_ACK_YES,
522 // LogMessages.serviceNotInDS(CommonId), ResponseCodes.RESPONSE_FAILED);
524 if (!service.isPresent()) {
525 LOG.error("tempServiceDelete: {}", LogMessages.serviceNotInDS(commonId));
526 return ModelMappingUtils.createDeleteServiceReply(
527 input, ResponseCodes.FINAL_ACK_YES,
528 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
531 LOG.info("Service '{}' present in datastore !", commonId);
532 this.pceListenerImpl.setInput(new ServiceInput(input));
533 this.pceListenerImpl.setServiceReconfigure(false);
534 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
535 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
536 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
537 this.rendererListenerImpl.setTempService(true);
538 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput output =
539 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
540 if (output == null) {
541 LOG.error("tempServiceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
542 return ModelMappingUtils.createDeleteServiceReply(
543 input, ResponseCodes.FINAL_ACK_YES,
544 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
546 LOG.info("RPC tempServiceDelete in progress...");
547 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
548 return ModelMappingUtils.createDeleteServiceReply(
549 input, common.getAckFinalIndicator(),
550 common.getResponseMessage(), common.getResponseCode());
554 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
555 LOG.info("RPC tempServiceCreate received");
557 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
558 new ServiceInput(input), RpcActions.TempServiceCreate);
559 if (! validationResult.isSuccess()) {
560 LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_VALID_FAILED);
561 return ModelMappingUtils.createCreateServiceReply(
562 input, ResponseCodes.FINAL_ACK_YES,
563 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
566 // Starting service create operation
567 LOG.debug("tempServiceCreate: {}", LogMessages.PCE_CALLING);
568 this.pceListenerImpl.setInput(new ServiceInput(input));
569 this.pceListenerImpl.setServiceReconfigure(false);
570 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
571 this.pceListenerImpl.setTempService(true);
572 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
573 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
574 this.rendererListenerImpl.setTempService(true);
575 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
576 if (output == null) {
577 LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_PCE_FAILED);
578 return ModelMappingUtils.createCreateServiceReply(
579 input, ResponseCodes.FINAL_ACK_YES,
580 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
582 LOG.info("RPC tempServiceCreate in progress...");
583 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
584 return ModelMappingUtils.createCreateServiceReply(
585 input, common.getAckFinalIndicator(),
586 common.getResponseMessage(), common.getResponseCode());
590 public ListenableFuture<RpcResult<
591 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
592 ServiceDeleteComplexResultNotificationRequestInput input) {
593 // TODO Auto-generated method stub
598 public ListenableFuture<RpcResult<
599 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
600 ServiceCreateResultNotificationRequestInput input) {
601 // TODO Auto-generated method stub
606 public ListenableFuture<RpcResult<
607 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
608 ServiceDeleteResultNotificationRequestInput input) {
609 // TODO Auto-generated method stub
614 public ListenableFuture<RpcResult<
615 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
616 ServiceCreateComplexResultNotificationRequestInput input) {
617 // TODO Auto-generated method stub
622 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
623 ServiceFeasibilityCheckBulkInput input) {
624 // TODO Auto-generated method stub