*/
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.transportpce.common.Timeouts;
-import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
import org.opendaylight.transportpce.renderer.ModelMappingUtils;
import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.ServicePathInputData;
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 {
dstNetowrkTp = destNode.getSrcTp();
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public OperationResult reserveResource(PathDescription pathDescription) {
+
+ try {
+ LOG.info("Reserving resources in network model");
+ networkModelWavelengthService.useWavelengths(pathDescription);
+ } catch (Exception e) {
+ LOG.warn("Reserving resources in network model failed");
+ return OperationResult.failed("Resources reserve failed in network model");
+ }
+ return OperationResult.ok("Resources reserved successfully in network model");
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public OperationResult freeResource(PathDescription pathDescription) {
+
+ try {
+ networkModelWavelengthService.freeWavelengths(pathDescription);
+ } catch (Exception e) {
+ return OperationResult.failed("Resources reserve failed in network model");
+ }
+ return OperationResult.ok("Resources reserved successfully in network model");
+ }
+
@Override
public ListenableFuture<ServiceDeleteOutput> serviceDelete(ServiceDeleteInput input) {
String serviceName = input.getServiceName();
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);
}