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> serviceOpt = 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);
216 if (!serviceOpt.isPresent()) {
217 LOG.warn("serviceDelete: {}", LogMessages.serviceNotInDS(serviceName));
218 return ModelMappingUtils.createDeleteServiceReply(
219 input, ResponseCodes.FINAL_ACK_YES,
220 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
222 service = serviceOpt.get();
223 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
224 this.pceListenerImpl.setInput(new ServiceInput(input));
225 this.pceListenerImpl.setServiceReconfigure(false);
226 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
227 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
228 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
229 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
230 .ServiceDeleteInput serviceDeleteInput =
231 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
232 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput output =
233 this.rendererServiceWrapper.performRenderer(
234 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
236 if (output == null) {
237 LOG.error("serviceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
238 return ModelMappingUtils.createDeleteServiceReply(
239 input, ResponseCodes.FINAL_ACK_YES,
240 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
243 LOG.debug("RPC serviceDelete in progress...");
244 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
245 return ModelMappingUtils.createDeleteServiceReply(
246 input, common.getAckFinalIndicator(),
247 common.getResponseMessage(), common.getResponseCode());
251 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
252 ServiceFeasibilityCheckInput input) {
253 LOG.info("RPC serviceFeasibilityCheck received");
255 ServiceInput serviceInput = new ServiceInput(input);
256 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
257 RpcActions.ServiceFeasibilityCheck);
258 if (! validationResult.isSuccess()) {
259 LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_VALID_FAILED);
260 return ModelMappingUtils.createCreateServiceReply(
261 input, ResponseCodes.FINAL_ACK_YES,
262 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
264 this.pceListenerImpl.setInput(new ServiceInput(input));
265 this.pceListenerImpl.setServiceReconfigure(false);
266 this.pceListenerImpl.setServiceFeasiblity(true);
267 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
268 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
269 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
270 LOG.debug("serviceFeasabilityCheck: {}", LogMessages.PCE_CALLING);
271 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
272 if (output == null) {
273 LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_PCE_FAILED);
274 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
275 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
277 LOG.info("RPC serviceFeasibilityCheck in progress...");
278 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
279 return ModelMappingUtils.createCreateServiceReply(
280 input, common.getAckFinalIndicator(),
281 common.getResponseMessage(), common.getResponseCode());
285 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
286 String serviceName = input.getServiceName();
287 LOG.info("RPC serviceReconfigure received for {}", serviceName);
288 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
289 if (!servicesObject.isPresent()) {
290 LOG.warn("serviceReconfigure: {}", LogMessages.serviceNotInDS(serviceName));
291 return ModelMappingUtils.createCreateServiceReply(
293 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
295 LOG.debug("Service '{}' found in datastore", serviceName);
296 OperationResult validationResult = ServiceCreateValidation
297 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
298 if (!validationResult.isSuccess()) {
299 LOG.warn("serviceReconfigure: {}", LogMessages.ABORT_VALID_FAILED);
300 return ModelMappingUtils.createCreateServiceReply(
302 validationResult.getResultMessage(), RpcStatus.Failed);
304 this.pceListenerImpl.setInput(new ServiceInput(input));
305 this.pceListenerImpl.setServiceReconfigure(true);
306 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
307 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
308 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
309 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
310 .ServiceDeleteInput serviceDeleteInput =
311 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
312 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
313 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
314 ServiceNotificationTypes.ServiceDeleteResult, null);
315 if (output == null) {
316 LOG.error("serviceReconfigure: {}", LogMessages.RENDERER_DELETE_FAILED);
317 return ModelMappingUtils.createCreateServiceReply(
319 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Successful);
320 //TODO check if RpcStatus.Successful is really expected here
322 LOG.info("RPC serviceReconfigure in progress...");
323 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
324 return ModelMappingUtils.createCreateServiceReply(
326 common.getResponseMessage(), RpcStatus.Successful);
330 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
331 String serviceName = input.getServiceName();
332 LOG.info("RPC serviceRestoration received for {}", serviceName);
333 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
335 if (!servicesObject.isPresent()) {
336 LOG.warn("serviceRestoration: {}", LogMessages.serviceNotInDS(serviceName));
337 return ModelMappingUtils.createRestoreServiceReply(
338 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
341 Services service = servicesObject.get();
342 State state = service.getOperationalState();
344 if (state == State.InService) {
345 LOG.error("serviceRestoration: {}", LogMessages.serviceInService(serviceName));
346 return ModelMappingUtils.createRestoreServiceReply(
347 LogMessages.serviceInService(serviceName), RpcStatus.Failed);
350 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
351 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
352 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
353 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
354 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
355 .setRequestId(service.getSdncRequestHeader().getRequestId())
356 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
357 .setRpcAction(RpcActions.ServiceDelete);
358 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
359 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
360 .setServiceName(serviceName)
361 .setDueDate(datetime)
362 .setTailRetention(TailRetention.No).build())
363 .setSdncRequestHeader(sdncBuilder.build());
364 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
365 serviceInput.setServiceAEnd(service.getServiceAEnd());
366 serviceInput.setServiceZEnd(service.getServiceZEnd());
367 serviceInput.setConnectionType(service.getConnectionType());
368 HardConstraints hardConstraints = service.getHardConstraints();
369 if (hardConstraints == null) {
370 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
372 SoftConstraints softConstraints = service.getSoftConstraints();
373 if (softConstraints == null) {
374 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
375 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
376 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
378 LOG.info("converting hard constraints to soft constraints ...");
379 serviceInput.setSoftConstraints(
380 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
381 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
384 this.pceListenerImpl.setInput(serviceInput);
385 this.pceListenerImpl.setServiceReconfigure(true);
386 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
387 this.rendererListenerImpl.setServiceInput(serviceInput);
388 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
389 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
390 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
391 new ServiceInput(deleteInputBldr.build()));
392 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
393 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
394 ServiceNotificationTypes.ServiceDeleteResult, null);
395 if (output == null) {
396 LOG.error("serviceRestoration: {}", LogMessages.RENDERER_DELETE_FAILED);
397 return ModelMappingUtils.createRestoreServiceReply(
398 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
400 LOG.info("RPC serviceRestore in progress...");
401 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
402 return ModelMappingUtils.createRestoreServiceReply(
403 common.getResponseMessage(), RpcStatus.Successful);
408 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
409 equipmentNotification(EquipmentNotificationInput input) {
410 // TODO Auto-generated method stub
415 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
416 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
417 // TODO Auto-generated method stub
422 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
423 String serviceName = input.getServiceName();
424 LOG.info("RPC serviceReroute received for {}", serviceName);
425 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
426 if (!servicesObject.isPresent()) {
427 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
428 return ModelMappingUtils.createRerouteServiceReply(
429 input, ResponseCodes.FINAL_ACK_NO,
430 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
432 Services service = servicesObject.get();
433 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
434 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
435 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
436 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
437 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
438 .setRequestId(service.getSdncRequestHeader().getRequestId())
439 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
440 .setRpcAction(RpcActions.ServiceDelete);
441 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
442 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
443 .setServiceName(serviceName).setDueDate(datetime)
444 .setTailRetention(TailRetention.No).build())
445 .setSdncRequestHeader(sdncBuilder.build());
446 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
447 serviceInput.setServiceAEnd(service.getServiceAEnd());
448 serviceInput.setServiceZEnd(service.getServiceZEnd());
449 serviceInput.setConnectionType(service.getConnectionType());
450 this.pceListenerImpl.setInput(serviceInput);
451 this.pceListenerImpl.setServiceReconfigure(true);
452 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
453 this.rendererListenerImpl.setServiceInput(serviceInput);
454 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
455 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
456 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
457 new ServiceInput(deleteInputBldr.build()));
458 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520
459 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
460 ServiceNotificationTypes.ServiceDeleteResult, null);
461 if (output == null) {
462 LOG.error("serviceReroute: {}", LogMessages.RENDERER_DELETE_FAILED);
463 return ModelMappingUtils.createRerouteServiceReply(
464 input, ResponseCodes.FINAL_ACK_YES,
465 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
467 LOG.info("RPC ServiceReroute in progress...");
468 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
469 return ModelMappingUtils.createRerouteServiceReply(
470 input, common.getAckFinalIndicator(),
471 common.getResponseMessage(), RpcStatus.Successful);
475 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
476 // TODO Auto-generated method stub
481 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
482 // TODO Auto-generated method stub
487 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
488 networkReOptimization(NetworkReOptimizationInput input) {
489 // TODO Auto-generated method stub
494 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
495 String commonId = input.getCommonId();
496 LOG.info("RPC temp serviceDelete request received for {}", commonId);
499 * Upon receipt of service-deleteService RPC, service header and sdnc-request
500 * header compliancy are verified.
502 LOG.debug("checking Service Compliance ...");
503 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
504 commonId, null, null, RpcActions.ServiceDelete, false, false
506 if (!serviceHandlerCheckResult.hasPassed()) {
507 LOG.warn("tempServiceDelete: {}", LogMessages.ABORT_SERVICE_NON_COMPLIANT);
508 return ModelMappingUtils.createDeleteServiceReply(
509 input, ResponseCodes.FINAL_ACK_YES,
510 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
513 //Check presence of service to be deleted
514 LOG.debug("service common-id '{}' is compliant", commonId);
515 //TODO check if an expected bug was justifying this NPE handling
517 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list.Services>
519 this.serviceDataStoreOperations.getTempService(commonId);
520 // } catch (NullPointerException e) {
521 // LOG.info("failed to get service '{}' from datastore : ", commonId, e);
522 // return ModelMappingUtils.createDeleteServiceReply(
523 // input, ResponseCodes.FINAL_ACK_YES,
524 // LogMessages.serviceNotInDS(CommonId), ResponseCodes.RESPONSE_FAILED);
526 if (!service.isPresent()) {
527 LOG.error("tempServiceDelete: {}", LogMessages.serviceNotInDS(commonId));
528 return ModelMappingUtils.createDeleteServiceReply(
529 input, ResponseCodes.FINAL_ACK_YES,
530 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
533 LOG.info("Service '{}' present in datastore !", commonId);
534 this.pceListenerImpl.setInput(new ServiceInput(input));
535 this.pceListenerImpl.setServiceReconfigure(false);
536 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
537 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
538 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
539 this.rendererListenerImpl.setTempService(true);
540 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput output =
541 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
542 if (output == null) {
543 LOG.error("tempServiceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
544 return ModelMappingUtils.createDeleteServiceReply(
545 input, ResponseCodes.FINAL_ACK_YES,
546 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
548 LOG.info("RPC tempServiceDelete in progress...");
549 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
550 return ModelMappingUtils.createDeleteServiceReply(
551 input, common.getAckFinalIndicator(),
552 common.getResponseMessage(), common.getResponseCode());
556 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
557 LOG.info("RPC tempServiceCreate received");
559 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
560 new ServiceInput(input), RpcActions.TempServiceCreate);
561 if (! validationResult.isSuccess()) {
562 LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_VALID_FAILED);
563 return ModelMappingUtils.createCreateServiceReply(
564 input, ResponseCodes.FINAL_ACK_YES,
565 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
568 // Starting service create operation
569 LOG.debug("tempServiceCreate: {}", LogMessages.PCE_CALLING);
570 this.pceListenerImpl.setInput(new ServiceInput(input));
571 this.pceListenerImpl.setServiceReconfigure(false);
572 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
573 this.pceListenerImpl.setTempService(true);
574 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
575 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
576 this.rendererListenerImpl.setTempService(true);
577 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
578 if (output == null) {
579 LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_PCE_FAILED);
580 return ModelMappingUtils.createCreateServiceReply(
581 input, ResponseCodes.FINAL_ACK_YES,
582 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
584 LOG.info("RPC tempServiceCreate in progress...");
585 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
586 return ModelMappingUtils.createCreateServiceReply(
587 input, common.getAckFinalIndicator(),
588 common.getResponseMessage(), common.getResponseCode());
592 public ListenableFuture<RpcResult<
593 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
594 ServiceDeleteComplexResultNotificationRequestInput input) {
595 // TODO Auto-generated method stub
600 public ListenableFuture<RpcResult<
601 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
602 ServiceCreateResultNotificationRequestInput input) {
603 // TODO Auto-generated method stub
608 public ListenableFuture<RpcResult<
609 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
610 ServiceDeleteResultNotificationRequestInput input) {
611 // TODO Auto-generated method stub
616 public ListenableFuture<RpcResult<
617 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
618 ServiceCreateComplexResultNotificationRequestInput input) {
619 // TODO Auto-generated method stub
624 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
625 ServiceFeasibilityCheckBulkInput input) {
626 // TODO Auto-generated method stub