Catalog RPC Implementation
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerImpl.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.servicehandler.impl;
9
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.Map;
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.CatalogInput;
23 import org.opendaylight.transportpce.servicehandler.DowngradeConstraints;
24 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
25 import org.opendaylight.transportpce.servicehandler.ServiceInput;
26 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
27 import org.opendaylight.transportpce.servicehandler.catalog.CatalogMapper;
28 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
29 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
30 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
31 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
32 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
33 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
34 import org.opendaylight.transportpce.servicehandler.validation.CatalogValidation;
35 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
36 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
37 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.reroute.request.input.EndpointsBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommon;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.OpenroadmOperationalModes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.SpecificOperationalModes;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkInput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkOutput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkInput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestInput;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestOutput;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmInput;
89 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmOutput;
90 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestInput;
91 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestOutput;
92 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
93 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
94 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
95 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
96 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestInput;
97 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestOutput;
98 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionInput;
99 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionOutput;
100 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestInput;
101 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestOutput;
102 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollInput;
103 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollOutput;
104 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestInput;
105 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestOutput;
106 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetInput;
107 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetOutput;
108 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkInput;
109 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkOutput;
110 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
111 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
112 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
113 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
114 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo.TailRetention;
115 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
116 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
117 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
118 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
119 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
120 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
121 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
122 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
123 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
124 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
125 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
126 import org.opendaylight.yangtools.yang.common.RpcResult;
127 import org.slf4j.Logger;
128 import org.slf4j.LoggerFactory;
129
130
131 /**
132  * Top level service interface providing main OpenROADM controller services.
133  */
134 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
135     private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
136     private static final String PUBLISHER = "ServiceHandler";
137     private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
138     private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
139     private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
140     private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
141     private static final String SERVICE_FEASIBILITY_CHECK_MSG = "serviceFeasibilityCheck: {}";
142     private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
143     private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
144     private static final String ADD_OR_TO_CATALOG_MSG = "addORToCatalog: {}";
145     private static final String ADD_SPECIFIC_TO_CATALOG_MSG = "addSpecificToCatalog: {}";
146
147     private DataBroker db;
148     private ServiceDataStoreOperations serviceDataStoreOperations;
149     private PCEServiceWrapper pceServiceWrapper;
150     private RendererServiceWrapper rendererServiceWrapper;
151     private PceListenerImpl pceListenerImpl;
152     private RendererListenerImpl rendererListenerImpl;
153     private NetworkModelListenerImpl networkModelListenerImpl;
154     private NotificationPublishService notificationPublishService;
155     private CatalogDataStoreOperations catalogDataStoreOperations;
156
157     //TODO: remove private request fields as they are in global scope
158
159     public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
160             RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
161             PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
162             NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations,
163                               CatalogDataStoreOperations catalogDataStoreOperations) {
164         this.db = databroker;
165         this.catalogDataStoreOperations = catalogDataStoreOperations;
166         this.serviceDataStoreOperations = serviceDataStoreOperations;
167         this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
168         this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
169         this.pceListenerImpl = pceListenerImpl;
170         this.rendererListenerImpl = rendererListenerImpl;
171         this.networkModelListenerImpl = networkModelListenerImpl;
172         this.notificationPublishService =  notificationPublishService;
173     }
174
175
176     // This is class is public so that these messages can be accessed from Junit (avoid duplications).
177     public static final class LogMessages {
178
179         public static final String PCE_CALLING;
180         public static final String ABORT_PCE_FAILED;
181         public static final String PCE_FAILED;
182         public static final String ABORT_SERVICE_NON_COMPLIANT;
183         public static final String SERVICE_NON_COMPLIANT;
184         public static final String RENDERER_DELETE_FAILED;
185         public static final String ABORT_VALID_FAILED;
186         public static final String ABORT_OR_TO_CATALOG_FAILED;
187         public static final String ABORT_SPECIFIC_TO_CATALOG_FAILED;
188
189         // Static blocks are generated once and spare memory.
190         static {
191             PCE_CALLING = "Calling PCE";
192             ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
193             PCE_FAILED = "PCE calculation failed";
194             ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
195             SERVICE_NON_COMPLIANT = "non-compliant service";
196             RENDERER_DELETE_FAILED = "Renderer service delete failed";
197             ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
198             ABORT_OR_TO_CATALOG_FAILED = "Aborting: validation of add OR to catalog request failed";
199             ABORT_SPECIFIC_TO_CATALOG_FAILED = "Aborting: validation of add Specific to catalog request failed";
200         }
201
202         public static String serviceInDS(String serviceName) {
203             return "Service '" + serviceName + "' already exists in datastore";
204         }
205
206         public static String serviceNotInDS(String serviceName) {
207             return "Service '" + serviceName + "' does not exist in datastore";
208         }
209
210         public static String servicePathNotInDS(String serviceName) {
211             return "Service Path from '" + serviceName + "' does not exist in datastore";
212         }
213
214         public static String serviceInService(String serviceName) {
215             return "Service '" + serviceName + "' is in 'inService' state";
216         }
217
218         private LogMessages() {
219         }
220     }
221
222     @Override
223     public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
224         LOG.info("RPC serviceCreate received");
225         // Validation
226         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
227                 new ServiceInput(input), RpcActions.ServiceCreate);
228         if (!validationResult.isSuccess()) {
229             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
230             return ModelMappingUtils.createCreateServiceReply(
231                     input, ResponseCodes.FINAL_ACK_YES,
232                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
233         }
234         //Check any presence of services with the same name
235         String serviceName = input.getServiceName();
236         if (this.serviceDataStoreOperations.getService(serviceName).isPresent()) {
237             LOG.warn(SERVICE_CREATE_MSG, LogMessages.serviceInDS(serviceName));
238             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
239                     LogMessages.serviceInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
240         }
241         this.pceListenerImpl.setInput(new ServiceInput(input));
242         this.pceListenerImpl.setServiceReconfigure(false);
243         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
244         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
245         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
246         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
247         LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
248         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
249         if (output == null) {
250             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
251             sendNbiNotification(new PublishNotificationProcessServiceBuilder()
252                     .setServiceName(serviceName)
253                     .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
254                     .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
255                     .setCommonId(input.getCommonId())
256                     .setConnectionType(input.getConnectionType())
257                     .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
258                     .setMessage("ServiceCreate request failed ...")
259                     .setOperationalState(State.Degraded)
260                     .setPublisherName(PUBLISHER)
261                     .build());
262             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
263                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
264         }
265         LOG.info("RPC serviceCreate in progress...");
266         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
267         return ModelMappingUtils.createCreateServiceReply(
268                 input, common.getAckFinalIndicator(),
269                 common.getResponseMessage(), common.getResponseCode());
270     }
271
272     @Override
273     public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
274         String serviceName = input.getServiceDeleteReqInfo().getServiceName();
275         LOG.info("RPC serviceDelete request received for {}", serviceName);
276
277         /*
278          * Upon receipt of service-deleteService RPC, service header and sdnc-request
279          * header compliance are verified.
280          */
281         ComplianceCheckResult serviceHandlerCheckResult =
282             ServicehandlerComplianceCheck.check(
283                 input.getServiceDeleteReqInfo().getServiceName(),
284                 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
285         if (!serviceHandlerCheckResult.hasPassed()) {
286             LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
287             return ModelMappingUtils.createDeleteServiceReply(
288                     input, ResponseCodes.FINAL_ACK_YES,
289                     LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
290         }
291
292         //Check presence of service to be deleted
293         Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
294         Services service;
295         if (serviceOpt.isEmpty()) {
296             LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
297             return ModelMappingUtils.createDeleteServiceReply(
298                     input, ResponseCodes.FINAL_ACK_YES,
299                     LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
300         }
301         service = serviceOpt.get();
302         LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
303         this.pceListenerImpl.setInput(new ServiceInput(input));
304         this.pceListenerImpl.setServiceReconfigure(false);
305         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
306         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
307         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
308         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
309         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
310                 serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
311         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
312             this.rendererServiceWrapper.performRenderer(
313                 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
314
315         if (output == null) {
316             LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
317             sendNbiNotification(new PublishNotificationProcessServiceBuilder()
318                     .setServiceName(service.getServiceName())
319                     .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
320                     .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
321                     .setCommonId(service.getCommonId())
322                     .setConnectionType(service.getConnectionType())
323                     .setMessage("ServiceDelete request failed ...")
324                     .setOperationalState(State.InService)
325                     .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED)
326                     .setPublisherName(PUBLISHER)
327                     .build());
328             return ModelMappingUtils.createDeleteServiceReply(
329                     input, ResponseCodes.FINAL_ACK_YES,
330                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
331         }
332
333         LOG.debug("RPC serviceDelete in progress...");
334         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
335         return ModelMappingUtils.createDeleteServiceReply(
336                 input, common.getAckFinalIndicator(),
337                 common.getResponseMessage(), common.getResponseCode());
338     }
339
340     @Override
341     public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
342             ServiceFeasibilityCheckInput input) {
343         LOG.info("RPC serviceFeasibilityCheck received");
344         // Validation
345         ServiceInput serviceInput = new ServiceInput(input);
346         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
347                 RpcActions.ServiceFeasibilityCheck);
348         if (! validationResult.isSuccess()) {
349             LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
350             return ModelMappingUtils.createCreateServiceReply(
351                     input, ResponseCodes.FINAL_ACK_YES,
352                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
353         }
354         this.pceListenerImpl.setInput(new ServiceInput(input));
355         this.pceListenerImpl.setServiceReconfigure(false);
356         this.pceListenerImpl.setServiceFeasiblity(true);
357         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
358         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
359         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
360         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
361         LOG.debug(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.PCE_CALLING);
362         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
363         if (output == null) {
364             LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
365             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
366                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
367         }
368         LOG.info("RPC serviceFeasibilityCheck in progress...");
369         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
370         return ModelMappingUtils.createCreateServiceReply(
371                 input, common.getAckFinalIndicator(),
372                 common.getResponseMessage(), common.getResponseCode());
373     }
374
375     @Override
376     public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
377         String serviceName = input.getServiceName();
378         LOG.info("RPC serviceReconfigure received for {}", serviceName);
379         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
380         if (servicesObject.isEmpty()) {
381             LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
382             return ModelMappingUtils.createCreateServiceReply(
383                 input,
384                 LogMessages.serviceNotInDS(serviceName));
385         }
386         LOG.debug("Service '{}' found in datastore", serviceName);
387         OperationResult validationResult = ServiceCreateValidation
388                 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
389         if (!validationResult.isSuccess()) {
390             LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
391             return ModelMappingUtils.createCreateServiceReply(
392                     input,
393                     validationResult.getResultMessage());
394         }
395         this.pceListenerImpl.setInput(new ServiceInput(input));
396         this.pceListenerImpl.setServiceReconfigure(true);
397         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
398         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
399         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
400         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
401         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
402                 .ServiceDeleteInput serviceDeleteInput =
403                         ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
404         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
405                 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
406                         ServiceNotificationTypes.ServiceDeleteResult, null);
407         if (output == null) {
408             LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
409             return ModelMappingUtils.createCreateServiceReply(
410                     input,
411                     LogMessages.RENDERER_DELETE_FAILED);
412                     //TODO check if RpcStatus.Successful is really expected here
413         }
414         LOG.info("RPC serviceReconfigure in progress...");
415         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
416         return ModelMappingUtils.createCreateServiceReply(
417                 input,
418                 common.getResponseMessage());
419     }
420
421     @Override
422     public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
423         String serviceName = input.getServiceName();
424         LOG.info("RPC serviceRestoration received for {}", serviceName);
425         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
426
427         if (!servicesObject.isPresent()) {
428             LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
429             return ModelMappingUtils.createRestoreServiceReply(
430                     LogMessages.serviceNotInDS(serviceName));
431         }
432
433         Services service = servicesObject.get();
434         State state = service.getOperationalState();
435
436         if (state == State.InService) {
437             LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
438             return ModelMappingUtils.createRestoreServiceReply(
439                     LogMessages.serviceInService(serviceName));
440         }
441
442         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
443         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
444         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
445         SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
446                 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
447                 .setRequestId(service.getSdncRequestHeader().getRequestId())
448                 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
449                 .setRpcAction(RpcActions.ServiceDelete);
450         ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
451                 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
452                     .setServiceName(serviceName)
453                     .setDueDate(datetime)
454                     .setTailRetention(TailRetention.No).build())
455                 .setSdncRequestHeader(sdncBuilder.build());
456         ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
457         serviceInput.setServiceAEnd(service.getServiceAEnd());
458         serviceInput.setServiceZEnd(service.getServiceZEnd());
459         serviceInput.setConnectionType(service.getConnectionType());
460         HardConstraints hardConstraints = service.getHardConstraints();
461         if (hardConstraints == null) {
462             LOG.warn("service '{}' HardConstraints is not set !", serviceName);
463         } else {
464             SoftConstraints softConstraints = service.getSoftConstraints();
465             if (softConstraints == null) {
466                 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
467                 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
468             } else {
469                 LOG.info("converting hard constraints to soft constraints ...");
470                 serviceInput.setSoftConstraints(
471                         DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
472             }
473             serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
474         }
475         this.pceListenerImpl.setInput(serviceInput);
476         this.pceListenerImpl.setServiceReconfigure(true);
477         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
478         this.rendererListenerImpl.setServiceInput(serviceInput);
479         this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
480         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
481         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
482             .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
483                     new ServiceInput(deleteInputBldr.build()));
484         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
485             .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
486                 ServiceNotificationTypes.ServiceDeleteResult, null);
487         if (output == null) {
488             LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
489             return ModelMappingUtils.createRestoreServiceReply(LogMessages.RENDERER_DELETE_FAILED);
490         }
491         LOG.info("RPC serviceRestore in progress...");
492         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
493         return ModelMappingUtils.createRestoreServiceReply(common.getResponseMessage());
494
495     }
496
497     @Override
498     public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
499             equipmentNotification(EquipmentNotificationInput input) {
500         // TODO Auto-generated method stub
501         return null;
502     }
503
504     @Override
505     public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
506             serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
507         // TODO Auto-generated method stub
508         return null;
509     }
510
511     @Override
512     public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
513         String serviceName = input.getServiceName();
514         LOG.info("RPC serviceReroute received for {}", serviceName);
515         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
516         if (servicesObject.isEmpty()) {
517             LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
518             return ModelMappingUtils.createRerouteServiceReply(
519                     input, ResponseCodes.FINAL_ACK_YES,
520                     LogMessages.serviceNotInDS(serviceName),
521                     ResponseCodes.RESPONSE_FAILED);
522         }
523         Services service = servicesObject.get();
524         Optional<ServicePaths> servicePathsObject = this.serviceDataStoreOperations.getServicePath(serviceName);
525         if (servicePathsObject.isEmpty()) {
526             LOG.warn("serviceReroute: {}", LogMessages.servicePathNotInDS(serviceName));
527             return ModelMappingUtils.createRerouteServiceReply(
528                     input, ResponseCodes.FINAL_ACK_YES,
529                     LogMessages.servicePathNotInDS(serviceName),
530                     ResponseCodes.RESPONSE_FAILED);
531         }
532         ServicePaths servicePaths = servicePathsObject.get();
533         // serviceInput for later use maybe...
534         ServiceInput serviceInput = new ServiceInput(input);
535         serviceInput.setServiceAEnd(service.getServiceAEnd());
536         serviceInput.setServiceZEnd(service.getServiceZEnd());
537         serviceInput.setConnectionType(service.getConnectionType());
538         serviceInput.setCommonId(service.getCommonId());
539         serviceInput.setHardConstraints(service.getHardConstraints());
540         serviceInput.setSoftConstraints(service.getSoftConstraints());
541         serviceInput.setCustomer(service.getCustomer());
542         serviceInput.setCustomerContact(service.getCustomerContact());
543
544         // Get the network xpdr termination points
545         Map<AToZKey, AToZ> mapaToz = servicePaths.getPathDescription().getAToZDirection().getAToZ();
546         String aendtp = ((TerminationPoint) mapaToz.get(new AToZKey(String.valueOf(mapaToz.size() - 3)))
547                 .getResource()
548                 .getResource())
549                 .getTpId();
550         String zendtp = ((TerminationPoint) mapaToz.get(new AToZKey("2"))
551                 .getResource()
552                 .getResource())
553                 .getTpId();
554
555         PathComputationRerouteRequestOutput output = this.pceServiceWrapper.performPCEReroute(
556                 service.getHardConstraints(), service.getSoftConstraints(), input.getSdncRequestHeader(),
557                 service.getServiceAEnd(), service.getServiceZEnd(),
558                 new EndpointsBuilder().setAEndTp(aendtp).setZEndTp(zendtp).build());
559
560         if (output == null) {
561             LOG.error("serviceReroute: {}", LogMessages.PCE_FAILED);
562             return ModelMappingUtils.createRerouteServiceReply(
563                     input, ResponseCodes.FINAL_ACK_YES,
564                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
565         }
566         LOG.info("RPC ServiceReroute is done");
567         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
568         return ModelMappingUtils.createRerouteServiceReply(input, common.getAckFinalIndicator(),
569                 common.getResponseMessage(), common.getResponseCode());
570     }
571
572     @Override
573     public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
574         // TODO Auto-generated method stub
575         return null;
576     }
577
578     @Override
579     public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
580         // TODO Auto-generated method stub
581         return null;
582     }
583
584     @Override
585     public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
586             networkReOptimization(NetworkReOptimizationInput input) {
587         // TODO Auto-generated method stub
588         return null;
589     }
590
591     @Override
592     public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
593         String commonId = input.getCommonId();
594         LOG.info("RPC temp serviceDelete request received for {}", commonId);
595
596         /*
597          * Upon receipt of service-deleteService RPC, service header and sdnc-request
598          * header compliance are verified.
599          */
600         LOG.debug("checking Service Compliance ...");
601         ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
602                 commonId, null, null, RpcActions.ServiceDelete, false, false
603             );
604         if (!serviceHandlerCheckResult.hasPassed()) {
605             LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
606             return ModelMappingUtils.createDeleteServiceReply(
607                     input, ResponseCodes.FINAL_ACK_YES,
608                     LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
609         }
610
611         //Check presence of service to be deleted
612         LOG.debug("service common-id '{}' is compliant", commonId);
613         Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.Services>
614                 service =
615             this.serviceDataStoreOperations.getTempService(commonId);
616         if (service.isEmpty()) {
617             LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
618             return ModelMappingUtils.createDeleteServiceReply(
619                     input, ResponseCodes.FINAL_ACK_YES,
620                     LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
621         }
622
623         LOG.info("Service '{}' present in datastore !", commonId);
624         this.pceListenerImpl.setInput(new ServiceInput(input));
625         this.pceListenerImpl.setServiceReconfigure(false);
626         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
627         this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
628         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
629         this.rendererListenerImpl.setTempService(true);
630         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
631         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
632                 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
633         if (output == null) {
634             LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
635             return ModelMappingUtils.createDeleteServiceReply(
636                     input, ResponseCodes.FINAL_ACK_YES,
637                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
638         }
639         LOG.info("RPC tempServiceDelete in progress...");
640         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
641         return ModelMappingUtils.createDeleteServiceReply(
642                 input, common.getAckFinalIndicator(),
643                 common.getResponseMessage(), common.getResponseCode());
644     }
645
646     @Override
647     public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
648         LOG.info("RPC tempServiceCreate received");
649         // Validation
650         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
651                 new ServiceInput(input), RpcActions.TempServiceCreate);
652         if (! validationResult.isSuccess()) {
653             LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
654             return ModelMappingUtils.createCreateServiceReply(
655                     input, ResponseCodes.FINAL_ACK_YES,
656                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
657         }
658
659         // Starting service create operation
660         LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
661         this.pceListenerImpl.setInput(new ServiceInput(input));
662         this.pceListenerImpl.setServiceReconfigure(false);
663         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
664         this.pceListenerImpl.setTempService(true);
665         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
666         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
667         this.rendererListenerImpl.setTempService(true);
668         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
669         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
670         if (output == null) {
671             LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
672             return ModelMappingUtils.createCreateServiceReply(
673                     input, ResponseCodes.FINAL_ACK_YES,
674                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
675         }
676         LOG.info("RPC tempServiceCreate in progress...");
677         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
678         return ModelMappingUtils.createCreateServiceReply(
679                 input, common.getAckFinalIndicator(),
680                 common.getResponseMessage(), common.getResponseCode());
681     }
682
683     @Override
684     public ListenableFuture<RpcResult<
685         ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
686             ServiceDeleteComplexResultNotificationRequestInput input) {
687         // TODO Auto-generated method stub
688         return null;
689     }
690
691     @Override
692     public ListenableFuture<RpcResult<
693         ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
694             ServiceCreateResultNotificationRequestInput input) {
695         // TODO Auto-generated method stub
696         return null;
697     }
698
699     @Override
700     public ListenableFuture<RpcResult<
701         ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
702             ServiceDeleteResultNotificationRequestInput input) {
703         // TODO Auto-generated method stub
704         return null;
705     }
706
707     @Override
708     public ListenableFuture<RpcResult<
709         ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
710             ServiceCreateComplexResultNotificationRequestInput input) {
711         // TODO Auto-generated method stub
712         return null;
713     }
714
715     @Override
716     public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
717         ServiceFeasibilityCheckBulkInput input) {
718         // TODO Auto-generated method stub
719         return null;
720     }
721
722     /**
723      * Send notification to NBI notification in order to publish message.
724      * @param service PublishNotificationService
725      */
726     private void sendNbiNotification(PublishNotificationProcessService service) {
727         try {
728             notificationPublishService.putNotification(service);
729         } catch (InterruptedException e) {
730             LOG.warn("Cannot send notification to nbi", e);
731             Thread.currentThread().interrupt();
732         }
733     }
734
735
736     @Override
737     public ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
738         // TODO Auto-generated method stub
739         return null;
740     }
741
742     @Override
743     public ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
744         TempServiceCreateBulkInput input) {
745         // TODO Auto-generated method stub
746         return null;
747     }
748
749     @Override
750     public ListenableFuture<RpcResult<ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
751         ServiceRollResultNotificationRequestInput input) {
752         // TODO Auto-generated method stub
753         return null;
754     }
755
756     @Override
757     public ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
758         ServiceReconfigureBulkInput input) {
759         // TODO Auto-generated method stub
760         return null;
761     }
762
763     @Override
764     public ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
765             serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
766         // TODO Auto-generated method stub
767         return null;
768     }
769
770     @Override
771     public ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
772             serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
773         // TODO Auto-generated method stub
774         return null;
775     }
776
777     @Override
778     public ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
779             serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
780         // TODO Auto-generated method stub
781         return null;
782     }
783
784     @Override
785     public ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
786             serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
787         // TODO Auto-generated method stub
788         return null;
789     }
790
791     @Override
792     public ListenableFuture<RpcResult<OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
793         // TODO Auto-generated method stub
794         return null;
795     }
796
797     @Override
798     public ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
799             OpticalTunnelRequestCancelInput input) {
800         // TODO Auto-generated method stub
801         return null;
802     }
803
804     @Override
805     /**
806      * Implementation of the RPC to set OR  operational modes in the catalog of the controller.
807      * Semantics of the RPC is such that the information in the input replaces the full content
808      * of the OR operational modes catalog in the config data store. Incremental changes to the
809      * catalog, if required, must be done via individual PUT/POST/DELETE RESTconf APIs.
810      *
811      * @param input AddOpenroadmOperationalModesToCatalogInput to be added to Catalog
812      * @return Result of the request
813      */
814     public ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
815         addOpenroadmOperationalModesToCatalog(AddOpenroadmOperationalModesToCatalogInput input) {
816
817         LOG.info("RPC addOpenroadmOperationalModesToCatalog in progress");
818         LOG.debug(" Input openRoadm {}", input);
819         // Validation
820         OperationResult validationResult = CatalogValidation.validateORCatalogRequest(
821                 new CatalogInput(input), RpcActions.FillCatalogWithOrOperationalModes);
822         if (! validationResult.isSuccess()) {
823             LOG.warn(ADD_OR_TO_CATALOG_MSG, LogMessages.ABORT_OR_TO_CATALOG_FAILED);
824             return ModelMappingUtils.addOpenroadmServiceReply(
825                     input, ResponseCodes.FINAL_ACK_YES,
826                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
827         }
828         LOG.info(" Request System Id {} " ,input.getSdncRequestHeader().getRequestSystemId());
829         LOG.info(" Rpc Action {} " ,input.getSdncRequestHeader().getRpcAction());
830
831         OpenroadmOperationalModes objToSave = CatalogMapper.createORModesToSave(input);
832         catalogDataStoreOperations.addOpenroadmOperationalModesToCatalog(objToSave);
833         LOG.info("RPC addOpenroadmOperationalModesToCatalog Completed");
834         return ModelMappingUtils.addOpenroadmServiceReply(input, ResponseCodes.FINAL_ACK_YES,
835                 validationResult.getResultMessage(), ResponseCodes.RESPONSE_OK);
836     }
837
838     @Override
839     /**
840      * Implementation of the RPC to set specific operational modes in the catalog of the controller.
841      * Semantics of the RPC is such that the information in the input replaces the full content
842      * of the specific operational modes catalog in the config data store. Incremental changes to the
843      * catalog, if required, must be done via individual PUT/POST/DELETE RESTconf APIs.
844      *
845      * @param input AddSpecificOperationalModesToCatalogInput to be added to Catalog
846      * @return Result of the request
847      */
848     public ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> addSpecificOperationalModesToCatalog(
849             AddSpecificOperationalModesToCatalogInput input) {
850
851         LOG.info("RPC addSpecificOperationalModesToCatalog in progress");
852         LOG.debug(" Input openSpecificRoadm {}", input);
853         // Validation
854         OperationResult validationResult = CatalogValidation.validateSpecificCatalogRequest(
855                 new CatalogInput(input), RpcActions.FillCatalogWithSpecificOperationalModes);
856         if (! validationResult.isSuccess()) {
857             LOG.warn(ADD_SPECIFIC_TO_CATALOG_MSG, LogMessages.ABORT_SPECIFIC_TO_CATALOG_FAILED);
858             return ModelMappingUtils.addSpecificOpenroadmServiceReply(
859                     input, ResponseCodes.FINAL_ACK_YES,
860                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
861         }
862         LOG.info(" Request System Id {} " ,input.getSdncRequestHeader().getRequestSystemId());
863         LOG.info(" Rpc Action {} " ,input.getSdncRequestHeader().getRpcAction());
864
865         SpecificOperationalModes objToSave = CatalogMapper.createSpecificModesToSave(input);
866         catalogDataStoreOperations.addSpecificOperationalModesToCatalog(objToSave);
867         LOG.info("RPC addSpecificOperationalModesToCatalog Completed");
868         return ModelMappingUtils.addSpecificOpenroadmServiceReply(input, ResponseCodes.FINAL_ACK_YES,
869                 validationResult.getResultMessage(), ResponseCodes.RESPONSE_OK);
870     }
871
872     @Override
873     public ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
874         // TODO Auto-generated method stub
875         return null;
876     }
877 }
878