+++ /dev/null
-module transportpce-servicepath {
- namespace "http://org/transportpce/B-C-interface/servicepath";
- prefix transportpce-servicepath;
-
- import ietf-yang-types {
- prefix yang;
- }
- import transportpce-common-service-path-types {
- prefix transportpce-common-service-path-types;
- }
-
- organization
- "transportPCE";
- contact
- "transportPCE committers - ODL";
- description
- "YANG definitions for service-path (transportPCE). Adapted from service definition (openroadm)
- Copyright © 2017 Orange, Inc. and others. All rights reserved.
-
- openroadm copyright:
- Copyright of the Members of the Open ROADM MSA Agreement dated (c) 2016,
- AT&T Intellectual Property. All other rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
- * Neither the Members of the Open ROADM MSA Agreement nor the names of its
- contributors may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT ''AS IS''
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE";
-
- revision 2017-04-26 {
- description
- "Version 1.5";
- }
-
- revision 2017-10-17 {
- description
- "Version 1.6";
- }
-
- container service-path-list {
- description
- "List of service paths. Can only be created, deleted, modified, etc. using special RPCs.";
- list service-paths {
- key "service-path-name";
- uses transportpce-common-service-path-types:service-path;
- }
- }
-
-}
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>transportpce-stubmodels</artifactId>
+ <artifactId>transportpce-pce</artifactId>
<version>${project.version}</version>
</dependency>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>test-common</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
</dependencies>
</project>
+++ /dev/null
-/*
- * Copyright © 2017 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.transportpce.servicehandler;
-
-import com.google.common.util.concurrent.FutureCallback;
-import org.slf4j.Logger;
-
-/**
- * Class to log future logging from datastore actions (write,modify and delete..).
- *
- * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
- */
-
-public class LoggingFuturesCallBack<V> implements FutureCallback<V> {
-
- private Logger log;
- private String message;
-
- public LoggingFuturesCallBack(String message, Logger log) {
- this.message = message;
- this.log = log;
- }
-
- @Override
- public void onFailure(Throwable ex) {
- log.warn(message, ex);
-
- }
-
- @Override
- public void onSuccess(V arg0) {
- log.info("Success! {} ", arg0);
-
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2017 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.transportpce.servicehandler;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.RoutingConstraintsSp.PceMetric;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraints;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraints;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * class for Mapping and Sending PCE requests : - path-computation-request -
- * cancel-resource-reserve.
- *
- * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
- *
- */
-public class MappingAndSendingPCRequest {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingPCRequest.class);
- /** Permit to call PCE RPCs. */
- private StubpceService service;
- /** define procedure success (or not ). */
- private Boolean success;
- /** permit to call bundle service (PCE, Renderer, Servicehandler. */
- private RpcProviderRegistry rpcRegistry;
- PathComputationRequestInput pathComputationRequestInput = null;
- CancelResourceReserveInput cancelResourceReserveInput = null;
- HardConstraints hard = null;
- SoftConstraints soft = null;
- private ServiceAEnd serviceAEndSp;
- private ServiceZEnd serviceZEndSp;
- /** store all error messages. */
- private String error;
- private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
-
- /**
- * MappingAndSendingPCRequest Class constructor for RPC serviceReconfigure.
- *
- * @param rpcRegistry
- * RpcProviderRegistry
- * @param serviceReconfigureInput
- * serviceReconfigureInput
- * @param resvResource
- * Boolean to define resource reserve
- */
- public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, ServiceReconfigureInput serviceReconfigureInput,
- Boolean resvResource) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubpceService.class);
- }
- endpointToEndpointStubpce(serviceReconfigureInput.getServiceAEnd(), serviceReconfigureInput.getServiceZEnd());
- SdncRequestHeader head = new SdncRequestHeaderBuilder()
- .setRequestId("reconfigure_" + serviceReconfigureInput.getServiceName())
- .setRpcAction(RpcActions.ServiceReconfigure)
- .build();
- MappingConstraints map = new MappingConstraints(serviceReconfigureInput.getHardConstraints(),
- serviceReconfigureInput.getSoftConstraints());
- map.serviceToServicePathConstarints();
- /**
- * mappingPCRequest(serviceReconfigureInput.getNewServiceName(),
- * serviceReconfigureInput.getHardConstraints(),
- * serviceReconfigureInput.getSoftConstraints(),head ,resvResource);
- */
- mappingPCRequest(serviceReconfigureInput.getNewServiceName(),serviceAEndSp, serviceZEndSp,
- map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(), head, resvResource);
- setSuccess(false);
- setError("");
- }
-
- /**
- * MappingAndSendingPCRequest Class constructor for RPC
- * serviceFeasibilityCheck.
- *
- * @param rpcRegistry
- * RpcProviderRegistry
- * @param serviceFeasibilityCheckInput
- * ServiceFeasibilityCheckInput
- * @param resvResource
- * Boolean to reserve resource
- */
- public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry,
- ServiceFeasibilityCheckInput serviceFeasibilityCheckInput, Boolean resvResource) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubpceService.class);
- }
- endpointToEndpointStubpce(serviceFeasibilityCheckInput.getServiceAEnd(),
- serviceFeasibilityCheckInput.getServiceZEnd());
- MappingConstraints map = new MappingConstraints(serviceFeasibilityCheckInput.getHardConstraints(),
- serviceFeasibilityCheckInput.getSoftConstraints());
- map.serviceToServicePathConstarints();
- mappingPCRequest("no name",serviceAEndSp, serviceZEndSp, map.getServicePathHardConstraints(),
- map.getServicePathSoftConstraints(), serviceFeasibilityCheckInput.getSdncRequestHeader(),
- resvResource);
- setSuccess(false);
- setError("");
- }
-
- /**
- * MappingAndSendingPCRequest Class constructor for RPC serviceCreate.
- *
- * @param rpcRegistry
- * RpcProviderRegistry
- * @param serviceCreateInput
- * ServiceCreateInput
- * @param resvResource
- * Boolean to reserve resource
- */
- public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, ServiceCreateInput serviceCreateInput,
- Boolean resvResource) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubpceService.class);
- }
- endpointToEndpointStubpce(serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd());
- MappingConstraints map = new MappingConstraints(serviceCreateInput.getHardConstraints(),
- serviceCreateInput.getSoftConstraints());
- map.serviceToServicePathConstarints();
- mappingPCRequest(serviceCreateInput.getServiceName(),serviceAEndSp, serviceZEndSp,
- map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(),
- serviceCreateInput.getSdncRequestHeader(), resvResource);
- setSuccess(false);
- setError("");
- }
-
- /**
- * MappingAndSendingPCRequest Class constructor for modify Service in ODL
- * Datastore.
- *
- * @param rpcRegistry
- * RpcProviderRegistry
- * @param input
- * Services
- * @param resvResource
- * Boolean to reserve resource
- */
- public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, Services input, Boolean resvResource) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubpceService.class);
- }
- endpointToEndpointStubpce(input.getServiceAEnd(), input.getServiceZEnd());
- MappingConstraints map = new MappingConstraints(input.getHardConstraints(), input.getSoftConstraints());
- map.serviceToServicePathConstarints();
- mappingPCRequest(input.getServiceName(),serviceAEndSp, serviceZEndSp, map.getServicePathHardConstraints(),
- map.getServicePathSoftConstraints(), input.getSdncRequestHeader(), resvResource);
- setSuccess(false);
- setError("");
- }
-
-
- public void endpointToEndpointStubpce(ServiceEndpoint serviceAEnd, ServiceEndpoint serviceZEnd) {
- LOG.info("Mapping Service Endpoint to Service Endpoint Stubpce");
- TxDirection txDirection = null;
- RxDirection rxDirection = null;
- if (serviceAEnd != null && serviceZEnd != null) {
- txDirection = new TxDirectionBuilder()
- .setPort(serviceAEnd.getTxDirection().getPort())
- .build();
- rxDirection = new RxDirectionBuilder()
- .setPort(serviceAEnd.getRxDirection().getPort())
- .build();
- serviceAEndSp = new ServiceAEndBuilder()
- .setClli(serviceAEnd.getClli())
- .setNodeId(serviceAEnd.getNodeId())
- .setServiceFormat(serviceAEnd.getServiceFormat())
- .setServiceRate(serviceAEnd.getServiceRate())
- .setTxDirection(txDirection)
- .setRxDirection(rxDirection)
- .build();
-
- txDirection = new TxDirectionBuilder()
- .setPort(serviceZEnd.getTxDirection().getPort())
- .build();
- rxDirection = new RxDirectionBuilder()
- .setPort(serviceZEnd.getRxDirection().getPort())
- .build();
- serviceZEndSp = new ServiceZEndBuilder()
- .setClli(serviceZEnd.getClli())
- .setNodeId(serviceZEnd.getNodeId())
- .setServiceFormat(serviceZEnd.getServiceFormat())
- .setServiceRate(serviceZEnd.getServiceRate())
- .setTxDirection(txDirection)
- .setRxDirection(rxDirection)
- .build();
- }
- }
-
- /**
- * Build pathComputationRequestInput or cancelResourceReserveInput with
- * input parameters (serviceReconfigureInput or serviceFeasibilityCheckInput.
- *
- * @param String
- * serviceName
- * @param zend Service ZEnd
- * @param aend Service AEnd
- * @param HardConstraints
- * hardConstraints
- * @param SoftConstraints
- * softConstraints
- * @param SdncRequestHeader
- * sdncRequestHeader
- * @param Boolean
- * resvResource
- */
- private void mappingPCRequest(String serviceName, ServiceAEnd aend, ServiceZEnd zend,
- HardConstraints hardConstraints, SoftConstraints softConstraints, org.opendaylight.yang.gen.v1.http.org
- .openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader sdncRequestHeader,
- Boolean resvResource) {
-
- LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput "
- + "to PCE requests");
-
- HardConstraints serviceCreateHard = hardConstraints;
- SoftConstraints serviceCreateSoft = softConstraints;
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing
- .constraints.sp.HardConstraints pceHardConstraints = null;
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing
- .constraints.sp.SoftConstraints pceSoftConstraints = null;
- if (serviceCreateHard != null) {
- pceHardConstraints = serviceCreateHard;
- }
- if (serviceCreateSoft != null) {
- pceSoftConstraints = serviceCreateSoft;
- }
-
- ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
- if (sdncRequestHeader != null) {
- serviceHandlerHeader.setRequestId(sdncRequestHeader.getRequestId());
- }
-
- /** PathComputationRequestInput build */
- pathComputationRequestInput = new PathComputationRequestInputBuilder()
- .setServiceName(serviceName)
- .setResourceReserve(resvResource)
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceAEnd(aend)
- .setServiceZEnd(zend)
- .setHardConstraints(pceHardConstraints)
- .setSoftConstraints(pceSoftConstraints)
- .setPceMetric(PceMetric.TEMetric).build();
-
- /** CancelResourceReserveInput build */
- cancelResourceReserveInput = new CancelResourceReserveInputBuilder().setServiceName(serviceName)
- .setServiceHandlerHeader(serviceHandlerHeader.build()).build();
- }
-
-
- /**
- * Send cancelResourceReserve request to PCE.
- *
- * @return Boolean true if success, false else
- */
- public ListenableFuture<Boolean> cancelResourceReserve() {
- setSuccess(false);
- return executor.submit(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- Boolean output = false;
- if (cancelResourceReserveInput != null) {
- RpcResult<CancelResourceReserveOutput> pceOutputResult = null;
- Future<RpcResult<CancelResourceReserveOutput>> pceOutputFuture = service
- .cancelResourceReserve(cancelResourceReserveInput);
- try {
- pceOutputResult = pceOutputFuture.get();
- } catch (InterruptedException | CancellationException | ExecutionException e) {
- setError("Did not receive the expected response from pce to cancelResourceReserve RPC "
- + e.toString());
- LOG.error(error);
- pceOutputFuture.cancel(true);
- }
-
- if (pceOutputResult != null && pceOutputResult.isSuccessful()) {
- LOG.info("PCE replied to CancelResource request !");
- output = true;
- setSuccess(true);
- }
- } else {
- LOG.info("cancelResourceReserveInput parameter not valid !");
- }
- return output;
- }
- });
-
- }
-
- /**
- * Send pathComputationRequest request to PCE.
- *
- * @return Boolean true if success, false else
- */
- public ListenableFuture<Boolean> pathComputationRequest() {
- LOG.info("In pathComputationRequest ...");
- setSuccess(false);
- return executor.submit(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- RpcResult<PathComputationRequestOutput> pceOutputResult = null;
- Boolean output = false;
- if (pathComputationRequestInput != null) {
- LOG.info("pathComputationRequestInput : {}", pathComputationRequestInput.toString());
- Future<RpcResult<PathComputationRequestOutput>> pceOutputFuture = service
- .pathComputationRequest(pathComputationRequestInput);
- try {
- pceOutputResult = pceOutputFuture.get();
- } catch (InterruptedException | CancellationException | ExecutionException e) {
- setError("Did not receive the expected response from pce to pathComputationRequest RPC "
- + e.toString());
- LOG.error(error);
- pceOutputFuture.cancel(true);
- }
- if (pceOutputResult != null && pceOutputResult.isSuccessful()) {
- setSuccess(true);
- output = true;
- LOG.info("PCE replied to pathComputation request !");
- }
- } else {
- LOG.info("pathComputationRequestInput parameter not valid !");
- }
- return output;
- }
- });
- }
-
- public Boolean getSuccess() {
- return success;
- }
-
- public void setSuccess(Boolean success) {
- this.success = success;
- }
-
- public String getError() {
- return error;
- }
-
- public void setError(String error) {
- this.error = error;
- }
-
- public RpcProviderRegistry getRpcRegistry() {
- return rpcRegistry;
- }
-
- public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
- }
-
- public ServiceAEnd getServiceAEndSp() {
- return serviceAEndSp;
- }
-
- public void setServiceAEndSp(ServiceAEnd serviceAEndSp) {
- this.serviceAEndSp = serviceAEndSp;
- }
-
- public ServiceZEnd getServiceZEndSp() {
- return serviceZEndSp;
- }
-
- public void setServiceZEndSp(ServiceZEnd serviceZEndSp) {
- this.serviceZEndSp = serviceZEndSp;
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.transportpce.servicehandler;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescriptionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-
-/**
- * Class for Mapping and Sending
- * Service Implemention requests :
- * - service implementation
- * - service delete.
- * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
- *
- */
-public class MappingAndSendingSIRequest {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingSIRequest.class);
- /** Permit to call Renderer RPCs. */
- private StubrendererService service;
- /** define procedure success (or not ). */
- private Boolean success = false;
- /** permit to call bundle service (PCE, Renderer, Servicehandler. */
- private RpcProviderRegistry rpcRegistry;
- /** store all error messages. */
- private String error;
- ServiceImplementationRequestInput serviceImplementationRequestInput = null;
- ServiceDeleteInput serviceDeleteInput = null;
-
- private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
-
-
- /**
- * MappingAndSendingSIRequest class constructor
- * for RPC serviceCreate.
- *
- * @param rpcRegistry rpcRegistry
- * @param serviceCreateInput serviceCreateInput
- * @param pathComputationOutput pathComputationOutput
- */
- public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
- ServiceCreateInput serviceCreateInput,PathComputationRequestOutput pathComputationOutput) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubrendererService.class);
- }
- setSuccess(false);
- setError("");
-
- /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput. */
- ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
- if (serviceCreateInput.getSdncRequestHeader() != null) {
- serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
- }
- mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(),
- serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName());
- /*
-
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
- .service.create.input.ServiceAEnd tempA = serviceCreateInput.getServiceAEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortRx =
- serviceCreateInput.getServiceAEnd().getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortTx =
- serviceCreateInput.getServiceAEnd().getTxDirection().getPort();
-
- RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
-
- TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
-
- ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
- .setClli(tempA.getClli())
- .setNodeId(tempA.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
- .setServiceRate(tempA.getServiceRate())
- .setRxDirection(rxDirectionAEnd)
- .setTxDirection(txDirectionAEnd)
- .build();
-
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
- .service.create.input.ServiceZEnd tempZ = serviceCreateInput.getServiceZEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortRx =
- serviceCreateInput.getServiceZEnd().getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortTx =
- serviceCreateInput.getServiceZEnd().getTxDirection().getPort();
-
- RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
-
- TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
-
- ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
- .setClli(tempZ.getClli())
- .setNodeId(tempZ.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
- .setServiceRate(tempZ.getServiceRate())
- .setRxDirection(rxDirectionZEnd)
- .setTxDirection(txDirectionZEnd)
- .build();
-
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
- .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
- try {
- tmp = pathComputationOutput.getResponseParameters().getPathDescription();
- } catch (NullPointerException e) {
- LOG.error("PathDescription is null : {}", e.toString());
- }
- PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
- if (tmp != null) {
- pathDescription = new PathDescriptionBuilder(tmp);
- }
- serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
- .setPathDescription(pathDescription.build())
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceName(serviceCreateInput.getServiceName())
- .setServiceAEnd(serviceAEnd)
- .setServiceZEnd(serviceZEnd)
- .build();*/
-
- mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(),
- serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName());
- }
-
- /**
- * MappingAndSendingSIRequest class constructor
- * for RPC serviceReconfigure.
- *
- * @param rpcRegistry rpcRegistry
- * @param serviceReconfigureInput serviceReconfigureInput
- * @param pathComputationOutput pathComputationOutput
- */
-
- public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
- ServiceReconfigureInput serviceReconfigureInput,PathComputationRequestOutput pathComputationOutput) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubrendererService.class);
- }
- setSuccess(false);
- setError("");
-
- /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/
- ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder()
- .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName());
- mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceReconfigureInput.getServiceAEnd(),
- serviceReconfigureInput.getServiceZEnd(), serviceReconfigureInput.getNewServiceName());
-
- /*
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
- .service.reconfigure.input.ServiceAEnd tempA = serviceReconfigureInput.getServiceAEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortRx =
- serviceReconfigureInput.getServiceAEnd().getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortTx =
- serviceReconfigureInput.getServiceAEnd().getTxDirection().getPort();
-
- RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
-
- TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
-
- ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
- .setClli(tempA.getClli())
- .setNodeId(tempA.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
- .setServiceRate(tempA.getServiceRate())
- .setRxDirection(rxDirectionAEnd)
- .setTxDirection(txDirectionAEnd)
- .build();
-
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
- .service.reconfigure.input.ServiceZEnd tempZ = serviceReconfigureInput.getServiceZEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortRx =
- serviceReconfigureInput.getServiceZEnd().getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortTx =
- serviceReconfigureInput.getServiceZEnd().getTxDirection().getPort();
-
-
- RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
- TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
-
- ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
- .setClli(tempZ.getClli())
- .setNodeId(tempZ.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
- .setServiceRate(tempZ.getServiceRate())
- .setRxDirection(rxDirectionZEnd)
- .setTxDirection(txDirectionZEnd)
- .build();
-
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
- .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
- try {
- tmp = pathComputationOutput.getResponseParameters().getPathDescription();
- } catch (NullPointerException e) {
- LOG.error("PathDescription is null : {}", e.toString());
- }
- PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
- if (tmp != null) {
- pathDescription = new PathDescriptionBuilder(tmp);
- }
- serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
- .setPathDescription(pathDescription.build())
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceName(serviceReconfigureInput.getNewServiceName())
- .setServiceAEnd(serviceAEnd)
- .setServiceZEnd(serviceZEnd)
- .build();
- LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/
- }
-
-
- /**
- * MappingAndSendingSIRequest class constructor
- * for RPC serviceDelete.
- *
- * @param rpcRegistry RpcProviderRegistry
- * @param requestId Request ID
- * @param serviceName Service name
- */
- public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,String requestId, String serviceName) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubrendererService.class);
- }
- setSuccess(false);
- setError("");
-
- /** ServiceDeleteInput Build .*/
- ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
- if (requestId != null) {
- serviceHandlerHeader.setRequestId(requestId);
- }
-
- serviceDeleteInput = new ServiceDeleteInputBuilder()
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceName(serviceName)
- .build();
- }
-
- /**
- * MappingAndSendingSIRequest Class constructor
- * for modify Service in ODL Datastore.
- *
- * @param rpcRegistry RpcProviderRegistry
- * @param services Services
- * @param pathComputationOutput PathComputationRequestOutput
- */
- public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,Services services,
- PathComputationRequestOutput pathComputationOutput) {
- this.setRpcRegistry(rpcRegistry);
- if (rpcRegistry != null) {
- service = rpcRegistry.getRpcService(StubrendererService.class);
- }
- setSuccess(false);
- setError("");
-
- /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/
- ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
- SdncRequestHeader sdnc = services.getSdncRequestHeader();
- if (sdnc != null) {
- String requestId = services.getSdncRequestHeader().getRequestId();
- if (requestId != null) {
- serviceHandlerHeader.setRequestId(requestId);
- }
- }
- mappingSIRequest(pathComputationOutput, serviceHandlerHeader, services.getServiceAEnd(),
- services.getServiceZEnd(), services.getServiceName());
- /*org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
- .types.rev161014.service.ServiceAEnd tempA = services.getServiceAEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortRx = tempA.getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempAPortTx = tempA.getTxDirection().getPort();
-
-
- RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
-
- TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
-
- ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
- .setClli(tempA.getClli())
- .setNodeId(tempA.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
- .setServiceRate(tempA.getServiceRate())
- .setRxDirection(rxDirectionAEnd)
- .setTxDirection(txDirectionAEnd)
- .build();
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
- .types.rev161014.service.ServiceZEnd tempZ = services.getServiceZEnd();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortRx = tempZ.getRxDirection().getPort();
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.service.port.Port tempZPortTx = tempZ.getTxDirection().getPort();
-
- RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
- TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
-
- ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
- .setClli(tempZ.getClli())
- .setNodeId(tempZ.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
- .setServiceRate(tempZ.getServiceRate())
- .setRxDirection(rxDirectionZEnd)
- .setTxDirection(txDirectionZEnd)
- .build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
- .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
- try {
- tmp = pathComputationOutput.getResponseParameters().getPathDescription();
- } catch (NullPointerException e) {
- LOG.error("PathDescription is null : {}", e);
- }
- PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
- if (tmp != null) {
- pathDescription = new PathDescriptionBuilder(tmp);
- }
-
- serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
- .setPathDescription(pathDescription.build())
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceName(services.getServiceName())
- .setServiceAEnd(serviceAEnd)
- .setServiceZEnd(serviceZEnd)
- .build();
- LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/
- }
-
- /**
- *Build serviceImplementationRequestInput with
- *input parameters from ServiceCreateInput or
- *Services or serviceReconfigureInput.
- *
- * @param pathComputationOutput PathComputationRequestOutput
- * @param serviceHandlerHeader ServiceHandlerHeaderBuilder
- * @param aend Beginning ServiceEndpoint
- * @param zend Ending ServiceEndpoint
- * @param serviceName Service Name
- */
- private void mappingSIRequest(PathComputationRequestOutput pathComputationOutput,
- ServiceHandlerHeaderBuilder serviceHandlerHeader, org.opendaylight.yang.gen .v1.http.org.openroadm.common
- .service.types.rev161014.ServiceEndpoint aend , org.opendaylight.yang.gen.v1.http.org.openroadm.common
- .service.types.rev161014.ServiceEndpoint zend, String serviceName) {
- LOG.info("Mapping ServiceCreateInput or Services or serviceReconfigureInput to SIR requests");
- /** ServiceAEnd Build. */
- RxDirection rxDirectionAEnd = new RxDirectionBuilder()
- .setPort(aend.getRxDirection().getPort())
- .build();
- TxDirection txDirectionAEnd = new TxDirectionBuilder()
- .setPort(aend.getTxDirection().getPort())
- .build();
-
- ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
- .setClli(aend.getClli())
- .setNodeId(aend.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(aend.getServiceFormat().getName()))
- .setServiceRate(aend.getServiceRate())
- .setRxDirection(rxDirectionAEnd)
- .setTxDirection(txDirectionAEnd)
- .build();
-
- /** ServiceZEnd Build. */
- RxDirection rxDirectionZEnd = new RxDirectionBuilder()
- .setPort(zend.getRxDirection().getPort())
- .build();
-
- TxDirection txDirectionZEnd = new TxDirectionBuilder()
- .setPort(zend.getTxDirection().getPort())
- .build();
-
- ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
- .setClli(zend.getClli())
- .setNodeId(zend.getNodeId())
- .setServiceFormat(ServiceFormat.valueOf(zend.getServiceFormat().getName()))
- .setServiceRate(zend.getServiceRate())
- .setRxDirection(rxDirectionZEnd)
- .setTxDirection(txDirectionZEnd)
- .build();
-
-
- /** ServiceImplementationRequestInput Build. */
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
- .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
- try {
- tmp = pathComputationOutput.getResponseParameters().getPathDescription();
- } catch (NullPointerException e) {
- LOG.error("PathDescription is null : {}", e.toString());
- }
- PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
- if (tmp != null) {
- pathDescription = new PathDescriptionBuilder(tmp);
- }
- serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
- .setPathDescription(pathDescription.build())
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setServiceName(serviceName)
- .setServiceAEnd(serviceAEnd)
- .setServiceZEnd(serviceZEnd)
- .build();
-
- }
-
- /**
- * Send serviceImplementation request to Render.
- *
- * @return ServiceImplementationRequestOutput data response from Renderer
- */
- public ListenableFuture<Boolean> serviceImplementation() {
- setSuccess(false);
- return executor.submit(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- Boolean output = null;
- if (serviceImplementationRequestInput != null) {
- RpcResult<ServiceImplementationRequestOutput> rendererOutputResult = null;
- Future<RpcResult<ServiceImplementationRequestOutput>> rendererOutputFuture =
- service.serviceImplementationRequest(serviceImplementationRequestInput);
- try {
- rendererOutputResult = rendererOutputFuture.get();//wait to get the result
- } catch (InterruptedException | CancellationException | ExecutionException e) {
- setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
- + e.toString());
- LOG.error(error);
- rendererOutputFuture.cancel(true);
- }
-
- if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
- LOG.info("Renderer replied to serviceImplementation Request !");
- setSuccess(true);
- output = true;
- setSuccess(true);
- }
- } else {
- LOG.info("serviceImplementationRequestInput is not valid");
- }
-
- return output;
- }
- });
-
- }
-
- /**
- * Send serviceDelete request to Render.
- *
- * @return ServiceDeleteOutput data response from Renderer
- */
- public ListenableFuture<Boolean> serviceDelete() {
- setSuccess(false);
- return executor.submit(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- Boolean output = null;
- if (serviceDeleteInput != null) {
- RpcResult<ServiceDeleteOutput> rendererOutputResult = null;
- Future<RpcResult<ServiceDeleteOutput>> rendererOutputFuture =
- service.serviceDelete(serviceDeleteInput);
- try {
- rendererOutputResult = rendererOutputFuture.get();//wait to get the result
- } catch (InterruptedException | CancellationException | ExecutionException e) {
- setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
- + e.toString());
- LOG.error(error);
- rendererOutputFuture.cancel(true);
- }
-
- if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
- LOG.info("Renderer replied to serviceDelete Request!");
- setSuccess(true);
- output = true;
- }
- }
- return output;
- }
- });
-
- }
-
-
- public Boolean getSuccess() {
- return success;
- }
-
- public void setSuccess(Boolean success) {
- this.success = success;
- }
-
- public String getError() {
- return error;
- }
-
- public void setError(String error) {
- this.error = error;
- }
-
- public RpcProviderRegistry getRpcRegistry() {
- return rpcRegistry;
- }
-
- public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
- }
-
-}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
+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.openroadm.common.service.types.rev161014.response.parameters.ResponseParametersBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.LifecycleState;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToABuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToAKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.path.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+public final class ModelMappingUtils {
+
+ private ModelMappingUtils() {
+ }
+
+ public static ServiceImplementationRequestInput createServiceImplementationRequest(ServiceCreateInput input,
+ PathComputationRequestOutput pceResponse) {
+
+ ServiceImplementationRequestInputBuilder serviceImplementationRequestInputBuilder =
+ new ServiceImplementationRequestInputBuilder();
+ serviceImplementationRequestInputBuilder.setServiceName(input.getServiceName());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input.ServiceAEndBuilder serviceAEnd =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input.ServiceAEndBuilder();
+ serviceAEnd.setServiceFormat(input.getServiceAEnd().getServiceFormat())
+ .setServiceRate(input.getServiceAEnd().getServiceRate()).setClli(input.getServiceAEnd().getClli())
+ .setNodeId(input.getServiceAEnd().getNodeId())
+ .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.TxDirectionBuilder()
+ .setPort(input.getServiceAEnd().getTxDirection().getPort()).build())
+ .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.RxDirectionBuilder()
+ .setPort(input.getServiceAEnd().getRxDirection().getPort()).build());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input.ServiceZEndBuilder serviceZEnd =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input.ServiceZEndBuilder();
+ serviceZEnd.setServiceFormat(input.getServiceZEnd().getServiceFormat())
+ .setServiceRate(input.getServiceZEnd().getServiceRate()).setClli(input.getServiceZEnd().getClli())
+ .setNodeId(input.getServiceZEnd().getNodeId())
+ .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.TxDirectionBuilder()
+ .setPort(input.getServiceZEnd().getTxDirection().getPort()).build())
+ .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.RxDirectionBuilder()
+ .setPort(input.getServiceZEnd().getRxDirection().getPort()).build());
+ serviceImplementationRequestInputBuilder.setServiceAEnd(serviceAEnd.build());
+ serviceImplementationRequestInputBuilder.setServiceZEnd(serviceZEnd.build());
+ serviceImplementationRequestInputBuilder.setServiceHandlerHeader(
+ new ServiceHandlerHeaderBuilder().setRequestId(input.getSdncRequestHeader().getRequestId()).build());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input.PathDescriptionBuilder pathDescBuilder =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
+ .rev170426.service.implementation.request.input
+ .PathDescriptionBuilder();
+ pathDescBuilder.setAToZDirection(pceResponse.getResponseParameters()
+ .getPathDescription().getAToZDirection());
+ pathDescBuilder.setZToADirection(pceResponse.getResponseParameters()
+ .getPathDescription().getZToADirection());
+ serviceImplementationRequestInputBuilder.setPathDescription(pathDescBuilder.build());
+ return serviceImplementationRequestInputBuilder.build();
+ }
+
+ public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
+ .ServiceDeleteInput createServiceDeleteInput(ServiceDeleteInput serviceDeleteInput) {
+ ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder();
+ builder.setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
+ builder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId(
+ serviceDeleteInput.getSdncRequestHeader().getRequestId()).build());
+ return builder.build();
+ }
+
+ public static ServiceAEnd createServiceAEnd(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
+ .ServiceAEnd serviceAEnd) {
+ ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder();
+ serviceAEndBuilder.setClli(serviceAEnd.getClli());
+ serviceAEndBuilder.setNodeId(serviceAEnd.getNodeId());
+ serviceAEndBuilder.setRxDirection(createRxDirection(serviceAEnd.getRxDirection()));
+ serviceAEndBuilder.setServiceFormat(serviceAEnd.getServiceFormat());
+ serviceAEndBuilder.setServiceRate(serviceAEnd.getServiceRate());
+ serviceAEndBuilder.setTxDirection(createTxDirection(serviceAEnd.getTxDirection()));
+ return serviceAEndBuilder.build();
+ }
+
+ public static ServiceZEnd createServiceZEnd(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceZEnd
+ serviceZEnd) {
+ ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder();
+ serviceZEndBuilder.setClli(serviceZEnd.getClli());
+ serviceZEndBuilder.setNodeId(serviceZEnd.getNodeId());
+ serviceZEndBuilder.setRxDirection(createRxDirection(serviceZEnd.getRxDirection()));
+ serviceZEndBuilder.setServiceFormat(serviceZEnd.getServiceFormat());
+ serviceZEndBuilder.setServiceRate(serviceZEnd.getServiceRate());
+ serviceZEndBuilder.setTxDirection(createTxDirection(serviceZEnd.getTxDirection()));
+ return serviceZEndBuilder.build();
+ }
+
+ public static RxDirection createRxDirection(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection
+ rxDirection) {
+ RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder();
+ rxDirectionBuilder.setPort(rxDirection.getPort());
+ return rxDirectionBuilder.build();
+ }
+
+ public static TxDirection createTxDirection(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection
+ txDirection) {
+ TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder();
+ txDirectionBuilder.setPort(txDirection.getPort());
+ return txDirectionBuilder.build();
+ }
+
+ public static Future<RpcResult<ServiceDeleteOutput>> createDeleteServiceReply(ServiceDeleteInput input,
+ String finalAck, String message, String responseCode) {
+ ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(finalAck).setResponseMessage(message).setResponseCode(responseCode);
+ if (input.getSdncRequestHeader() != null) {
+ builder.setRequestId(input.getSdncRequestHeader().getRequestId());
+ } else {
+ builder.setRequestId(null);
+ }
+ ConfigurationResponseCommon configurationResponseCommon = builder.build();
+ ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+
+ public static Future<RpcResult<ServiceCreateOutput>> createCreateServiceReply(ServiceCreateInput input,
+ String finalAck,
+ String message, String responseCode) {
+ ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
+ ConfigurationResponseCommonBuilder configurationResponseCommon
+ = new ConfigurationResponseCommonBuilder().setAckFinalIndicator(finalAck)
+ .setResponseMessage(message)
+ .setResponseCode(responseCode);
+ if (input.getSdncRequestHeader() != null) {
+ configurationResponseCommon.setRequestId(input.getSdncRequestHeader().getRequestId());
+ } else {
+ configurationResponseCommon.setRequestId(null);
+ }
+ ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build())
+ .setResponseParameters(responseParameters.build());
+ return RpcResultBuilder.success(output.build()).buildFuture();
+ }
+
+ /*
+ * Map Input (ServiceCreateInmput, ServiceReconfigureInput) & output
+ * (PathComputationRequestOutput) to Service.
+ * @param serviceCreateInput
+ * ServiceCreateInput parameter
+ * @param serviceReconfigureInput
+ * serviceReconfigureInput parameter
+ * @param output
+ * PathComputationRequestOutput parameter
+ * @return Services Service data
+ */
+ public static Services mappingServices(ServiceCreateInput serviceCreateInput,
+ ServiceReconfigureInput serviceReconfigureInput, PathComputationRequestOutput output) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd aend = null;
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd zend = null;
+ ServicesBuilder service = new ServicesBuilder();
+ if (serviceCreateInput != null) {
+ aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceAEndBuilder(serviceCreateInput.getServiceAEnd()).build();
+ zend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceZEndBuilder(serviceCreateInput.getServiceZEnd()).build();
+ service.setServiceName(serviceCreateInput.getServiceName()).setAdministrativeState(State.OutOfService)
+ .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId())
+ .setConnectionType(serviceCreateInput.getConnectionType())
+ .setCustomer(serviceCreateInput.getCustomer())
+ .setCustomerContact(serviceCreateInput.getCustomerContact())
+ .setHardConstraints(serviceCreateInput.getHardConstraints())
+ .setSoftConstraints(serviceCreateInput.getSoftConstraints())
+ .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
+
+ } else if (serviceReconfigureInput != null) {
+ aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build();
+ zend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceZEndBuilder(serviceReconfigureInput.getServiceZEnd()).build();
+ service.setServiceName(serviceReconfigureInput.getNewServiceName())
+ .setAdministrativeState(State.OutOfService).setOperationalState(State.OutOfService)
+ .setCommonId(serviceReconfigureInput.getCommonId())
+ .setConnectionType(serviceReconfigureInput.getConnectionType())
+ .setCustomer(serviceReconfigureInput.getCustomer())
+ .setCustomerContact(serviceReconfigureInput.getCustomerContact())
+ .setHardConstraints(serviceReconfigureInput.getHardConstraints())
+ .setSoftConstraints(serviceReconfigureInput.getSoftConstraints())
+ .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
+ }
+
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
+ .parameters.sp.ResponseParameters responseParameters = output.getResponseParameters();
+ if (responseParameters != null) {
+ // service.setPceMetric(responseParameters.getPceMetric());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426
+ .response.parameters.sp.response.parameters.PathDescription pathDescription =
+ responseParameters.getPathDescription();
+ if (pathDescription != null) {
+ List<AToZ> atozList = new ArrayList<>();
+ List<ZToA> ztoaList = new ArrayList<>();
+
+ for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
+ .path.description.atoz.direction.AToZ tmp : pathDescription.getAToZDirection().getAToZ()) {
+
+ AToZKey key = new AToZKey(tmp.getKey().getId());
+ AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key)
+ // .setResource(tmp.getResource())
+ .build();
+ atozList.add(atoz);
+ }
+
+ for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
+ .path.description.ztoa.direction.ZToA
+ tmp : pathDescription.getZToADirection().getZToA()) {
+ ZToAKey key = new ZToAKey(tmp.getKey().getId());
+ ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key)
+ // .setResource(tmp.getResource())
+ .build();
+ ztoaList.add(ztoa);
+ }
+
+ Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList).build();
+ service.setTopology(topology);
+ }
+ }
+ return service.build();
+ }
+
+ /*
+ * Map Input (ServiceCreateInmput, ServiceReconfigureInput) & output
+ * (PathComputationRequestOutput) to ServicePath.
+ * @param serviceCreateInput
+ * ServiceCreateInput parameter
+ * @param serviceReconfigureInput
+ * serviceReconfigureInput parameter
+ * @param output
+ * PathComputationRequestOutput parameter
+ * @return ServicesPaths Service Path data
+ */
+ public static ServicePaths mappingServicePaths(ServiceCreateInput serviceCreateInput,
+ ServiceReconfigureInput serviceReconfigureInput, PathComputationRequestOutput output) {
+ ServicePathsBuilder servicePathBuilder = new ServicePathsBuilder();
+ if (serviceCreateInput != null) {
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+ .service.types.rev170426.service.path.ServiceAEndBuilder serviceAEnd =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+ .service.types.rev170426.service.path.ServiceAEndBuilder();
+ serviceAEnd.setServiceFormat(serviceCreateInput.getServiceAEnd().getServiceFormat())
+ .setServiceRate(serviceCreateInput.getServiceAEnd().getServiceRate())
+ .setClli(serviceCreateInput.getServiceAEnd().getClli())
+ .setNodeId(serviceCreateInput.getServiceAEnd().getNodeId())
+ .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.TxDirectionBuilder()
+ .setPort(serviceCreateInput.getServiceAEnd().getTxDirection().getPort()).build())
+ .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.RxDirectionBuilder()
+ .setPort(serviceCreateInput.getServiceAEnd().getRxDirection().getPort()).build());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+ .service.types.rev170426.service.path.ServiceZEndBuilder serviceZEnd =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+ .service.types.rev170426.service.path.ServiceZEndBuilder();
+ serviceZEnd.setServiceFormat(serviceCreateInput.getServiceZEnd().getServiceFormat())
+ .setServiceRate(serviceCreateInput.getServiceZEnd().getServiceRate())
+ .setClli(serviceCreateInput.getServiceZEnd().getClli())
+ .setNodeId(serviceCreateInput.getServiceZEnd().getNodeId())
+ .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.TxDirectionBuilder()
+ .setPort(serviceCreateInput.getServiceZEnd().getTxDirection().getPort()).build())
+ .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
+ .rev170426.service.endpoint.sp.RxDirectionBuilder()
+ .setPort(serviceCreateInput.getServiceZEnd().getRxDirection().getPort()).build());
+
+ servicePathBuilder.setServiceAEnd(serviceAEnd.build());
+ servicePathBuilder.setServiceZEnd(serviceZEnd.build());
+ MappingConstraints mapConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
+ serviceCreateInput.getSoftConstraints());
+ mapConstraints.serviceToServicePathConstarints();
+ if (mapConstraints.getServicePathHardConstraints() != null) {
+ HardConstraintsBuilder hardConstraintBuilder = new HardConstraintsBuilder();
+ hardConstraintBuilder.setCustomerCode(serviceCreateInput.getHardConstraints().getCustomerCode());
+ hardConstraintBuilder.setCoRoutingOrGeneral(mapConstraints.getServicePathHardConstraints()
+ .getCoRoutingOrGeneral());
+ servicePathBuilder.setHardConstraints(hardConstraintBuilder.build());
+ }
+ if (mapConstraints.getServicePathSoftConstraints() != null) {
+ SoftConstraintsBuilder softConstraintBuilder = new SoftConstraintsBuilder();
+ softConstraintBuilder.setCustomerCode(mapConstraints.getServicePathSoftConstraints().getCustomerCode());
+ softConstraintBuilder.setCoRoutingOrGeneral(mapConstraints.getServicePathSoftConstraints()
+ .getCoRoutingOrGeneral());
+ servicePathBuilder.setSoftConstraints(softConstraintBuilder.build());
+ }
+ servicePathBuilder.setServicePathName(serviceCreateInput.getServiceName());
+ servicePathBuilder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
+ .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId()).build());
+ PathDescriptionBuilder pathDescBuilder = new PathDescriptionBuilder(output.getResponseParameters()
+ .getPathDescription());
+ servicePathBuilder.setPathDescription(pathDescBuilder.build());
+ }
+ return servicePathBuilder.build();
+ }
+}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.transportpce.servicehandler;
+import com.google.common.collect.ImmutableMap;
+
import java.util.Map;
/**
* Enum class to identify ServiceAEnd / serviceZEnd.
*
- * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
- *
*/
-enum MyEndpoint {
+public enum ServiceEndpointType {
SERVICEAEND(1),
SERVICEZEND(2);
int value;
- private static final Map<Integer, MyEndpoint> VALUE_MAP;
+ private static final Map<Integer, ServiceEndpointType> VALUE_MAP;
- MyEndpoint(int value) {
+ ServiceEndpointType(int value) {
this.value = value;
}
static {
- final com.google.common.collect.ImmutableMap.Builder<java.lang.Integer, MyEndpoint> b =
- com.google.common.collect.ImmutableMap.builder();
- for (MyEndpoint enumItem : MyEndpoint.values()) {
- b.put(enumItem.value, enumItem);
+ final ImmutableMap.Builder<java.lang.Integer, ServiceEndpointType> builder =
+ ImmutableMap.builder();
+ for (ServiceEndpointType enumItem : ServiceEndpointType.values()) {
+ builder.put(enumItem.value, enumItem);
}
-
- VALUE_MAP = b.build();
+ VALUE_MAP = builder.build();
}
/**
* Integer to identify Enum
* @return corresponding ServiceFormat item
*/
- public static MyEndpoint forValue(int valueArg) {
+ public static ServiceEndpointType forValue(int valueArg) {
return VALUE_MAP.get(valueArg);
}
+
}
+++ /dev/null
-/*
- * Copyright © 2017 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.transportpce.servicehandler;
-
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class for checking service sdnc-request-header compliancy.
- *
- * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
- *
- */
-public class ServicehandlerCompliancyCheck {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerCompliancyCheck.class);
- /** SdncRequestHeader. */
- private SdncRequestHeader sndcRequestHeader;
- /** Service Name. */
- private String serviceName;
- /** Type of connection : service / infrastructure / roadm-line. */
- private ConnectionType conType;
- /** type of service : service-create / service-delete ... */
- private RpcActions action;
- /** Response message from procedure. */
- private String message;
-
- /**
- * ServicehandlerCompliancyCheck class constructor.
- *
- * @param sdncRequestHeader
- * SdncRequestHeader
- * @param serviceName
- * String Service Name
- * @param conType
- * Connection Type
- * @param action
- * RPC type
- */
- public ServicehandlerCompliancyCheck(SdncRequestHeader sdncRequestHeader, String serviceName,
- ConnectionType conType, RpcActions action) {
- this.sndcRequestHeader = sdncRequestHeader;
- this.serviceName = serviceName;
- this.conType = conType;
- this.action = action;
- this.setMessage("");
- }
-
- /**
- * ServicehandlerCompliancyCheck class constructor.
- *
- * @param sdncRequestHeader
- * SdncRequestHeader
- * @param serviceName
- * String Service Name
- * @param action
- * RPC type
- */
- public ServicehandlerCompliancyCheck(SdncRequestHeader sdncRequestHeader, String serviceName, RpcActions action) {
- this.sndcRequestHeader = sdncRequestHeader;
- this.serviceName = serviceName;
- this.action = action;
- this.setMessage("");
- }
-
- /**
- * ServicehandlerCompliancyCheck class constructor.
- *
- * @param serviceName
- * String Service Name
- * @param conType
- * Connection Type
- * @param action
- * RPC type
- */
- public ServicehandlerCompliancyCheck(String serviceName, ConnectionType conType, RpcActions action) {
- this.serviceName = serviceName;
- this.conType = conType;
- this.action = action;
- this.setMessage("");
- }
-
- /**
- * ServicehandlerCompliancyCheck class constructor.
- *
- * @param serviceName
- * String Service Name
- * @param action
- * RPC type
- */
- public ServicehandlerCompliancyCheck(String serviceName, RpcActions action) {
- this.serviceName = serviceName;
- this.action = action;
- this.setMessage("");
- }
-
- /**
- * Check if a String is not null and not equal to void.
- *
- * @param value
- * String value
- * @return true if String ok false if not
- */
- public Boolean checkString(String value) {
- Boolean result = false;
- if (value != null && value.compareTo("") != 0) {
- result = true;
- }
- return result;
-
- }
-
- /**
- * Check Compliancy of Service request.
- *
- * @param contype
- * Boolean to check connection Type
- * @param sndcRequest
- * Boolean to check sndcRequestHeader
- *
- * @return true if String ok false if not
- */
- public Boolean check(Boolean contype, Boolean sndcRequest) {
- Boolean result = true;
- if (!checkString(serviceName)) {
- result = false;
- message = "Service Name is not set";
- LOG.debug(message);
- } else if (contype && conType == null) {
- result = false;
- message = "Service ConnectionType is not set";
- LOG.debug(message);
- }
- if (sndcRequest) {
- if (sndcRequestHeader != null) {
- RpcActions serviceAction = sndcRequestHeader.getRpcAction();
- String requestId = sndcRequestHeader.getRequestId();
- if (!checkString(requestId)) {
- result = false;
- message = "Service sndcRequestHeader 'request-id' is not set";
- LOG.debug(message);
- } else if (serviceAction != null) {
- if (serviceAction.compareTo(action) != 0) {
- result = false;
- message = "Service sndcRequestHeader rpc-action '" + serviceAction + "' not equal to '"
- + action.name() + "'";
- LOG.debug(message);
- }
- } else {
- result = false;
- message = "Service sndc-request-header 'rpc-action' is not set ";
- LOG.debug(message);
- }
-
- } else {
- result = false;
- message = "Service sndc-request-header is not set ";
- LOG.debug(message);
- }
- }
- return result;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.transportpce.servicehandler.impl;
-import com.google.common.base.Optional;
-
-import com.google.common.util.concurrent.FutureCallback;
-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.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
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.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.transportpce.servicehandler.CheckCoherencyHardSoft;
-import org.opendaylight.transportpce.servicehandler.MappingAndSendingPCRequest;
-import org.opendaylight.transportpce.servicehandler.MappingAndSendingSIRequest;
-import org.opendaylight.transportpce.servicehandler.ServicehandlerCompliancyCheck;
-import org.opendaylight.transportpce.servicehandler.ServicehandlerTxRxCheck;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultSh;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultShBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServicehandlerService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
+import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+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;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
-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.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.LifecycleState;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceListBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo.TailRetention;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToABuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToAKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescriptionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopology;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopologyBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
- * Class to implement ServicehandlerService and ServicehandlerListener.
- *
- * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
+ * Top level service interface providing main OpenROADM controller services.
*/
-public class ServicehandlerImpl implements OrgOpenroadmServiceService, ServicehandlerService, StubpceListener,
- StubrendererListener,AutoCloseable {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
- /** Permit to access database. */
- private DataBroker db;
- /** check service sdnc-request-header compliancy. */
- private ServicehandlerCompliancyCheck compliancyCheck;
- /** check missing info on Tx/Rx for A/Z end. */
- private ServicehandlerTxRxCheck txrxCheck;
- /** check coherency between hard and soft constraints. */
- private CheckCoherencyHardSoft checkCoherencyHardSoft;
- /**
- * Map and Send PCE requests : -
- * path-computation-request/cancel-resource-reserve.
- */
- private MappingAndSendingPCRequest mappingAndSendingPCRequest;
- /**
- * Map and Send Service Implemention requests : - service
- * implementation/service delete.
- */
- private MappingAndSendingSIRequest mappingAndSendingSIRequest;
-
- private RpcProviderRegistry rpcRegistry;
- private NotificationPublishService notificationPublishService;
- private final ListeningExecutorService executor;
+public class ServicehandlerImpl implements OrgOpenroadmServiceService {
- private ServicePathRpcResult servicePathRpcResult = null;
- private ServiceRpcResultSp serviceRpcResultSp = null;
+ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
- private RpcActions action;
+ private DataBroker db;
+ private ServiceDataStoreOperations serviceDataStoreOperations;
+ private RendererServiceOperations rendererServiceOperations;
+ private PCEServiceWrapper pceServiceWrapper;
- private PathDescription pathDescription;
- private PathTopology pathTopology;
- private ServiceCreateInput serviceCreateInput;
- private ServiceDeleteInput serviceDeleteInput;
- private ServiceReconfigureInput serviceReconfigureInput;
- private Services service;
- private ServiceFeasibilityCheckInput serviceFeasibilityCheckInput;
+ //TODO: remove private request fields as they are in global scope
- public ServicehandlerImpl(DataBroker databroker, RpcProviderRegistry rpcRegistry,
- NotificationPublishService notificationPublishService) {
+ public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
+ RendererServiceOperations rendererServiceOperations) {
this.db = databroker;
- this.rpcRegistry = rpcRegistry;
- this.notificationPublishService = notificationPublishService;
- executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
- serviceCreateInput = null;
- setServiceDeleteInput(null);
- setServiceReconfigureInput(null);
- initializeDataTree(db);
- }
-
- /**
- * delete service from
- * datastore after receiving
- * Stubrenderer notification.
- *
- */
- private void deleteServiceFromDatastore() {
- String serviceName = null;
- if (serviceDeleteInput != null) {
- LOG.info("deleteServiceFromDatastore came from RPC serviceDelete");
- serviceName = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName();
- } else if (service != null) {
- LOG.info("deleteServiceFromDatastore came from RPC serviceRestoration");
- serviceName = service.getServiceName();
- }
- if (serviceName != null) {
- LOG.info("deleting service '{}' from datastore ...", serviceName);
- ServiceRpcResultSh notification = null;
- String message = "";
- /**
- * Service delete confirmed deleting service from
- * database
- */
- if (writeOrModifyOrDeleteServiceList(serviceName, null,
- null,1) == null) {
- /** Service delete. */
- message = "Service deleted from database";
- } else {
- message = "deleting service from database failed !";
- }
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult)
- .setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName())
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- LOG.error("Parameter 'ServiceName' fro deleteServiceFromDatastore is null !");
- }
+ this.rendererServiceOperations = rendererServiceOperations;
+ this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
+ this.serviceDataStoreOperations.initialize();
+ this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
}
-
- /**
- *Put Service status to up
- *and add topology information
- *after receiving Stubrenderer
- *service implementation
- *notification.
- *
- * @param input ServiceCreateInput or
- */
- private <T> void updateServiceStatus(T input) {
- LOG.info("Updating Service Status ...");
- ServiceRpcResultSh notification = null;
- String message = "";
- String serviceName = null;
- ServiceNotificationTypes notif = null;
- if (input instanceof ServiceCreateInput) {
- LOG.info("Updating Service Status came from RPC serviceCreateInput ...");
- serviceName = serviceCreateInput.getServiceName();
- notif = ServiceNotificationTypes.ServiceCreateResult;
- } else if (input instanceof ServiceReconfigureInput) {
- LOG.info("Updating Service Status came from RPC serviceReconfigure ...");
- serviceName = serviceReconfigureInput.getNewServiceName();
- notif = ServiceNotificationTypes.ServiceReconfigureResult;
- } else if (input instanceof Services) {
- LOG.info("Updating Service Status came from RPC serviceRestoration ...");
- serviceName = service.getServiceName();
- notif = ServiceNotificationTypes.ServiceRestorationResult;
- }
- if (serviceName != null && notif != null) {
- if (pathTopology != null) {
- LOG.info("PathTopology contains in Stubrenderer notification received !");
- Topology topo = new TopologyBuilder()
- .setAToZ(pathTopology.getAToZ())
- .setZToA(pathTopology.getZToA())
- .build();
-
- /**
- * Service implemented setting
- * Service op status to up.
- */
- if (writeOrModifyOrDeleteServiceList(serviceName, null,topo,0) == null) {
- /**
- * Service modified.
- */
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" : Service Op Status changed to Up !");
- message = build.toString();
- } else {
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" but Failed to modify service from Service List !");
- message = build.toString();
- }
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notif)
- .setServiceName(serviceName)
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = "pathTopology not in stubrenderer notification, cancelling pce resource reserve ...";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(serviceCreateInput.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("message")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- pceCancelResResource();
- }
- } else {
- LOG.info("Parameters 'serviceName' or/ and 'notiftype' is null");
- }
- }
-
- /**
- * Send pathComputation
- * request to PCE.
- *
- * @param input ServiceCreate or ServiceReconfigure or Services
- */
- private <T> void pcePathComputation(T input) {
- LOG.info("sending pathcomputation request to pce ...");
- ServiceRpcResultSh notification = null;
- String serviceName = null;
- ServiceNotificationTypes type = null;
- /**
- * Before sending the PCE request, input data need to be
- * formatted according to the Service Handler PCE
- * interface data model.
- */
- if (input instanceof ServiceReconfigureInput) {
- LOG.info("PCR came from RPC serviceReconfigure ...");
- ServiceReconfigureInput tmp = (ServiceReconfigureInput)input;
- serviceName = tmp.getNewServiceName();
- type = ServiceNotificationTypes.ServiceReconfigureResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof ServiceCreateInput) {
- LOG.info("PCR came from RPC serviceCreate ...");
- ServiceCreateInput tmp = (ServiceCreateInput)input;
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceCreateResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof Services) {
- LOG.info("PCR came from RPC serviceRestoration ...");
- Services tmp = (Services)input;
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceRestorationResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof ServiceFeasibilityCheckInput) {
- LOG.info("PCR came from RPC ServiceFeasibilityCheck ...");
- ServiceFeasibilityCheckInput tmp = (ServiceFeasibilityCheckInput)input;
- serviceName = "no name";
- type = ServiceNotificationTypes.ServiceCreateResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, false);
- }
- final String name = serviceName;
- final ServiceNotificationTypes notifType = type;
-
- /**
- * Once PCE request is being sent to the PCE on
- * interface B, PCE reply is expected until a timer
- * expires.
- */
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service compliant, submitting PathComputation Request ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- /**
- * If PCE reply is received before timer
- * expiration with a positive result, a
- * service is created with admin and
- * operational status 'down'.
- */
- message = "PCE replied to PCR Request !";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = mappingAndSendingPCRequest.getError();
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Path not calculated..");
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- }
- };
- ListenableFuture<Boolean> pce = mappingAndSendingPCRequest.pathComputationRequest();
- Futures.addCallback(pce, pceCallback, executor);
- }
-
- /**
- * Send RPC cancel reserve
- * resource to PCE.
- */
- private void pceCancelResResource() {
- LOG.info("sending RPC cancel reserve resource to PCE ...");
- Services pceService = null;
- ServiceNotificationTypes notif = null;
- if (serviceDeleteInput != null) {
- LOG.info("pceCancelResResource came from RPC serviceDelete");
- notif = ServiceNotificationTypes.ServiceDeleteResult;
- String serviceName = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- } else if (service != null) {
- notif = ServiceNotificationTypes.ServiceRestorationResult;
- LOG.info("pceCancelResResource came from RPC serviceRestoration");
- pceService = service;
- } else if (serviceReconfigureInput != null) {
- notif = ServiceNotificationTypes.ServiceReconfigureResult;
- LOG.info("pceCancelResResource came from RPC serviceReconfigure");
- String serviceName = serviceReconfigureInput.getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- } else if (serviceCreateInput != null) {
- notif = ServiceNotificationTypes.ServiceCreateResult;
- LOG.info("pceCancelResResource came from RPC serviceCreate");
- String serviceName = serviceCreateInput.getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- }
- if (pceService != null && notif != null) {
- final Services cancelService = pceService;
- final ServiceNotificationTypes type = notif;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, pceService, false);
- FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- /**
- * If PCE reply is received before timer
- * expiration with a positive result, a
- * service is created with admin and
- * operational status 'down'.
- */
- message = "PCE replied to cancel resource Request !";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = mappingAndSendingPCRequest.getError();
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- message = "Cancel resource request failed !";
- LOG.error(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Failed)
- .setStatusMessage(message + " : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- }
- };
- ListenableFuture<Boolean> pce = mappingAndSendingPCRequest.cancelResourceReserve();
- Futures.addCallback(pce, pceCallback, executor);
- }
- }
-
- private void stubrendererDelete() {
- LOG.info("sending RPC service delete to stubrenderer ...");
- String tmp = null;
- String id = null;
- if (service != null) {
- LOG.info("RPC service delete came from RPC serviceRestoration !");
- tmp = service.getServiceName();
- id = service.getCommonId();
- } else if (serviceDeleteInput != null) {
- LOG.info("RPC service delete came from ServiceDelete !");
- tmp = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName();
- id = serviceDeleteInput.getSdncRequestHeader().getRequestId();
+ @Override
+ public Future<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
+ LOG.info("RPC service creation received");
+ // Validation
+ OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(input);
+ if (! validationResult.isSuccess()) {
+ LOG.warn("Aborting service create because validation of service create request failed: {}",
+ validationResult.getResultMessage());
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
}
- if (tmp != null && id != null) {
- final String serviceName = tmp;
- LOG.info("stubrendererDelete service '{}'", serviceName);
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, id, serviceName);
- ListenableFuture<Boolean> renderer = mappingAndSendingSIRequest.serviceDelete();
- FutureCallback<Boolean> rendererCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onFailure(Throwable arg0) {
- message = "ServiceDelete Request failed : " + arg0;
- LOG.error("ServiceDelete Request failed !");
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- }
-
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- message = "Service deleted !";
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = "deleting service failed !";
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
- .setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- }
- }
- };
- Futures.addCallback(renderer, rendererCallback, executor);
- } else {
- LOG.info("Parameter 'serviceName' and / or 'id' is null");
+ // Starting service create operation
+ LOG.info("Commencing PCE");
+ //TODO: createService service status into datastore
+ PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
+ String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
+ if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
+ LOG.info("PCE calculation failed {}", pceResponseCode);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
}
- }
-
- /**
- * send a RPC serviceImplementation
- * to stubrenderer after
- * receiving a stubpce notification.
- *
- * @param input ServiceCreate or ServiceReconfigure
- */
- private <T> void stubrendererImplementation(T input) {
- ServiceRpcResultSh notification = null;
- String serviceName = null;
- String message = "";
- String newServiceName = null;
- ServiceNotificationTypes type = null;
- Boolean create = false;
- Boolean delete = true;
- if (pathDescription != null) {
- LOG.info("Pathdescription conatins in Stubpce notification received !");
- String result = null;
- PathComputationRequestOutput pathComputationResponse =
- new PathComputationRequestOutputBuilder()
- .setResponseParameters(new org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.service.types.rev170426.response
- .parameters.sp.ResponseParametersBuilder()
- .setPathDescription(pathDescription)
- .build())
- .build();
- if (input instanceof ServiceReconfigureInput) {
- /** delete and write . */
- LOG.info("RPC serviceImplementation came from RPC serviceReconfigure ...");
- ServiceReconfigureInput tmp = (ServiceReconfigureInput)input;
- serviceName = tmp.getServiceName();
- newServiceName = tmp.getNewServiceName();
- type = ServiceNotificationTypes.ServiceReconfigureResult;
- delete = false;
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp,pathComputationResponse);
- } else if (input instanceof ServiceCreateInput) {
- /** create. */
- LOG.info("RPC serviceImplementation came from RPC serviceCreate ...");
- ServiceCreateInput tmp = (ServiceCreateInput)input;
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceCreateResult;
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp,pathComputationResponse);
- delete = true;
- create = true;
- } else if (input instanceof Services) {
- /** update. */
- LOG.info("RPC serviceImplementation came from RPC ServiceRestoration ...");
- Services tmp = new ServicesBuilder((Services)input)
- .setAdministrativeState(State.OutOfService)
- .setOperationalState(State.OutOfService)
- .setLifecycleState(LifecycleState.Planned)
- .build();
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceRestorationResult;
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp, pathComputationResponse);
- delete = true;
- create = true;
- }
- final String name = serviceName;
- final ServiceNotificationTypes notifType = type;
- if (!create) { /** ServiceReconfigure. */
- if ((result = writeOrModifyOrDeleteServiceList(serviceName, pathComputationResponse,null, 1)) == null) {
- LOG.info("Service '{}' deleted from datastore", serviceName);
- serviceName = newServiceName;
- delete = true;
- } else {
- LOG.info("deleting Service '{}' failed !", serviceName);
- }
- }
- if (delete) {
- if ((result = writeOrModifyOrDeleteServiceList(serviceName,pathComputationResponse,null, 2)) != null) {
- LOG.info("writting Service failed !");
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" " + result);
- message = build.toString();
- } else {
- /**
- * Send Implementation order to renderer
- */
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name)
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Submitting ServiceImplementation Request ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- FutureCallback<Boolean> rendererCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- /**
- * If stubrenderer reply is received before timer
- * expiration with a positive result, a
- * service is created with admin and
- * operational status 'down'.
- */
- message = "StubRenderer replied to Request !";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = mappingAndSendingSIRequest.getError();
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Failed).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- }
- }
+ LOG.info("PCE calculation done OK {}", pceResponseCode);
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Service not implemented ...");
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Service implementation failed : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- }
- };
- ListenableFuture<Boolean> renderer = mappingAndSendingSIRequest.serviceImplementation();
- Futures.addCallback(renderer, rendererCallback, executor);
- }
- } else {
- LOG.info("deleting Service failed");
- }
- } else {
- message = "PathDescription contains in Stubpce notification "
- + "not recieved !";
+ OperationResult operationResult = this.serviceDataStoreOperations.createService(input, pceResponse);
+ if (!operationResult.isSuccess()) {
+ String message = "Service status not updated in datastore !";
LOG.info(message);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
}
- }
-
- /**
- * Checking Service Compliancy.
- *
- * @return String if not compliant, null else
- */
- private String serviceCompliancy(SdncRequestHeader sdncRequestHeader, String serviceName,
- ConnectionType connectionType, RpcActions rpcActions, ServiceEndpoint aend, ServiceEndpoint zend,
- String commonIdValue, HardConstraints hard, SoftConstraints soft) {
- String message = null;
- Boolean contype = false;
- Boolean sdncRequest = false;
- Boolean commonId = true;
- Boolean coherencyHardSoft = false;
- if (rpcActions.equals(RpcActions.ServiceCreate) || rpcActions.equals(RpcActions.ServiceFeasibilityCheck)
- || rpcActions.equals(RpcActions.ServiceDelete)) {
- sdncRequest = true;
- } else if (rpcActions.equals(RpcActions.ServiceCreate)
- || rpcActions.equals(RpcActions.ServiceFeasibilityCheck)
- || rpcActions.equals(RpcActions.ServiceReconfigure)) {
- contype = true;
- }
- compliancyCheck = new ServicehandlerCompliancyCheck(sdncRequestHeader, serviceName,
- connectionType, rpcActions);
- if (compliancyCheck.check(contype, sdncRequest)) {
- LOG.info("Service compliant !");
- /**
- * If compliant, service-request parameters are verified in order to
- * check if there is no missing parameter that prevents calculating
- * a path and implement a service.
- */
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(aend, 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(zend, 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- /**
- * If OK, common-id is verified in order to see if there is
- * no routing policy provided. If yes, the routing
- * constraints of the policy are recovered and coherency
- * with hard/soft constraints provided in the input of the
- * RPC.
- */
- if (commonIdValue != null) {
- LOG.info("Common-id specified");
- /**
- * Check coherency with hard/soft constraints.
- */
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(hard,soft);
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- }
- } else {
- commonId = false;
- }
- if (!commonId || (commonId && coherencyHardSoft)) {
- message = null;
- }
- } else {
- message = txrxCheck.getMessage();
- }
- } else {
- message = txrxCheck.getMessage();
- }
- } else {
- message = compliancyCheck.getMessage();
+ OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(input,
+ pceResponse);
+ if (!operationServicePathSaveResult.isSuccess()) {
+ String message = "Service Path not updated in datastore !";
+ LOG.info(message);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
}
- return message;
- }
-
- @Override
- public Future<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
- LOG.info("RPC service creation received");
- pathDescription = null;
- pathTopology = null;
- action = RpcActions.ServiceCreate;
- setPathDescription(null);
- serviceCreateInput = input;
- setServiceDeleteInput(null);
- setServiceReconfigureInput(null);
- service = null;
- String message = "";
- String responseCode = "";
- ConfigurationResponseCommon configurationResponseCommon;
- LOG.info("checking Service Compliancy ...");
- /**
- * Upon receipt of service-create RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- String serviceCompliancy = null;
- if ((serviceCompliancy = serviceCompliancy(input.getSdncRequestHeader(), input.getServiceName(),
- input.getConnectionType(), RpcActions.ServiceCreate, input.getServiceAEnd(), input.getServiceZEnd(),
- input.getCommonId(), input.getHardConstraints(), input.getSoftConstraints())) != null) {
- message = "Service not compliant : " + serviceCompliancy;
- responseCode = "500";
+ ServiceImplementationRequestInput serviceImplementationRequest =
+ ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
+ .ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
+ .serviceImplementation(serviceImplementationRequest);
+ if (ResponseCodes.RESPONSE_OK
+ .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
+ String message = "Service rendered successfully !";
LOG.info(message);
+ operationResult = this.serviceDataStoreOperations.modifyService(input.getServiceName(), State.InService,
+ State.InService);
+ if (!operationResult.isSuccess()) {
+ LOG.warn("Service status not updated in datastore !");
+ }
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_OK);
} else {
- LOG.info("Service compliant !");
- String name = input.getServiceName();
- if (readServiceList(name) == null) {
- pcePathComputation(input);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, serviceCreate in progress...")
- .setResponseCode("200").build();
+ String message = "Service rendering has failed !";
+ LOG.warn(message);
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon);
-
- return RpcResultBuilder.success(output.build()).buildFuture();
- } else {
- LOG.info("Service '{}' already created !", name);
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service already created !")
- .setResponseCode("500").build();
-
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon);
-
- return RpcResultBuilder.success(output.build()).buildFuture();
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
}
- }
- /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(),
- input.getConnectionType(), RpcActions.ServiceCreate);
- if (compliancyCheck.check(true, true)) {
- LOG.info("Service compliant !");
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- responseCode = "500";
- }
- } else {
- commonId = false;
- }
- if (!commonId || (commonId && coherencyHardSoft)) {
- pcePathComputation(input);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, serviceCreate in progress...")
- .setResponseCode("200").build();
-
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon);
- return RpcResultBuilder.success(output.build()).buildFuture();
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteService(input.getServiceName());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
}
- } else {
- message = compliancyCheck.getMessage();
- responseCode = "500";
- }*/
- ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("Yes")
- .setResponseMessage(message)
- .setResponseCode(responseCode);
- SdncRequestHeader sdnc = input.getSdncRequestHeader();
- if (sdnc != null) {
- String requestId = sdnc.getRequestId();
- if (requestId != null) {
- builder.setRequestId(requestId);
- }
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
}
- configurationResponseCommon = builder.build();
-
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon);
-
- return RpcResultBuilder.success(output.build()).buildFuture();
}
@Override
public Future<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
- LOG.info("RPC serviceDelete request received for Service '{}'", input.getServiceDeleteReqInfo()
- .getServiceName());
- setServiceDeleteInput(input);
- setServiceReconfigureInput(null);
- serviceCreateInput = null;
- service = null;
+ LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName());
String message = "";
- String responseCode = "";
- LOG.info("checking Service Compliancy ...");
- /**
- * Upon receipt of service-delete RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(),
- input.getServiceDeleteReqInfo().getServiceName(), RpcActions.ServiceDelete);
- if (compliancyCheck.check(false, true)) {
- LOG.info("Service compliant !");
- String serviceName = input.getServiceDeleteReqInfo().getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- LOG.debug("Service '{}' present in datastore !", serviceName);
- stubrendererDelete();
- LOG.info("ServiceDelete Request in progress ... ");
- ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("ServiceDelete Request in progress ...").setResponseCode("200").build();
- ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.info(message);
- }
- } else {
- message = "Service not compliant !";
- responseCode = "500";
- LOG.info(message);
- }
- ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage(message).setResponseCode(responseCode).build();
- ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- }
-
- @Override
- public Future<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
- ServiceFeasibilityCheckInput input) {
- action = RpcActions.ServiceFeasibilityCheck;
- LOG.info("RPC service feasibilityCheck received");
- mappingAndSendingPCRequest = null;
- serviceFeasibilityCheckInput = input;
- serviceCreateInput = null;
- serviceDeleteInput = null;
- service = null;
- serviceReconfigureInput = null;
-
- ConfigurationResponseCommon configurationResponseCommon = null;
- String message = "";
- String responseCode = "";
- LOG.info("checking Service Compliancy ...");
- /**
- * Upon receipt of service-create RPC, service header and sdnc-request
+ /*
+ * Upon receipt of service-deleteService RPC, service header and sdnc-request
* header compliancy are verified.
*/
- String name = "no name";
- String serviceCompliancy = null;
- if ((serviceCompliancy = serviceCompliancy(input.getSdncRequestHeader(), name, input.getConnectionType(),
- RpcActions.ServiceFeasibilityCheck, input.getServiceAEnd(), input.getServiceZEnd(), input.getCommonId(),
- input.getHardConstraints(), input.getSoftConstraints())) != null) {
- message = "Service not compliant : " + serviceCompliancy;
- LOG.info(message);
- } else {
- LOG.info("Service compliant !");
- pcePathComputation(input);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, ServiceFeasibilityCheck in progress...")
- .setResponseCode("200").build();
-
- ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- }
- /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), name,
- input.getConnectionType(), RpcActions.ServiceFeasibilityCheck);
- if (compliancyCheck.check(true, true)) {
- LOG.info("Service compliant !");
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- responseCode = "500";
- }
- } else {
- commonId = false;
- }
-
- if (!commonId || (commonId && coherencyHardSoft)) {
- pcePathComputation(input);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, ServiceFeasibilityCheck in progress...")
- .setResponseCode("200").build();
-
- ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = compliancyCheck.getMessage();
- responseCode = "500";
- }*/
- configurationResponseCommon = new ConfigurationResponseCommonBuilder().setAckFinalIndicator("Yes")
- .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message)
- .setResponseCode(responseCode).build();
- ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
-
- return RpcResultBuilder.success(output).buildFuture();
- }
-
- @Override
- public Future<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
- LOG.info("RPC service reconfigure received");
- setServiceReconfigureInput(input);
- setServiceDeleteInput(null);
- serviceCreateInput = null;
- service = null;
- String message = "";
LOG.info("checking Service Compliancy ...");
- /**
- * Upon receipt of service-create RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- String serviceCompliancy = null;
- if ((serviceCompliancy = serviceCompliancy(null, input.getServiceName(), input.getConnectionType(),
- RpcActions.ServiceReconfigure, input.getServiceAEnd(), input.getServiceZEnd(), input.getCommonId(),
- input.getHardConstraints(), input.getSoftConstraints())) != null) {
- message = "Service not compliant : " + serviceCompliancy;
- LOG.info(message);
- } else {
- LOG.info("Service compliant !");
- /**
- * Retrieving initial service topology.
- */
- String serviceName = input.getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- LOG.debug("Service '{}' present in datastore !", serviceName);
- /**
- * Sending cancel resource reserve request to PCE.
- */
- pceCancelResResource();
- ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder()
- .setStatus(RpcStatus.Successful)
- .setStatusMessage("ServiceReconfigure in progress ...").build();
- return RpcResultBuilder.success(output).buildFuture();
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.info(message);
- }
- }
- /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), input.getConnectionType(),
- RpcActions.ServiceReconfigure);
- if (compliancyCheck.check(true, false)) {
+ ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
+ input.getServiceDeleteReqInfo().getServiceName(),
+ input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
+ if (serviceHandlerCheckResult.hasPassed()) {
LOG.info("Service compliant !");
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- }
- } else {
- commonId = false;
- }
-
- if (!commonId || (commonId && coherencyHardSoft)) {
- String serviceName = input.getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- LOG.debug("Service '{}' present in datastore !", serviceName);
- pceCancelResResource();
- ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder()
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("ServiceReconfigure in progress ...").build();
- return RpcResultBuilder.success(output).buildFuture();
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.error("Service '{}' not exists in datastore", serviceName);
- }
- }
- } else {
- message = txrxCheck.getMessage();
- }
- } else {
- message = txrxCheck.getMessage();
- }
} else {
- message = compliancyCheck.getMessage();
- }*/
-
- ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Failed)
- .setStatusMessage(message).build();
- return RpcResultBuilder.success(output).buildFuture();
- }
+ LOG.info("Service is not compliant !");
+ return ModelMappingUtils
+ .createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
+ }
- @Override
- public Future<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
- LOG.info("RPC service restoration received");
- ServiceRpcResultSh notification = null;
- setServiceDeleteInput(null);
- setServiceReconfigureInput(null);
- String message = "";
- LOG.info("checking Service Compliancy ...");
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), RpcActions.ServiceRestoration);
- if (compliancyCheck.check(false, false)) {
- LOG.info("Service compliant !");
- /**
- * If compliant, Getting path from service DB.
- */
- String serviceName = input.getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- this.service = service;
- LOG.debug("Service '{}' present in datastore !", serviceName);
- /** verify if service state is down. */
- State state = service.getOperationalState();
- if (state != null && !state.equals(State.InService)) {
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ..")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- stubrendererDelete();
- LOG.info("PCR Request in progress ");
- ServiceRestorationOutput output = new ServiceRestorationOutputBuilder()
- .setStatus(RpcStatus.Successful)
- .setStatusMessage("ServiceRestoration in progress...").build();
- return RpcResultBuilder.success(output).buildFuture();
- } else {
- LOG.info("Service '{}' still in '{}' state", serviceName, state);
- ServiceRestorationOutput output = new ServiceRestorationOutputBuilder()
- .setStatus(RpcStatus.Failed)
- .setStatusMessage("ServiceRestoration failed : Service still in service !")
- .build();
- return RpcResultBuilder.success(output).buildFuture();
- }
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.error(message);
- }
- } else {
- message = compliancyCheck.getMessage();
+ //Check presence of service to be deleted
+ String serviceName = input.getServiceDeleteReqInfo().getServiceName();
+ Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
+ if (!service.isPresent()) {
+ message = "Service '" + serviceName + "' does not exist in datastore";
LOG.error(message);
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ message, ResponseCodes.RESPONSE_FAILED);
}
- ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Failed)
- .setStatusMessage(message).build();
-
- return RpcResultBuilder.success(output).buildFuture();
- }
-
- @Override
- public Future<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * Initialize ServiceList Structure on Datastore.
- *
- * @param DataBroker
- * Access Datastore
- */
- private void initializeDataTree(DataBroker db) {
- LOG.info("Preparing to initialize the greeting registry");
- WriteTransaction transaction = db.newWriteOnlyTransaction();
- InstanceIdentifier<ServiceList> iid = InstanceIdentifier.create(ServiceList.class);
- ServiceList greetingRegistry = new ServiceListBuilder().build();
- transaction.put(LogicalDatastoreType.OPERATIONAL, iid, greetingRegistry);
- Future<Void> future = transaction.submit();
- try {
- Futures.getChecked(future, ExecutionException.class);
- } catch (ExecutionException e) {
- LOG.error("Failed to create Service List");
+ LOG.debug("Service '{}' present in datastore !", serviceName);
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput
+ serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
+ .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
+
+ if (!ResponseCodes.RESPONSE_OK
+ .equals(output.getConfigurationResponseCommon().getResponseCode())) {
+ message = "Service delete failed!";
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
}
- }
- /**
- * Map Input (ServiceCreateInmput, ServiceReconfigureInput) and output
- * (PathComputationRequestOutput) to Service.
- *
- * @param serviceCreateInput
- * ServiceCreateInput parameter
- * @param serviceReconfigureInput
- * serviceReconfigureInput parameter
- * @param output
- * PathComputationRequestOutput parameter
- *
- * @return Services Service data
- */
- private Services mappingServices(ServiceCreateInput serviceCreateInput,
- ServiceReconfigureInput serviceReconfigureInput, PathComputationRequestOutput output) {
- LOG.info("Mapping informations to Services");
- ServiceAEnd aend = null;
- ServiceZEnd zend = null;
- ServicesBuilder service = new ServicesBuilder();
- if (serviceCreateInput != null) {
- aend = new ServiceAEndBuilder(serviceCreateInput.getServiceAEnd()).build();
- zend = new ServiceZEndBuilder(serviceCreateInput.getServiceZEnd()).build();
- service.setServiceName(serviceCreateInput.getServiceName())
- .setAdministrativeState(State.OutOfService)
- .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId())
- .setConnectionType(serviceCreateInput.getConnectionType())
- .setCustomer(serviceCreateInput.getCustomer())
- .setCustomerContact(serviceCreateInput.getCustomerContact())
- .setHardConstraints(serviceCreateInput.getHardConstraints())
- .setSoftConstraints(serviceCreateInput.getSoftConstraints())
- .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend)
- .setSdncRequestHeader(new SdncRequestHeaderBuilder()
- .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId())
- .setRpcAction(serviceCreateInput.getSdncRequestHeader().getRpcAction())
- .build());
-
- } else if (serviceReconfigureInput != null) {
- aend = new ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build();
- zend = new ServiceZEndBuilder(serviceReconfigureInput.getServiceZEnd()).build();
- service.setServiceName(serviceReconfigureInput.getNewServiceName())
- .setAdministrativeState(State.OutOfService).setOperationalState(State.OutOfService)
- .setCommonId(serviceReconfigureInput.getCommonId())
- .setConnectionType(serviceReconfigureInput.getConnectionType())
- .setCustomer(serviceReconfigureInput.getCustomer())
- .setCustomerContact(serviceReconfigureInput.getCustomerContact())
- .setHardConstraints(serviceReconfigureInput.getHardConstraints())
- .setSoftConstraints(serviceReconfigureInput.getSoftConstraints())
- .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend)
- .setSdncRequestHeader(new SdncRequestHeaderBuilder()
- .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName())
- .setRpcAction(RpcActions.ServiceReconfigure)
- .build());
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getServiceDeleteReqInfo().getServiceName());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
}
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
- .parameters.sp.ResponseParameters responseParameters = output.getResponseParameters();
- if (responseParameters != null) {
- // service.setPceMetric(responseParameters.getPceMetric());
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426
- .response.parameters.sp.response.parameters.PathDescription pathDescription =
- responseParameters.getPathDescription();
- if (pathDescription != null) {
- List<AToZ> atozList = new ArrayList<AToZ>();
- List<ZToA> ztoaList = new ArrayList<ZToA>();
-
- for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
- .path.description.atoz.direction.AToZ
- tmp : pathDescription.getAToZDirection().getAToZ()) {
-
- AToZKey key = new AToZKey(tmp.getKey().getId());
- AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key)
- // .setResource(tmp.getResource())
- .build();
- atozList.add(atoz);
- }
-
- for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
- .path.description.ztoa.direction.ZToA
- tmp : pathDescription.getZToADirection().getZToA()) {
- ZToAKey key = new ZToAKey(tmp.getKey().getId());
- ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key)
- // .setResource(tmp.getResource())
- .build();
- ztoaList.add(ztoa);
- }
-
- Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList).build();
- service.setTopology(topology);
- }
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteService(input.getServiceDeleteReqInfo().getServiceName());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
}
- return service.build();
- }
- /**
- * read Service from ServiceList DataStore.
- *
- * @param serviceName
- * Name of Service
- *
- * @return <code>Services</code>
- */
- private Services readServiceList(String serviceName) {
- Services result = null;
- ReadOnlyTransaction readTx = db.newReadOnlyTransaction();
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceName));
- Future<Optional<Services>> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid);
- Optional<Services> optional = Optional.absent();
- try {
- optional = Futures.getChecked(future, ExecutionException.class);
- } catch (ExecutionException e) {
- LOG.error("Reading service failed:", e);
- }
- if (optional.isPresent()) {
- LOG.debug("Service '{}' present !", serviceName);
- result = new ServicesBuilder(optional.get()).build();
- }
- return result;
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ "Service delete was successful!", ResponseCodes.RESPONSE_OK);
}
- /**
- * Write or Modify or Delete Service from/to ServiceList.
- *
- * @param serviceName
- * Name of service
- * @param output
- * PathComputationRequestOutput
- * @param topo
- * Topology
- * @param choice
- * 0 - Modify 1 - Delete 2 - Write
- * @return String operations result, null if ok or not otherwise
- */
- private String writeOrModifyOrDeleteServiceList(String serviceName, PathComputationRequestOutput output,
- Topology topo, int choice) {
- LOG.info("WriteOrModifyOrDeleting '{}' Service", serviceName);
- WriteTransaction writeTx = db.newWriteOnlyTransaction();
- String result = null;
- Services readService = readServiceList(serviceName);
- Future<Void> future = null;
- if (readService != null) {
- /**
- * Modify / Delete Service.
- */
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceName));
- ServicesBuilder service = new ServicesBuilder(readService);
-
- String action = null;
- switch (choice) {
- case 0: /** Modify. */
- LOG.info("Modifying '{}' Service", serviceName);
- service.setOperationalState(State.InService).setAdministrativeState(State.InService);
- service.setTopology(topo);
- writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build());
- action = "modify";
- break;
-
- case 1: /** Delete. */
- LOG.info("Deleting '{}' Service", serviceName);
- writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
- action = "delete";
- break;
+ @Override
+ public Future<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
+ ServiceFeasibilityCheckInput input) {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
- default:
- LOG.info("No choice found");
- break;
- }
- future = writeTx.submit();
- try {
- Futures.getChecked(future, ExecutionException.class);
- } catch (ExecutionException e) {
- LOG.info("Failed to {} service from Service List", action);
- result = "Failed to " + action + " service from Service List";
- }
- } else if (choice == 2) { /** Write Service. */
- LOG.info("Writing '{}' Service", serviceName);
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceName));
- Services writeService = null;
- if (this.service != null) {
- writeService = service;
- } else {
- writeService = mappingServices(serviceCreateInput, serviceReconfigureInput, output);
- }
- writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, writeService);
- future = writeTx.submit();
- try {
- Futures.getChecked(future, ExecutionException.class);
- result = null;
- } catch (ExecutionException e) {
- LOG.error("Failed to write service to Service List");
- result = "Failed to write service to Service List";
- }
- } else {
- LOG.info("Service is not present in datastore ! ");
- result = "Service is not present in datastore ! ";
- }
- return result;
+ @Override
+ public Future<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
+ throw new UnsupportedOperationException("Not implemented yet");
}
@Override
- public void close() throws Exception {
- executor.shutdown();
+ public Future<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
+ throw new UnsupportedOperationException("Not implemented yet");
}
@Override
@Override
public Future<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
- // TODO Auto-generated method stub
- return null;
+ InstanceIdentifier<Services> servicesIID = InstanceIdentifier.create(ServiceList.class)
+ .child(Services.class, new ServicesKey(input.getServiceName()));
+ ReadOnlyTransaction rtx = this.db.newReadOnlyTransaction();
+ Optional<Services> servicesObject;
+ try {
+ servicesObject = rtx.read(LogicalDatastoreType.CONFIGURATION, servicesIID).get().toJavaUtil();
+ if (servicesObject.isPresent()) {
+ ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyy-MM-dd'T'HH:mm:ssX");
+ LocalDateTime now = LocalDateTime.now();
+ DateAndTime datetime = new DateAndTime(dtf.format(now));
+ deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
+ .setServiceName(input.getServiceName()).setDueDate(datetime)
+ .setTailRetention(TailRetention.No).build());
+ SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder();
+ sdncBuilder.setNotificationUrl(servicesObject.get().getSdncRequestHeader().getNotificationUrl());
+ sdncBuilder.setRequestId(servicesObject.get().getSdncRequestHeader().getRequestId());
+ sdncBuilder.setRequestSystemId(servicesObject.get().getSdncRequestHeader().getRequestSystemId());
+ sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
+ deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
+ // Calling delete service
+ serviceDelete(deleteInputBldr.build());
+ // Calling create request now
+ ServiceCreateInputBuilder serviceCreateBldr = new ServiceCreateInputBuilder();
+ serviceCreateBldr.setServiceName(input.getServiceName() + 2);
+ serviceCreateBldr.setCommonId(servicesObject.get().getCommonId());
+ serviceCreateBldr.setConnectionType(servicesObject.get().getConnectionType());
+ serviceCreateBldr.setCustomer(servicesObject.get().getCustomer());
+ serviceCreateBldr.setCustomerContact(servicesObject.get().getCustomerContact());
+ serviceCreateBldr.setDueDate(servicesObject.get().getDueDate());
+ serviceCreateBldr.setEndDate(servicesObject.get().getEndDate());
+ serviceCreateBldr.setHardConstraints(servicesObject.get().getHardConstraints());
+ serviceCreateBldr.setNcCode(servicesObject.get().getNcCode());
+ serviceCreateBldr.setNciCode(servicesObject.get().getNciCode());
+ serviceCreateBldr.setOperatorContact(servicesObject.get().getOperatorContact());
+ serviceCreateBldr.setSdncRequestHeader(servicesObject.get().getSdncRequestHeader());
+ serviceCreateBldr.setSecondaryNciCode(servicesObject.get().getSecondaryNciCode());
+ ServiceAEndBuilder serviceAendBuilder = new ServiceAEndBuilder(servicesObject.get().getServiceAEnd());
+ serviceCreateBldr.setServiceAEnd(serviceAendBuilder.build());
+ ServiceZEndBuilder serviceZendBuilder = new ServiceZEndBuilder(servicesObject.get().getServiceZEnd());
+ serviceCreateBldr.setServiceZEnd(serviceZendBuilder.build());
+ serviceCreateBldr.setSoftConstraints(servicesObject.get().getSoftConstraints());
+ serviceCreate(serviceCreateBldr.build());
+ ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
+ .setHardConstraints(null).setSoftConstraints(null).setStatus(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful)
+ .setStatusMessage("Success");
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.info("Exception caught" , e);
+ }
+ ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
+ .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage("Failure");
+
+ return RpcResultBuilder.success(output).buildFuture();
+ // return null;
}
@Override
}
@Override
- public void onServiceRpcResultSp(ServiceRpcResultSp notification) {
- if (notification != null && !compareServiceRpcResultSp(notification)) {
- serviceRpcResultSp = notification;
- StringBuilder build = new StringBuilder();
- build.append(
- "Received '" + notification.getNotificationType() + "' StubRenderer notification" + "from service '"
- + notification.getServiceName() + "' " + "with status '" + notification.getStatus() + "'");
- build.append(" with StatusMessage '" + notification.getStatusMessage() + "'");
- LOG.info(build.toString());
- switch (serviceRpcResultSp.getNotificationType().getIntValue()) {
- case 3 : /** service-implementation-request. */
- if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
- if (serviceRpcResultSp.getPathTopology() != null) {
- pathTopology = new PathTopologyBuilder()
- .setAToZ(serviceRpcResultSp.getPathTopology().getAToZ())
- .setZToA(serviceRpcResultSp.getPathTopology().getZToA())
- .build();
- LOG.info("PathTopology gets !");
- } else {
- LOG.info("'serviceRpcResultSp.getPathTopology()' parameter is null ");
- }
- if (serviceCreateInput != null) {
- updateServiceStatus(serviceCreateInput);
- } else if (serviceReconfigureInput != null) {
- updateServiceStatus(serviceReconfigureInput);
- } else if (service != null) {
- updateServiceStatus(service);
- }
- } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
- LOG.info("Stubrenderer computation failed !");
- pceCancelResResource();
- }
- break;
-
- case 4 : /** service-delete. */
- if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
- if (service != null) { //serviceRestoration
- LOG.info("RPC service delete came from serviceRestoration");
- pcePathComputation(service);
- } else {
- pceCancelResResource();
- }
- } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
- LOG.info("Stubrenderer computation failed !");
- }
- break;
-
- default:
- break;
- }
- } else {
- LOG.info("ServiceRpcResultSp already wired !");
- }
+ public Future<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
+ // TODO Auto-generated method stub
+ return null;
}
@Override
- public void onServicePathRpcResult(ServicePathRpcResult notification) {
- if (notification != null && !compareServicePathRpcResult(notification)) {
- servicePathRpcResult = notification;
- StringBuilder build = new StringBuilder();
- build.append(
- "Received '" + notification.getNotificationType() + "' Stubpce notification" + "from service '"
- + notification.getServiceName() + "' " + "with status '" + notification.getStatus() + "'");
- build.append(" with StatusMessage '" + notification.getStatusMessage() + "'");
- LOG.info(build.toString());
- switch (servicePathRpcResult.getNotificationType().getIntValue()) {
- case 1 : /** path-computation-request. */
- if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
- if (servicePathRpcResult.getPathDescription() != null) {
- pathDescription = new PathDescriptionBuilder()
- .setAToZDirection(servicePathRpcResult.getPathDescription().getAToZDirection())
- .setZToADirection(servicePathRpcResult.getPathDescription().getZToADirection())
- .build();
- LOG.info("PathDescription gets !");
- if (serviceReconfigureInput != null) {
- stubrendererImplementation(serviceReconfigureInput);
- } else if (serviceCreateInput != null) {
- stubrendererImplementation(serviceCreateInput);
- } else if (service != null) {
- stubrendererImplementation(service);
- }
- } else {
- LOG.info("'servicePathRpcResult.getPathDescription()'parameter is null ");
- }
- } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
- LOG.info("Stupce computation failed !");
- }
- break;
-
- case 2 : /** cancel-resource-reserve. */
- if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
- /**if it was an RPC serviceReconfigure, relaunch
- * PCR else delete the service.
- */
- if (serviceReconfigureInput != null) {
- LOG.info("cancel reserve resource request came from RPC serviceReconfigure !");
- pcePathComputation(serviceReconfigureInput);
- } else {
- deleteServiceFromDatastore();
- }
- } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
- LOG.info("Stupce computation failed !");
- }
- break;
-
- default:
- break;
- }
- } else {
- LOG.info("ServicePathRpcResult already wired !");
- }
- }
-
- public RpcActions getAction() {
- return action;
- }
-
- public void setAction(RpcActions action) {
- this.action = action;
- }
-
- /**
- * Compare ServicePathRpcResult.
- *
- * @param notification ServicePathRpcResult
- * @return <code>Boolean</code> true if idem, false else
- */
- public Boolean compareServicePathRpcResult(ServicePathRpcResult notification) {
- Boolean result = true;
- if (servicePathRpcResult == null) {
- result = false;
- } else {
- if (servicePathRpcResult.getNotificationType() != notification.getNotificationType()) {
- result = false;
- }
- if (servicePathRpcResult.getServiceName() != notification.getServiceName()) {
- result = false;
- }
- if (servicePathRpcResult.getStatus() != notification.getStatus()) {
- result = false;
- }
- if (servicePathRpcResult.getStatusMessage() != notification.getStatusMessage()) {
- result = false;
- }
- }
- return result;
- }
-
- /**
- * Compare ServiceRpcResultSp.
- *
- * @param notification ServiceRpcResultSp
- * @return <code>Boolean</code> true if idem, false else
- */
- public Boolean compareServiceRpcResultSp(ServiceRpcResultSp notification) {
- Boolean result = true;
- if (serviceRpcResultSp == null) {
- result = false;
- } else {
- if (serviceRpcResultSp.getNotificationType() != notification.getNotificationType()) {
- result = false;
- }
- if (serviceRpcResultSp.getServiceName() != notification.getServiceName()) {
- result = false;
- }
- if (serviceRpcResultSp.getStatus() != notification.getStatus()) {
- result = false;
- }
- if (serviceRpcResultSp.getStatusMessage() != notification.getStatusMessage()) {
- result = false;
- }
- }
- return result;
- }
-
- public PathDescription getPathDescription() {
- return pathDescription;
- }
-
- public void setPathDescription(PathDescription pathDescription) {
- this.pathDescription = pathDescription;
- }
-
- public ServiceDeleteInput getServiceDeleteInput() {
- return serviceDeleteInput;
- }
-
- public void setServiceDeleteInput(ServiceDeleteInput serviceDeleteInput) {
- this.serviceDeleteInput = serviceDeleteInput;
- }
-
- public ServiceReconfigureInput getServiceReconfigureInput() {
- return serviceReconfigureInput;
- }
-
- public void setServiceReconfigureInput(ServiceReconfigureInput serviceReconfigureInput) {
- this.serviceReconfigureInput = serviceReconfigureInput;
- }
-
- public ServiceFeasibilityCheckInput getServiceFeasibilityCheckInput() {
- return serviceFeasibilityCheckInput;
- }
-
- public void setServiceFeasibilityCheckInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) {
- this.serviceFeasibilityCheckInput = serviceFeasibilityCheckInput;
+ public Future<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
+ // TODO Auto-generated method stub
+ return null;
}
- @Override
- public Future<RpcResult<ServiceStateModifyOutput>> serviceStateModify(ServiceStateModifyInput input) {
- LOG.info("RPC service state modify received");
- String servicename = input.getServiceName();
- String message = "";
- String responseCode = "500";
- if (servicename != null) {
- Services service = readServiceList(servicename);
- if (service != null) {
- LOG.info("Modify '{}' Service state", servicename);
- WriteTransaction writeTx = db.newWriteOnlyTransaction();
- String result = null;
- Future<Void> future = null;
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(servicename));
- ServicesBuilder modifyService = new ServicesBuilder(service);
- modifyService.setOperationalState(State.OutOfService);
- writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, modifyService.build());
- future = writeTx.submit();
- try {
- Futures.getChecked(future, ExecutionException.class);
- } catch (ExecutionException e) {
- LOG.info("Failed to {} service from Service List", action);
- result = "Failed to " + action + " service from Service List";
- }
- if (result == null) {
- responseCode = "200";
- message = "Service state modified !";
- }
- } else {
- message = "Service not present in datastore ! ";
- }
- } else {
- message = "servicename not set in ServiceStateModifyInput";
- }
- ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("Yes")
- .setResponseCode(responseCode)
- .setResponseMessage(message)
- .build();
- ServiceStateModifyOutput output = new ServiceStateModifyOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon)
- .build();
- return RpcResultBuilder.success(output).buildFuture();
- }
}
package org.opendaylight.transportpce.servicehandler.impl;
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.NotificationService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServicehandlerService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+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.PceListener;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.slf4j.Logger;
/**
* Class to register
* Servicehandler Service and Notification.
- *
- * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
+ * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
*
*/
public class ServicehandlerProvider {
private final DataBroker dataBroker;
private final RpcProviderRegistry rpcRegistry;
private final NotificationService notificationService;
- private final NotificationPublishService notificationPublishService;
-
- /** Listener register for TransportpceService Notification. */
- private ListenerRegistration<StubpceListener> stubpcelistenerRegistration;
- private ListenerRegistration<StubrendererListener> stubrendererlistenerRegistration;
+ private ListenerRegistration<PceListener> pcelistenerRegistration;
private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
- private RpcRegistration<ServicehandlerService> rpcRegistrationServiceHandler;
-
+ private PathComputationService pathComputationService;
+ private RendererServiceOperations rendererServiceOperations;
public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
- NotificationService notificationService, NotificationPublishService notificationPublishService) {
+ NotificationService notificationService, PathComputationService pathComputationService,
+ RendererServiceOperations rendererServiceOperations) {
this.dataBroker = dataBroker;
this.rpcRegistry = rpcProviderRegistry;
this.notificationService = notificationService;
- this.notificationPublishService = notificationPublishService;
+ this.pathComputationService = pathComputationService;
+ this.rendererServiceOperations = rendererServiceOperations;
}
/**
*/
public void init() {
LOG.info("ServicehandlerProvider Session Initiated");
- final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService);
- stubpcelistenerRegistration = notificationService.registerNotificationListener(consumer);
- stubrendererlistenerRegistration = notificationService.registerNotificationListener(consumer);
- rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, consumer);
- rpcRegistrationServiceHandler = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer);
+ final ServicehandlerImpl servicehandler = new ServicehandlerImpl(dataBroker, pathComputationService,
+ rendererServiceOperations);
+ final PceListenerImpl pceListener = new PceListenerImpl();
+ pcelistenerRegistration = notificationService.registerNotificationListener(pceListener);
+ rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
}
/**
*/
public void close() {
LOG.info("ServicehandlerProvider Closed");
- stubpcelistenerRegistration.close();
- stubrendererlistenerRegistration.close();
+ pcelistenerRegistration.close();
rpcRegistration.close();
- rpcRegistrationServiceHandler.close();
}
+
}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.listeners;
+
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PceListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Deprecated
+public class PceListenerImpl implements PceListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PceListenerImpl.class);
+
+ private ServicePathRpcResult servicePathRpcResult = null;
+
+ @Override
+ public void onServicePathRpcResult(ServicePathRpcResult notification) {
+ if (!compareServicePathRpcResult(notification)) {
+ servicePathRpcResult = notification;
+ StringBuilder build = new StringBuilder();
+ build.append(
+ "Received '" + notification.getNotificationType() + "' StubPce notification " + "from service '"
+ + notification.getServiceName() + "' " + "with status '" + notification.getStatus() + "'");
+ build.append(" with StatusMessage '" + notification.getStatusMessage() + "'");
+ if (notification.getStatus() == RpcStatusEx.Successful && notification.getNotificationType()
+ .getIntValue() == ServicePathNotificationTypes.PathComputationRequest.getIntValue()) {
+ build.append(" PathDescription : " + notification.getPathDescription().toString());
+ /*
+ * switch (action.getIntValue()) { case 1: //service-create case
+ * 3: //service-delete case 8: //service-reconfigure case 9:
+ * //service-restoration case 10://service-reversion case
+ * 11://service-reroute break;
+ *
+ * default: break; }
+ */
+ }
+
+ LOG.info(build.toString());
+ } else {
+ LOG.info("ServicePathRpcResult already wired !");
+ }
+ }
+
+ @Deprecated
+ private Boolean compareServicePathRpcResult(ServicePathRpcResult notification) {
+ Boolean result = true;
+ if (servicePathRpcResult == null) {
+ result = false;
+ } else {
+ if (servicePathRpcResult.getNotificationType() != notification.getNotificationType()) {
+ result = false;
+ }
+ if (servicePathRpcResult.getServiceName() != notification.getServiceName()) {
+ result = false;
+ }
+ if (servicePathRpcResult.getStatus() != notification.getStatus()) {
+ result = false;
+ }
+ if (servicePathRpcResult.getStatusMessage() != notification.getStatusMessage()) {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.service;
+
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.servicehandler.MappingConstraints;
+import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.RoutingConstraintsSp;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraints;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraints;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PCEServiceWrapper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PCEServiceWrapper.class);
+
+ private final PathComputationService pathComputationService;
+
+ public PCEServiceWrapper(PathComputationService pathComputationService) {
+ this.pathComputationService = pathComputationService;
+ }
+
+ public PathComputationRequestOutput performPCE(ServiceCreateInput serviceCreateInput, boolean reserveResource) {
+ MappingConstraints mappingConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
+ serviceCreateInput.getSoftConstraints());
+ mappingConstraints.serviceToServicePathConstarints();
+ PathComputationRequestInput pathComputationRequestInput =
+ createPceRequestInput(serviceCreateInput, mappingConstraints.getServicePathHardConstraints(),
+ mappingConstraints.getServicePathSoftConstraints(), reserveResource);
+ LOG.debug("Calling path computation.");
+ PathComputationRequestOutput pathComputationRequestOutput
+ = this.pathComputationService.pathComputationRequest(pathComputationRequestInput);
+ LOG.debug("Path computation done.");
+ return pathComputationRequestOutput;
+ }
+
+ private PathComputationRequestInput createPceRequestInput(ServiceCreateInput serviceCreateInput,
+ HardConstraints hardConstraints,
+ SoftConstraints softConstraints,
+ Boolean reserveResource) {
+ LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
+ + "requests");
+ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
+ if (serviceCreateInput.getSdncRequestHeader() != null) {
+ serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
+ }
+ return new PathComputationRequestInputBuilder()
+ .setServiceName(serviceCreateInput.getServiceName())
+ .setResourceReserve(reserveResource)
+ .setServiceHandlerHeader(serviceHandlerHeader.build())
+ .setHardConstraints(hardConstraints)
+ .setSoftConstraints(softConstraints)
+ .setPceMetric(RoutingConstraintsSp.PceMetric.TEMetric)
+ .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceCreateInput.getServiceAEnd()))
+ .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceCreateInput.getServiceZEnd()))
+ .build();
+ }
+
+ private CancelResourceReserveInput mappingCancelResourceReserve(String serviceName,
+ SdncRequestHeader sdncRequestHeader) {
+ LOG.debug("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
+ + "requests");
+ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
+ if (sdncRequestHeader != null) {
+ serviceHandlerHeader.setRequestId(sdncRequestHeader.getRequestId());
+ }
+ CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder()
+ .setServiceName(serviceName)
+ .setServiceHandlerHeader(serviceHandlerHeader.build());
+ return cancelResourceReserveInput.build();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.service;
+
+import java.util.Optional;
+import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
+
+/**
+ * OpenROADM Service operations API providing basic operations on services.
+ */
+public interface ServiceDataStoreOperations {
+
+ /**
+ * initialize services DataStore.
+ */
+ void initialize();
+
+ /**
+ * get service by name.
+ *
+ * @param serviceName
+ * unique name of the service
+ * @return Optional of Services
+ */
+ Optional<Services> getService(String serviceName);
+
+ /**
+ * deleteService service by name.
+ *
+ * @param serviceName
+ * unique name of the service
+ * @return result of Delete operation
+ */
+ OperationResult deleteService(String serviceName);
+
+ /**
+ * modifyService service attributes.
+ *
+ * @param serviceName
+ * unique name of the service
+ * @param operationalState
+ * operational state of service
+ * @param administrativeState
+ * administrative state of service
+ * @return result of modifyService operation
+ */
+ OperationResult modifyService(String serviceName, State operationalState, State administrativeState);
+
+ /**
+ * create new service entry.
+ *
+ * @param serviceCreateInput
+ * serviceCreateInput data for creation of service
+ * @param outputFromPce
+ * output from pce request which is used as input for creating of service.
+ * @return result of createService operation
+ */
+ OperationResult createService(ServiceCreateInput serviceCreateInput, PathComputationRequestOutput outputFromPce);
+
+ /**
+ * create new servicePath entry.
+ *
+ * @param serviceCreateInput
+ * serviceCreateInput data for creation of service
+ * @param outputFromPce
+ * output from pce request which is used as input for creating of service.
+ * @return result of createServicePath operation
+ */
+ OperationResult createServicePath(ServiceCreateInput serviceCreateInput,
+ PathComputationRequestOutput outputFromPce);
+
+ /**
+ * deleteServicePath by name.
+ *
+ * @param serviceName
+ * unique name of the service
+ * @return result of Delete operation
+ */
+ OperationResult deleteServicePath(String serviceName);
+
+ /**
+ * All actions (createService|modifyService|deleteService) combined.
+ * This method exists only for backwards compatibility. It will be deleted once refactoring is done.
+ *
+ * @param serviceName
+ * unique name of the service
+ * @param input ServiceCreateInput data
+ * @param output PathComputationRequestOutput data
+ * @param choice 0:modify, 1:delete, 2:write
+ * @return result of createService, deleteService, or modifyService operation
+ */
+ @Deprecated
+ String writeOrModifyOrDeleteServiceList(String serviceName, ServiceCreateInput input,
+ PathComputationRequestOutput output, int choice);
+
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.service;
+
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathList;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceDataStoreOperationsImpl.class);
+ private static final String SUCCESSFUL_MESSAGE = "Successful";
+
+ private DataBroker dataBroker;
+
+ public ServiceDataStoreOperationsImpl(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
+ @Override
+ public void initialize() {
+ try {
+ LOG.info("initializing service registry");
+ WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<ServiceList> iid = InstanceIdentifier.create(ServiceList.class);
+ ServiceList initialRegistry = new ServiceListBuilder().build();
+ transaction.put(LogicalDatastoreType.OPERATIONAL, iid, initialRegistry);
+ Future<Void> future = transaction.submit();
+ future.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("init failed: {}", e.getMessage());
+ }
+ }
+
+ @Override
+ public Optional<Services> getService(String serviceName) {
+ try {
+ ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction();
+ InstanceIdentifier<Services> iid = InstanceIdentifier
+ .create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
+ Future<com.google.common.base.Optional<Services>> future
+ = readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
+ return future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil();
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("Reading service {} failed:", serviceName, e);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public OperationResult deleteService(String serviceName) {
+ LOG.debug("Deleting '{}' Service", serviceName);
+ try {
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+ .child(Services.class, new ServicesKey(serviceName));
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
+ writeTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to delete service " + serviceName + " from Service List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
+ @Override
+ public OperationResult modifyService(String serviceName, State operationalState, State administrativeState) {
+ LOG.debug("Modifying '{}' Service", serviceName);
+ Optional<Services> readService = getService(serviceName);
+ if (readService.isPresent()) {
+ try {
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+ .child(Services.class, new ServicesKey(serviceName));
+ Services services = new ServicesBuilder(readService.get())
+ .setOperationalState(operationalState)
+ .setAdministrativeState(administrativeState)
+ .build();
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, services);
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to modify service " + serviceName + " from Service List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ } else {
+ String message = "Service " + serviceName + " is not present!";
+ LOG.warn(message);
+ return OperationResult.failed(message);
+ }
+ }
+
+ @Override
+ public OperationResult createService(ServiceCreateInput serviceCreateInput,
+ PathComputationRequestOutput outputFromPce) {
+ LOG.debug("Writing '{}' Service", serviceCreateInput.getServiceName());
+ try {
+ InstanceIdentifier<Services> iid = InstanceIdentifier
+ .create(ServiceList.class).child(Services.class,
+ new ServicesKey(serviceCreateInput.getServiceName()));
+ Services service = ModelMappingUtils.mappingServices(serviceCreateInput, null, outputFromPce);
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
+ @Override
+ public OperationResult createServicePath(ServiceCreateInput serviceCreateInput,
+ PathComputationRequestOutput outputFromPce) {
+ LOG.debug("Writing '{}' Service", serviceCreateInput.getServiceName());
+ try {
+ InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier
+ .create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceCreateInput.getServiceName()));
+ ServicePaths servicePath = ModelMappingUtils.mappingServicePaths(serviceCreateInput, null, outputFromPce);
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, servicePathsIID, servicePath);
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to create servicePath " + serviceCreateInput.getServiceName()
+ + " to ServicePath List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
+ @Override
+ public OperationResult deleteServicePath(String serviceName) {
+ InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier.create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceName));
+ LOG.debug("Deleting service from {}", servicePathsIID);
+ WriteTransaction servicePathsWriteTx = this.dataBroker.newWriteOnlyTransaction();
+ servicePathsWriteTx.delete(LogicalDatastoreType.OPERATIONAL, servicePathsIID);
+ try {
+ servicePathsWriteTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ String message = "Unable to delete service path " + serviceName;
+ LOG.error(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
+ /*
+ * Write or Modify or Delete Service from/to SreviceList.
+ *
+ * @param serviceName
+ * Name of service
+ * @param input
+ * ServiceCreateInput
+ * @param output
+ * PathComputationRequestOutput
+ * @param choice
+ * 0 - Modify 1 - Delete 2 - Write
+ * @return String operations result, null if ok or not otherwise
+ */
+ @Deprecated
+ @Override
+ public String writeOrModifyOrDeleteServiceList(String serviceName, ServiceCreateInput input,
+ PathComputationRequestOutput output, int choice) {
+ LOG.debug("WriteOrModifyOrDeleting '{}' Service",serviceName);
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ String result = null;
+ Optional<Services> readService = getService(serviceName);
+ if (readService.isPresent()) {
+ /*
+ * Modify / Delete Service.
+ */
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
+ new ServicesKey(serviceName));
+ ServicesBuilder service = new ServicesBuilder(readService.get());
+
+ String action = null;
+ switch (choice) {
+ case 0: /* Modify. */
+ LOG.debug("Modifying '{}' Service", serviceName);
+ service.setOperationalState(State.InService).setAdministrativeState(State.InService);
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build());
+ action = "modifyService";
+ break;
+
+ case 1: /* Delete */
+ LOG.debug("Deleting '{}' Service", serviceName);
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
+ action = "deleteService";
+ break;
+
+ default:
+ LOG.debug("No choice found");
+ break;
+
+ }
+ try {
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.error("Failed to {} service from Service List", action, e);
+ result = "Failed to " + action + " service from Service List";
+ }
+ } else {
+ if (choice == 2) { /* Write Service */
+ LOG.debug("Writing '{}' Service", serviceName);
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
+ new ServicesKey(serviceName));
+
+ Services service = ModelMappingUtils.mappingServices(input, null, output);
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
+ try {
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ result = null;
+ } catch (InterruptedException | TimeoutException | ExecutionException e) {
+ LOG.error("Failed to createService service to Service List", e);
+ result = "Failed to createService service to Service List";
+ }
+ } else {
+ LOG.info("Service is not present ! ");
+ result = "Service is not present ! ";
+ }
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.servicehandler.validation;
+
+import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.validation.checks.CheckCoherencyHardSoft;
+import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
+import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
+import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerTxRxCheck;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ServiceCreateValidation {
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceCreateValidation.class);
+
+ public static OperationResult validateServiceCreateRequest(ServiceCreateInput input) {
+ /*
+ * Upon receipt of service
+ * -create RPC, service header and sdnc
+ * -request header compliancy are verified.
+ */
+ LOG.debug("checking Service Compliancy ...");
+ try {
+ String serviceNmame = input.getServiceName();
+ SdncRequestHeader sdncRequestHeader = input.getSdncRequestHeader();
+ ConnectionType conType = input.getConnectionType();
+ ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
+ serviceNmame, sdncRequestHeader, conType, RpcActions.ServiceCreate, true, true);
+ if (serviceHandlerCheckResult.hasPassed()) {
+ LOG.debug("Service request compliant !");
+ } else {
+ return OperationResult.failed(serviceHandlerCheckResult.getMessage());
+ }
+ /*
+ * If compliant, service-request parameters are verified in order to
+ * check if there is no missing parameter that prevents calculating
+ * a path and implement a service.
+ */
+ LOG.debug("checking Tx/Rx Info for AEnd ...");
+ ComplianceCheckResult txrxCheckAEnd = ServicehandlerTxRxCheck.check(input.getServiceAEnd(),
+ ServiceEndpointType.SERVICEAEND);
+ if (txrxCheckAEnd.hasPassed()) {
+ LOG.debug("Tx/Rx Info for AEnd checked !");
+ } else {
+ return OperationResult.failed(txrxCheckAEnd.getMessage());
+ }
+
+ LOG.debug("checking Tx/Rx Info for ZEnd ...");
+ ComplianceCheckResult txrxCheckZEnd = ServicehandlerTxRxCheck.check(input.getServiceZEnd(),
+ ServiceEndpointType.SERVICEZEND);
+ if (txrxCheckZEnd.hasPassed()) {
+ LOG.debug("Tx/Rx Info for ZEnd checked");
+ /*
+ * If OK, common-id is verified in order to see if there is
+ * no routing policy provided. If yes, the routing
+ * constraints of the policy are recovered and coherency
+ * with hard/soft constraints provided in the input of the
+ * RPC.
+ */
+ } else {
+ return OperationResult.failed(txrxCheckZEnd.getMessage());
+ }
+
+ if (input.getCommonId() != null) {
+ LOG.debug("Common-id specified");
+ // Check coherency with hard/soft constraints
+ if (CheckCoherencyHardSoft.check(input.getHardConstraints(), input.getSoftConstraints())) {
+ LOG.debug("hard/soft constraints coherent !");
+ } else {
+ return OperationResult.failed("hard/soft constraints are not coherent !");
+ }
+ } else {
+ LOG.warn("Common-id not specified !");
+ }
+ } catch (NullPointerException e) {
+ LOG.error("one of input parameter is null ",e);
+ OperationResult.failed("one of input parameter is null.");
+ }
+ return OperationResult.ok("Validation successful.");
+ }
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.transportpce.servicehandler;
+package org.opendaylight.transportpce.servicehandler.validation.checks;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
import org.slf4j.LoggerFactory;
/**
- * Class to check coherency between hard and soft constraints.
- *
- * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
+ * Class to check coherency between hard and soft constraints.
*
*/
public class CheckCoherencyHardSoft {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(CheckCoherencyHardSoft.class);
- /** Hard Constraints. */
- private HardConstraints hard;
- /** Soft Constraints. */
- private SoftConstraints soft;
- public CheckCoherencyHardSoft(HardConstraints hard, SoftConstraints soft) {
- this.hard = hard;
- this.soft = soft;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(CheckCoherencyHardSoft.class);
/**
* function to check coherency between hard and soft constraints.
* @return <code> true </code> if coherent
* <code> false </code> else
*/
- public boolean check() {
+ public static boolean check(HardConstraints hard, SoftConstraints soft) {
boolean result = false;
if (hard != null && soft != null) {
- /**
+ /*
* Check coherency with hard/soft constraints
* hard/soft include/exclude coherency
*
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.validation.checks;
+
+public class ComplianceCheckResult {
+
+ private boolean passed;
+ private String message;
+
+ public ComplianceCheckResult(boolean result) {
+ this.passed = result;
+ this.message = "";
+ }
+
+ public ComplianceCheckResult(boolean passed, String message) {
+ this.passed = passed;
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public boolean hasPassed() {
+ return passed;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.validation.checks;
+
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class for checking service sdnc-request-header compliancy.
+ *
+ */
+public class ServicehandlerCompliancyCheck {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerCompliancyCheck.class);
+
+ /**
+ * Check if a String is not null and not equal to void.
+ *
+ * @param value
+ * String value
+ * @return true if String ok false if not
+ */
+ public static boolean checkString(String value) {
+ return ((value != null) && (value.compareTo("") != 0));
+ }
+
+ /**
+ * Check Compliancy of Service request.
+ *
+ * @param contype
+ * Boolean to check connection Type
+ * @param sndcRequest
+ * Boolean to check sndcRequestHeader
+ *
+ * @return true if String ok false if not
+ */
+ public static ComplianceCheckResult check(String serviceName, SdncRequestHeader sdncRequestHeader,
+ ConnectionType conType, RpcActions action,
+ Boolean contype, Boolean sndcRequest) {
+ boolean result = true;
+ String message = "";
+ if (!checkString(serviceName)) {
+ result = false;
+ message = "Service Name is not set";
+ } else if (contype && (conType == null)) {
+ result = false;
+ message = "Service ConnectionType is not set";
+ }
+ if (sndcRequest) {
+ if (sdncRequestHeader != null) {
+ RpcActions serviceAction = sdncRequestHeader.getRpcAction();
+ String requestId = sdncRequestHeader.getRequestId();
+ if (!checkString(requestId)) {
+ result = false;
+ message = "Service sdncRequestHeader 'request-id' is not set";
+ LOG.debug(message);
+ } else if (serviceAction != null) {
+ if (serviceAction.compareTo(action) != 0) {
+ result = false;
+ message = "Service sdncRequestHeader rpc-action '" + serviceAction + "' not equal to '"
+ + action.name() + "'";
+ }
+ } else {
+ result = false;
+ message = "Service sndc-request-header 'rpc-action' is not set ";
+ }
+
+ } else {
+ result = false;
+ message = "Service sndc-request-header is not set ";
+ }
+ }
+ LOG.debug(message);
+ return new ComplianceCheckResult(result, message);
+ }
+
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.transportpce.servicehandler;
+package org.opendaylight.transportpce.servicehandler.validation.checks;
+import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection;
/**
* Class for checking missing info on Tx/Rx for A/Z end.
*
- * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
*/
public class ServicehandlerTxRxCheck {
- /** Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerTxRxCheck.class);
- /** ServiceEndpoint. */
- private ServiceEndpoint serviceEnd;
- /** Response message from procedure. */
- private String message;
- /** type serviceEndpoint : serviceAEnd / serviceZEnd. */
- private String service = null;
- /**
- * ServicehandlerTxRxCheck class constructor.
- *
- * @param endPoint
- * ServiceEndpoint
- * @param value
- * Integer to define ServiceAEND/ZEND
- */
- public ServicehandlerTxRxCheck(ServiceEndpoint endPoint, int value) {
- this.serviceEnd = endPoint;
- this.setMessage("");
- if (value > 0) {
- service = MyEndpoint.forValue(value).name();
- }
- }
+ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerTxRxCheck.class);
/**
* Check if a String is not null and not equal to ''.
* String value
* @return true if String ok false if not
*/
- public Boolean checkString(String value) {
- Boolean result = false;
- if (value != null && value.compareTo("") != 0) {
- result = true;
- }
- return result;
-
+ public static boolean checkString(String value) {
+ return ((value != null) && (value.compareTo("") != 0));
}
/**
* port info
* @return true if String ok false if not
*/
- public Boolean checkPort(Port port) {
- Boolean result = false;
+ public static boolean checkPort(Port port) {
+ boolean result = false;
if (port != null) {
String portDeviceName = port.getPortDeviceName();
String portType = port.getPortType();
}
}
return result;
-
}
/**
* lgx info
* @return true if String ok false if not
*/
- public Boolean checkLgx(Lgx lgx) {
- Boolean result = false;
+ public static boolean checkLgx(Lgx lgx) {
+ boolean result = false;
if (lgx != null) {
String lgxDeviceName = lgx.getLgxDeviceName();
String lgxPortName = lgx.getLgxPortName();
*
* @return <code>true</code> if check is ok <code>false</code> else
*/
- public boolean checkTxOrRxInfo(TxDirection txDirection, RxDirection rxDirection) {
- Boolean result = true;
+ public static ComplianceCheckResult checkTxOrRxInfo(TxDirection txDirection, RxDirection rxDirection) {
+ boolean result = true;
+ String message = "";
if (txDirection != null) {
if (!checkPort(txDirection.getPort())) {
result = false;
result = false;
message = "Service TxDirection is not correctly set";
}
- return result;
+ return new ComplianceCheckResult(result, message);
}
/**
*
* @return true if String ok false if not
*/
- public Boolean check() {
- Boolean result = true;
+ public static ComplianceCheckResult check(ServiceEndpoint serviceEnd, ServiceEndpointType endpointType) {
+ boolean result = true;
+ String message = "";
if (serviceEnd != null) {
- Long serviceRate = serviceEnd.getServiceRate();
- ServiceFormat serviceformat = serviceEnd.getServiceFormat();
- String clli = serviceEnd.getClli();
- if (serviceRate != null && serviceRate <= 0) {
- result = false;
- message = "Service " + service + " rate is not set";
- LOG.debug(message);
- } else if (serviceformat == null) {
- result = false;
- message = "Service " + service + " format is not set";
- LOG.debug(message);
- } else if (!checkString(clli)) {
- result = false;
- message = "Service" + service + " clli format is not set";
- LOG.debug(message);
- } else {
- if (!checkTxOrRxInfo(serviceEnd.getTxDirection(), serviceEnd.getRxDirection())) {
+ try {
+ Long serviceRate = serviceEnd.getServiceRate();
+ ServiceFormat serviceformat = serviceEnd.getServiceFormat();
+ String clli = serviceEnd.getClli();
+ if ((serviceRate == null) || (serviceRate <= 0)) {
+ result = false;
+ message = "Service " + endpointType + " rate is not set";
+ LOG.debug(message);
+ } else if (serviceformat == null) {
result = false;
+ message = "Service " + endpointType + " format is not set";
+ LOG.debug(message);
+ } else if (!checkString(clli)) {
+ result = false;
+ message = "Service" + endpointType + " clli format is not set";
+ LOG.debug(message);
+ } else {
+ ComplianceCheckResult complianceCheckResult
+ = checkTxOrRxInfo(serviceEnd.getTxDirection(), serviceEnd.getRxDirection());
+ if (!complianceCheckResult.hasPassed()) {
+ result = false;
+ message = complianceCheckResult.getMessage();
+ }
}
+ } catch (NullPointerException e) {
+ message = "Service " + endpointType + " rate, format or clli is not set";
+ LOG.error(message, e);
+ return new ComplianceCheckResult(false, message);
}
} else {
result = false;
- message = service + " is not set";
+ message = endpointType + " is not set";
LOG.debug(message);
}
- return result;
-
- }
-
- public static void main(String[] args) {
-
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
+ return new ComplianceCheckResult(result, message);
}
}
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2017 Orange and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
-
-Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="rpcRegistry"
- interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
-
- <reference id="dataBroker"
- interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
- odl:type="default" />
-
- <reference id="notificationPublishService"
- interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
- odl:type="default" />
-
- <reference id="notificationService"
- interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"
- odl:type="default" />
-
- <bean id="provider"
- class="org.opendaylight.transportpce.servicehandler.impl.ServicehandlerProvider"
- init-method="init" destroy-method="close">
- <argument ref="rpcRegistry" />
- <argument ref="dataBroker" />
- <argument ref="notificationPublishService" />
- <argument ref="notificationService"/>
- </bean>
-</blueprint>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!-- vi: set et smarttab sw=4 tabstop=4: -->\r
+<!--\r
+Copyright © 2017 Orange and others. All rights reserved.\r
+\r
+This program and the accompanying materials are made available under the\r
+terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+and is available at http://www.eclipse.org/legal/epl-v10.html\r
+\r
+Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange\r
+-->\r
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
+ odl:use-default-for-reference-types="true">\r
+\r
+ <reference id="rpcRegistry"\r
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>\r
+\r
+ <reference id="dataBroker"\r
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"\r
+ odl:type="default" />\r
+\r
+ <reference id="notificationService"\r
+ interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"\r
+ odl:type="default" />\r
+\r
+ <reference id="pathComputationService"\r
+ interface="org.opendaylight.transportpce.pce.service.PathComputationService"/>\r
+\r
+ <reference id="rendererServiceOperations"\r
+ interface="org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations" />\r
+\r
+ <bean id="provider"\r
+ class="org.opendaylight.transportpce.servicehandler.impl.ServicehandlerProvider"\r
+ init-method="init" destroy-method="close">\r
+ <argument ref="rpcRegistry" />\r
+ <argument ref="dataBroker" />\r
+ <argument ref="notificationService" />\r
+ <argument ref="pathComputationService" />\r
+ <argument ref="rendererServiceOperations" />\r
+ </bean>\r
+\r
+</blueprint>\r