+ writeTx.put(
+ LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceInput.getServiceName())),
+ ModelMappingUtils.mappingServicePaths(serviceInput, outputFromPce));
+ writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(LogMessages.SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ LOG.warn("createServicePath : {}",
+ LogMessages.failedTo("create servicePath", serviceInput.getCommonId()), e);
+ return OperationResult.failed(LogMessages.failedTo("create servicePath", serviceInput.getCommonId()));
+ }
+ }
+
+ @Override
+ public OperationResult modifyServicePath(PathDescription pathDescription, String serviceName) {
+ LOG.debug("Updating servicePath because of a change in the openroadm-topology");
+ Optional<ServicePaths> readServicePath = getServicePath(serviceName);
+ if (readServicePath.isEmpty()) {
+ LOG.warn("modifyServicePath: {}", LogMessages.SERVICE_PATH_NOT_FOUND);
+ return OperationResult.failed(LogMessages.SERVICE_PATH_NOT_FOUND);
+ }
+ try {
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(
+ LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceName)),
+ new ServicePathsBuilder()
+ .setServiceAEnd(readServicePath.orElseThrow().getServiceAEnd())
+ .setServiceHandlerHeader(readServicePath.orElseThrow().getServiceHandlerHeader())
+ .setServicePathName(readServicePath.orElseThrow().getServicePathName())
+ .setServiceZEnd(readServicePath.orElseThrow().getServiceZEnd())
+ .setSupportingServiceName(readServicePath.orElseThrow().getSupportingServiceName())
+ .setEquipmentSrgs(readServicePath.orElseThrow().getEquipmentSrgs())
+ .setFiberSpanSrlgs(readServicePath.orElseThrow().getFiberSpanSrlgs())
+ .setHardConstraints(readServicePath.orElseThrow().getHardConstraints())
+ .setLatency(readServicePath.orElseThrow().getLatency())
+ .setPathDescription(pathDescription)
+ .setPceRoutingMetric(readServicePath.orElseThrow().getPceRoutingMetric())
+ .setSoftConstraints(readServicePath.orElseThrow().getSoftConstraints())
+ .build());