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.provisiondevice.RendererServiceOperations;
21 import org.opendaylight.transportpce.servicehandler.DowngradeConstraints;
22 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
23 import org.opendaylight.transportpce.servicehandler.ServiceInput;
24 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
25 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
26 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
27 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
28 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
29 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
30 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
31 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
32 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestOutput;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommon;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev190531.RpcStatus;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraints;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraints;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationInput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.EquipmentNotificationOutput;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationInput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.NetworkReOptimizationOutput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateComplexResultNotificationRequestOutput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateResultNotificationRequestOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteComplexResultNotificationRequestOutput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteResultNotificationRequestOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckBulkOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteConfirmOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReversionOutput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollInput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRollOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteOutput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo.TailRetention;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
83 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
84 import org.opendaylight.yangtools.yang.common.RpcResult;
85 import org.slf4j.Logger;
86 import org.slf4j.LoggerFactory;
90 * Top level service interface providing main OpenROADM controller services.
92 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
93 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
94 private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
95 private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
96 private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
97 private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
98 private static final String SERVICE_FEASABILITY_CHECK_MSG = "serviceFeasabilityCheck: {}";
99 private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
100 private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
102 private DataBroker db;
103 private ServiceDataStoreOperations serviceDataStoreOperations;
104 private PCEServiceWrapper pceServiceWrapper;
105 private RendererServiceWrapper rendererServiceWrapper;
106 private PceListenerImpl pceListenerImpl;
107 private RendererListenerImpl rendererListenerImpl;
109 //TODO: remove private request fields as they are in global scope
111 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
112 RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
113 PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl) {
114 this.db = databroker;
115 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
116 this.serviceDataStoreOperations.initialize();
117 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
118 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
119 this.pceListenerImpl = pceListenerImpl;
120 this.rendererListenerImpl = rendererListenerImpl;
124 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
125 public static final class LogMessages {
127 public static final String PCE_CALLING;
128 public static final String ABORT_PCE_FAILED;
129 public static final String PCE_FAILED;
130 public static final String ABORT_SERVICE_NON_COMPLIANT;
131 public static final String SERVICE_NON_COMPLIANT;
132 public static final String RENDERER_DELETE_FAILED;
133 public static final String ABORT_VALID_FAILED;
135 // Static blocks are generated once and spare memory.
137 PCE_CALLING = "Calling PCE";
138 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
139 PCE_FAILED = "PCE calculation failed";
140 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
141 SERVICE_NON_COMPLIANT = "non-compliant service";
142 RENDERER_DELETE_FAILED = "Renderer service delete failed";
143 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
146 public static String serviceNotInDS(String serviceName) {
147 return "Service '" + serviceName + "' does not exist in datastore";
150 public static String serviceInService(String serviceName) {
151 return "Service '" + serviceName + "' is in 'inService' state";
154 private LogMessages() {
159 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
160 LOG.info("RPC serviceCreate received");
162 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
163 new ServiceInput(input), RpcActions.ServiceCreate);
164 if (! validationResult.isSuccess()) {
165 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
166 return ModelMappingUtils.createCreateServiceReply(
167 input, ResponseCodes.FINAL_ACK_YES,
168 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
170 this.pceListenerImpl.setInput(new ServiceInput(input));
171 this.pceListenerImpl.setServiceReconfigure(false);
172 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
173 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
174 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
175 LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
176 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
177 if (output == null) {
178 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
179 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
180 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
182 LOG.info("RPC serviceCreate in progress...");
183 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
184 return ModelMappingUtils.createCreateServiceReply(
185 input, common.getAckFinalIndicator(),
186 common.getResponseMessage(), common.getResponseCode());
190 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
191 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
192 LOG.info("RPC serviceDelete request received for {}", serviceName);
195 * Upon receipt of service-deleteService RPC, service header and sdnc-request
196 * header compliance are verified.
198 ComplianceCheckResult serviceHandlerCheckResult =
199 ServicehandlerComplianceCheck.check(
200 input.getServiceDeleteReqInfo().getServiceName(),
201 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
202 if (!serviceHandlerCheckResult.hasPassed()) {
203 LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
204 return ModelMappingUtils.createDeleteServiceReply(
205 input, ResponseCodes.FINAL_ACK_YES,
206 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
209 //Check presence of service to be deleted
210 Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
212 if (!serviceOpt.isPresent()) {
213 LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
214 return ModelMappingUtils.createDeleteServiceReply(
215 input, ResponseCodes.FINAL_ACK_YES,
216 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
218 service = serviceOpt.get();
219 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
220 this.pceListenerImpl.setInput(new ServiceInput(input));
221 this.pceListenerImpl.setServiceReconfigure(false);
222 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
223 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
224 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
225 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
226 .ServiceDeleteInput serviceDeleteInput =
227 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
228 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput output =
229 this.rendererServiceWrapper.performRenderer(
230 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
232 if (output == null) {
233 LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
234 return ModelMappingUtils.createDeleteServiceReply(
235 input, ResponseCodes.FINAL_ACK_YES,
236 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
239 LOG.debug("RPC serviceDelete in progress...");
240 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
241 return ModelMappingUtils.createDeleteServiceReply(
242 input, common.getAckFinalIndicator(),
243 common.getResponseMessage(), common.getResponseCode());
247 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
248 ServiceFeasibilityCheckInput input) {
249 LOG.info("RPC serviceFeasibilityCheck received");
251 ServiceInput serviceInput = new ServiceInput(input);
252 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
253 RpcActions.ServiceFeasibilityCheck);
254 if (! validationResult.isSuccess()) {
255 LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
256 return ModelMappingUtils.createCreateServiceReply(
257 input, ResponseCodes.FINAL_ACK_YES,
258 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
260 this.pceListenerImpl.setInput(new ServiceInput(input));
261 this.pceListenerImpl.setServiceReconfigure(false);
262 this.pceListenerImpl.setServiceFeasiblity(true);
263 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
264 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
265 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
266 LOG.debug(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.PCE_CALLING);
267 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
268 if (output == null) {
269 LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
270 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
271 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
273 LOG.info("RPC serviceFeasibilityCheck in progress...");
274 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
275 return ModelMappingUtils.createCreateServiceReply(
276 input, common.getAckFinalIndicator(),
277 common.getResponseMessage(), common.getResponseCode());
281 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
282 String serviceName = input.getServiceName();
283 LOG.info("RPC serviceReconfigure received for {}", serviceName);
284 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
285 if (!servicesObject.isPresent()) {
286 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
287 return ModelMappingUtils.createCreateServiceReply(
289 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
291 LOG.debug("Service '{}' found in datastore", serviceName);
292 OperationResult validationResult = ServiceCreateValidation
293 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
294 if (!validationResult.isSuccess()) {
295 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
296 return ModelMappingUtils.createCreateServiceReply(
298 validationResult.getResultMessage(), RpcStatus.Failed);
300 this.pceListenerImpl.setInput(new ServiceInput(input));
301 this.pceListenerImpl.setServiceReconfigure(true);
302 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
303 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
304 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
305 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
306 .ServiceDeleteInput serviceDeleteInput =
307 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
308 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
309 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
310 ServiceNotificationTypes.ServiceDeleteResult, null);
311 if (output == null) {
312 LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
313 return ModelMappingUtils.createCreateServiceReply(
315 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Successful);
316 //TODO check if RpcStatus.Successful is really expected here
318 LOG.info("RPC serviceReconfigure in progress...");
319 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
320 return ModelMappingUtils.createCreateServiceReply(
322 common.getResponseMessage(), RpcStatus.Successful);
326 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
327 String serviceName = input.getServiceName();
328 LOG.info("RPC serviceRestoration received for {}", serviceName);
329 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
331 if (!servicesObject.isPresent()) {
332 LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
333 return ModelMappingUtils.createRestoreServiceReply(
334 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
337 Services service = servicesObject.get();
338 State state = service.getOperationalState();
340 if (state == State.InService) {
341 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
342 return ModelMappingUtils.createRestoreServiceReply(
343 LogMessages.serviceInService(serviceName), RpcStatus.Failed);
346 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
347 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
348 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
349 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
350 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
351 .setRequestId(service.getSdncRequestHeader().getRequestId())
352 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
353 .setRpcAction(RpcActions.ServiceDelete);
354 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
355 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
356 .setServiceName(serviceName)
357 .setDueDate(datetime)
358 .setTailRetention(TailRetention.No).build())
359 .setSdncRequestHeader(sdncBuilder.build());
360 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
361 serviceInput.setServiceAEnd(service.getServiceAEnd());
362 serviceInput.setServiceZEnd(service.getServiceZEnd());
363 serviceInput.setConnectionType(service.getConnectionType());
364 HardConstraints hardConstraints = service.getHardConstraints();
365 if (hardConstraints == null) {
366 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
368 SoftConstraints softConstraints = service.getSoftConstraints();
369 if (softConstraints == null) {
370 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
371 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
372 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
374 LOG.info("converting hard constraints to soft constraints ...");
375 serviceInput.setSoftConstraints(
376 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
377 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
380 this.pceListenerImpl.setInput(serviceInput);
381 this.pceListenerImpl.setServiceReconfigure(true);
382 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
383 this.rendererListenerImpl.setServiceInput(serviceInput);
384 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
385 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
386 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
387 new ServiceInput(deleteInputBldr.build()));
388 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
389 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
390 ServiceNotificationTypes.ServiceDeleteResult, null);
391 if (output == null) {
392 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
393 return ModelMappingUtils.createRestoreServiceReply(
394 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
396 LOG.info("RPC serviceRestore in progress...");
397 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
398 return ModelMappingUtils.createRestoreServiceReply(
399 common.getResponseMessage(), RpcStatus.Successful);
404 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
405 equipmentNotification(EquipmentNotificationInput input) {
406 // TODO Auto-generated method stub
411 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
412 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
413 // TODO Auto-generated method stub
418 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
419 String serviceName = input.getServiceName();
420 LOG.info("RPC serviceReroute received for {}", serviceName);
421 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
422 if (!servicesObject.isPresent()) {
423 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
424 return ModelMappingUtils.createRerouteServiceReply(
425 input, ResponseCodes.FINAL_ACK_NO,
426 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
428 Services service = servicesObject.get();
429 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
430 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
431 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
432 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
433 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
434 .setRequestId(service.getSdncRequestHeader().getRequestId())
435 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
436 .setRpcAction(RpcActions.ServiceDelete);
437 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
438 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
439 .setServiceName(serviceName).setDueDate(datetime)
440 .setTailRetention(TailRetention.No).build())
441 .setSdncRequestHeader(sdncBuilder.build());
442 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
443 serviceInput.setServiceAEnd(service.getServiceAEnd());
444 serviceInput.setServiceZEnd(service.getServiceZEnd());
445 serviceInput.setConnectionType(service.getConnectionType());
446 this.pceListenerImpl.setInput(serviceInput);
447 this.pceListenerImpl.setServiceReconfigure(true);
448 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
449 this.rendererListenerImpl.setServiceInput(serviceInput);
450 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
451 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
452 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
453 new ServiceInput(deleteInputBldr.build()));
454 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
455 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
456 ServiceNotificationTypes.ServiceDeleteResult, null);
457 if (output == null) {
458 LOG.error("serviceReroute: {}", LogMessages.RENDERER_DELETE_FAILED);
459 return ModelMappingUtils.createRerouteServiceReply(
460 input, ResponseCodes.FINAL_ACK_YES,
461 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
463 LOG.info("RPC ServiceReroute in progress...");
464 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
465 return ModelMappingUtils.createRerouteServiceReply(
466 input, common.getAckFinalIndicator(),
467 common.getResponseMessage(), RpcStatus.Successful);
471 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
472 // TODO Auto-generated method stub
477 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
478 // TODO Auto-generated method stub
483 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
484 networkReOptimization(NetworkReOptimizationInput input) {
485 // TODO Auto-generated method stub
490 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
491 String commonId = input.getCommonId();
492 LOG.info("RPC temp serviceDelete request received for {}", commonId);
495 * Upon receipt of service-deleteService RPC, service header and sdnc-request
496 * header compliancy are verified.
498 LOG.debug("checking Service Compliance ...");
499 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
500 commonId, null, null, RpcActions.ServiceDelete, false, false
502 if (!serviceHandlerCheckResult.hasPassed()) {
503 LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
504 return ModelMappingUtils.createDeleteServiceReply(
505 input, ResponseCodes.FINAL_ACK_YES,
506 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
509 //Check presence of service to be deleted
510 LOG.debug("service common-id '{}' is compliant", commonId);
511 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list.Services>
513 this.serviceDataStoreOperations.getTempService(commonId);
514 if (!service.isPresent()) {
515 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
516 return ModelMappingUtils.createDeleteServiceReply(
517 input, ResponseCodes.FINAL_ACK_YES,
518 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
521 LOG.info("Service '{}' present in datastore !", commonId);
522 this.pceListenerImpl.setInput(new ServiceInput(input));
523 this.pceListenerImpl.setServiceReconfigure(false);
524 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
525 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
526 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
527 this.rendererListenerImpl.setTempService(true);
528 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput output =
529 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
530 if (output == null) {
531 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
532 return ModelMappingUtils.createDeleteServiceReply(
533 input, ResponseCodes.FINAL_ACK_YES,
534 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
536 LOG.info("RPC tempServiceDelete in progress...");
537 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
538 return ModelMappingUtils.createDeleteServiceReply(
539 input, common.getAckFinalIndicator(),
540 common.getResponseMessage(), common.getResponseCode());
544 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
545 LOG.info("RPC tempServiceCreate received");
547 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
548 new ServiceInput(input), RpcActions.TempServiceCreate);
549 if (! validationResult.isSuccess()) {
550 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
551 return ModelMappingUtils.createCreateServiceReply(
552 input, ResponseCodes.FINAL_ACK_YES,
553 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
556 // Starting service create operation
557 LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
558 this.pceListenerImpl.setInput(new ServiceInput(input));
559 this.pceListenerImpl.setServiceReconfigure(false);
560 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
561 this.pceListenerImpl.setTempService(true);
562 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
563 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
564 this.rendererListenerImpl.setTempService(true);
565 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
566 if (output == null) {
567 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
568 return ModelMappingUtils.createCreateServiceReply(
569 input, ResponseCodes.FINAL_ACK_YES,
570 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
572 LOG.info("RPC tempServiceCreate in progress...");
573 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
574 return ModelMappingUtils.createCreateServiceReply(
575 input, common.getAckFinalIndicator(),
576 common.getResponseMessage(), common.getResponseCode());
580 public ListenableFuture<RpcResult<
581 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
582 ServiceDeleteComplexResultNotificationRequestInput input) {
583 // TODO Auto-generated method stub
588 public ListenableFuture<RpcResult<
589 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
590 ServiceCreateResultNotificationRequestInput input) {
591 // TODO Auto-generated method stub
596 public ListenableFuture<RpcResult<
597 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
598 ServiceDeleteResultNotificationRequestInput input) {
599 // TODO Auto-generated method stub
604 public ListenableFuture<RpcResult<
605 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
606 ServiceCreateComplexResultNotificationRequestInput input) {
607 // TODO Auto-generated method stub
612 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
613 ServiceFeasibilityCheckBulkInput input) {
614 // TODO Auto-generated method stub