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
9 package org.opendaylight.transportpce.stubpce.impl;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import com.google.common.util.concurrent.ListeningExecutorService;
16 import com.google.common.util.concurrent.MoreExecutors;
17 import java.util.Iterator;
18 import java.util.SortedSet;
19 import java.util.concurrent.ExecutionException;
20 import java.util.concurrent.Executors;
21 import java.util.concurrent.Future;
22 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
23 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
24 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
25 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
26 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
27 import org.opendaylight.transportpce.stubpce.CheckCoherencyHardSoft;
28 import org.opendaylight.transportpce.stubpce.SendingPceRPCs;
29 import org.opendaylight.transportpce.stubpce.StubpceCompliancyCheck;
30 import org.opendaylight.transportpce.stubpce.StubpceTxRxCheck;
31 import org.opendaylight.transportpce.stubpce.topology.PathDescriptionsOrdered;
32 import org.opendaylight.transportpce.stubpce.topology.SuperNodePath;
33 import org.opendaylight.transportpce.stubpce.topology.Topology;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInput;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutput;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutputBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathDescriptionList;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathDescriptionListBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathList;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathListBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResultBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptions;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsKey;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePaths;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsKey;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.rpc.result.PathDescriptionBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.rpc.result.PathDescription;
62 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
63 import org.opendaylight.yangtools.yang.common.RpcResult;
64 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
65 import org.slf4j.Logger;
66 import org.slf4j.LoggerFactory;
69 * Class to implement StubpceService StubpceListener.
70 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on
74 public class StubpceImpl implements StubpceService {
76 private static final Logger LOG = LoggerFactory.getLogger(StubpceImpl.class);
77 /** Permit to access database. */
78 private DataBroker db;
79 /** check service sdnc-request-header compliancy. */
80 private StubpceCompliancyCheck compliancyCheck;
81 /** check missing info on Tx/Rx for A/Z end. */
82 private StubpceTxRxCheck txrxCheck;
83 /** check coherency between hard and soft constraints. */
84 private CheckCoherencyHardSoft checkCoherencyHardSoft;
85 private NotificationPublishService notificationPublishService;
86 private ServicePathRpcResult notification;
87 private PathDescriptionBuilder pathDescriptionBuilder;
88 private SendingPceRPCs sendingPCE;
89 private final ListeningExecutorService executor = MoreExecutors
90 .listeningDecorator(Executors.newFixedThreadPool(10));
92 public StubpceImpl(NotificationPublishService notificationPublishService, DataBroker databroker) {
93 this.notificationPublishService = notificationPublishService;
95 this.pathDescriptionBuilder = null;
96 if (initializePathDescriptionList(databroker)) {
97 fillPathDesciptionList();
99 initializeServicePathList(databroker);
100 /*if (initializeServicePathList(databroker)) {
101 fillServicePathList();
106 public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
107 cancelResourceReserve(CancelResourceReserveInput input) {
108 LOG.info("RPC cancelResourceReserve request received");
110 String responseCode = "";
111 ConfigurationResponseCommonBuilder configurationResponseCommon = null;
112 String serviceName = input.getServiceName();
113 LOG.info("serviceName : {}", serviceName);
114 if (serviceName != null) {
115 this.sendingPCE = new SendingPceRPCs(input,this.db,this.executor);
116 FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
118 ServicePathRpcResult notification = null;
121 public void onFailure(Throwable arg0) {
122 LOG.error("Cancel resource failed : {}", arg0);
123 this.notification = new ServicePathRpcResultBuilder()
124 .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve)
125 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
126 .setStatusMessage("Cancel resource request failed : " + arg0.getMessage()).build();
128 StubpceImpl.this.notificationPublishService.putNotification(this.notification);
129 } catch (InterruptedException e) {
130 LOG.info("notification offer rejected : {}", e);
135 public void onSuccess(Boolean response) {
136 LOG.info("response : {}", response);
138 this.message = "Resource cancelled !";
139 this.notification = new ServicePathRpcResultBuilder()
140 .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve)
141 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful)
142 .setStatusMessage(this.message)
145 this.message = StubpceImpl.this.sendingPCE.getError();
146 this.notification = new ServicePathRpcResultBuilder()
147 .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve)
149 .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message)
151 this.message = "Cancel request failed !";
153 LOG.info(this.notification.toString());
155 StubpceImpl.this.notificationPublishService.putNotification(this.notification);
156 } catch (InterruptedException e) {
157 LOG.info("notification offer rejected : {}", e);
159 LOG.info(this.message);
162 ListenableFuture<Boolean> pce = this.sendingPCE.cancelResourceReserve();
163 Futures.addCallback(pce, pceCallback, this.executor);
164 LOG.info("Cancel Resource Request in progress ...");
165 configurationResponseCommon = new ConfigurationResponseCommonBuilder()
166 .setAckFinalIndicator("No")
167 .setRequestId(input.getServiceHandlerHeader().getRequestId())
168 .setResponseMessage("Service compliant, Cancel resource request in progress...")
169 .setResponseCode("200");
171 CancelResourceReserveOutputBuilder output = new CancelResourceReserveOutputBuilder()
172 .setConfigurationResponseCommon(configurationResponseCommon.build());
173 return RpcResultBuilder.success(output.build()).buildFuture();
175 message = "serviceName / requestId is not correct !";
176 responseCode = "500";
177 this.notification = new ServicePathRpcResultBuilder()
178 .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve)
179 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
180 .setStatusMessage(message).build();
182 this.notificationPublishService.putNotification(this.notification);
183 } catch (InterruptedException e) {
184 LOG.info("notification offer rejected : {}", e);
187 configurationResponseCommon = new ConfigurationResponseCommonBuilder();
188 configurationResponseCommon.setAckFinalIndicator("Yes")
189 .setRequestId(input.getServiceHandlerHeader().getRequestId())
190 .setResponseMessage(message)
191 .setResponseCode(responseCode).build();
192 CancelResourceReserveOutputBuilder output = new CancelResourceReserveOutputBuilder();
193 output.setConfigurationResponseCommon(configurationResponseCommon.build());
194 return RpcResultBuilder.success(output.build()).buildFuture();
198 public ListenableFuture<RpcResult<PathComputationRequestOutput>>
199 pathComputationRequest(PathComputationRequestInput input) {
200 LOG.info("RPC pathcomputation request received");
202 String responseCode = "";
203 boolean coherencyHardSoft = false;
204 boolean commonId = true;
205 ConfigurationResponseCommonBuilder configurationResponseCommon = null;
206 this.compliancyCheck = new StubpceCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader());
207 if (this.compliancyCheck.check(false, true)) {
208 LOG.info("Service compliant !");
210 * If compliant, service-request parameters are verified in order to
211 * check if there is no missing parameter that prevents calculating
212 * a path and implement a service.
214 LOG.info("checking Tx/Rx Info for AEnd ...");
215 this.txrxCheck = new StubpceTxRxCheck(input.getServiceAEnd(), 1);
216 if (this.txrxCheck.check()) {
217 LOG.info("Tx/Rx Info for AEnd checked !");
218 LOG.info("checking Tx/Rx Info for ZEnd ...");
219 this.txrxCheck = new StubpceTxRxCheck(input.getServiceZEnd(), 2);
220 if (this.txrxCheck.check()) {
221 LOG.info("Tx/Rx Info for ZEnd checked !");
223 * If OK, common-id is verified in order to see if there is
224 * no routing policy provided. If yes, the routing
225 * constraints of the policy are recovered and coherency
226 * with hard/soft constraints provided in the input of the
229 if ((input.getHardConstraints() != null) || (input.getSoftConstraints() != null)) {
230 LOG.info("Constraints specified !");
231 this.checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
232 input.getSoftConstraints());
233 if (this.checkCoherencyHardSoft.check()) {
234 LOG.info("hard/soft constraints coherent !");
235 coherencyHardSoft = true;
237 LOG.info("hard/soft constraints are not coherent !");
238 message = "hard/soft constraints are not coherent !";
239 responseCode = "500";
244 if (!commonId || (commonId && coherencyHardSoft)) {
245 this.notification = new ServicePathRpcResultBuilder()
246 .setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
247 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
248 .setStatusMessage("Service compliant, submitting pathComputation Request ...").build();
250 this.notificationPublishService.putNotification(this.notification);
251 } catch (InterruptedException e) {
252 LOG.info("notification offer rejected : {}", e);
254 this.sendingPCE = new SendingPceRPCs(input,this.db,this.executor);
255 FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
257 ServicePathRpcResult notification = null;
260 public void onFailure(Throwable arg0) {
261 LOG.error("Failure message : {}", arg0.toString());
262 LOG.error("Path calculation failed !");
263 this.notification = new ServicePathRpcResultBuilder()
264 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
265 .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build();
267 StubpceImpl.this.notificationPublishService.putNotification(this.notification);
268 } catch (InterruptedException e) {
269 LOG.info("notification offer rejected : {}", e);
274 public void onSuccess(Boolean response) {
275 LOG.info("response : {}", response);
277 this.message = "Path Computated !";
278 ServicePathRpcResultBuilder tmp = new ServicePathRpcResultBuilder()
279 .setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
280 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful)
281 .setStatusMessage(this.message);
282 StubpceImpl.this.pathDescriptionBuilder =
283 StubpceImpl.this.sendingPCE.getPathDescription();
284 if (StubpceImpl.this.pathDescriptionBuilder != null) {
285 PathDescription pathDescription = new org.opendaylight.yang.gen.v1.http.org
286 .transportpce.b.c._interface.servicepath.rev170426.service.path
287 .rpc.result.PathDescriptionBuilder()
289 StubpceImpl.this.pathDescriptionBuilder.getAToZDirection())
291 StubpceImpl.this.pathDescriptionBuilder.getZToADirection())
293 tmp.setPathDescription(new PathDescriptionBuilder()
294 .setAToZDirection(pathDescription.getAToZDirection())
295 .setZToADirection(pathDescription.getZToADirection())
298 this.notification = tmp.build();
300 this.message = StubpceImpl.this.sendingPCE.getError();
301 this.notification = new ServicePathRpcResultBuilder()
302 .setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
304 .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message)
306 this.message = "Path not calculated!";
309 StubpceImpl.this.notificationPublishService.putNotification(this.notification);
310 } catch (InterruptedException e) {
311 LOG.info("notification offer rejected : {}", e);
313 LOG.info(this.message);
316 ListenableFuture<Boolean> pce = this.sendingPCE.pathComputation();
317 Futures.addCallback(pce, pceCallback, this.executor);
318 LOG.info("PathComputation Request in progress ...");
319 configurationResponseCommon = new ConfigurationResponseCommonBuilder()
320 .setAckFinalIndicator("No")
321 .setRequestId(input.getServiceHandlerHeader().getRequestId())
322 .setResponseMessage("Service compliant, Path calculating in progress...")
323 .setResponseCode("200");
325 PathComputationRequestOutputBuilder output = new PathComputationRequestOutputBuilder()
326 .setConfigurationResponseCommon(configurationResponseCommon.build());
327 return RpcResultBuilder.success(output.build()).buildFuture();
331 message = this.txrxCheck.getMessage();
332 responseCode = "500";
335 message = this.txrxCheck.getMessage();
336 responseCode = "500";
339 message = this.compliancyCheck.getMessage();
340 responseCode = "500";
341 this.notification = new ServicePathRpcResultBuilder()
342 .setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
343 .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
344 .setStatusMessage("Service not compliant : " + message).build();
346 this.notificationPublishService.putNotification(this.notification);
347 } catch (InterruptedException e) {
348 LOG.info("notification offer rejected : {}", e);
351 configurationResponseCommon = new ConfigurationResponseCommonBuilder();
352 configurationResponseCommon.setAckFinalIndicator("Yes")
353 .setRequestId(input.getServiceHandlerHeader().getRequestId())
354 .setResponseMessage(message)
355 .setResponseCode(responseCode).build();
356 PathComputationRequestOutputBuilder output = new PathComputationRequestOutputBuilder();
357 output.setConfigurationResponseCommon(configurationResponseCommon.build());
358 return RpcResultBuilder.success(output.build()).buildFuture();
363 * Initialize PathDescriptionList Structure on DataStore.
368 private boolean initializePathDescriptionList(DataBroker dataBroker) {
369 Boolean result = true;
370 LOG.info("Preparing to initialize the PathDescription List");
371 WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
372 InstanceIdentifier<PathDescriptionList> iid = InstanceIdentifier.create(PathDescriptionList.class);
373 PathDescriptionList pathDescriptionList = new PathDescriptionListBuilder().build();
374 transaction.put(LogicalDatastoreType.OPERATIONAL, iid, pathDescriptionList);
375 Future<Void> future = transaction.submit();
377 Futures.getChecked(future, ExecutionException.class);
378 } catch (ExecutionException e) {
379 LOG.error("Failed to create PathDescription List");
386 * Initialize ServicePathList Structure on DataStore.
390 * @return <code>true</code> if ok, <code>false</code> else
392 private boolean initializeServicePathList(DataBroker dataBroker) {
393 Boolean result = true;
394 LOG.info("Preparing to initialize the ServicePathList registry");
395 WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
396 InstanceIdentifier<ServicePathList> iid = InstanceIdentifier.create(ServicePathList.class);
397 ServicePathList servicePathList = new ServicePathListBuilder().build();
398 transaction.put(LogicalDatastoreType.OPERATIONAL, iid, servicePathList);
399 Future<Void> future = transaction.submit();
401 Futures.getChecked(future, ExecutionException.class);
402 } catch (ExecutionException e) {
403 LOG.error("Failed to create ServicePathList List : {}", e.toString());
410 * fill PathDescriptionList
411 * with direct paths and
414 private void fillPathDesciptionList() {
415 LOG.info("filling PathDescription List...");
416 Topology topo = new Topology();
418 LOG.info("Network : {}", topo.getNetwork());
419 SuperNodePath superNodePath = new SuperNodePath(topo.getNetwork());
420 String aend = "NodeA";
421 String zend = "NodeZ";
422 superNodePath.run(aend, zend);
423 fill(superNodePath.getDirectPathDesc(aend, zend, superNodePath.getPaths()));
424 fill(superNodePath.getIndirectPathDesc(aend, zend, superNodePath.getPaths()));
428 * fill datastore with
429 * Pathdescriptions List.
431 * @param sortedSet PathDescriptionsOrdered List
433 private void fill(SortedSet<PathDescriptionsOrdered> sortedSet) {
434 InstanceIdentifier<PathDescriptions> iid;
435 WriteTransaction writeTx;
437 if (!sortedSet.isEmpty()) {
438 Iterator<PathDescriptionsOrdered> it = sortedSet.iterator();
439 while (it.hasNext()) {
440 PathDescriptions pathDesc = it.next().getPathDescriptions();
441 if (pathDesc != null) {
442 iid = InstanceIdentifier.create(PathDescriptionList.class)
443 .child(PathDescriptions.class, new PathDescriptionsKey(pathDesc.getPathName()));
444 writeTx = this.db.newWriteOnlyTransaction();
445 writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, pathDesc);
446 future = writeTx.submit();
448 Futures.getChecked(future, ExecutionException.class);
449 } catch (ExecutionException e) {
450 LOG.error("Failed to write PathDescriptions to PathDescriptionsList : {}", e.toString());
453 LOG.error("PathDescriptions gets is null !");
457 LOG.info("PathDescriptions List is empty !");
462 * read Service from ServiceList DataStore.
467 * @return <code>Services</code>
469 @SuppressWarnings("unused")
470 private Services readServiceList(String serviceName) {
471 Services result = null;
472 ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction();
473 InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
474 new ServicesKey(serviceName));
475 Future<Optional<Services>> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid);
476 Optional<Services> optional = Optional.absent();
478 optional = Futures.getChecked(future, ExecutionException.class);
479 } catch (ExecutionException e) {
480 LOG.error("Reading service failed:", e);
482 if (optional.isPresent()) {
483 LOG.debug("Service '{}' present !", serviceName);
484 result = new ServicesBuilder(optional.get()).build();
490 * read ServicePath Service from ServicePathList DataStore.
493 * Name of ServicePath
495 * @return <code>Services</code>
497 @SuppressWarnings("unused")
498 private ServicePaths readServicePathList(String serviceName) {
499 ServicePaths result = null;
500 ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction();
501 InstanceIdentifier<ServicePaths> iid = InstanceIdentifier.create(ServicePathList.class)
502 .child(ServicePaths.class, new ServicePathsKey(serviceName));
503 Future<Optional<ServicePaths>> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid);
504 Optional<ServicePaths> optional = Optional.absent();
506 optional = Futures.getChecked(future, ExecutionException.class);
507 } catch (ExecutionException e) {
508 LOG.error("Reading service failed:", e);
510 if (optional.isPresent()) {
511 LOG.debug("Service '{}' present !", serviceName);
512 result = new ServicePathsBuilder(optional.get()).build();
518 * read PathDescription information from PathDescriptionList.
521 * Name of PathDescription
523 * @return <code>PathDescriptions</code>
525 @SuppressWarnings("unused")
526 private PathDescriptions readPathDescriptionList(String pathName) {
527 PathDescriptions result = null;
528 ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction();
529 InstanceIdentifier<PathDescriptions> iid = InstanceIdentifier.create(PathDescriptionList.class)
530 .child(PathDescriptions.class, new PathDescriptionsKey(pathName));
531 Future<Optional<PathDescriptions>> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid);
532 Optional<PathDescriptions> optional = Optional.absent();
534 optional = Futures.getChecked(future, ExecutionException.class);
535 } catch (ExecutionException e) {
536 LOG.error("Reading service failed:", e);
538 if (optional.isPresent()) {
539 LOG.debug("PathDescritions '{}' present !", pathName);
540 result = new PathDescriptionsBuilder(optional.get()).build();
546 * register ServicePath Service to ServicePathList with PathDescription
550 * PathComputationRequestInput
551 * @return String operations result, null if ok or not otherwise
553 @SuppressWarnings("unused")
554 private String writeServicePathList(PathComputationRequestInput input) {
555 String serviceName = input.getServiceName();
556 LOG.debug("Write ServicePath '{}' Service", serviceName);
557 String result = null;
558 LOG.debug("Writing '{}' ServicePath", serviceName);
559 InstanceIdentifier<ServicePaths> iid = InstanceIdentifier.create(ServicePathList.class)
560 .child(ServicePaths.class, new ServicePathsKey(serviceName));
562 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service
563 .path.PathDescriptionBuilder path = new org.opendaylight.yang.gen.v1.http.org.transportpce
564 .b.c._interface.service.types.rev170426.service.path.PathDescriptionBuilder();
565 path.setAToZDirection(this.pathDescriptionBuilder.getAToZDirection());
566 path.setZToADirection(this.pathDescriptionBuilder.getZToADirection());
567 ServicePaths service = new ServicePathsBuilder().setServicePathName(input.getServiceName())
568 .setSoftConstraints(input.getSoftConstraints()).setHardConstraints(input.getHardConstraints())
569 .setPathDescription(path.build()).build();
570 WriteTransaction writeTx = this.db.newWriteOnlyTransaction();
571 writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
572 Future<Void> future = writeTx.submit();
574 Futures.getChecked(future, ExecutionException.class);
576 } catch (ExecutionException e) {
577 LOG.error("Failed to write service to Service List");
578 result = "Failed to write service to Service List";
583 public PathDescriptionBuilder getPathDescriptionBuilder() {
584 return this.pathDescriptionBuilder;
587 public void setPathDescriptionBuilder(PathDescriptionBuilder pathDescriptionBuilder) {
588 this.pathDescriptionBuilder = pathDescriptionBuilder;