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;
15 import java.util.Optional;
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.NetworkListener;
25 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
26 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
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.rev220808.PathComputationRequestOutput;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.reroute.request.input.EndpointsBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommon;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationOutput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelOutput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmOutput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestInput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestOutput;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
89 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestInput;
90 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestOutput;
91 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionInput;
92 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionOutput;
93 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestInput;
94 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestOutput;
95 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollInput;
96 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollOutput;
97 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestInput;
98 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestOutput;
99 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetInput;
100 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetOutput;
101 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkInput;
102 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkOutput;
103 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
104 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
105 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
106 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
107 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo.TailRetention;
108 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
109 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
110 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
111 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
112 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
113 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
114 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
115 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
116 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
117 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
118 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
119 import org.opendaylight.yangtools.yang.common.RpcResult;
120 import org.osgi.service.component.annotations.Activate;
121 import org.osgi.service.component.annotations.Component;
122 import org.osgi.service.component.annotations.Reference;
123 import org.slf4j.Logger;
124 import org.slf4j.LoggerFactory;
128 * Top level service interface providing main OpenROADM controller services.
131 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
132 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
133 private static final String PUBLISHER = "ServiceHandler";
134 private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
135 private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
136 private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
137 private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
138 private static final String SERVICE_FEASIBILITY_CHECK_MSG = "serviceFeasibilityCheck: {}";
139 private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
140 private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
142 private ServiceDataStoreOperations serviceDataStoreOperations;
143 private PCEServiceWrapper pceServiceWrapper;
144 private RendererServiceWrapper rendererServiceWrapper;
145 private PceListener pceListenerImpl;
146 private RendererListener rendererListenerImpl;
147 private NetworkListener networkModelListenerImpl;
148 private NotificationPublishService notificationPublishService;
151 public ServicehandlerImpl(@Reference PathComputationService pathComputationService,
152 @Reference RendererServiceOperations rendererServiceOperations,
153 @Reference NotificationPublishService notificationPublishService,
154 @Reference PceListener pceListenerImpl,
155 @Reference RendererListener rendererListenerImpl,
156 @Reference NetworkListener networkModelListenerImpl,
157 @Reference ServiceDataStoreOperations serviceDataStoreOperations) {
158 this.serviceDataStoreOperations = serviceDataStoreOperations;
159 this.notificationPublishService = notificationPublishService;
160 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
161 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
162 this.pceListenerImpl = pceListenerImpl;
163 this.rendererListenerImpl = rendererListenerImpl;
164 this.networkModelListenerImpl = networkModelListenerImpl;
165 LOG.info("ServicehandlerImpl Initiated");
169 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
170 public static final class LogMessages {
172 public static final String PCE_CALLING;
173 public static final String ABORT_PCE_FAILED;
174 public static final String PCE_FAILED;
175 public static final String ABORT_SERVICE_NON_COMPLIANT;
176 public static final String SERVICE_NON_COMPLIANT;
177 public static final String RENDERER_DELETE_FAILED;
178 public static final String ABORT_VALID_FAILED;
180 // Static blocks are generated once and spare memory.
182 PCE_CALLING = "Calling PCE";
183 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
184 PCE_FAILED = "PCE calculation failed";
185 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
186 SERVICE_NON_COMPLIANT = "non-compliant service";
187 RENDERER_DELETE_FAILED = "Renderer service delete failed";
188 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
191 public static String serviceInDS(String serviceName) {
192 return "Service '" + serviceName + "' already exists in datastore";
195 public static String serviceNotInDS(String serviceName) {
196 return "Service '" + serviceName + "' does not exist in datastore";
199 public static String servicePathNotInDS(String serviceName) {
200 return "Service Path from '" + serviceName + "' does not exist in datastore";
203 public static String serviceInService(String serviceName) {
204 return "Service '" + serviceName + "' is in 'inService' state";
207 private LogMessages() {
212 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
213 LOG.info("RPC serviceCreate received");
215 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
216 new ServiceInput(input), RpcActions.ServiceCreate);
217 if (!validationResult.isSuccess()) {
218 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
219 return ModelMappingUtils.createCreateServiceReply(
220 input, ResponseCodes.FINAL_ACK_YES,
221 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
223 //Check any presence of services with the same name
224 String serviceName = input.getServiceName();
225 if (this.serviceDataStoreOperations.getService(serviceName).isPresent()) {
226 LOG.warn(SERVICE_CREATE_MSG, LogMessages.serviceInDS(serviceName));
227 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
228 LogMessages.serviceInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
230 this.pceListenerImpl.setInput(new ServiceInput(input));
231 this.pceListenerImpl.setServiceReconfigure(false);
232 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
233 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
234 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
235 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
236 LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
237 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
238 if (output == null) {
239 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
240 sendNbiNotification(new PublishNotificationProcessServiceBuilder()
241 .setServiceName(serviceName)
242 .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
243 .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
244 .setCommonId(input.getCommonId())
245 .setConnectionType(input.getConnectionType())
246 .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
247 .setMessage("ServiceCreate request failed ...")
248 .setOperationalState(State.Degraded)
249 .setPublisherName(PUBLISHER)
251 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
252 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
254 LOG.info("RPC serviceCreate in progress...");
255 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
256 return ModelMappingUtils.createCreateServiceReply(
257 input, common.getAckFinalIndicator(),
258 common.getResponseMessage(), common.getResponseCode());
262 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
263 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
264 LOG.info("RPC serviceDelete request received for {}", serviceName);
267 * Upon receipt of service-deleteService RPC, service header and sdnc-request
268 * header compliance are verified.
270 ComplianceCheckResult serviceHandlerCheckResult =
271 ServicehandlerComplianceCheck.check(
272 input.getServiceDeleteReqInfo().getServiceName(),
273 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
274 if (!serviceHandlerCheckResult.hasPassed()) {
275 LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
276 return ModelMappingUtils.createDeleteServiceReply(
277 input, ResponseCodes.FINAL_ACK_YES,
278 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
281 //Check presence of service to be deleted
282 Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
284 if (serviceOpt.isEmpty()) {
285 LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
286 return ModelMappingUtils.createDeleteServiceReply(
287 input, ResponseCodes.FINAL_ACK_YES,
288 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
290 service = serviceOpt.get();
291 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
292 this.pceListenerImpl.setInput(new ServiceInput(input));
293 this.pceListenerImpl.setServiceReconfigure(false);
294 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
295 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
296 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
297 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
298 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
299 serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
300 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
301 this.rendererServiceWrapper.performRenderer(
302 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
304 if (output == null) {
305 LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
306 sendNbiNotification(new PublishNotificationProcessServiceBuilder()
307 .setServiceName(service.getServiceName())
308 .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
309 .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
310 .setCommonId(service.getCommonId())
311 .setConnectionType(service.getConnectionType())
312 .setMessage("ServiceDelete request failed ...")
313 .setOperationalState(State.InService)
314 .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED)
315 .setPublisherName(PUBLISHER)
317 return ModelMappingUtils.createDeleteServiceReply(
318 input, ResponseCodes.FINAL_ACK_YES,
319 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
322 LOG.debug("RPC serviceDelete in progress...");
323 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
324 return ModelMappingUtils.createDeleteServiceReply(
325 input, common.getAckFinalIndicator(),
326 common.getResponseMessage(), common.getResponseCode());
330 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
331 ServiceFeasibilityCheckInput input) {
332 LOG.info("RPC serviceFeasibilityCheck received");
334 ServiceInput serviceInput = new ServiceInput(input);
335 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
336 RpcActions.ServiceFeasibilityCheck);
337 if (! validationResult.isSuccess()) {
338 LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
339 return ModelMappingUtils.createCreateServiceReply(
340 input, ResponseCodes.FINAL_ACK_YES,
341 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
343 this.pceListenerImpl.setInput(new ServiceInput(input));
344 this.pceListenerImpl.setServiceReconfigure(false);
345 this.pceListenerImpl.setServiceFeasiblity(true);
346 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
347 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
348 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
349 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
350 LOG.debug(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.PCE_CALLING);
351 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
352 if (output == null) {
353 LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
354 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
355 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
357 LOG.info("RPC serviceFeasibilityCheck in progress...");
358 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
359 return ModelMappingUtils.createCreateServiceReply(
360 input, common.getAckFinalIndicator(),
361 common.getResponseMessage(), common.getResponseCode());
365 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
366 String serviceName = input.getServiceName();
367 LOG.info("RPC serviceReconfigure received for {}", serviceName);
368 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
369 if (servicesObject.isEmpty()) {
370 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
371 return ModelMappingUtils.createCreateServiceReply(
373 LogMessages.serviceNotInDS(serviceName));
375 LOG.debug("Service '{}' found in datastore", serviceName);
376 OperationResult validationResult = ServiceCreateValidation
377 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
378 if (!validationResult.isSuccess()) {
379 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
380 return ModelMappingUtils.createCreateServiceReply(
382 validationResult.getResultMessage());
384 this.pceListenerImpl.setInput(new ServiceInput(input));
385 this.pceListenerImpl.setServiceReconfigure(true);
386 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
387 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
388 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
389 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
390 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
391 .ServiceDeleteInput serviceDeleteInput =
392 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
393 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
394 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
395 ServiceNotificationTypes.ServiceDeleteResult, null);
396 if (output == null) {
397 LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
398 return ModelMappingUtils.createCreateServiceReply(
400 LogMessages.RENDERER_DELETE_FAILED);
401 //TODO check if RpcStatus.Successful is really expected here
403 LOG.info("RPC serviceReconfigure in progress...");
404 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
405 return ModelMappingUtils.createCreateServiceReply(
407 common.getResponseMessage());
411 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
412 String serviceName = input.getServiceName();
413 LOG.info("RPC serviceRestoration received for {}", serviceName);
414 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
416 if (!servicesObject.isPresent()) {
417 LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
418 return ModelMappingUtils.createRestoreServiceReply(
419 LogMessages.serviceNotInDS(serviceName));
422 Services service = servicesObject.get();
423 State state = service.getOperationalState();
425 if (state == State.InService) {
426 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
427 return ModelMappingUtils.createRestoreServiceReply(
428 LogMessages.serviceInService(serviceName));
431 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
432 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
433 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
434 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
435 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
436 .setRequestId(service.getSdncRequestHeader().getRequestId())
437 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
438 .setRpcAction(RpcActions.ServiceDelete);
439 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
440 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
441 .setServiceName(serviceName)
442 .setDueDate(datetime)
443 .setTailRetention(TailRetention.No).build())
444 .setSdncRequestHeader(sdncBuilder.build());
445 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
446 serviceInput.setServiceAEnd(service.getServiceAEnd());
447 serviceInput.setServiceZEnd(service.getServiceZEnd());
448 serviceInput.setConnectionType(service.getConnectionType());
449 HardConstraints hardConstraints = service.getHardConstraints();
450 if (hardConstraints == null) {
451 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
453 SoftConstraints softConstraints = service.getSoftConstraints();
454 if (softConstraints == null) {
455 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
456 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
458 LOG.info("converting hard constraints to soft constraints ...");
459 serviceInput.setSoftConstraints(
460 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
462 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
464 this.pceListenerImpl.setInput(serviceInput);
465 this.pceListenerImpl.setServiceReconfigure(true);
466 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
467 this.rendererListenerImpl.setServiceInput(serviceInput);
468 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
469 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
470 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
471 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
472 new ServiceInput(deleteInputBldr.build()));
473 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
474 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
475 ServiceNotificationTypes.ServiceDeleteResult, null);
476 if (output == null) {
477 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
478 return ModelMappingUtils.createRestoreServiceReply(LogMessages.RENDERER_DELETE_FAILED);
480 LOG.info("RPC serviceRestore in progress...");
481 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
482 return ModelMappingUtils.createRestoreServiceReply(common.getResponseMessage());
487 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
488 equipmentNotification(EquipmentNotificationInput input) {
489 // TODO Auto-generated method stub
494 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
495 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
496 // TODO Auto-generated method stub
501 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
502 String serviceName = input.getServiceName();
503 LOG.info("RPC serviceReroute received for {}", serviceName);
504 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
505 if (servicesObject.isEmpty()) {
506 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
507 return ModelMappingUtils.createRerouteServiceReply(
508 input, ResponseCodes.FINAL_ACK_YES,
509 LogMessages.serviceNotInDS(serviceName),
510 ResponseCodes.RESPONSE_FAILED);
512 Services service = servicesObject.get();
513 Optional<ServicePaths> servicePathsObject = this.serviceDataStoreOperations.getServicePath(serviceName);
514 if (servicePathsObject.isEmpty()) {
515 LOG.warn("serviceReroute: {}", LogMessages.servicePathNotInDS(serviceName));
516 return ModelMappingUtils.createRerouteServiceReply(
517 input, ResponseCodes.FINAL_ACK_YES,
518 LogMessages.servicePathNotInDS(serviceName),
519 ResponseCodes.RESPONSE_FAILED);
521 ServicePaths servicePaths = servicePathsObject.get();
522 // serviceInput for later use maybe...
523 ServiceInput serviceInput = new ServiceInput(input);
524 serviceInput.setServiceAEnd(service.getServiceAEnd());
525 serviceInput.setServiceZEnd(service.getServiceZEnd());
526 serviceInput.setConnectionType(service.getConnectionType());
527 serviceInput.setCommonId(service.getCommonId());
528 serviceInput.setHardConstraints(service.getHardConstraints());
529 serviceInput.setSoftConstraints(service.getSoftConstraints());
530 serviceInput.setCustomer(service.getCustomer());
531 serviceInput.setCustomerContact(service.getCustomerContact());
533 // Get the network xpdr termination points
534 Map<AToZKey, AToZ> mapaToz = servicePaths.getPathDescription().getAToZDirection().getAToZ();
535 String aendtp = ((TerminationPoint) mapaToz.get(new AToZKey(String.valueOf(mapaToz.size() - 3)))
539 String zendtp = ((TerminationPoint) mapaToz.get(new AToZKey("2"))
544 PathComputationRerouteRequestOutput output = this.pceServiceWrapper.performPCEReroute(
545 service.getHardConstraints(), service.getSoftConstraints(), input.getSdncRequestHeader(),
546 service.getServiceAEnd(), service.getServiceZEnd(),
547 new EndpointsBuilder().setAEndTp(aendtp).setZEndTp(zendtp).build());
549 if (output == null) {
550 LOG.error("serviceReroute: {}", LogMessages.PCE_FAILED);
551 return ModelMappingUtils.createRerouteServiceReply(
552 input, ResponseCodes.FINAL_ACK_YES,
553 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
555 LOG.info("RPC ServiceReroute is done");
556 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
557 return ModelMappingUtils.createRerouteServiceReply(input, common.getAckFinalIndicator(),
558 common.getResponseMessage(), common.getResponseCode());
562 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
563 // TODO Auto-generated method stub
568 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
569 // TODO Auto-generated method stub
574 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
575 networkReOptimization(NetworkReOptimizationInput input) {
576 // TODO Auto-generated method stub
581 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
582 String commonId = input.getCommonId();
583 LOG.info("RPC temp serviceDelete request received for {}", commonId);
586 * Upon receipt of service-deleteService RPC, service header and sdnc-request
587 * header compliance are verified.
589 LOG.debug("checking Service Compliance ...");
590 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
591 commonId, null, null, RpcActions.ServiceDelete, false, false
593 if (!serviceHandlerCheckResult.hasPassed()) {
594 LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
595 return ModelMappingUtils.createDeleteServiceReply(
596 input, ResponseCodes.FINAL_ACK_YES,
597 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
600 //Check presence of service to be deleted
601 LOG.debug("service common-id '{}' is compliant", commonId);
602 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.Services>
604 this.serviceDataStoreOperations.getTempService(commonId);
605 if (service.isEmpty()) {
606 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
607 return ModelMappingUtils.createDeleteServiceReply(
608 input, ResponseCodes.FINAL_ACK_YES,
609 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
612 LOG.info("Service '{}' present in datastore !", commonId);
613 this.pceListenerImpl.setInput(new ServiceInput(input));
614 this.pceListenerImpl.setServiceReconfigure(false);
615 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
616 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
617 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
618 this.rendererListenerImpl.setTempService(true);
619 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
620 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
621 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
622 if (output == null) {
623 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
624 return ModelMappingUtils.createDeleteServiceReply(
625 input, ResponseCodes.FINAL_ACK_YES,
626 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
628 LOG.info("RPC tempServiceDelete in progress...");
629 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
630 return ModelMappingUtils.createDeleteServiceReply(
631 input, common.getAckFinalIndicator(),
632 common.getResponseMessage(), common.getResponseCode());
636 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
637 LOG.info("RPC tempServiceCreate received");
639 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
640 new ServiceInput(input), RpcActions.TempServiceCreate);
641 if (! validationResult.isSuccess()) {
642 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
643 return ModelMappingUtils.createCreateServiceReply(
644 input, ResponseCodes.FINAL_ACK_YES,
645 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
648 // Starting service create operation
649 LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
650 this.pceListenerImpl.setInput(new ServiceInput(input));
651 this.pceListenerImpl.setServiceReconfigure(false);
652 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
653 this.pceListenerImpl.setTempService(true);
654 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
655 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
656 this.rendererListenerImpl.setTempService(true);
657 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
658 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
659 if (output == null) {
660 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
661 return ModelMappingUtils.createCreateServiceReply(
662 input, ResponseCodes.FINAL_ACK_YES,
663 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
665 LOG.info("RPC tempServiceCreate in progress...");
666 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
667 return ModelMappingUtils.createCreateServiceReply(
668 input, common.getAckFinalIndicator(),
669 common.getResponseMessage(), common.getResponseCode());
673 public ListenableFuture<RpcResult<
674 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
675 ServiceDeleteComplexResultNotificationRequestInput input) {
676 // TODO Auto-generated method stub
681 public ListenableFuture<RpcResult<
682 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
683 ServiceCreateResultNotificationRequestInput input) {
684 // TODO Auto-generated method stub
689 public ListenableFuture<RpcResult<
690 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
691 ServiceDeleteResultNotificationRequestInput input) {
692 // TODO Auto-generated method stub
697 public ListenableFuture<RpcResult<
698 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
699 ServiceCreateComplexResultNotificationRequestInput input) {
700 // TODO Auto-generated method stub
705 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
706 ServiceFeasibilityCheckBulkInput input) {
707 // TODO Auto-generated method stub
712 * Send notification to NBI notification in order to publish message.
713 * @param service PublishNotificationService
715 private void sendNbiNotification(PublishNotificationProcessService service) {
717 notificationPublishService.putNotification(service);
718 } catch (InterruptedException e) {
719 LOG.warn("Cannot send notification to nbi", e);
720 Thread.currentThread().interrupt();
726 public ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
727 // TODO Auto-generated method stub
732 public ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
733 TempServiceCreateBulkInput input) {
734 // TODO Auto-generated method stub
739 public ListenableFuture<RpcResult<ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
740 ServiceRollResultNotificationRequestInput input) {
741 // TODO Auto-generated method stub
746 public ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
747 ServiceReconfigureBulkInput input) {
748 // TODO Auto-generated method stub
753 public ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
754 serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
755 // TODO Auto-generated method stub
760 public ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
761 serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
762 // TODO Auto-generated method stub
767 public ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
768 serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
769 // TODO Auto-generated method stub
774 public ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
775 serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
776 // TODO Auto-generated method stub
781 public ListenableFuture<RpcResult<OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
782 // TODO Auto-generated method stub
787 public ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
788 OpticalTunnelRequestCancelInput input) {
789 // TODO Auto-generated method stub
794 public ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
795 addOpenroadmOperationalModesToCatalog(AddOpenroadmOperationalModesToCatalogInput input) {
796 // TODO Auto-generated method stub
801 public ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> addSpecificOperationalModesToCatalog(
802 AddSpecificOperationalModesToCatalogInput input) {
803 // TODO Auto-generated method stub
808 public ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
809 // TODO Auto-generated method stub