<service ref="rendererServiceOperations"
interface="org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations" />
+ <service ref="networkModelWavelengthService"
+ interface="org.opendaylight.transportpce.renderer.NetworkModelWavelengthService" />
+
</blueprint>
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
import org.opendaylight.transportpce.servicehandler.ServiceInput;
//TODO: remove private request fields as they are in global scope
public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
- RendererServiceOperations rendererServiceOperations) {
+ RendererServiceOperations rendererServiceOperations,
+ NetworkModelWavelengthService networkModelWavelengthService) {
this.db = databroker;
this.rendererServiceOperations = rendererServiceOperations;
this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
.ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
new ServiceInput(input));
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
+ .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
if (!ResponseCodes.RESPONSE_OK
.equals(output.getConfigurationResponseCommon().getResponseCode())) {
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.TransportpcePceListener;
private final DataBroker dataBroker;
private final RpcProviderRegistry rpcRegistry;
private final NotificationService notificationService;
+ private final NetworkModelWavelengthService networkModelWavelengthService;
private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
private PathComputationService pathComputationService;
public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
NotificationService notificationService, PathComputationService pathComputationService,
- RendererServiceOperations rendererServiceOperations) {
+ RendererServiceOperations rendererServiceOperations,
+ NetworkModelWavelengthService networkModelWavelengthService) {
this.dataBroker = dataBroker;
this.rpcRegistry = rpcProviderRegistry;
this.notificationService = notificationService;
this.pathComputationService = pathComputationService;
this.rendererServiceOperations = rendererServiceOperations;
+ this.networkModelWavelengthService = networkModelWavelengthService;
}
/**
public void init() {
LOG.info("ServicehandlerProvider Session Initiated");
final ServicehandlerImpl servicehandler = new ServicehandlerImpl(dataBroker, pathComputationService,
- rendererServiceOperations);
+ rendererServiceOperations, networkModelWavelengthService);
final PceListenerImpl pceListener = new PceListenerImpl();
rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
}
package org.opendaylight.transportpce.servicehandler.stub;
import com.google.common.util.concurrent.ListenableFuture;
+
import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
public class StubRendererServiceOperations implements RendererServiceOperations {
private static final Logger LOG = LoggerFactory.getLogger(StubRendererServiceOperations.class);
+ private StubrendererImpl stubrendererImpl;
+
+ public StubRendererServiceOperations(NetworkModelWavelengthService networkModelWavelengthService,
+ DataBroker dataBroker) {
+ this.stubrendererImpl = new StubrendererImpl(networkModelWavelengthService, dataBroker);
+ }
@Override
public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
- ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> rpcResultFuture = StubrendererImpl
- .serviceImplementation(input);
+ ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> rpcResultFuture =
+ this.stubrendererImpl.serviceImplementation(input);
try {
return rpcResultFuture.get().getResult();
} catch (InterruptedException e) {
@Override
public ServiceDeleteOutput serviceDelete(ServiceDeleteInput input) {
- ListenableFuture<RpcResult<ServiceDeleteOutput>> rpcResultFuture = StubrendererImpl.serviceDelete(input);
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> rpcResultFuture = this.stubrendererImpl.serviceDelete(input);
try {
return rpcResultFuture.get().getResult();
} catch (InterruptedException e) {
package org.opendaylight.transportpce.servicehandler.stub;
+import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
+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.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;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
* @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
*
*/
-public final class StubrendererImpl {
+public class StubrendererImpl {
/** Logging. */
private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class);
/** check service sdnc-request-header compliancy. */
+ private final NetworkModelWavelengthService networkModelWavelengthService;
+ private final DataBroker dataBroker;
- private StubrendererImpl() {
-
+ public StubrendererImpl(NetworkModelWavelengthService networkModelWavelengthService, DataBroker dataBroker) {
+ this.networkModelWavelengthService = networkModelWavelengthService;
+ this.dataBroker = dataBroker;
}
-
- public static ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
+ public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
LOG.info("ServiceDelete request ...");
+ String serviceName = input.getServiceName();
String message = "";
String responseCode = null;
try {
LOG.error("deleting service failed !", e);
responseCode = ResponseCodes.RESPONSE_FAILED;
}
- responseCode = ResponseCodes.RESPONSE_OK;
+ // Obtain path description
+ Optional<PathDescription> pathDescriptionOpt = getPathDescriptionFromDatastore(serviceName);
+ PathDescription pathDescription;
+ if (pathDescriptionOpt.isPresent()) {
+ pathDescription = pathDescriptionOpt.get();
+ this.networkModelWavelengthService.freeWavelengths(pathDescription);
+ responseCode = ResponseCodes.RESPONSE_OK;
+ message = "service deleted !";
+ } else {
+ LOG.error("failed to get pathDescription for service : {}", serviceName);
+ responseCode = ResponseCodes.RESPONSE_FAILED;
+ message = "failed to get pathDescription for service : " + serviceName;
+ }
ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
.setRequestId(input.getServiceHandlerHeader().getRequestId())
return RpcResultBuilder.success(output).buildFuture();
}
- public static ListenableFuture<RpcResult<ServiceImplementationRequestOutput>>
+ public ListenableFuture<RpcResult<ServiceImplementationRequestOutput>>
serviceImplementation(ServiceImplementationRequestInput input) {
LOG.info("serviceImplementation request ...");
String message = "";
LOG.error(message);
responseCode = ResponseCodes.RESPONSE_FAILED;
}
+ this.networkModelWavelengthService.useWavelengths(input.getPathDescription());
+ message = "service implemented !";
responseCode = ResponseCodes.RESPONSE_OK;
ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
.build();
return RpcResultBuilder.success(output).buildFuture();
}
+
+ 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();
+ try {
+ LOG.debug("Getting path description for service {}", serviceName);
+ return pathDescReadTx.read(LogicalDatastoreType.OPERATIONAL, pathDescriptionIID)
+ .get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("Exception while getting path description from datastore {} for service {}!", pathDescriptionIID,
+ serviceName, e);
+ return Optional.absent();
+ }
+ }
}
<reference id="rendererServiceOperations"\r
interface="org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations" />\r
\r
+ <reference id="networkModelWavelengthService"\r
+ interface="org.opendaylight.transportpce.renderer.NetworkModelWavelengthService" />\r
+\r
<bean id="provider"\r
class="org.opendaylight.transportpce.servicehandler.impl.ServicehandlerProvider"\r
init-method="init" destroy-method="close">\r
<argument ref="notificationService" />\r
<argument ref="pathComputationService" />\r
<argument ref="rendererServiceOperations" />\r
+ <argument ref="networkModelWavelengthService" />\r
</bean>\r
\r
</blueprint>\r
import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
import org.opendaylight.transportpce.pce.utils.PceTestData;
import org.opendaylight.transportpce.pce.utils.PceTestUtils;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
private PathComputationService pathComputationService;
private RendererServiceOperations rendererServiceOperations;
+ private NetworkModelWavelengthService networkModelWavelengthService;
private ServicehandlerImpl serviceHandler;
@Mock
@Before
public void setUp() {
this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
- this.rendererServiceOperations);
- this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.rendererServiceOperations, this.networkModelWavelengthService);
+ this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
MockitoAnnotations.initMocks(this);
}
this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
"topologyData/NW-simple-topology.xml");
- this.rendererServiceOperations = new StubRendererServiceOperations();
+ this.rendererServiceOperations =
+ new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());
}
@Test
@Test
public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ ServicehandlerImpl servicehandler =
+ new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
@Test
public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ ServicehandlerImpl servicehandler =
+ new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
txDirectionBuilder.setLgx(lgx);
serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
- this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
.getResult();
}
rxDirectionBuilder.setLgx(lgx);
serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
- this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
.getResult();
}
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl;
import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
private PCEServiceWrapper pceServiceWrapper;
private ServicehandlerImpl serviceHandler;
private RendererServiceOperations rendererServiceOperations;
+ private NetworkModelWavelengthService networkModelWavelengthService;
public ServiceDataStoreOperationsImplTest() {
NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
notificationPublishService);
this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
- this.rendererServiceOperations = new StubRendererServiceOperations();
+ this.rendererServiceOperations =
+ new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());
this.serviceHandler = new ServicehandlerImpl(getDataBroker(), pathComputationService,
- this.rendererServiceOperations);
+ this.rendererServiceOperations, this.networkModelWavelengthService);
}
diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-index 44ef53a..810f093 100644
+index 3a07abb..f79862d 100644
--- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
+++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-@@ -25,6 +25,7 @@ import org.opendaylight.transportpce.servicehandler.ServiceInput;
+@@ -26,6 +26,7 @@ import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
-@@ -87,6 +88,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -87,7 +88,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+
private DataBroker db;
private ServiceDataStoreOperations serviceDataStoreOperations;
- private RendererServiceOperations rendererServiceOperations;
-+ private StubRendererServiceOperations stubRendererServiceOperations;
+- private RendererServiceOperations rendererServiceOperations;
++ private StubRendererServiceOperations rendererServiceOperations;
private PCEServiceWrapper pceServiceWrapper;
//TODO: remove private request fields as they are in global scope
-@@ -95,6 +97,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
- RendererServiceOperations rendererServiceOperations) {
+@@ -96,7 +97,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+ RendererServiceOperations rendererServiceOperations,
+ NetworkModelWavelengthService networkModelWavelengthService) {
this.db = databroker;
- this.rendererServiceOperations = rendererServiceOperations;
-+ this.stubRendererServiceOperations = new StubRendererServiceOperations();
+- this.rendererServiceOperations = rendererServiceOperations;
++ this.rendererServiceOperations = new StubRendererServiceOperations(networkModelWavelengthService, db);
this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
this.serviceDataStoreOperations.initialize();
this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
-@@ -145,7 +148,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
-
- ServiceImplementationRequestInput serviceImplementationRequest =
- ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
-- ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
-+ ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
- .serviceImplementation(serviceImplementationRequest);
- if (ResponseCodes.RESPONSE_OK
- .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
-@@ -221,7 +224,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
- .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
- new ServiceInput(input));
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-- .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
-+ .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
-
- if (!ResponseCodes.RESPONSE_OK
- .equals(output.getConfigurationResponseCommon().getResponseCode())) {
-@@ -406,7 +409,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
- .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
- new ServiceInput(input));
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-- .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
-+ .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
-
- if (!ResponseCodes.RESPONSE_OK
- .equals(output.getConfigurationResponseCommon().getResponseCode())) {
-@@ -476,7 +479,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
-
- ServiceImplementationRequestInput serviceImplementationRequest =
- ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
-- ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
-+ ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
- .serviceImplementation(serviceImplementationRequest);
- if (ResponseCodes.RESPONSE_OK
- .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {