SH RPC temp-service-create/delete 11/78611/2
authorMartial COULIBALY <martial.coulibaly@gfi.fr>
Tue, 20 Nov 2018 16:34:31 +0000 (17:34 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Mon, 10 Dec 2018 17:24:57 +0000 (17:24 +0000)
Handle missing RPC in Service Handler :
- temporary-service-create
- temporary-service-delete

Change-Id: Iff6db6a135a0a6a608572e3b4ba8713bf57e4631
JIRA: TRNSPRTPCE-53
Signed-off-by: Martial COULIBALY <martial.coulibaly@gfi.fr>
15 files changed:
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperations.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/validation/ServiceCreateValidation.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/validation/checks/ServicehandlerCompliancyCheck.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtilsTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/ServiceCreateValidationTest.java
tests/SH_stubs.diff
tests/transportpce_tests/test_servicehandler.py

index 08bdfe3ea4c97f27623f1c2733ee977014f9be09..2bc8c957a4af96af47d4d3066785ddf4b1708be4 100644 (file)
@@ -32,6 +32,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 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.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutputBuilder;
+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.TempServiceDeleteOutputBuilder;
 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.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraintsBuilder;
@@ -55,7 +61,7 @@ public final class ModelMappingUtils {
     private ModelMappingUtils() {
     }
 
-    public static ServiceImplementationRequestInput createServiceImplementationRequest(ServiceCreateInput input,
+    public static ServiceImplementationRequestInput createServiceImplementationRequest(ServiceInput input,
             PathComputationRequestOutput pceResponse) {
         ServiceImplementationRequestInputBuilder serviceImplementationRequestInputBuilder =
                 new ServiceImplementationRequestInputBuilder();
@@ -100,13 +106,12 @@ public final class ModelMappingUtils {
         return serviceImplementationRequestInputBuilder.build();
     }
 
-
     public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-        .ServiceDeleteInput createServiceDeleteInput(ServiceDeleteInput serviceDeleteInput) {
+        .ServiceDeleteInput createServiceDeleteInput(ServiceInput serviceInput) {
         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder();
-        builder.setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
+        builder.setServiceName(serviceInput.getServiceName());
         builder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
-                .setRequestId(serviceDeleteInput.getSdncRequestHeader().getRequestId()).build());
+                .setRequestId(serviceInput.getSdncRequestHeader().getRequestId()).build());
         return builder.build();
     }
 
@@ -119,8 +124,8 @@ public final class ModelMappingUtils {
         return builder.build();
     }
 
-    public static ServiceAEnd createServiceAEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
-            .service.create.input.ServiceAEnd serviceAEnd) {
+    public static ServiceAEnd createServiceAEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types
+            .rev161014.ServiceEndpoint serviceAEnd) {
         ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder();
         serviceAEndBuilder.setClli(serviceAEnd.getClli());
         serviceAEndBuilder.setNodeId(serviceAEnd.getNodeId());
@@ -131,8 +136,8 @@ public final class ModelMappingUtils {
         return serviceAEndBuilder.build();
     }
 
-    public static ServiceZEnd createServiceZEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
-            .service.create.input.ServiceZEnd serviceZEnd) {
+    public static ServiceZEnd createServiceZEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types
+            .rev161014.ServiceEndpoint serviceZEnd) {
         ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder();
         serviceZEndBuilder.setClli(serviceZEnd.getClli());
         serviceZEndBuilder.setNodeId(serviceZEnd.getNodeId());
@@ -172,6 +177,17 @@ public final class ModelMappingUtils {
         return RpcResultBuilder.success(output).buildFuture();
     }
 
+    public static ListenableFuture<RpcResult<TempServiceDeleteOutput>> createDeleteServiceReply(
+            TempServiceDeleteInput input, String finalAck, String message, String responseCode) {
+        ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(finalAck).setResponseMessage(message).setResponseCode(responseCode);
+        builder.setRequestId(null);
+        ConfigurationResponseCommon configurationResponseCommon = builder.build();
+        TempServiceDeleteOutput output = new TempServiceDeleteOutputBuilder()
+                .setConfigurationResponseCommon(configurationResponseCommon).build();
+        return RpcResultBuilder.success(output).buildFuture();
+    }
+
     public static ListenableFuture<RpcResult<ServiceCreateOutput>> createCreateServiceReply(ServiceCreateInput input,
             String finalAck, String message, String responseCode) {
         ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
@@ -188,6 +204,22 @@ public final class ModelMappingUtils {
         return RpcResultBuilder.success(output.build()).buildFuture();
     }
 
+    public static ListenableFuture<RpcResult<TempServiceCreateOutput>> createCreateServiceReply(
+            TempServiceCreateInput 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);
+        }
+        TempServiceCreateOutputBuilder output =
+                new TempServiceCreateOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon.build())
+                        .setResponseParameters(responseParameters.build());
+        return RpcResultBuilder.success(output.build()).buildFuture();
+    }
+
     public static ListenableFuture<RpcResult<ServiceRerouteOutput>> createRerouteServiceReply(ServiceRerouteInput input,
             String finalAckYes, String message, RpcStatus status) {
         ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
@@ -198,18 +230,6 @@ public final class ModelMappingUtils {
         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) {
         org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd aend = null;
@@ -230,13 +250,12 @@ public final class ModelMappingUtils {
                     .setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader())
                     .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();
+            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())
+            service.setServiceName(serviceReconfigureInput.getServiceName()).setAdministrativeState(State.OutOfService)
+                    .setOperationalState(State.OutOfService).setCommonId(serviceReconfigureInput.getCommonId())
                     .setConnectionType(serviceReconfigureInput.getConnectionType())
                     .setCustomer(serviceReconfigureInput.getCustomer())
                     .setCustomerContact(serviceReconfigureInput.getCustomerContact())
@@ -247,58 +266,68 @@ public final class ModelMappingUtils {
         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) {
+    public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+        .Services mappingServices(TempServiceCreateInput tempServiceCreateInput) {
+        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;
+        org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+            .ServicesBuilder service = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+                .service.list.ServicesBuilder();
+        aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                .ServiceAEndBuilder(tempServiceCreateInput.getServiceAEnd()).build();
+        zend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                .ServiceZEndBuilder(tempServiceCreateInput.getServiceZEnd()).build();
+        service.setServiceName(tempServiceCreateInput.getCommonId()).setAdministrativeState(State.OutOfService)
+                .setOperationalState(State.OutOfService).setCommonId(tempServiceCreateInput.getCommonId())
+                .setConnectionType(tempServiceCreateInput.getConnectionType())
+                .setCustomer(tempServiceCreateInput.getCustomer())
+                .setCustomerContact(tempServiceCreateInput.getCustomerContact())
+                .setHardConstraints(tempServiceCreateInput.getHardConstraints())
+                .setSoftConstraints(tempServiceCreateInput.getSoftConstraints())
+                .setSdncRequestHeader(tempServiceCreateInput.getSdncRequestHeader())
+                .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
+        return service.build();
+    }
+
+    public static ServicePaths mappingServicePaths(ServiceInput serviceInput, PathComputationRequestOutput output) {
         ServicePathsBuilder servicePathBuilder = new ServicePathsBuilder();
-        if (serviceCreateInput != null) {
+        if (serviceInput != null) {
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                 .service.types.rev171016.service.path.ServiceAEndBuilder serviceAEnd =
                 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                     .service.types.rev171016.service.path.ServiceAEndBuilder();
-            serviceAEnd.setServiceFormat(serviceCreateInput.getServiceAEnd().getServiceFormat())
-                .setServiceRate(serviceCreateInput.getServiceAEnd().getServiceRate())
-                .setClli(serviceCreateInput.getServiceAEnd().getClli())
-                .setNodeId(serviceCreateInput.getServiceAEnd().getNodeId())
+            serviceAEnd.setServiceFormat(serviceInput.getServiceAEnd().getServiceFormat())
+                .setServiceRate(serviceInput.getServiceAEnd().getServiceRate())
+                .setClli(serviceInput.getServiceAEnd().getClli())
+                .setNodeId(serviceInput.getServiceAEnd().getNodeId())
                 .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
                 .rev171016.service.endpoint.sp.TxDirectionBuilder()
-                .setPort(serviceCreateInput.getServiceAEnd().getTxDirection().getPort()).build())
+                .setPort(serviceInput.getServiceAEnd().getTxDirection().getPort()).build())
                 .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
                 .rev171016.service.endpoint.sp.RxDirectionBuilder()
-                .setPort(serviceCreateInput.getServiceAEnd().getRxDirection().getPort()).build());
+                .setPort(serviceInput.getServiceAEnd().getRxDirection().getPort()).build());
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                 .service.types.rev171016.service.path.ServiceZEndBuilder serviceZEnd =
                 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                     .service.types.rev171016.service.path.ServiceZEndBuilder();
-            serviceZEnd.setServiceFormat(serviceCreateInput.getServiceZEnd().getServiceFormat())
-                .setServiceRate(serviceCreateInput.getServiceZEnd().getServiceRate())
-                .setClli(serviceCreateInput.getServiceZEnd().getClli())
-                .setNodeId(serviceCreateInput.getServiceZEnd().getNodeId())
+            serviceZEnd.setServiceFormat(serviceInput.getServiceZEnd().getServiceFormat())
+                .setServiceRate(serviceInput.getServiceZEnd().getServiceRate())
+                .setClli(serviceInput.getServiceZEnd().getClli())
+                .setNodeId(serviceInput.getServiceZEnd().getNodeId())
                 .setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
                 .rev171016.service.endpoint.sp.TxDirectionBuilder()
-                .setPort(serviceCreateInput.getServiceZEnd().getTxDirection().getPort()).build())
+                .setPort(serviceInput.getServiceZEnd().getTxDirection().getPort()).build())
                 .setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
                 .rev171016.service.endpoint.sp.RxDirectionBuilder()
-                .setPort(serviceCreateInput.getServiceZEnd().getRxDirection().getPort()).build());
+                .setPort(serviceInput.getServiceZEnd().getRxDirection().getPort()).build());
             servicePathBuilder.setServiceAEnd(serviceAEnd.build());
             servicePathBuilder.setServiceZEnd(serviceZEnd.build());
-            MappingConstraints mapConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
-                    serviceCreateInput.getSoftConstraints());
+            MappingConstraints mapConstraints = new MappingConstraints(serviceInput.getHardConstraints(),
+                    serviceInput.getSoftConstraints());
             mapConstraints.serviceToServicePathConstarints();
             if (mapConstraints.getServicePathHardConstraints() != null) {
                 HardConstraintsBuilder hardConstraintBuilder = new HardConstraintsBuilder();
-                hardConstraintBuilder.setCustomerCode(serviceCreateInput.getHardConstraints().getCustomerCode());
+                hardConstraintBuilder.setCustomerCode(serviceInput.getHardConstraints().getCustomerCode());
                 hardConstraintBuilder
                         .setCoRoutingOrGeneral(mapConstraints.getServicePathHardConstraints().getCoRoutingOrGeneral());
                 servicePathBuilder.setHardConstraints(hardConstraintBuilder.build());
@@ -310,9 +339,9 @@ public final class ModelMappingUtils {
                         .setCoRoutingOrGeneral(mapConstraints.getServicePathSoftConstraints().getCoRoutingOrGeneral());
                 servicePathBuilder.setSoftConstraints(softConstraintBuilder.build());
             }
-            servicePathBuilder.setServicePathName(serviceCreateInput.getServiceName());
+            servicePathBuilder.setServicePathName(serviceInput.getServiceName());
             servicePathBuilder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
-                    .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId()).build());
+                    .setRequestId(serviceInput.getSdncRequestHeader().getRequestId()).build());
             PathDescriptionBuilder pathDescBuilder =
                     new PathDescriptionBuilder(output.getResponseParameters().getPathDescription());
             servicePathBuilder.setPathDescription(pathDescBuilder.build());
diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java
new file mode 100644 (file)
index 0000000..ae7e337
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * 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.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.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.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+
+/**
+ * Super class of {@link ServiceCreateInput} and {@link TempServiceCreateInput}.
+ *
+ * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
+ *
+ */
+public class ServiceInput {
+    private String serviceName;
+    private String commonId;
+    private ConnectionType connectionType;
+    private SdncRequestHeader sdncRequestHeader;
+    private HardConstraints hardConstraints;
+    private SoftConstraints softConstraints;
+    private ServiceEndpoint serviceAEnd;
+    private ServiceEndpoint serviceZEnd;
+    private String customer;
+    private String customerContact;
+
+    public ServiceInput(TempServiceCreateInput tempServiceCreateInput) {
+        setServiceName(tempServiceCreateInput.getCommonId());
+        setCommonId(tempServiceCreateInput.getCommonId());
+        setConnectionType(tempServiceCreateInput.getConnectionType());
+        setSdncRequestHeader(tempServiceCreateInput.getSdncRequestHeader());
+        setHardConstraints(tempServiceCreateInput.getHardConstraints());
+        setSoftConstraints(tempServiceCreateInput.getSoftConstraints());
+        setServiceAEnd(tempServiceCreateInput.getServiceAEnd());
+        setServiceZEnd(tempServiceCreateInput.getServiceZEnd());
+        setCustomer(tempServiceCreateInput.getCustomer());
+        setCustomerContact(tempServiceCreateInput.getCustomerContact());
+    }
+
+    public ServiceInput(ServiceCreateInput serviceCreateInput) {
+        setServiceName(serviceCreateInput.getServiceName());
+        setCommonId(serviceCreateInput.getCommonId());
+        setConnectionType(serviceCreateInput.getConnectionType());
+        setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader());
+        setHardConstraints(serviceCreateInput.getHardConstraints());
+        setSoftConstraints(serviceCreateInput.getSoftConstraints());
+        setServiceAEnd(serviceCreateInput.getServiceAEnd());
+        setServiceZEnd(serviceCreateInput.getServiceZEnd());
+        setCustomer(serviceCreateInput.getCustomer());
+        setCustomerContact(serviceCreateInput.getCustomerContact());
+    }
+
+    public ServiceInput(ServiceDeleteInput serviceDeleteInput) {
+        setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
+        setSdncRequestHeader(serviceDeleteInput.getSdncRequestHeader());
+    }
+
+    public ServiceInput(TempServiceDeleteInput tempServiceDeleteInput) {
+        String comId = tempServiceDeleteInput.getCommonId();
+        setServiceName(comId);
+        setCommonId(comId);
+        setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId(comId).build());
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getCommonId() {
+        return commonId;
+    }
+
+    public void setCommonId(String commonId) {
+        this.commonId = commonId;
+    }
+
+    public ConnectionType getConnectionType() {
+        return connectionType;
+    }
+
+    public void setConnectionType(ConnectionType connectionType) {
+        this.connectionType = connectionType;
+    }
+
+    public SdncRequestHeader getSdncRequestHeader() {
+        return sdncRequestHeader;
+    }
+
+    public void setSdncRequestHeader(SdncRequestHeader sdncRequestHeader) {
+        this.sdncRequestHeader = sdncRequestHeader;
+    }
+
+    public ServiceEndpoint getServiceAEnd() {
+        return serviceAEnd;
+    }
+
+    public void setServiceAEnd(ServiceEndpoint serviceAEnd) {
+        this.serviceAEnd = serviceAEnd;
+    }
+
+    public ServiceEndpoint getServiceZEnd() {
+        return serviceZEnd;
+    }
+
+    public void setServiceZEnd(ServiceEndpoint serviceZEnd) {
+        this.serviceZEnd = serviceZEnd;
+    }
+
+    public HardConstraints getHardConstraints() {
+        return hardConstraints;
+    }
+
+    public void setHardConstraints(HardConstraints hardConstraints) {
+        this.hardConstraints = hardConstraints;
+    }
+
+    public SoftConstraints getSoftConstraints() {
+        return softConstraints;
+    }
+
+    public void setSoftConstraints(SoftConstraints softConstraints) {
+        this.softConstraints = softConstraints;
+    }
+
+    public String getCustomer() {
+        return customer;
+    }
+
+    public void setCustomer(String customer) {
+        this.customer = customer;
+    }
+
+    public String getCustomerContact() {
+        return customerContact;
+    }
+
+    public void setCustomerContact(String customerContact) {
+        this.customerContact = customerContact;
+    }
+}
index ccd0f143ad785b3a4a30cb6ff1242a371b7e070d..44ef53a17c0fc6b1e62c71be6994dac6bde24205 100644 (file)
@@ -8,17 +8,20 @@
 package org.opendaylight.transportpce.servicehandler.impl;
 
 import com.google.common.util.concurrent.ListenableFuture;
+
 import java.time.OffsetDateTime;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 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.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
@@ -101,7 +104,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
         LOG.info("RPC service creation received");
         // Validation
-        OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
+                new ServiceInput(input), RpcActions.ServiceCreate);
         if (! validationResult.isSuccess()) {
             LOG.warn("Aborting service create because validation of service create request failed: {}",
                     validationResult.getResultMessage());
@@ -130,8 +134,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                     ResponseCodes.RESPONSE_FAILED);
         }
 
-        OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(input,
-            pceResponse);
+        OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
+                new ServiceInput(input), pceResponse);
         if (!operationServicePathSaveResult.isSuccess()) {
             String message = "Service Path not updated in datastore !";
             LOG.info(message);
@@ -140,7 +144,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         }
 
         ServiceImplementationRequestInput serviceImplementationRequest =
-                ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
+                ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
         ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
             .serviceImplementation(serviceImplementationRequest);
         if (ResponseCodes.RESPONSE_OK
@@ -214,7 +218,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
         LOG.debug("Service '{}' present in datastore !", serviceName);
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-            .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
+            .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(input));
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
             .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
 
@@ -362,14 +367,147 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
     @Override
     public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
-        // TODO Auto-generated method stub
-        return null;
+        LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
+        String message = "";
+
+        /*
+         * Upon receipt of service-deleteService RPC, service header and sdnc-request
+         * header compliancy are verified.
+         */
+        LOG.info("checking Service Compliancy ...");
+        ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
+                null, null, RpcActions.ServiceDelete, false, false);
+        if (serviceHandlerCheckResult.hasPassed()) {
+            LOG.info("Service compliant !");
+        } else {
+            LOG.info("Service is not compliant !");
+            return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+                    "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
+        }
+
+        //Check presence of service to be deleted
+        String commonId = input.getCommonId();
+        LOG.info("service common-id : {}", commonId);
+        try {
+            Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
+            if (!service.isPresent()) {
+                message = "Service '" + commonId + "' does not exist in datastore";
+                LOG.error(message);
+                return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+                        message, ResponseCodes.RESPONSE_FAILED);
+            }
+        } catch (NullPointerException e) {
+            LOG.info("failed to get service '{}' from datastore : ", commonId, e);
+        }
+
+        LOG.debug("Service '{}' present in datastore !", commonId);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(input));
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .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);
+        }
+
+        OperationResult deleteServicePathOperationResult =
+                this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
+        if (!deleteServicePathOperationResult.isSuccess()) {
+            LOG.warn("Service path was not removed from datastore!");
+        }
+
+        OperationResult deleteServiceOperationResult =
+                this.serviceDataStoreOperations.deleteTempService(input.getCommonId());
+        if (!deleteServiceOperationResult.isSuccess()) {
+            LOG.warn("Service was not removed from datastore!");
+        }
+
+        return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+                "Service delete was successful!", ResponseCodes.RESPONSE_OK);
     }
 
     @Override
     public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
-        // TODO Auto-generated method stub
-        return null;
+        LOG.info("RPC temp service creation received");
+        // Validation
+        OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
+                new ServiceInput(input), RpcActions.TempServiceCreate);
+        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);
+        }
+
+        // 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);
+        }
+
+        LOG.info("PCE calculation done OK {}", pceResponseCode);
+
+        OperationResult operationResult = this.serviceDataStoreOperations.createTempService(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);
+        }
+
+        OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
+                new ServiceInput(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);
+        }
+
+        ServiceImplementationRequestInput serviceImplementationRequest =
+                ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
+        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.modifyTempService(input.getCommonId(), 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 {
+            String message = "Service rendering has failed !";
+            LOG.warn(message);
+
+            OperationResult deleteServicePathOperationResult =
+                    this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
+            if (!deleteServicePathOperationResult.isSuccess()) {
+                LOG.warn("Service path was not removed from datastore!");
+            }
+
+            OperationResult deleteServiceOperationResult =
+                    this.serviceDataStoreOperations.deleteService(input.getCommonId());
+            if (!deleteServiceOperationResult.isSuccess()) {
+                LOG.warn("Service was not removed from datastore!");
+            }
+
+            return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+                    ResponseCodes.RESPONSE_FAILED);
+        }
     }
 
 }
index 3d06f96f9bf3923b633892ab144ec7c5239258e1..8fc869ef0d74ccc2fac20081fe1193045fedf2b2 100644 (file)
@@ -15,8 +15,10 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev17
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
+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.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp.PceMetric;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraints;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.SoftConstraints;
@@ -35,12 +37,29 @@ public class PCEServiceWrapper {
     }
 
     public PathComputationRequestOutput performPCE(ServiceCreateInput serviceCreateInput, boolean reserveResource) {
-        MappingConstraints mappingConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
-                serviceCreateInput.getSoftConstraints());
+        return performPCE(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints(),
+                serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader(),
+                serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd(), reserveResource);
+    }
+
+    public PathComputationRequestOutput performPCE(TempServiceCreateInput tempServiceCreateInput,
+            boolean reserveResource) {
+        return performPCE(tempServiceCreateInput.getHardConstraints(), tempServiceCreateInput.getSoftConstraints(),
+                tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader(),
+                tempServiceCreateInput.getServiceAEnd(), tempServiceCreateInput.getServiceZEnd(), reserveResource);
+    }
+
+    private PathComputationRequestOutput performPCE(org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains
+            .rev161014.routing.constraints.HardConstraints hardConstraints, org.opendaylight.yang.gen.v1.http.org
+            .openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints softConstraints,
+            String serviceName, SdncRequestHeader sdncRequestHeader, ServiceEndpoint serviceAEnd,
+            ServiceEndpoint serviceZEnd, boolean reserveResource) {
+        MappingConstraints mappingConstraints = new MappingConstraints(hardConstraints, softConstraints);
         mappingConstraints.serviceToServicePathConstarints();
         PathComputationRequestInput pathComputationRequestInput =
-                createPceRequestInput(serviceCreateInput, mappingConstraints.getServicePathHardConstraints(),
-                mappingConstraints.getServicePathSoftConstraints(), reserveResource);
+                createPceRequestInput(serviceName, sdncRequestHeader,mappingConstraints.getServicePathHardConstraints(),
+                        mappingConstraints.getServicePathSoftConstraints(), reserveResource, serviceAEnd,
+                        serviceZEnd);
         LOG.debug("Calling path computation.");
         PathComputationRequestOutput pathComputationRequestOutput
                 = this.pathComputationService.pathComputationRequest(pathComputationRequestInput);
@@ -48,26 +67,26 @@ public class PCEServiceWrapper {
         return pathComputationRequestOutput;
     }
 
-    private PathComputationRequestInput createPceRequestInput(ServiceCreateInput serviceCreateInput,
-                                                          HardConstraints hardConstraints,
-                                                          SoftConstraints softConstraints,
-                                                          Boolean reserveResource) {
+    private PathComputationRequestInput createPceRequestInput(String serviceName,
+            SdncRequestHeader serviceHandler, HardConstraints hardConstraints,
+            SoftConstraints softConstraints, Boolean reserveResource, ServiceEndpoint serviceAEnd,
+            ServiceEndpoint serviceZEnd) {
         LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
                 + "requests");
         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
-        if (serviceCreateInput.getSdncRequestHeader() != null) {
-            serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
+        if (serviceHandler != null) {
+            serviceHandlerHeader.setRequestId(serviceHandler.getRequestId());
         }
         return new PathComputationRequestInputBuilder()
-                .setServiceName(serviceCreateInput.getServiceName())
-                .setResourceReserve(reserveResource)
-                .setServiceHandlerHeader(serviceHandlerHeader.build())
-                .setHardConstraints(hardConstraints)
-                .setSoftConstraints(softConstraints)
-                .setPceMetric(PceMetric.TEMetric)
-                .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceCreateInput.getServiceAEnd()))
-                .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceCreateInput.getServiceZEnd()))
-                .build();
+            .setServiceName(serviceName)
+            .setResourceReserve(reserveResource)
+            .setServiceHandlerHeader(serviceHandlerHeader.build())
+            .setHardConstraints(hardConstraints)
+            .setSoftConstraints(softConstraints)
+            .setPceMetric(PceMetric.TEMetric)
+            .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceAEnd))
+            .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceZEnd))
+            .build();
     }
 
     private CancelResourceReserveInput mappingCancelResourceReserve(String serviceName,
index 90a883c49390738185738aa464dcffebe3f2aaac..7109b9a52fc4295f4b44ebda9dafa02a8dd8c82b 100644 (file)
@@ -9,9 +9,11 @@ package org.opendaylight.transportpce.servicehandler.service;
 
 import java.util.Optional;
 import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.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.TempServiceCreateInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
 
 /**
@@ -33,6 +35,16 @@ public interface ServiceDataStoreOperations {
      */
     Optional<Services> getService(String serviceName);
 
+    /**
+     * get temp service by common-id.
+     *
+     * @param commonId
+     *   unique common-id of the service
+     * @return Optional of Services
+     */
+    Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+        .Services> getTempService(String commonId);
+
     /**
      * deleteService service by name.
      *
@@ -42,6 +54,15 @@ public interface ServiceDataStoreOperations {
      */
     OperationResult deleteService(String serviceName);
 
+    /**
+     * deleteService service by common-id.
+     *
+     * @param commonId
+     *   unique common-id of the service
+     * @return result of Delete operation
+     */
+    OperationResult deleteTempService(String commonId);
+
     /**
      * modifyService service attributes.
      *
@@ -55,6 +76,16 @@ public interface ServiceDataStoreOperations {
      */
     OperationResult modifyService(String serviceName, State operationalState, State administrativeState);
 
+    /**
+     * modify Temp Service.
+     *
+     * @param commonId unique common-id of the service
+     * @param operationalState operational state of service
+     * @param administrativeState administrative state of service
+     * @return result of modifyTempService operation
+     */
+    OperationResult modifyTempService(String commonId, State operationalState, State administrativeState);
+
     /**
      * create new service entry.
      *
@@ -69,13 +100,24 @@ public interface ServiceDataStoreOperations {
     /**
      * create new servicePath entry.
      *
-     * @param serviceCreateInput
-     *   serviceCreateInput data for creation of service
+     * @param serviceInput
+     *   ServiceInput 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,
+    OperationResult createServicePath(ServiceInput serviceInput, PathComputationRequestOutput outputFromPce);
+
+    /**
+     * create new Temp service entry.
+     *
+     * @param tempServiceCreateInput
+     *   tempServiceCreateInput data for creation of service
+     * @param outputFromPce
+     *   output from pce request which is used as input for creating of service.
+     * @return result of createTempService operation
+     */
+    OperationResult createTempService(TempServiceCreateInput tempServiceCreateInput,
         PathComputationRequestOutput outputFromPce);
 
     /**
index 372b7b801be95041298ab4d436c9b61c1e8caddc..a2a849929c8ccf3ce371dacb828907689cded6f8 100644 (file)
@@ -12,6 +12,7 @@ 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;
@@ -19,11 +20,15 @@ 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.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.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.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceListBuilder;
 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;
@@ -35,10 +40,8 @@ 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) {
@@ -47,6 +50,11 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
 
     @Override
     public void initialize() {
+        initializeServiceList();
+        initializeTempServiceList();
+    }
+
+    private void initializeServiceList() {
         try {
             LOG.info("initializing service registry");
             WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
@@ -60,14 +68,47 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         }
     }
 
+    private void initializeTempServiceList() {
+        try {
+            LOG.info("initializing temp service registry");
+            WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
+            InstanceIdentifier<TempServiceList> iid = InstanceIdentifier.create(TempServiceList.class);
+            TempServiceList initialRegistry = new TempServiceListBuilder().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);
+            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 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+        .Services> getTempService(String serviceName) {
+        try {
+            ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction();
+            InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                .Services> iid = InstanceIdentifier.create(TempServiceList.class).child(org.opendaylight.yang.gen.v1
+                        .http.org.openroadm.service.rev161014.temp.service.list.Services.class,
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                            .ServicesKey(serviceName));
+            Future<com.google.common.base.Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+                .temp.service.list.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);
@@ -80,8 +121,8 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         LOG.debug("Deleting '{}' Service", serviceName);
         try {
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
-            InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
-                    .child(Services.class, new ServicesKey(serviceName));
+            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);
@@ -92,6 +133,26 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         }
     }
 
+    @Override
+    public OperationResult deleteTempService(String commonId) {
+        LOG.debug("Deleting '{}' Service", commonId);
+        try {
+            WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+            InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                .Services> iid = InstanceIdentifier.create(TempServiceList.class).child(org.opendaylight.yang.gen.v1
+                        .http.org.openroadm.service.rev161014.temp.service.list.Services.class,
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                            .ServicesKey(commonId));
+            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 " + commonId + " 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);
@@ -101,10 +162,8 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
                 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();
+                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);
@@ -120,14 +179,46 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         }
     }
 
+    @Override
+    public OperationResult modifyTempService(String serviceName, State operationalState, State administrativeState) {
+        LOG.debug("Modifying '{}' Temp Service", serviceName);
+        Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+            .Services> readService = getTempService(serviceName);
+        if (readService.isPresent()) {
+            try {
+                WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+                InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                    .Services> iid = InstanceIdentifier.create(TempServiceList.class)
+                        .child(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                                .Services.class, new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+                                    .temp.service.list.ServicesKey(serviceName));
+                org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                    .Services services = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+                        .service.list.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 temp service " + serviceName + " from Temp Service List";
+                LOG.warn(message, e);
+                return OperationResult.failed(message);
+            }
+        } else {
+            String message = "Temp 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()));
+            InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+                    .child(Services.class, new ServicesKey(serviceCreateInput.getServiceName()));
             Services service = ModelMappingUtils.mappingServices(serviceCreateInput, null);
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
             writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
@@ -141,21 +232,42 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
     }
 
     @Override
-    public OperationResult createServicePath(ServiceCreateInput serviceCreateInput,
+    public OperationResult createTempService(TempServiceCreateInput tempServiceCreateInput,
             PathComputationRequestOutput outputFromPce) {
-        LOG.debug("Writing '{}' Service", serviceCreateInput.getServiceName());
+        LOG.debug("Writing '{}' Temp Service", tempServiceCreateInput.getCommonId());
+        try {
+            InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                .Services> iid = InstanceIdentifier.create(TempServiceList.class)
+                    .child(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                            .Services.class, new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+                                .service.list.ServicesKey(tempServiceCreateInput.getCommonId()));
+            org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+                .Services service = ModelMappingUtils.mappingServices(tempServiceCreateInput);
+            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 Temp service " + tempServiceCreateInput.getCommonId()
+                + " to TempService List";
+            LOG.warn(message, e);
+            return OperationResult.failed(message);
+        }
+    }
+
+    @Override
+    public OperationResult createServicePath(ServiceInput serviceInput, PathComputationRequestOutput outputFromPce) {
+        LOG.debug("Writing '{}' ServicePath ", serviceInput.getServiceName());
         try {
-            InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier
-                    .create(ServicePathList.class)
-                    .child(ServicePaths.class, new ServicePathsKey(serviceCreateInput.getServiceName()));
-            ServicePaths servicePath =  ModelMappingUtils.mappingServicePaths(serviceCreateInput, null, outputFromPce);
+            InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier.create(ServicePathList.class)
+                    .child(ServicePaths.class, new ServicePathsKey(serviceInput.getServiceName()));
+            ServicePaths servicePath = ModelMappingUtils.mappingServicePaths(serviceInput, 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";
+            String message = "Failed to create servicePath " + serviceInput.getCommonId() + " to ServicePath List";
             LOG.warn(message, e);
             return OperationResult.failed(message);
         }
@@ -181,21 +293,21 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
     /*
      * 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
+     * @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);
+            PathComputationRequestOutput output, int choice) {
+        LOG.debug("WriteOrModifyOrDeleting '{}' Service", serviceName);
         WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
         String result = null;
         Optional<Services> readService = getService(serviceName);
@@ -203,29 +315,25 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             /*
              * Modify / Delete Service.
              */
-            InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
-                    new ServicesKey(serviceName));
+            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. */
+                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 */
+                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);
@@ -236,9 +344,8 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         } else {
             if (choice == 2) { /* Write Service */
                 LOG.debug("Writing '{}' Service", serviceName);
-                InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
-                        new ServicesKey(serviceName));
-
+                InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+                        .child(Services.class, new ServicesKey(serviceName));
                 Services service = ModelMappingUtils.mappingServices(input, null);
                 writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
                 try {
@@ -255,5 +362,4 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         }
         return result;
     }
-
 }
index 630fb67c67d5dece88af05ad9151ca4719317757..167525fe89ba416738b1559c909bc91808372730 100644 (file)
@@ -10,6 +10,8 @@
 package org.opendaylight.transportpce.servicehandler.stub;
 
 import com.google.common.util.concurrent.ListenableFuture;
+
+import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
@@ -49,10 +51,11 @@ public final class StubrendererImpl {
         } catch (InterruptedException e) {
             message = "deleting service failed !";
             LOG.error("deleting service failed !", e);
-            responseCode = "500";
+            responseCode = ResponseCodes.RESPONSE_FAILED;
         }
+        responseCode = ResponseCodes.RESPONSE_OK;
         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator("yes")
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
                 .setResponseCode(responseCode)
                 .setResponseMessage(message);
@@ -73,10 +76,11 @@ public final class StubrendererImpl {
         } catch (InterruptedException e) {
             message = "implementing service failed !";
             LOG.error(message);
-            responseCode = "500";
+            responseCode = ResponseCodes.RESPONSE_FAILED;
         }
+        responseCode = ResponseCodes.RESPONSE_OK;
         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator("yes")
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
                 .setResponseCode(responseCode)
                 .setResponseMessage(message);
index 6d962aea0dcfdaa0ff12044ef150739cd985cfce..7b3e9cf1a15a629b43a9e2e511632035cc2f724e 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.transportpce.servicehandler.validation;
 
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.validation.checks.CheckCoherencyHardSoft;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
@@ -17,14 +18,13 @@ import org.opendaylight.transportpce.servicehandler.validation.checks.Servicehan
 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 final class ServiceCreateValidation {
     private static final Logger LOG = LoggerFactory.getLogger(ServiceCreateValidation.class);
 
-    public static OperationResult validateServiceCreateRequest(ServiceCreateInput input) {
+    public static OperationResult validateServiceCreateRequest(ServiceInput input, RpcActions rpcActions) {
         /*
          * Upon receipt of service
          * -create RPC, service header and sdnc
@@ -36,7 +36,7 @@ public final class ServiceCreateValidation {
             SdncRequestHeader sdncRequestHeader = input.getSdncRequestHeader();
             ConnectionType conType = input.getConnectionType();
             ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
-                    serviceNmame, sdncRequestHeader, conType, RpcActions.ServiceCreate, true, true);
+                    serviceNmame, sdncRequestHeader, conType, rpcActions, true, true);
             if (serviceHandlerCheckResult.hasPassed()) {
                 LOG.debug("Service request compliant !");
             } else {
index 24432ae577786d0520984722e47f7f81d3f9a37d..e8b38cb9842fe0f503e904ecd7a44180c67e3b81 100644 (file)
@@ -57,7 +57,7 @@ public final class ServicehandlerCompliancyCheck {
         String message = "";
         if (!checkString(serviceName)) {
             result = false;
-            message = "Service Name is not set";
+            message = "Service Name (common-id for Temp service) is not set";
         } else if (contype && (conType == null)) {
             result = false;
             message = "Service ConnectionType is not set";
index 5dbb939b6b7390c8e1118ab68a47ce8db0aca57d..ebc7294ce9f5f5d6f38c6494ae5e90a89cbd21cc 100644 (file)
@@ -101,8 +101,7 @@ public class ModelMappingUtilsTest extends AbstractTest {
 
     @Test
     public void mappingServicesPathNullServiceCreateInput() {
-        ServicePaths services = ModelMappingUtils.mappingServicePaths(null, null,
-            this.pathComputationRequestOutput);
+        ServicePaths services = ModelMappingUtils.mappingServicePaths(null, this.pathComputationRequestOutput);
         Assert.assertEquals(new ServicePathsBuilder().build(), services);
     }
 
index 561935a8db72e85242cf9feeb5765efe7160a4ab..bb9529952b331557b9d16fe881f12002beca85eb 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,6 +37,7 @@ import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
@@ -67,6 +69,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
 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.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+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.TempServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
 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;
@@ -131,7 +139,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
             .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -152,6 +160,40 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(0, output0.get().getErrors().size());
     }
 
+    @Test
+    public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
+        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+        PathComputationRequestOutput pathComputationRequestOutput =
+                new PathComputationRequestOutputBuilder(PceTestData.getPCE_simpletopology_test1_result((long) 5))
+                        .setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
+                .thenReturn(pathComputationRequestOutput);
+        Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
+                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
+                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+        ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
+        Mockito.when(
+                this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
+                .thenReturn(new ServiceImplementationRequestOutputBuilder()
+                        .setConfigurationResponseCommon(configurationResponseCommon2).build());
+        Mockito.when(this.serviceDataStoreOperationsMock.modifyTempService(serviceInput.getCommonId(), State.InService,
+                State.InService)).thenReturn(OperationResult.ok("successful"));
+        Future<RpcResult<TempServiceCreateOutput>> output0 =
+                this.serviceHandlerImplMock.tempServiceCreate(serviceInput);
+        Assert.assertNotNull(output0);
+        Assert.assertTrue(output0.get().isSuccessful());
+        Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
+                ResponseCodes.FINAL_ACK_YES, "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get()
+                .getResult());
+        Assert.assertEquals(0, output0.get().getErrors().size());
+    }
+
     @Test
     public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
         ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
@@ -159,7 +201,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         emptyServiceNameInput = builtInput.setServiceName("").build();
         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
                 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
-                        "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
     }
 
     @Test
@@ -169,7 +212,30 @@ public class ServiceHandlerImplTest extends AbstractTest {
         nullServiceNameInput = builtInput.setServiceName(null).build();
         Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
                 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
-                        "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
+    }
+
+    @Test
+    public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+        TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+        emptyServiceNameInput = builtInput.setCommonId("").build();
+        Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+                ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
+    }
+
+    @Test
+    public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+        TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+        emptyServiceNameInput = builtInput.setCommonId(null).build();
+        Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+                ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+                                "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
+                        .get().getResult());
     }
 
     @Test
@@ -576,7 +642,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class)))
                 .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
                         + " to ServicePath List"));
@@ -584,7 +650,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
                 ResponseCodes.FINAL_ACK_YES);
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
+        verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class));
     }
 
@@ -601,7 +667,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -634,7 +700,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -667,7 +733,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
@@ -702,7 +768,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
@@ -770,6 +836,28 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
     }
 
+    @Test
+    public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+        serviceDeleteInput = builder.setCommonId("").build();
+        TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+    }
+
+    @Test
+    public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+        serviceDeleteInput = builder.setCommonId(null).build();
+        TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+    }
+
     @Test
     public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
@@ -876,6 +964,17 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
     }
 
+    @Test
+    public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
+        TempServiceDeleteOutput result =
+                this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+    }
+
     @Test
     public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
 
@@ -883,7 +982,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
                 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
@@ -904,7 +1004,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
@@ -931,7 +1032,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
@@ -958,7 +1060,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
@@ -979,6 +1082,38 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
     }
 
+    @Test
+    public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
+
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+            .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+                    .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
+        Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
+        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+                .rev171017.ServiceDeleteOutputBuilder()
+                .setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
+        Mockito.when(this.serviceDataStoreOperationsMock
+                .deleteServicePath(serviceDeleteInput.getCommonId()))
+                .thenReturn(OperationResult.ok("success"));
+        Mockito.when(this.serviceDataStoreOperationsMock
+                .deleteTempService(serviceDeleteInput.getCommonId()))
+                .thenReturn(OperationResult.ok("success"));
+        TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
+                .getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
+    }
+
     @Test
     public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
 
@@ -1029,7 +1164,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
             .thenReturn(pathComputationRequestOutput);
         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
index 2006b4ce75748b3a9f7619536678f07545b88e4e..f6cc22b19d301bb932287bb55f3018fa67f3c7b0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.transportpce.servicehandler.utils;
 import java.time.OffsetDateTime;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
+
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResult;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResultBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.service.path.rpc.result.PathDescription;
@@ -18,6 +19,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev1
 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.ServiceFormat;
 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.endpoint.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
@@ -26,6 +29,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
@@ -48,26 +55,8 @@ public final class ServiceDataUtils {
             .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service
             .create.input.ServiceZEndBuilder()
             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
-            .setTxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.TxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
-            .setRxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.RxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection())
             .build();
 
         builtInput.setCommonId("commonId");
@@ -82,31 +71,42 @@ public final class ServiceDataUtils {
         return builtInput.build();
     }
 
+    public static TempServiceCreateInput buildTempServiceCreateInput() {
+
+        TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder();
+        org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
+            .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+            .temp.service.create.input.ServiceAEndBuilder()
+            .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection())
+            .build();
+        org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
+            .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+            .service.create.input.ServiceZEndBuilder()
+            .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection())
+            .build();
+
+        builtInput.setCommonId("commonId");
+        builtInput.setConnectionType(ConnectionType.Service);
+        builtInput.setCustomer("Customer");
+        builtInput.setServiceAEnd(serviceAEnd);
+        builtInput.setServiceZEnd(serviceZEnd);
+        builtInput.setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
+                .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
+
+        return builtInput.build();
+    }
+
     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
         .ServiceAEndBuilder getServiceAEndBuild() {
         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
             .ServiceAEndBuilder()
             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
-            .setTxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.TxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
-            .setRxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.RxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build());
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection());
     }
 
     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
@@ -114,26 +114,30 @@ public final class ServiceDataUtils {
         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
             .ServiceZEndBuilder()
             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
-            .setTxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.TxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
-            .setRxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.RxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build());
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection());
+    }
+
+    private static TxDirection getTxDirection() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
+                        .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
+                        .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
+                        .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
+                                .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
+                        .build();
+    }
+
+    private static RxDirection getRxDirection() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                .endpoint.RxDirectionBuilder()
+                .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                    .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                    .setPortSubSlot("port subslot").setPortType("port type").build())
+                .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                    .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                    .setLgxPortShelf("lgx port shelf").build())
+                        .build();
     }
 
     public static ServiceDeleteInput buildServiceDeleteInput() {
@@ -152,6 +156,12 @@ public final class ServiceDataUtils {
         return deleteInputBldr.build();
     }
 
+    public static TempServiceDeleteInput buildTempServiceDeleteInput() {
+        TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder();
+        deleteInputBldr.setCommonId("service 1");
+        return deleteInputBldr.build();
+    }
+
     public static ServiceRerouteInput buildServiceRerouteInput() {
         ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder();
         builder.setServiceName("service 1");
@@ -206,26 +216,8 @@ public final class ServiceDataUtils {
         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
             .ServiceAEndBuilder()
             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
-            .setTxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.TxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
-            .setRxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.RxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build());
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection());
     }
 
     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
@@ -233,26 +225,8 @@ public final class ServiceDataUtils {
         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
             .ServiceZEndBuilder()
             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
-            .setTxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.TxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build())
-            .setRxDirection(
-                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
-                    .endpoint.RxDirectionBuilder()
-                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
-                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
-                        .setPortSubSlot("port subslot").setPortType("port type").build())
-                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
-                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
-                        .setLgxPortShelf("lgx port shelf").build())
-                    .build());
+            .setTxDirection(getTxDirection())
+            .setRxDirection(getRxDirection());
     }
 
     private ServiceDataUtils() {
index 06958d2049ba6e887c3fe451365a17095846ae6b..e2a6eda38e97234144d0680f1fb4854b8d460fd4 100644 (file)
@@ -8,10 +8,13 @@
 package org.opendaylight.transportpce.servicehandler.validation;
 
 import java.util.Arrays;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRoutingBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraintsBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraintsBuilder;
@@ -25,7 +28,8 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfCommonIdNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setCommonId(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -49,7 +53,8 @@ public class ServiceCreateValidationTest {
                     .build())
                 .setCustomerCode(Arrays.asList("Some customer-code"))
                 .build()).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(false, result.isSuccess());
     }
 
@@ -57,7 +62,8 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfConstraintsNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setSoftConstraints(null).setHardConstraints(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -73,7 +79,8 @@ public class ServiceCreateValidationTest {
                     .build())
                 .setCustomerCode(Arrays.asList("Some customer-code"))
                 .build()).setHardConstraints(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -89,7 +96,8 @@ public class ServiceCreateValidationTest {
                     .build())
                 .setCustomerCode(Arrays.asList("Some customer-code"))
                 .build()).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 }
index bb26d8af2967ebed315ac92c78b70aea7c229b84..4a19db109840b90434c1f3f0d7fcecd043c9cbb3 100644 (file)
@@ -1,8 +1,8 @@
 diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-index ccd0f14..8219393 100644
+index 44ef53a..810f093 100644
 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
 +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-@@ -22,6 +22,7 @@ import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+@@ -25,6 +25,7 @@ import org.opendaylight.transportpce.servicehandler.ServiceInput;
  import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
  import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
  import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
@@ -10,7 +10,7 @@ index ccd0f14..8219393 100644
  import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
  import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
  import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
-@@ -84,6 +85,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -87,6 +88,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
      private DataBroker db;
      private ServiceDataStoreOperations serviceDataStoreOperations;
      private RendererServiceOperations rendererServiceOperations;
@@ -18,7 +18,7 @@ index ccd0f14..8219393 100644
      private PCEServiceWrapper pceServiceWrapper;
  
      //TODO: remove private request fields as they are in global scope
-@@ -92,6 +94,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -95,6 +97,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                                RendererServiceOperations rendererServiceOperations) {
          this.db = databroker;
          this.rendererServiceOperations = rendererServiceOperations;
@@ -26,46 +26,39 @@ index ccd0f14..8219393 100644
          this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
          this.serviceDataStoreOperations.initialize();
          this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
-@@ -141,8 +144,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -145,7 +148,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
  
          ServiceImplementationRequestInput serviceImplementationRequest =
-                 ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
+                 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
 -        ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
--            .serviceImplementation(serviceImplementationRequest);
 +        ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
-+                .serviceImplementation(serviceImplementationRequest);
+             .serviceImplementation(serviceImplementationRequest);
          if (ResponseCodes.RESPONSE_OK
                  .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
-             String message = "Service rendered successfully !";
-@@ -216,8 +219,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -221,7 +224,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+             .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+                     new ServiceInput(input));
          org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
-             .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
+-            .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
++            .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
+         if (!ResponseCodes.RESPONSE_OK
+                 .equals(output.getConfigurationResponseCommon().getResponseCode())) {
+@@ -406,7 +409,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+             .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+                     new ServiceInput(input));
          org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
 -            .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
--
 +            .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
          if (!ResponseCodes.RESPONSE_OK
                  .equals(output.getConfigurationResponseCommon().getResponseCode())) {
-             message = "Service delete failed!";
-diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-index 630fb67..2cc2bdf 100644
---- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-+++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-@@ -51,6 +51,8 @@ public final class StubrendererImpl {
-             LOG.error("deleting service failed !", e);
-             responseCode = "500";
-         }
-+        responseCode = "200";
-+        message = "Service deleted";
-         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                 .setAckFinalIndicator("yes")
-                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
-@@ -75,6 +77,8 @@ public final class StubrendererImpl {
-             LOG.error(message);
-             responseCode = "500";
-         }
-+        responseCode = "200";
-+        message = "Service implemented";
-         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                 .setAckFinalIndicator("yes")
-                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
+@@ -476,7 +479,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+         ServiceImplementationRequestInput serviceImplementationRequest =
+                 ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
+-        ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
++        ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
+             .serviceImplementation(serviceImplementationRequest);
+         if (ResponseCodes.RESPONSE_OK
+                 .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
index 51271fa15eaca92b625453cac681594ac84ea0be..44c46a1c8411aecb0b52abb97d30d216cfe22812 100644 (file)
@@ -627,7 +627,7 @@ class TransportPCEtesting(unittest.TestCase):
 #             'inService')
 #         time.sleep(1)
 
-    # Delete non existing service
+    # Delete  service
     def test_12_delete_service(self):
         url = ("{}/operations/org-openroadm-service:service-delete"
               .format(self.restconf_baseurl))
@@ -666,6 +666,267 @@ class TransportPCEtesting(unittest.TestCase):
         self.assertEqual(response.status_code, 404)
         time.sleep(1)
 
+    # Create Temp Service 'ASATT1234567' with correct parameters
+    def test_14_create_temp_service(self):
+        url = ("{}/operations/org-openroadm-service:temp-service-create"
+              .format(self.restconf_baseurl))
+        data = {
+            "input": {
+                "sdnc-request-header": {
+                    "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
+                    "rpc-action": "temp-service-create",
+                    "request-system-id": "appname",
+                    "notification-url": "http://localhost:8585/NotificationServer/notify"
+                },
+                "common-id": "ASATT1234567",
+                "connection-type": "infrastructure",
+                "service-a-end": {
+                    "service-rate": "100",
+                    "node-id": "ROADMA",
+                    "service-format": "Ethernet",
+                    "clli": "SNJSCAMCJP8",
+                    "tx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                            "lgx-port-name": "LGX Back.3",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "rx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                            "lgx-port-name": "LGX Back.4",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "optic-type": "gray"
+                },
+                "service-z-end": {
+                    "service-rate": "100",
+                    "node-id": "ROADMC",
+                    "service-format": "Ethernet",
+                    "clli": "SNJSCAMCJT4",
+                    "tx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                            "lgx-port-name": "LGX Back.29",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "rx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                            "lgx-port-name": "LGX Back.30",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "optic-type": "gray"
+                },
+                "due-date": "2016-11-28T00:00:01Z",
+                "operator-contact": "pw1234"
+            }
+        }
+        headers = {'content-type': 'application/json',
+        "Accept": "application/json"}
+        response = requests.request(
+            "POST", url, data=json.dumps(data), headers=headers,
+            auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Service rendered successfully !',
+            res['output']['configuration-response-common']['response-message'])
+        time.sleep(10)
+
+
+    # Create Temp Service not compliant with no common-id
+    def test_15_create_temp_service(self):
+        url = ("{}/operations/org-openroadm-service:temp-service-create"
+              .format(self.restconf_baseurl))
+        data = {
+            "input": {
+                "sdnc-request-header": {
+                    "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
+                    "rpc-action": "temp-service-create",
+                    "request-system-id": "appname",
+                    "notification-url": "http://localhost:8585/NotificationServer/notify"
+                },
+                "connection-type": "infrastructure",
+                "service-a-end": {
+                    "service-rate": "100",
+                    "node-id": "ROADMA",
+                    "service-format": "Ethernet",
+                    "clli": "SNJSCAMCJP8",
+                    "tx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                            "lgx-port-name": "LGX Back.3",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "rx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                            "lgx-port-name": "LGX Back.4",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "optic-type": "gray"
+                },
+                "service-z-end": {
+                    "service-rate": "100",
+                    "node-id": "ROADMC",
+                    "service-format": "Ethernet",
+                    "clli": "SNJSCAMCJT4",
+                    "tx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                            "lgx-port-name": "LGX Back.29",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "rx-direction": {
+                        "port": {
+                            "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                            "port-type": "router",
+                            "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
+                            "port-rack": "000000.00",
+                            "port-shelf": "00"
+                        },
+                        "lgx": {
+                            "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                            "lgx-port-name": "LGX Back.30",
+                            "lgx-port-rack": "000000.00",
+                            "lgx-port-shelf": "00"
+                        }
+                    },
+                    "optic-type": "gray"
+                },
+                "due-date": "2016-11-28T00:00:01Z",
+                "operator-contact": "pw1234"
+            }
+        }
+        headers = {'content-type': 'application/json',
+        "Accept": "application/json"}
+        response = requests.request(
+            "POST", url, data=json.dumps(data), headers=headers,
+            auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Service Name (common-id for Temp service) is not set',
+            res['output']['configuration-response-common']['response-message'])
+        time.sleep(5)
+
+    # Get 'ASATT1234567' temp service created
+    def test_16_get_temp_service(self):
+        url = ("{}/operational/org-openroadm-service:temp-service-list/services/ASATT1234567"
+              .format(self.restconf_baseurl))
+        headers = {'content-type': 'application/json',
+        "Accept": "application/json"}
+        response = requests.request(
+            "GET", url, headers=headers, auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertEqual(
+            res['services'][0]['administrative-state'],
+            'inService')
+        time.sleep(1)
+
+    # get non existing service
+    def test_17_get_temp_service(self):
+        url = ("{}/operational/org-openroadm-service:temp-service-list/services/test1"
+              .format(self.restconf_baseurl))
+        headers = {'content-type': 'application/json',
+        "Accept": "application/json"}
+        response = requests.request(
+            "GET", url, headers=headers, auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, 404)
+        time.sleep(1)
+
+    # Delete temp service
+    def test_18_delete_temp_service(self):
+        url = ("{}/operations/org-openroadm-service:temp-service-delete"
+              .format(self.restconf_baseurl))
+        data = {"input": {
+                "common-id": "ASATT1234567"
+            }
+        }
+        headers = {'content-type': 'application/json'}
+        response = requests.request(
+            "POST", url, data=json.dumps(data), headers=headers,
+            auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Service delete was successful!',
+            res['output']['configuration-response-common']['response-message'])
+        time.sleep(1)
+
+# Verify 'test' service deleted
+    def test_13_verify_temp_service_deleted(self):
+        url = ("{}/operational/org-openroadm-service:service-list/services/ASATT1234567"
+              .format(self.restconf_baseurl))
+        headers = {'content-type': 'application/json',
+        "Accept": "application/json"}
+        response = requests.request(
+            "GET", url, headers=headers, auth=('admin', 'admin'))
+        self.assertEqual(response.status_code, 404)
+        time.sleep(1)
+
 
 if __name__ == "__main__":
     unittest.main(verbosity=2)