From 88cd6993a331006572958e3846a5e1e6d2c44d19 Mon Sep 17 00:00:00 2001 From: Martial COULIBALY Date: Thu, 24 Jan 2019 16:29:21 +0100 Subject: [PATCH] reintroduce SP 1.6 in SH - Backport all changes to Service Path in the 1.6 version (Added container in path-description resources). - Add service-feasability-check rpc. - Add service-reconfigure rpc. JIRA: TRNSPRTPCE-44 Change-Id: Ibe6fc57115d2fd0c7dedc54211440727b288f7ed Signed-off-by: Martial COULIBALY --- .../servicehandler/ModelMappingUtils.java | 45 ++- .../servicehandler/ServiceInput.java | 66 +++- .../impl/ServicehandlerImpl.java | 68 +++- .../listeners/PceListenerImpl.java | 72 ++-- .../listeners/RendererListenerImpl.java | 1 - .../service/PCEServiceWrapper.java | 16 + .../impl/ServiceHandlerImplTest.java | 39 +- .../listeners/PceListenerImplTest.java | 11 + .../utils/ServiceDataUtils.java | 51 +++ .../transportpce_tests/test_servicehandler.py | 334 +++++++----------- 10 files changed, 454 insertions(+), 249 deletions(-) diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java index ae8d48e6f..c427b216a 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java @@ -30,7 +30,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.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; @@ -67,7 +72,11 @@ public final class ModelMappingUtils { PathDescription pathDescription) { ServiceImplementationRequestInputBuilder serviceImplementationRequestInputBuilder = new ServiceImplementationRequestInputBuilder(); - serviceImplementationRequestInputBuilder.setServiceName(input.getServiceName()); + if (input.isServiceReconfigure()) { + serviceImplementationRequestInputBuilder.setServiceName(input.getNewServiceName()); + } else { + serviceImplementationRequestInputBuilder.setServiceName(input.getServiceName()); + } org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.service.implementation .request.input.ServiceAEndBuilder serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.opendaylight .transportpce.renderer.rev171017.service.implementation.request.input.ServiceAEndBuilder(); @@ -124,6 +133,16 @@ public final class ModelMappingUtils { return builder.build(); } + public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput + createServiceDeleteInput(ServiceReconfigureInput serviceReconfigureInput) { + ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(); + String serviceName = serviceReconfigureInput.getServiceName(); + builder.setServiceName(serviceReconfigureInput.getServiceName()); + builder.setServiceHandlerHeader( + new ServiceHandlerHeaderBuilder().setRequestId(serviceName + "-reconfigure").build()); + return builder.build(); + } + public static ServiceAEnd createServiceAEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types .rev161014.ServiceEndpoint serviceAEnd) { ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder(); @@ -220,6 +239,30 @@ public final class ModelMappingUtils { return RpcResultBuilder.success(output.build()).buildFuture(); } + public static ListenableFuture> createCreateServiceReply( + ServiceFeasibilityCheckInput 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); + } + ServiceFeasibilityCheckOutputBuilder output = new ServiceFeasibilityCheckOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .setResponseParameters(responseParameters.build()); + return RpcResultBuilder.success(output.build()).buildFuture(); + } + + public static ListenableFuture> createCreateServiceReply( + ServiceReconfigureInput input, String message, RpcStatus rpcStatus) { + ServiceReconfigureOutputBuilder output = new ServiceReconfigureOutputBuilder() + .setStatus(rpcStatus) + .setStatusMessage(message); + return RpcResultBuilder.success(output.build()).buildFuture(); + } + public static ListenableFuture> createRerouteServiceReply(ServiceRerouteInput input, String finalAckYes, String message, RpcStatus status) { ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder() diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java index b8781c507..30b3cbf40 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServiceInput.java @@ -8,6 +8,7 @@ package org.opendaylight.transportpce.servicehandler; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.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; @@ -16,6 +17,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.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; @@ -30,6 +33,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service */ public class ServiceInput { private String serviceName; + private String newServiceName; private String commonId; private ConnectionType connectionType; private SdncRequestHeader sdncRequestHeader; @@ -39,6 +43,7 @@ public class ServiceInput { private ServiceEndpoint serviceZEnd; private String customer; private String customerContact; + private boolean serviceReconfigure; public ServiceInput(ServiceCreateInput serviceCreateInput) { setServiceName(serviceCreateInput.getServiceName()); @@ -51,11 +56,30 @@ public class ServiceInput { setServiceZEnd(serviceCreateInput.getServiceZEnd()); setCustomer(serviceCreateInput.getCustomer()); setCustomerContact(serviceCreateInput.getCustomerContact()); + setServiceReconfigure(false); + } + + public ServiceInput(ServiceReconfigureInput serviceReconfigureInput) { + setServiceName(serviceReconfigureInput.getServiceName()); + setNewServiceName(serviceReconfigureInput.getNewServiceName()); + setSdncRequestHeader(new SdncRequestHeaderBuilder() + .setRequestId(serviceReconfigureInput.getServiceName() + "-reconfigure") + .setRpcAction(RpcActions.ServiceReconfigure).build()); + setCommonId(serviceReconfigureInput.getCommonId()); + setConnectionType(serviceReconfigureInput.getConnectionType()); + setHardConstraints(serviceReconfigureInput.getHardConstraints()); + setSoftConstraints(serviceReconfigureInput.getSoftConstraints()); + setServiceAEnd(serviceReconfigureInput.getServiceAEnd()); + setServiceZEnd(serviceReconfigureInput.getServiceZEnd()); + setCustomer(serviceReconfigureInput.getCustomer()); + setCustomerContact(serviceReconfigureInput.getCustomerContact()); + setServiceReconfigure(true); } public ServiceInput(ServiceDeleteInput serviceDeleteInput) { setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()); setSdncRequestHeader(serviceDeleteInput.getSdncRequestHeader()); + setServiceReconfigure(false); } public ServiceInput(TempServiceCreateInput tempServiceCreateInput) { @@ -69,6 +93,21 @@ public class ServiceInput { setServiceZEnd(tempServiceCreateInput.getServiceZEnd()); setCustomer(tempServiceCreateInput.getCustomer()); setCustomerContact(tempServiceCreateInput.getCustomerContact()); + setServiceReconfigure(false); + } + + public ServiceInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) { + setServiceName(serviceFeasibilityCheckInput.getCommonId()); + setCommonId(serviceFeasibilityCheckInput.getCommonId()); + setConnectionType(serviceFeasibilityCheckInput.getConnectionType()); + setSdncRequestHeader(serviceFeasibilityCheckInput.getSdncRequestHeader()); + setHardConstraints(serviceFeasibilityCheckInput.getHardConstraints()); + setSoftConstraints(serviceFeasibilityCheckInput.getSoftConstraints()); + setServiceAEnd(serviceFeasibilityCheckInput.getServiceAEnd()); + setServiceZEnd(serviceFeasibilityCheckInput.getServiceZEnd()); + setCustomer(serviceFeasibilityCheckInput.getCustomer()); + setCustomerContact(serviceFeasibilityCheckInput.getCustomerContact()); + setServiceReconfigure(false); } public ServiceInput(TempServiceDeleteInput tempServiceDeleteInput) { @@ -76,10 +115,11 @@ public class ServiceInput { setServiceName(comId); setCommonId(comId); setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId(comId).build()); + setServiceReconfigure(false); } public ServiceCreateInput getServiceCreateInput() { - return new ServiceCreateInputBuilder().setServiceName(serviceName) + ServiceCreateInputBuilder serviceCreateInputBuilder = new ServiceCreateInputBuilder() .setCommonId(commonId) .setConnectionType(connectionType) .setSdncRequestHeader(sdncRequestHeader) @@ -88,7 +128,13 @@ public class ServiceInput { .setServiceAEnd(new ServiceAEndBuilder(serviceAEnd).build()) .setServiceZEnd(new ServiceZEndBuilder(serviceZEnd).build()) .setCustomer(customer) - .setCustomerContact(customerContact).build(); + .setCustomerContact(customerContact); + if (isServiceReconfigure()) { + serviceCreateInputBuilder.setServiceName(newServiceName); + } else { + serviceCreateInputBuilder.setServiceName(serviceName); + } + return serviceCreateInputBuilder.build(); } public TempServiceCreateInput getTempServiceCreateInput() { @@ -181,4 +227,20 @@ public class ServiceInput { public void setCustomerContact(String customerContact) { this.customerContact = customerContact; } + + public String getNewServiceName() { + return newServiceName; + } + + public void setNewServiceName(String newServiceName) { + this.newServiceName = newServiceName; + } + + public boolean isServiceReconfigure() { + return serviceReconfigure; + } + + public void setServiceReconfigure(boolean serviceReconfigure) { + this.serviceReconfigure = serviceReconfigure; + } } 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 b2fc9994a..47eb143de 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 @@ -200,12 +200,76 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { @Override public ListenableFuture> serviceFeasibilityCheck( ServiceFeasibilityCheckInput input) { - throw new UnsupportedOperationException("Not implemented yet"); + LOG.info("RPC service feasibility check received"); + // Validation + ServiceInput serviceInput = new ServiceInput(input); + OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput, + RpcActions.ServiceFeasibilityCheck); + if (! validationResult.isSuccess()) { + LOG.warn("Aborting service feasibility check because validation of service create request failed: {}", + validationResult.getResultMessage()); + return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, + validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED); + } + this.pceListenerImpl.setInput(new ServiceInput(input)); + this.pceListenerImpl.setServiceReconfigure(false); + this.pceListenerImpl.setServiceFeasiblity(true); + this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations); + this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations); + this.rendererListenerImpl.setServiceInput(new ServiceInput(input)); + LOG.info("Commencing PCE"); + PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true); + if (output != null) { + LOG.info("Service compliant, serviceFeasibilityCheck in progress..."); + ConfigurationResponseCommon common = output.getConfigurationResponseCommon(); + return ModelMappingUtils.createCreateServiceReply(input, common.getAckFinalIndicator(), + common.getResponseMessage(), common.getResponseCode()); + } else { + return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, + "PCE calculation failed", ResponseCodes.RESPONSE_FAILED); + } } @Override public ListenableFuture> serviceReconfigure(ServiceReconfigureInput input) { - throw new UnsupportedOperationException("Not implemented yet"); + LOG.info("RPC service reconfigure received"); + String message = ""; + Optional servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName()); + if (servicesObject.isPresent()) { + LOG.info("Service '{}' is present", input.getServiceName()); + OperationResult validationResult = ServiceCreateValidation + .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure); + if (!validationResult.isSuccess()) { + LOG.warn("Aborting service reconfigure because validation of service create request failed: {}", + validationResult.getResultMessage()); + return ModelMappingUtils.createCreateServiceReply(input, validationResult.getResultMessage(), + RpcStatus.Failed); + } + this.pceListenerImpl.setInput(new ServiceInput(input)); + this.pceListenerImpl.setServiceReconfigure(true); + this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations); + this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations); + this.rendererListenerImpl.setServiceInput(new ServiceInput(input)); + 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.rendererServiceWrapper.performRenderer(serviceDeleteInput, + ServiceNotificationTypes.ServiceDeleteResult); + if (output != null) { + LOG.info("Service compliant, service reconfigure in progress..."); + ConfigurationResponseCommon common = output.getConfigurationResponseCommon(); + return ModelMappingUtils.createCreateServiceReply(input, common.getResponseMessage(), + RpcStatus.Successful); + } else { + return ModelMappingUtils.createCreateServiceReply(input, "Renderer service delete failed !", + RpcStatus.Successful); + } + } else { + LOG.error("Service '{}' is not present", input.getServiceName()); + message = "Service '" + input.getServiceName() + "' is not present"; + return ModelMappingUtils.createCreateServiceReply(input, message, RpcStatus.Failed); + } } @Override diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java index 0d5b266d1..ed38fdef2 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java @@ -39,6 +39,7 @@ public class PceListenerImpl implements TransportpcePceListener { private ServiceInput input; private Boolean serviceReconfigure; private Boolean tempService; + private Boolean serviceFeasiblity; public PceListenerImpl(RendererServiceOperations rendererServiceOperations, PathComputationService pathComputationService, NotificationPublishService notificationPublishService, @@ -49,6 +50,7 @@ public class PceListenerImpl implements TransportpcePceListener { setServiceReconfigure(false); setInput(null); setTempService(false); + setServiceFeasiblity(false); } @Override @@ -67,40 +69,44 @@ public class PceListenerImpl implements TransportpcePceListener { .setAToZDirection(servicePathRpcResult.getPathDescription().getAToZDirection()) .setZToADirection(servicePathRpcResult.getPathDescription().getZToADirection()).build(); LOG.info("PathDescription gets : {}", pathDescription); - if (input == null) { - LOG.error("Input is null !"); - return; - } - OperationResult operationResult = null; - if (tempService) { - operationResult = this.serviceDataStoreOperations - .createTempService(input.getTempServiceCreateInput()); - if (!operationResult.isSuccess()) { - LOG.error("Temp Service not created in datastore !"); + if (!serviceFeasiblity) { + if (input == null) { + LOG.error("Input is null !"); + return; } - } else { - operationResult = this.serviceDataStoreOperations - .createService(input.getServiceCreateInput()); - if (!operationResult.isSuccess()) { - LOG.error("Service not created in datastore !"); + OperationResult operationResult = null; + if (tempService) { + operationResult = this.serviceDataStoreOperations + .createTempService(input.getTempServiceCreateInput()); + if (!operationResult.isSuccess()) { + LOG.error("Temp Service not created in datastore !"); + } + } else { + operationResult = this.serviceDataStoreOperations + .createService(input.getServiceCreateInput()); + if (!operationResult.isSuccess()) { + LOG.error("Service not created in datastore !"); + } } + ResponseParameters responseParameters = new ResponseParametersBuilder() + .setPathDescription(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c + ._interface.service.types.rev171016.response.parameters.sp.response + .parameters.PathDescriptionBuilder(pathDescription).build()) + .build(); + PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder() + .setResponseParameters(responseParameters).build(); + OperationResult operationServicePathSaveResult = + this.serviceDataStoreOperations.createServicePath(input, pceResponse); + if (!operationServicePathSaveResult.isSuccess()) { + LOG.error("Service Path not created in datastore !"); + } + ServiceImplementationRequestInput serviceImplementationRequest = + ModelMappingUtils.createServiceImplementationRequest(input, pathDescription); + LOG.info("Sending serviceImplementation request : {}", serviceImplementationRequest); + this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest); + } else { + LOG.warn("service-feasibility-check RPC "); } - ResponseParameters responseParameters = new ResponseParametersBuilder() - .setPathDescription(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c - ._interface.service.types.rev171016.response.parameters.sp.response - .parameters.PathDescriptionBuilder(pathDescription).build()) - .build(); - PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder() - .setResponseParameters(responseParameters).build(); - OperationResult operationServicePathSaveResult = - this.serviceDataStoreOperations.createServicePath(input, pceResponse); - if (!operationServicePathSaveResult.isSuccess()) { - LOG.error("Service Path not created in datastore !"); - } - ServiceImplementationRequestInput serviceImplementationRequest = - ModelMappingUtils.createServiceImplementationRequest(input, pathDescription); - LOG.info("Sending serviceImplementation request : {}", serviceImplementationRequest); - this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest); } else { LOG.error("'PathDescription' parameter is null "); return; @@ -189,4 +195,8 @@ public class PceListenerImpl implements TransportpcePceListener { this.tempService = tempService; } + public void setServiceFeasiblity(Boolean serviceFeasiblity) { + this.serviceFeasiblity = serviceFeasiblity; + } + } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index 492b73cfe..8adb6d1b9 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -109,7 +109,6 @@ public class RendererListenerImpl implements TransportpceRendererListener { return; } break; - default: break; } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java index c274c3b2f..3aaea4a9c 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java @@ -36,6 +36,7 @@ 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.configuration.response.common.ConfigurationResponseCommonBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.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; @@ -88,6 +89,21 @@ public class PCEServiceWrapper { } } + public PathComputationRequestOutput performPCE(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput, + boolean reserveResource) { + LOG.info("performing PCE ..."); + if (validateParams(serviceFeasibilityCheckInput.getCommonId(), + serviceFeasibilityCheckInput.getSdncRequestHeader())) { + return performPCE(serviceFeasibilityCheckInput.getHardConstraints(), + serviceFeasibilityCheckInput.getSoftConstraints(), serviceFeasibilityCheckInput.getCommonId(), + serviceFeasibilityCheckInput.getSdncRequestHeader(), serviceFeasibilityCheckInput.getServiceAEnd(), + serviceFeasibilityCheckInput.getServiceZEnd(), + ServiceNotificationTypes.ServiceFeasibilityCheckResult, reserveResource); + } else { + return returnPCEFailed(); + } + } + 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, diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java index 24ab643d1..cea175dfe 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java @@ -74,6 +74,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput; 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; @@ -850,7 +852,7 @@ public class ServiceHandlerImplTest extends AbstractTest { .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get()); ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1") - .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Service reroute successfully !") + .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress") .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 @@ -862,6 +864,39 @@ public class ServiceHandlerImplTest extends AbstractTest { ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult(); Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful, result.getStatus()); - Assert.assertEquals("Service reroute successfully !", result.getStatusMessage()); + Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage()); + } + + @Test + public void reConfigureServiceIfserviceNotPresent() throws ExecutionException, InterruptedException { + ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput(); + ServiceReconfigureOutput result = this.serviceHandler.serviceReconfigure(input).get().getResult(); + Assert.assertEquals(result.getStatus(), RpcStatus.Failed); + Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present"); + } + + @Test + public void reConfigureServiceIfserviceIsPresent() throws ExecutionException, InterruptedException { + ServiceReconfigureInput serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput(); + Services serviceMock = ModelMappingUtils.mappingServices(null, serviceReconfigureInput); + Optional service = Optional.of(serviceMock); + Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input = + ModelMappingUtils.createServiceDeleteInput(serviceReconfigureInput); + ConfigurationResponseCommon configurationResponseCommon = + new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES) + .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK) + .setResponseMessage("Renderer service delete in progress").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.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult)) + .thenReturn(output); + ServiceReconfigureOutput result = + this.serviceHandlerImplMock.serviceReconfigure(serviceReconfigureInput).get().getResult(); + Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful, + result.getStatus()); + Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage()); } } diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImplTest.java index f2850990e..196fc2edc 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImplTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImplTest.java @@ -126,6 +126,17 @@ public class PceListenerImplTest extends AbstractTest { verify(this.rendererServiceOperationsMock).serviceImplementation(any(ServiceImplementationRequestInput.class)); } + @Test + public void onServicePathRpcResultPCRSuccessFeasabilityCheck() { + InjectField.inject(this.pceListenerImplMock, "serviceReconfigure", false); + InjectField.inject(this.pceListenerImplMock, "serviceFeasiblity", true); + ServicePathRpcResult notification = ServiceDataUtils.buildServicePathRpcResult( + ServicePathNotificationTypes.PathComputationRequest, "service 1", RpcStatusEx.Successful, "", true); + this.pceListenerImplMock.onServicePathRpcResult(notification); + verifyZeroInteractions(this.serviceDataStoreOperationsMock); + verifyZeroInteractions(this.rendererServiceOperationsMock); + } + @Test public void onServicePathRpcResultCRRSuccessWithNoReconfigure() { ServicePathRpcResult notification = ServiceDataUtils.buildServicePathRpcResult( diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java index 99c0390fa..6298e55f5 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java @@ -43,6 +43,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInputBuilder; 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; @@ -139,6 +143,30 @@ public final class ServiceDataUtils { return builtInput.build(); } + public static ServiceFeasibilityCheckInput buildServiceFeasibilityCheckInput() { + ServiceFeasibilityCheckInputBuilder builtInput = new ServiceFeasibilityCheckInputBuilder(); + org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.feasibility.check.input + .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service + .feasibility.check.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.service.feasibility.check.input + .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service + .feasibility.check.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.ServiceFeasibilityCheck).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 @@ -207,6 +235,29 @@ public final class ServiceDataUtils { return builder.build(); } + public static ServiceReconfigureInput buildServiceReconfigureInput() { + ServiceReconfigureInputBuilder builtInput = new ServiceReconfigureInputBuilder(); + org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input + .ServiceAEnd serviceAEnd = 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(getTxDirection()).setRxDirection(getRxDirection()) + .build(); + org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input + .ServiceZEnd serviceZEnd = 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-3-2").setTxDirection(getTxDirection()).setRxDirection(getRxDirection()) + .build(); + builtInput.setCommonId("commonId"); + builtInput.setConnectionType(ConnectionType.Service); + builtInput.setCustomer("Customer"); + builtInput.setServiceName("service 1"); + builtInput.setServiceAEnd(serviceAEnd); + builtInput.setServiceZEnd(serviceZEnd); + return builtInput.build(); + } + public static ServicePathRpcResult buildServicePathRpcResult() { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx"); OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC); diff --git a/tests/transportpce_tests/test_servicehandler.py b/tests/transportpce_tests/test_servicehandler.py index 1b40e2f53..e1ab9483f 100644 --- a/tests/transportpce_tests/test_servicehandler.py +++ b/tests/transportpce_tests/test_servicehandler.py @@ -118,7 +118,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(1) # Create Service 'test' with correct parameters - def test_07_create_service(self): + def test_07_create_service_success(self): url = ("{}/operations/org-openroadm-service:service-create" .format(self.restconf_baseurl)) data = {"input": { @@ -221,7 +221,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(20) # Create Service 'test' with not compliant parameter : no 'sdnc-request-header' parameter - def test_08_create_service(self): + def test_08_create_service_failed(self): url = ("{}/operations/org-openroadm-service:service-create" .format(self.restconf_baseurl)) data = {"input": { @@ -318,7 +318,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) # Create Service 'test' with not compliant parameter : no 'tx-direction' for serviceAEnd - def test_09_create_service(self): + def test_09_create_service_failed(self): url = ("{}/operations/org-openroadm-service:service-create" .format(self.restconf_baseurl)) data = {"input": { @@ -406,7 +406,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) # Get 'test' service created - def test_10_get_service(self): + def test_10_verify_service_created(self): url = ("{}/operational/org-openroadm-service:service-list/services/test" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', @@ -421,7 +421,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(1) # get non existing service - def test_11_get_service(self): + def test_11_get_non_existing_service(self): url = ("{}/operational/org-openroadm-service:service-list/services/test1" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', @@ -431,204 +431,118 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(response.status_code, 404) time.sleep(1) -# These tests is not available in this commit (cf commit message ) -# reconfigure 'test' to be 'test-new' -# def test_08_reconfigure_service(self): -# url = ("{}/operations/org-openroadm-service:service-reconfigure" -# .format(self.restconf_baseurl)) -# data = {"input": { -# "service-name": "test", -# "new-service-name": "test-new", -# "common-id": "ASATT1234567", -# "connection-type": "infrastructure", -# "service-a-end": { -# "service-rate": "100", -# "node-id": "XPDRA", -# "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": "XPDRC", -# "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" -# }, -# "hard-constraints": { -# "diversity": { -# "existing-service": [ -# "104/GE100/SNJSCAMCJP8/SNJSCAMCJT4" -# ], -# "existing-service-applicability": { -# "node": "true" -# } -# }, -# "exclude": { -# "fiber-bundle": [ -# "l(string)" -# ], -# "node-id": [ -# "SNJSCAMCJP8_000000.00" -# ] -# }, -# "latency": { -# "max-latency": "30" -# } -# } -# } -# } -# 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('in progress', -# res['output']['status-message']) -# time.sleep(30) -# -# # get new service 'test-new' -# def test_09_get_service(self): -# url = ("{}/operational/org-openroadm-service:service-list/services/test-new" -# .format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json', -# "Accept": "application/json"} -# response = requests.request( -# "GET", url, headers=headers, auth=('admin', 'admin')) -# res = response.json() -# self.assertEqual( -# res['services'][0]['operational-state'], -# 'inService') -# time.sleep(1) -# -# # Modify 'test-new' state -# def test_10_modify_service_state(self): -# url = ("{}/operations/servicehandler:service-state-modify" -# .format(self.restconf_baseurl)) -# data = {"input": { -# "service-name": "test-new", -# "operational-state": "outOfService" -# } -# } -# headers = {'content-type': 'application/json'} -# response = requests.request( -# "POST", url, data=json.dumps(data), headers=headers, -# auth=('admin', 'admin')) -# res = response.json() -# self.assertIn('Service state modified', -# res['output']['configuration-response-common']['response-message']) -# time.sleep(5) -# -# # get new service 'test-new' state -# def test_11_get_service(self): -# url = ("{}/operational/org-openroadm-service:service-list/services/test-new" -# .format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json', -# "Accept": "application/json"} -# response = requests.request( -# "GET", url, headers=headers, auth=('admin', 'admin')) -# res = response.json() -# self.assertEqual( -# res['services'][0]['operational-state'], -# 'outOfService') -# time.sleep(1) -# -# # restore service 'test-new' -# def test_12_restore_service(self): -# url = ("{}/operations/org-openroadm-service:service-restoration" -# .format(self.restconf_baseurl)) -# data = {"input": { -# "service-name": "test-new", -# "option": "permanent" -# } -# } -# headers = {'content-type': 'application/json'} -# response = requests.request( -# "POST", url, data=json.dumps(data), headers=headers, -# auth=('admin', 'admin')) -# res = response.json() -# self.assertIn('in progress', -# res['output']['status-message']) -# time.sleep(60) -# -# # get new service 'test-new' state -# def test_13_get_service(self): -# url = ("{}/operational/org-openroadm-service:service-list/services/test-new" -# .format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json', -# "Accept": "application/json"} -# response = requests.request( -# "GET", url, headers=headers, auth=('admin', 'admin')) -# res = response.json() -# self.assertEqual( -# res['services'][0]['operational-state'], -# 'inService') -# time.sleep(1) + #reconfigure 'test' to be 'test-new' + def test_12_reconfigure_service_test(self): + url = ("{}/operations/org-openroadm-service:service-reconfigure" + .format(self.restconf_baseurl)) + data = {"input": { + "service-name": "test", + "new-service-name": "test-new", + "common-id": "ASATT1234567", + "connection-type": "infrastructure", + "service-a-end": { + "service-rate": "100", + "node-id": "XPDRA", + "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": "XPDRC", + "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" + } + } + } + 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('Renderer service delete in progress', + res['output']['status-message']) + time.sleep(30) + + # get new service 'test-new' + def test_13_verify_service_reconfigure(self): + url = ("{}/operational/org-openroadm-service:service-list/services/test-new" + .format(self.restconf_baseurl)) + headers = {'content-type': 'application/json', + "Accept": "application/json"} + response = requests.request( + "GET", url, headers=headers, auth=('admin', 'admin')) + res = response.json() + self.assertEqual( + res['services'][0]['administrative-state'], + 'inService') + time.sleep(1) # Delete service - def test_12_delete_service(self): + def test_14_delete_service_reconfigure(self): url = ("{}/operations/org-openroadm-service:service-delete" .format(self.restconf_baseurl)) data = {"input": { @@ -639,7 +553,7 @@ class TransportPCEtesting(unittest.TestCase): "notification-url": "http://localhost:8585/NotificationServer/notify" }, "service-delete-req-info": { - "service-name": "test", + "service-name": "test-new", "due-date": "2016-11-28T00:00:01Z", "tail-retention": "no" } @@ -656,8 +570,8 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(20) # Verify 'test' service deleted - def test_13_get_service(self): - url = ("{}/operational/org-openroadm-service:service-list/services/test" + def test_15_verify_service_reconfigure_deleted(self): + url = ("{}/operational/org-openroadm-service:service-list/services/test-new" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', "Accept": "application/json"} @@ -667,7 +581,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(1) # Create Temp Service 'ASATT1234567' with correct parameters - def test_14_create_temp_service(self): + def test_16_create_temp_service_success(self): url = ("{}/operations/org-openroadm-service:temp-service-create" .format(self.restconf_baseurl)) data = { @@ -771,7 +685,7 @@ class TransportPCEtesting(unittest.TestCase): # Create Temp Service not compliant with no common-id - def test_15_create_temp_service(self): + def test_17_create_temp_service_failed(self): url = ("{}/operations/org-openroadm-service:temp-service-create" .format(self.restconf_baseurl)) data = { @@ -873,7 +787,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) # Get 'ASATT1234567' temp service created - def test_16_get_temp_service(self): + def test_18_verify_temp_service_created(self): url = ("{}/operational/org-openroadm-service:temp-service-list/services/ASATT1234567" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', @@ -888,7 +802,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(1) # get non existing service - def test_17_get_temp_service(self): + def test_19_get_temp_service_non_existed(self): url = ("{}/operational/org-openroadm-service:temp-service-list/services/test1" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', @@ -899,7 +813,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(1) # Delete temp service - def test_18_delete_temp_service(self): + def test_20_delete_temp_service_created(self): url = ("{}/operations/org-openroadm-service:temp-service-delete" .format(self.restconf_baseurl)) data = {"input": { @@ -917,7 +831,7 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(20) # Verify 'test' service deleted - def test_19_verify_temp_service_deleted(self): + def test_21_verify_temp_service_deleted(self): url = ("{}/operational/org-openroadm-service:service-list/services/ASATT1234567" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json', -- 2.36.6