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.NetworkModelListenerImpl;
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.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;
108 private NetworkModelListenerImpl networkModelListenerImpl;
110 //TODO: remove private request fields as they are in global scope
112 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
113 RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
114 PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
115 NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations) {
116 this.db = databroker;
117 this.serviceDataStoreOperations = serviceDataStoreOperations;
118 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
119 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
120 this.pceListenerImpl = pceListenerImpl;
121 this.rendererListenerImpl = rendererListenerImpl;
122 this.networkModelListenerImpl = networkModelListenerImpl;
126 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
127 public static final class LogMessages {
129 public static final String PCE_CALLING;
130 public static final String ABORT_PCE_FAILED;
131 public static final String PCE_FAILED;
132 public static final String ABORT_SERVICE_NON_COMPLIANT;
133 public static final String SERVICE_NON_COMPLIANT;
134 public static final String RENDERER_DELETE_FAILED;
135 public static final String ABORT_VALID_FAILED;
137 // Static blocks are generated once and spare memory.
139 PCE_CALLING = "Calling PCE";
140 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
141 PCE_FAILED = "PCE calculation failed";
142 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
143 SERVICE_NON_COMPLIANT = "non-compliant service";
144 RENDERER_DELETE_FAILED = "Renderer service delete failed";
145 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
148 public static String serviceNotInDS(String serviceName) {
149 return "Service '" + serviceName + "' does not exist in datastore";
152 public static String serviceInService(String serviceName) {
153 return "Service '" + serviceName + "' is in 'inService' state";
156 private LogMessages() {
161 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
162 LOG.info("RPC serviceCreate received");
164 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
165 new ServiceInput(input), RpcActions.ServiceCreate);
166 if (! validationResult.isSuccess()) {
167 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
168 return ModelMappingUtils.createCreateServiceReply(
169 input, ResponseCodes.FINAL_ACK_YES,
170 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
172 this.pceListenerImpl.setInput(new ServiceInput(input));
173 this.pceListenerImpl.setServiceReconfigure(false);
174 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
175 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
176 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
177 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
178 LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
179 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
180 if (output == null) {
181 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
182 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
183 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
185 LOG.info("RPC serviceCreate in progress...");
186 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
187 return ModelMappingUtils.createCreateServiceReply(
188 input, common.getAckFinalIndicator(),
189 common.getResponseMessage(), common.getResponseCode());
193 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
194 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
195 LOG.info("RPC serviceDelete request received for {}", serviceName);
198 * Upon receipt of service-deleteService RPC, service header and sdnc-request
199 * header compliance are verified.
201 ComplianceCheckResult serviceHandlerCheckResult =
202 ServicehandlerComplianceCheck.check(
203 input.getServiceDeleteReqInfo().getServiceName(),
204 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
205 if (!serviceHandlerCheckResult.hasPassed()) {
206 LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
207 return ModelMappingUtils.createDeleteServiceReply(
208 input, ResponseCodes.FINAL_ACK_YES,
209 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
212 //Check presence of service to be deleted
213 Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
215 if (!serviceOpt.isPresent()) {
216 LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
217 return ModelMappingUtils.createDeleteServiceReply(
218 input, ResponseCodes.FINAL_ACK_YES,
219 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
221 service = serviceOpt.get();
222 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
223 this.pceListenerImpl.setInput(new ServiceInput(input));
224 this.pceListenerImpl.setServiceReconfigure(false);
225 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
226 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
227 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
228 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
229 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
230 .ServiceDeleteInput serviceDeleteInput =
231 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
232 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput output =
233 this.rendererServiceWrapper.performRenderer(
234 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
236 if (output == null) {
237 LOG.error(SERVICE_DELETE_MSG, 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(SERVICE_FEASABILITY_CHECK_MSG, 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 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
271 LOG.debug(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.PCE_CALLING);
272 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
273 if (output == null) {
274 LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
275 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
276 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
278 LOG.info("RPC serviceFeasibilityCheck in progress...");
279 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
280 return ModelMappingUtils.createCreateServiceReply(
281 input, common.getAckFinalIndicator(),
282 common.getResponseMessage(), common.getResponseCode());
286 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
287 String serviceName = input.getServiceName();
288 LOG.info("RPC serviceReconfigure received for {}", serviceName);
289 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
290 if (!servicesObject.isPresent()) {
291 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
292 return ModelMappingUtils.createCreateServiceReply(
294 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
296 LOG.debug("Service '{}' found in datastore", serviceName);
297 OperationResult validationResult = ServiceCreateValidation
298 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
299 if (!validationResult.isSuccess()) {
300 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
301 return ModelMappingUtils.createCreateServiceReply(
303 validationResult.getResultMessage(), RpcStatus.Failed);
305 this.pceListenerImpl.setInput(new ServiceInput(input));
306 this.pceListenerImpl.setServiceReconfigure(true);
307 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
308 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
309 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
310 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
311 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
312 .ServiceDeleteInput serviceDeleteInput =
313 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
314 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
315 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
316 ServiceNotificationTypes.ServiceDeleteResult, null);
317 if (output == null) {
318 LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
319 return ModelMappingUtils.createCreateServiceReply(
321 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Successful);
322 //TODO check if RpcStatus.Successful is really expected here
324 LOG.info("RPC serviceReconfigure in progress...");
325 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
326 return ModelMappingUtils.createCreateServiceReply(
328 common.getResponseMessage(), RpcStatus.Successful);
332 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
333 String serviceName = input.getServiceName();
334 LOG.info("RPC serviceRestoration received for {}", serviceName);
335 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
337 if (!servicesObject.isPresent()) {
338 LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
339 return ModelMappingUtils.createRestoreServiceReply(
340 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
343 Services service = servicesObject.get();
344 State state = service.getOperationalState();
346 if (state == State.InService) {
347 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
348 return ModelMappingUtils.createRestoreServiceReply(
349 LogMessages.serviceInService(serviceName), RpcStatus.Failed);
352 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
353 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
354 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
355 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
356 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
357 .setRequestId(service.getSdncRequestHeader().getRequestId())
358 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
359 .setRpcAction(RpcActions.ServiceDelete);
360 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
361 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
362 .setServiceName(serviceName)
363 .setDueDate(datetime)
364 .setTailRetention(TailRetention.No).build())
365 .setSdncRequestHeader(sdncBuilder.build());
366 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
367 serviceInput.setServiceAEnd(service.getServiceAEnd());
368 serviceInput.setServiceZEnd(service.getServiceZEnd());
369 serviceInput.setConnectionType(service.getConnectionType());
370 HardConstraints hardConstraints = service.getHardConstraints();
371 if (hardConstraints == null) {
372 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
374 SoftConstraints softConstraints = service.getSoftConstraints();
375 if (softConstraints == null) {
376 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
377 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
378 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
380 LOG.info("converting hard constraints to soft constraints ...");
381 serviceInput.setSoftConstraints(
382 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
383 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
386 this.pceListenerImpl.setInput(serviceInput);
387 this.pceListenerImpl.setServiceReconfigure(true);
388 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
389 this.rendererListenerImpl.setServiceInput(serviceInput);
390 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
391 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
392 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
393 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
394 new ServiceInput(deleteInputBldr.build()));
395 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
396 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
397 ServiceNotificationTypes.ServiceDeleteResult, null);
398 if (output == null) {
399 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
400 return ModelMappingUtils.createRestoreServiceReply(
401 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
403 LOG.info("RPC serviceRestore in progress...");
404 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
405 return ModelMappingUtils.createRestoreServiceReply(
406 common.getResponseMessage(), RpcStatus.Successful);
411 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
412 equipmentNotification(EquipmentNotificationInput input) {
413 // TODO Auto-generated method stub
418 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
419 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
420 // TODO Auto-generated method stub
425 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
426 String serviceName = input.getServiceName();
427 LOG.info("RPC serviceReroute received for {}", serviceName);
428 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
429 if (!servicesObject.isPresent()) {
430 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
431 return ModelMappingUtils.createRerouteServiceReply(
432 input, ResponseCodes.FINAL_ACK_NO,
433 LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
435 Services service = servicesObject.get();
436 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
437 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
438 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
439 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
440 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
441 .setRequestId(service.getSdncRequestHeader().getRequestId())
442 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
443 .setRpcAction(RpcActions.ServiceDelete);
444 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
445 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
446 .setServiceName(serviceName).setDueDate(datetime)
447 .setTailRetention(TailRetention.No).build())
448 .setSdncRequestHeader(sdncBuilder.build());
449 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
450 serviceInput.setServiceAEnd(service.getServiceAEnd());
451 serviceInput.setServiceZEnd(service.getServiceZEnd());
452 serviceInput.setConnectionType(service.getConnectionType());
453 this.pceListenerImpl.setInput(serviceInput);
454 this.pceListenerImpl.setServiceReconfigure(true);
455 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
456 this.rendererListenerImpl.setServiceInput(serviceInput);
457 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
458 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
459 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
460 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
461 new ServiceInput(deleteInputBldr.build()));
462 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125
463 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
464 ServiceNotificationTypes.ServiceDeleteResult, null);
465 if (output == null) {
466 LOG.error("serviceReroute: {}", LogMessages.RENDERER_DELETE_FAILED);
467 return ModelMappingUtils.createRerouteServiceReply(
468 input, ResponseCodes.FINAL_ACK_YES,
469 LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
471 LOG.info("RPC ServiceReroute in progress...");
472 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
473 return ModelMappingUtils.createRerouteServiceReply(
474 input, common.getAckFinalIndicator(),
475 common.getResponseMessage(), RpcStatus.Successful);
479 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
480 // TODO Auto-generated method stub
485 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
486 // TODO Auto-generated method stub
491 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
492 networkReOptimization(NetworkReOptimizationInput input) {
493 // TODO Auto-generated method stub
498 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
499 String commonId = input.getCommonId();
500 LOG.info("RPC temp serviceDelete request received for {}", commonId);
503 * Upon receipt of service-deleteService RPC, service header and sdnc-request
504 * header compliancy are verified.
506 LOG.debug("checking Service Compliance ...");
507 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
508 commonId, null, null, RpcActions.ServiceDelete, false, false
510 if (!serviceHandlerCheckResult.hasPassed()) {
511 LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
512 return ModelMappingUtils.createDeleteServiceReply(
513 input, ResponseCodes.FINAL_ACK_YES,
514 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
517 //Check presence of service to be deleted
518 LOG.debug("service common-id '{}' is compliant", commonId);
519 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list.Services>
521 this.serviceDataStoreOperations.getTempService(commonId);
522 if (!service.isPresent()) {
523 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
524 return ModelMappingUtils.createDeleteServiceReply(
525 input, ResponseCodes.FINAL_ACK_YES,
526 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
529 LOG.info("Service '{}' present in datastore !", commonId);
530 this.pceListenerImpl.setInput(new ServiceInput(input));
531 this.pceListenerImpl.setServiceReconfigure(false);
532 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
533 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
534 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
535 this.rendererListenerImpl.setTempService(true);
536 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
537 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput output =
538 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
539 if (output == null) {
540 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
541 return ModelMappingUtils.createDeleteServiceReply(
542 input, ResponseCodes.FINAL_ACK_YES,
543 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
545 LOG.info("RPC tempServiceDelete in progress...");
546 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
547 return ModelMappingUtils.createDeleteServiceReply(
548 input, common.getAckFinalIndicator(),
549 common.getResponseMessage(), common.getResponseCode());
553 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
554 LOG.info("RPC tempServiceCreate received");
556 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
557 new ServiceInput(input), RpcActions.TempServiceCreate);
558 if (! validationResult.isSuccess()) {
559 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
560 return ModelMappingUtils.createCreateServiceReply(
561 input, ResponseCodes.FINAL_ACK_YES,
562 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
565 // Starting service create operation
566 LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
567 this.pceListenerImpl.setInput(new ServiceInput(input));
568 this.pceListenerImpl.setServiceReconfigure(false);
569 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
570 this.pceListenerImpl.setTempService(true);
571 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
572 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
573 this.rendererListenerImpl.setTempService(true);
574 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
575 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
576 if (output == null) {
577 LOG.warn(TEMP_SERVICE_CREATE_MSG, 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