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.DataBroker;
17 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
18 import org.opendaylight.transportpce.common.OperationResult;
19 import org.opendaylight.transportpce.common.ResponseCodes;
20 import org.opendaylight.transportpce.pce.service.PathComputationService;
21 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
22 import org.opendaylight.transportpce.servicehandler.DowngradeConstraints;
23 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
24 import org.opendaylight.transportpce.servicehandler.ServiceInput;
25 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
26 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
27 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
28 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
29 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
30 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
31 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
32 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
33 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.reroute.request.input.EndpointsBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommon;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationOutput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkOutput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestInput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestOutput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmInput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestInput;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestOutput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
89 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
90 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestInput;
91 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestOutput;
92 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionInput;
93 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionOutput;
94 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestInput;
95 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestOutput;
96 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollInput;
97 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollOutput;
98 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestInput;
99 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestOutput;
100 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetInput;
101 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetOutput;
102 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkInput;
103 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkOutput;
104 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
105 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
106 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
107 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
108 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo.TailRetention;
109 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
110 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
111 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
112 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
113 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
114 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
115 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
116 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
117 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
118 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
119 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
120 import org.opendaylight.yangtools.yang.common.RpcResult;
121 import org.slf4j.Logger;
122 import org.slf4j.LoggerFactory;
126 * Top level service interface providing main OpenROADM controller services.
128 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
129 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
130 private static final String PUBLISHER = "ServiceHandler";
131 private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
132 private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
133 private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
134 private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
135 private static final String SERVICE_FEASIBILITY_CHECK_MSG = "serviceFeasibilityCheck: {}";
136 private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
137 private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
139 private DataBroker db;
140 private ServiceDataStoreOperations serviceDataStoreOperations;
141 private PCEServiceWrapper pceServiceWrapper;
142 private RendererServiceWrapper rendererServiceWrapper;
143 private PceListenerImpl pceListenerImpl;
144 private RendererListenerImpl rendererListenerImpl;
145 private NetworkModelListenerImpl networkModelListenerImpl;
146 private NotificationPublishService notificationPublishService;
148 //TODO: remove private request fields as they are in global scope
150 public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
151 RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
152 PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
153 NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations) {
154 this.db = databroker;
155 this.serviceDataStoreOperations = serviceDataStoreOperations;
156 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
157 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
158 this.pceListenerImpl = pceListenerImpl;
159 this.rendererListenerImpl = rendererListenerImpl;
160 this.networkModelListenerImpl = networkModelListenerImpl;
161 this.notificationPublishService = notificationPublishService;
165 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
166 public static final class LogMessages {
168 public static final String PCE_CALLING;
169 public static final String ABORT_PCE_FAILED;
170 public static final String PCE_FAILED;
171 public static final String ABORT_SERVICE_NON_COMPLIANT;
172 public static final String SERVICE_NON_COMPLIANT;
173 public static final String RENDERER_DELETE_FAILED;
174 public static final String ABORT_VALID_FAILED;
176 // Static blocks are generated once and spare memory.
178 PCE_CALLING = "Calling PCE";
179 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
180 PCE_FAILED = "PCE calculation failed";
181 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
182 SERVICE_NON_COMPLIANT = "non-compliant service";
183 RENDERER_DELETE_FAILED = "Renderer service delete failed";
184 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
187 public static String serviceInDS(String serviceName) {
188 return "Service '" + serviceName + "' already exists in datastore";
191 public static String serviceNotInDS(String serviceName) {
192 return "Service '" + serviceName + "' does not exist in datastore";
195 public static String servicePathNotInDS(String serviceName) {
196 return "Service Path from '" + serviceName + "' does not exist in datastore";
199 public static String serviceInService(String serviceName) {
200 return "Service '" + serviceName + "' is in 'inService' state";
203 private LogMessages() {
208 public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
209 LOG.info("RPC serviceCreate received");
211 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
212 new ServiceInput(input), RpcActions.ServiceCreate);
213 if (!validationResult.isSuccess()) {
214 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
215 return ModelMappingUtils.createCreateServiceReply(
216 input, ResponseCodes.FINAL_ACK_YES,
217 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
219 //Check any presence of services with the same name
220 String serviceName = input.getServiceName();
221 if (this.serviceDataStoreOperations.getService(serviceName).isPresent()) {
222 LOG.warn(SERVICE_CREATE_MSG, LogMessages.serviceInDS(serviceName));
223 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
224 LogMessages.serviceInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
226 this.pceListenerImpl.setInput(new ServiceInput(input));
227 this.pceListenerImpl.setServiceReconfigure(false);
228 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
229 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
230 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
231 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
232 LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
233 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
234 if (output == null) {
235 LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
236 sendNbiNotification(new PublishNotificationProcessServiceBuilder()
237 .setServiceName(serviceName)
238 .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
239 .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
240 .setCommonId(input.getCommonId())
241 .setConnectionType(input.getConnectionType())
242 .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
243 .setMessage("ServiceCreate request failed ...")
244 .setOperationalState(State.Degraded)
245 .setPublisherName(PUBLISHER)
247 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
248 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
250 LOG.info("RPC serviceCreate in progress...");
251 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
252 return ModelMappingUtils.createCreateServiceReply(
253 input, common.getAckFinalIndicator(),
254 common.getResponseMessage(), common.getResponseCode());
258 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
259 String serviceName = input.getServiceDeleteReqInfo().getServiceName();
260 LOG.info("RPC serviceDelete request received for {}", serviceName);
263 * Upon receipt of service-deleteService RPC, service header and sdnc-request
264 * header compliance are verified.
266 ComplianceCheckResult serviceHandlerCheckResult =
267 ServicehandlerComplianceCheck.check(
268 input.getServiceDeleteReqInfo().getServiceName(),
269 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
270 if (!serviceHandlerCheckResult.hasPassed()) {
271 LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
272 return ModelMappingUtils.createDeleteServiceReply(
273 input, ResponseCodes.FINAL_ACK_YES,
274 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
277 //Check presence of service to be deleted
278 Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
280 if (serviceOpt.isEmpty()) {
281 LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
282 return ModelMappingUtils.createDeleteServiceReply(
283 input, ResponseCodes.FINAL_ACK_YES,
284 LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
286 service = serviceOpt.get();
287 LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
288 this.pceListenerImpl.setInput(new ServiceInput(input));
289 this.pceListenerImpl.setServiceReconfigure(false);
290 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
291 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
292 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
293 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
294 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
295 serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
296 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
297 this.rendererServiceWrapper.performRenderer(
298 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
300 if (output == null) {
301 LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
302 sendNbiNotification(new PublishNotificationProcessServiceBuilder()
303 .setServiceName(service.getServiceName())
304 .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
305 .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
306 .setCommonId(service.getCommonId())
307 .setConnectionType(service.getConnectionType())
308 .setMessage("ServiceDelete request failed ...")
309 .setOperationalState(State.InService)
310 .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED)
311 .setPublisherName(PUBLISHER)
313 return ModelMappingUtils.createDeleteServiceReply(
314 input, ResponseCodes.FINAL_ACK_YES,
315 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
318 LOG.debug("RPC serviceDelete in progress...");
319 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
320 return ModelMappingUtils.createDeleteServiceReply(
321 input, common.getAckFinalIndicator(),
322 common.getResponseMessage(), common.getResponseCode());
326 public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
327 ServiceFeasibilityCheckInput input) {
328 LOG.info("RPC serviceFeasibilityCheck received");
330 ServiceInput serviceInput = new ServiceInput(input);
331 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
332 RpcActions.ServiceFeasibilityCheck);
333 if (! validationResult.isSuccess()) {
334 LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
335 return ModelMappingUtils.createCreateServiceReply(
336 input, ResponseCodes.FINAL_ACK_YES,
337 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
339 this.pceListenerImpl.setInput(new ServiceInput(input));
340 this.pceListenerImpl.setServiceReconfigure(false);
341 this.pceListenerImpl.setServiceFeasiblity(true);
342 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
343 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
344 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
345 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
346 LOG.debug(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.PCE_CALLING);
347 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
348 if (output == null) {
349 LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
350 return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
351 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
353 LOG.info("RPC serviceFeasibilityCheck in progress...");
354 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
355 return ModelMappingUtils.createCreateServiceReply(
356 input, common.getAckFinalIndicator(),
357 common.getResponseMessage(), common.getResponseCode());
361 public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
362 String serviceName = input.getServiceName();
363 LOG.info("RPC serviceReconfigure received for {}", serviceName);
364 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
365 if (servicesObject.isEmpty()) {
366 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
367 return ModelMappingUtils.createCreateServiceReply(
369 LogMessages.serviceNotInDS(serviceName));
371 LOG.debug("Service '{}' found in datastore", serviceName);
372 OperationResult validationResult = ServiceCreateValidation
373 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
374 if (!validationResult.isSuccess()) {
375 LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
376 return ModelMappingUtils.createCreateServiceReply(
378 validationResult.getResultMessage());
380 this.pceListenerImpl.setInput(new ServiceInput(input));
381 this.pceListenerImpl.setServiceReconfigure(true);
382 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
383 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
384 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
385 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
386 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
387 .ServiceDeleteInput serviceDeleteInput =
388 ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
389 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
390 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
391 ServiceNotificationTypes.ServiceDeleteResult, null);
392 if (output == null) {
393 LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
394 return ModelMappingUtils.createCreateServiceReply(
396 LogMessages.RENDERER_DELETE_FAILED);
397 //TODO check if RpcStatus.Successful is really expected here
399 LOG.info("RPC serviceReconfigure in progress...");
400 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
401 return ModelMappingUtils.createCreateServiceReply(
403 common.getResponseMessage());
407 public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
408 String serviceName = input.getServiceName();
409 LOG.info("RPC serviceRestoration received for {}", serviceName);
410 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
412 if (!servicesObject.isPresent()) {
413 LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
414 return ModelMappingUtils.createRestoreServiceReply(
415 LogMessages.serviceNotInDS(serviceName));
418 Services service = servicesObject.get();
419 State state = service.getOperationalState();
421 if (state == State.InService) {
422 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
423 return ModelMappingUtils.createRestoreServiceReply(
424 LogMessages.serviceInService(serviceName));
427 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
428 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
429 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
430 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
431 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
432 .setRequestId(service.getSdncRequestHeader().getRequestId())
433 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
434 .setRpcAction(RpcActions.ServiceDelete);
435 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
436 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
437 .setServiceName(serviceName)
438 .setDueDate(datetime)
439 .setTailRetention(TailRetention.No).build())
440 .setSdncRequestHeader(sdncBuilder.build());
441 ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
442 serviceInput.setServiceAEnd(service.getServiceAEnd());
443 serviceInput.setServiceZEnd(service.getServiceZEnd());
444 serviceInput.setConnectionType(service.getConnectionType());
445 HardConstraints hardConstraints = service.getHardConstraints();
446 if (hardConstraints == null) {
447 LOG.warn("service '{}' HardConstraints is not set !", serviceName);
449 SoftConstraints softConstraints = service.getSoftConstraints();
450 if (softConstraints == null) {
451 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
452 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
454 LOG.info("converting hard constraints to soft constraints ...");
455 serviceInput.setSoftConstraints(
456 DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
458 serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
460 this.pceListenerImpl.setInput(serviceInput);
461 this.pceListenerImpl.setServiceReconfigure(true);
462 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
463 this.rendererListenerImpl.setServiceInput(serviceInput);
464 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
465 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
466 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
467 .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
468 new ServiceInput(deleteInputBldr.build()));
469 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
470 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
471 ServiceNotificationTypes.ServiceDeleteResult, null);
472 if (output == null) {
473 LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
474 return ModelMappingUtils.createRestoreServiceReply(LogMessages.RENDERER_DELETE_FAILED);
476 LOG.info("RPC serviceRestore in progress...");
477 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
478 return ModelMappingUtils.createRestoreServiceReply(common.getResponseMessage());
483 public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
484 equipmentNotification(EquipmentNotificationInput input) {
485 // TODO Auto-generated method stub
490 public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
491 serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
492 // TODO Auto-generated method stub
497 public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
498 String serviceName = input.getServiceName();
499 LOG.info("RPC serviceReroute received for {}", serviceName);
500 Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
501 if (servicesObject.isEmpty()) {
502 LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
503 return ModelMappingUtils.createRerouteServiceReply(
504 input, ResponseCodes.FINAL_ACK_YES,
505 LogMessages.serviceNotInDS(serviceName),
506 ResponseCodes.RESPONSE_FAILED);
508 Services service = servicesObject.get();
509 Optional<ServicePaths> servicePathsObject = this.serviceDataStoreOperations.getServicePath(serviceName);
510 if (servicePathsObject.isEmpty()) {
511 LOG.warn("serviceReroute: {}", LogMessages.servicePathNotInDS(serviceName));
512 return ModelMappingUtils.createRerouteServiceReply(
513 input, ResponseCodes.FINAL_ACK_YES,
514 LogMessages.servicePathNotInDS(serviceName),
515 ResponseCodes.RESPONSE_FAILED);
517 ServicePaths servicePaths = servicePathsObject.get();
518 // serviceInput for later use maybe...
519 ServiceInput serviceInput = new ServiceInput(input);
520 serviceInput.setServiceAEnd(service.getServiceAEnd());
521 serviceInput.setServiceZEnd(service.getServiceZEnd());
522 serviceInput.setConnectionType(service.getConnectionType());
523 serviceInput.setCommonId(service.getCommonId());
524 serviceInput.setHardConstraints(service.getHardConstraints());
525 serviceInput.setSoftConstraints(service.getSoftConstraints());
526 serviceInput.setCustomer(service.getCustomer());
527 serviceInput.setCustomerContact(service.getCustomerContact());
529 // Get the network xpdr termination points
530 Map<AToZKey, AToZ> mapaToz = servicePaths.getPathDescription().getAToZDirection().getAToZ();
531 String aendtp = ((TerminationPoint) mapaToz.get(new AToZKey(String.valueOf(mapaToz.size() - 3)))
535 String zendtp = ((TerminationPoint) mapaToz.get(new AToZKey("2"))
540 PathComputationRerouteRequestOutput output = this.pceServiceWrapper.performPCEReroute(
541 service.getHardConstraints(), service.getSoftConstraints(), input.getSdncRequestHeader(),
542 service.getServiceAEnd(), service.getServiceZEnd(),
543 new EndpointsBuilder().setAEndTp(aendtp).setZEndTp(zendtp).build());
545 if (output == null) {
546 LOG.error("serviceReroute: {}", LogMessages.PCE_FAILED);
547 return ModelMappingUtils.createRerouteServiceReply(
548 input, ResponseCodes.FINAL_ACK_YES,
549 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
551 LOG.info("RPC ServiceReroute is done");
552 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
553 return ModelMappingUtils.createRerouteServiceReply(input, common.getAckFinalIndicator(),
554 common.getResponseMessage(), common.getResponseCode());
558 public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
559 // TODO Auto-generated method stub
564 public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
565 // TODO Auto-generated method stub
570 public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
571 networkReOptimization(NetworkReOptimizationInput input) {
572 // TODO Auto-generated method stub
577 public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
578 String commonId = input.getCommonId();
579 LOG.info("RPC temp serviceDelete request received for {}", commonId);
582 * Upon receipt of service-deleteService RPC, service header and sdnc-request
583 * header compliance are verified.
585 LOG.debug("checking Service Compliance ...");
586 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
587 commonId, null, null, RpcActions.ServiceDelete, false, false
589 if (!serviceHandlerCheckResult.hasPassed()) {
590 LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
591 return ModelMappingUtils.createDeleteServiceReply(
592 input, ResponseCodes.FINAL_ACK_YES,
593 LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
596 //Check presence of service to be deleted
597 LOG.debug("service common-id '{}' is compliant", commonId);
598 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.Services>
600 this.serviceDataStoreOperations.getTempService(commonId);
601 if (service.isEmpty()) {
602 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
603 return ModelMappingUtils.createDeleteServiceReply(
604 input, ResponseCodes.FINAL_ACK_YES,
605 LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
608 LOG.info("Service '{}' present in datastore !", commonId);
609 this.pceListenerImpl.setInput(new ServiceInput(input));
610 this.pceListenerImpl.setServiceReconfigure(false);
611 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
612 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
613 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
614 this.rendererListenerImpl.setTempService(true);
615 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
616 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
617 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
618 if (output == null) {
619 LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
620 return ModelMappingUtils.createDeleteServiceReply(
621 input, ResponseCodes.FINAL_ACK_YES,
622 LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
624 LOG.info("RPC tempServiceDelete in progress...");
625 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
626 return ModelMappingUtils.createDeleteServiceReply(
627 input, common.getAckFinalIndicator(),
628 common.getResponseMessage(), common.getResponseCode());
632 public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
633 LOG.info("RPC tempServiceCreate received");
635 OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
636 new ServiceInput(input), RpcActions.TempServiceCreate);
637 if (! validationResult.isSuccess()) {
638 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
639 return ModelMappingUtils.createCreateServiceReply(
640 input, ResponseCodes.FINAL_ACK_YES,
641 validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
644 // Starting service create operation
645 LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
646 this.pceListenerImpl.setInput(new ServiceInput(input));
647 this.pceListenerImpl.setServiceReconfigure(false);
648 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
649 this.pceListenerImpl.setTempService(true);
650 this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
651 this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
652 this.rendererListenerImpl.setTempService(true);
653 this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
654 PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
655 if (output == null) {
656 LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
657 return ModelMappingUtils.createCreateServiceReply(
658 input, ResponseCodes.FINAL_ACK_YES,
659 LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
661 LOG.info("RPC tempServiceCreate in progress...");
662 ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
663 return ModelMappingUtils.createCreateServiceReply(
664 input, common.getAckFinalIndicator(),
665 common.getResponseMessage(), common.getResponseCode());
669 public ListenableFuture<RpcResult<
670 ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
671 ServiceDeleteComplexResultNotificationRequestInput input) {
672 // TODO Auto-generated method stub
677 public ListenableFuture<RpcResult<
678 ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
679 ServiceCreateResultNotificationRequestInput input) {
680 // TODO Auto-generated method stub
685 public ListenableFuture<RpcResult<
686 ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
687 ServiceDeleteResultNotificationRequestInput input) {
688 // TODO Auto-generated method stub
693 public ListenableFuture<RpcResult<
694 ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
695 ServiceCreateComplexResultNotificationRequestInput input) {
696 // TODO Auto-generated method stub
701 public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
702 ServiceFeasibilityCheckBulkInput input) {
703 // TODO Auto-generated method stub
708 * Send notification to NBI notification in order to publish message.
709 * @param service PublishNotificationService
711 private void sendNbiNotification(PublishNotificationProcessService service) {
713 notificationPublishService.putNotification(service);
714 } catch (InterruptedException e) {
715 LOG.warn("Cannot send notification to nbi", e);
716 Thread.currentThread().interrupt();
722 public ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
723 // TODO Auto-generated method stub
728 public ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
729 TempServiceCreateBulkInput input) {
730 // TODO Auto-generated method stub
735 public ListenableFuture<RpcResult<ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
736 ServiceRollResultNotificationRequestInput input) {
737 // TODO Auto-generated method stub
742 public ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
743 ServiceReconfigureBulkInput input) {
744 // TODO Auto-generated method stub
749 public ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
750 serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
751 // TODO Auto-generated method stub
756 public ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
757 serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
758 // TODO Auto-generated method stub
763 public ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
764 serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
765 // TODO Auto-generated method stub
770 public ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
771 serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
772 // TODO Auto-generated method stub
777 public ListenableFuture<RpcResult<OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
778 // TODO Auto-generated method stub
783 public ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
784 OpticalTunnelRequestCancelInput input) {
785 // TODO Auto-generated method stub
790 public ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
791 addOpenroadmOperationalModesToCatalog(AddOpenroadmOperationalModesToCatalogInput input) {
792 // TODO Auto-generated method stub
797 public ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> addSpecificOperationalModesToCatalog(
798 AddSpecificOperationalModesToCatalogInput input) {
799 // TODO Auto-generated method stub
804 public ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
805 // TODO Auto-generated method stub