*/
package org.opendaylight.transportpce.renderer.provisiondevice;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceRpcResultSpBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity;
import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.RpcStatusEx;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.ServicePathNotificationTypes;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.service.path.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev191009.RpcStatusEx;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev191009.ServicePathNotificationTypes;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev191009.service.path.PathDescription;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey;
}
}
-/* @Override
- public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
- LOG.info("Calling service impl request {} {}", input.getServiceName());
- RollbackProcessor rollbackProcessor = new RollbackProcessor();
-
- ServicePathInputData servicePathInputDataAtoZ
- = ModelMappingUtils.rendererCreateServiceInputAToZ(input.getServiceName(),
- input.getPathDescription());
- ServicePathInputData servicePathInputDataZtoA
- = ModelMappingUtils.rendererCreateServiceInputZToA(input.getServiceName(),
- input.getPathDescription());
- List<DeviceRenderingResult> renderingResults = deviceRendering(rollbackProcessor, servicePathInputDataAtoZ,
- servicePathInputDataZtoA);
- if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
- }
-
- ServicePowerSetupInput olmPowerSetupInputAtoZ = ModelMappingUtils.createServicePowerSetupInput(
- renderingResults.get(0).getOlmList(), input);
- ServicePowerSetupInput olmPowerSetupInputZtoA = ModelMappingUtils.createServicePowerSetupInput(
- renderingResults.get(1).getOlmList(), input);
- olmPowerSetup(rollbackProcessor, olmPowerSetupInputAtoZ, olmPowerSetupInputZtoA);
- if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
- }
-
- // run service activation test twice - once on source node and once on destination node
- List<Nodes> nodes = servicePathInputDataAtoZ.getServicePathInput().getNodes();
- Nodes sourceNode = nodes.get(0);
- Nodes destNode = nodes.get(nodes.size() - 1);
-
- String srcNetworkTp;
- String dstNetowrkTp;
-
- if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
- srcNetworkTp = sourceNode.getDestTp();
- } else {
- srcNetworkTp = sourceNode.getSrcTp();
- }
- if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
- dstNetowrkTp = destNode.getDestTp();
- } else {
- dstNetowrkTp = destNode.getSrcTp();
- }
-
- if (!isServiceActivated(sourceNode.getNodeId(), srcNetworkTp)
- || !isServiceActivated(destNode.getNodeId(), dstNetowrkTp)) {
- rollbackProcessor.rollbackAll();
- return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
- }
- } */
-
@Override
public ListenableFuture<ServiceImplementationRequestOutput>
serviceImplementation(ServiceImplementationRequestInput input) {
Nodes destNode = nodes.get(nodes.size() - 1);
String srcNetworkTp;
String dstNetowrkTp;
- //if (sourceNode.getDestTp().contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
srcNetworkTp = sourceNode.getDestTp();
} else {
srcNetworkTp = sourceNode.getSrcTp();
}
- //if (destNode.getDestTp().contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
dstNetowrkTp = destNode.getDestTp();
} else {
private Optional<PathDescription> getPathDescriptionFromDatastore(String serviceName) {
InstanceIdentifier<PathDescription> pathDescriptionIID = InstanceIdentifier.create(ServicePathList.class)
.child(ServicePaths.class, new ServicePathsKey(serviceName)).child(PathDescription.class);
- ReadOnlyTransaction pathDescReadTx = this.dataBroker.newReadOnlyTransaction();
+ ReadTransaction pathDescReadTx = this.dataBroker.newReadOnlyTransaction();
try {
LOG.debug("Getting path description for service {}", serviceName);
return pathDescReadTx.read(LogicalDatastoreType.OPERATIONAL, pathDescriptionIID)
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Exception while getting path description from datastore {} for service {}!", pathDescriptionIID,
serviceName, e);
- return Optional.absent();
+ return Optional.empty();
}
}
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
"Device rendering was not successful! Rendering will be rolled back.");
//FIXME we can't do rollback here, because we don't have rendering results.
- //rollbackProcessor.addTask(new DeviceRenderingRollbackTask("AtoZDeviceTask", true));
- //rollbackProcessor.addTask(new DeviceRenderingRollbackTask("ZtoADeviceTask", true));
return renderingResults;
}
GetPmOutput getPmOutput = getPmRpcResult.getResult();
if ((getPmOutput != null) && (getPmOutput.getNodeId() != null)) {
LOG.info("successfully finished calling OLM's get PM");
- return getPmOutput.getMeasurements(); // may return null
+ return getPmOutput.getMeasurements();
+ // may return null
} else {
LOG.warn("OLM's get PM failed for node {} and tp {}", nodeId, tp);
}