From f635c4d0e4252050154b89d53bd7e658eaf75be8 Mon Sep 17 00:00:00 2001 From: Martial COULIBALY Date: Tue, 23 Jan 2018 09:48:26 +0100 Subject: [PATCH] Servicehandler Tests this commit includes : - Add rpc-state-modify on servicehandler.yang to test rpc-service-restoration which can only be launch on service with operational state 'outOfService'. - Move stubpce.yang and stubrenderer.yang to stubmodels maven project under tests folder. - Create specific profile for servicehandler tests in tox.ini file. So now to only launch servihandler tests you have to use this command : 'tox -e servicehandler' in tests folder. - Use parameterized loggins. - Add 5 more tests to 'tests_servicehandler' python file. - Mofify some errors on service-create rpc implementaion. - Add python file 'tests_servichandler.py' to test servicehandler functions. - Modifiy stubpce and stubrenderer yang model to add RPCs from servicepath version 1.5. This modification came from having two version of servicepath (1.5 and 1.6) in the model directory does not allow me to access some RPCs. For example trying to get service path list for 1.5 version failed caused the url is the same : http://localhost:8181/restconf/operational/transportpce-servicepath:service-path-list So REST API seems to use the last version which is 1.6. Change-Id: Ief8aab19750fe2959407b90772df8a8a6280e73d Signed-off-by: Martial COULIBALY Signed-off-by: Olivier RENAIS --- api/src/main/yang/servicehandler.yang | 17 + pom.xml | 2 +- servicehandler/pom.xml | 5 + .../MappingAndSendingPCRequest.java | 2 +- .../MappingAndSendingSIRequest.java | 20 +- .../impl/ServicehandlerImpl.java | 255 ++++--- .../impl/ServicehandlerProvider.java | 4 + tests/pom.xml | 1 + tests/setup.cfg | 1 + tests/stubmodels/pom.xml | 80 +++ .../stubmodels}/src/main/yang/stubpce.yang | 29 + .../src/main/yang/stubrenderer.yang | 0 tests/stubpce/pom.xml | 5 + .../transportpce/stubpce/SendingPceRPCs.java | 76 +- .../stubpce/impl/StubpceImpl.java | 106 ++- .../stubpce/impl/StubpceProvider.java | 10 +- .../stubpce/topology/InterNodePath.java | 10 +- .../stubpce/topology/NodePath.java | 6 +- .../topology/PathDescriptionsOrdered.java | 2 +- .../stubpce/topology/SuperNodePath.java | 44 +- .../stubpce/topology/Topology.java | 2 +- tests/stubrenderer/pom.xml | 5 + .../stubrenderer/SendingRendererRPCs.java | 4 +- .../stubrenderer/impl/StubrendererImpl.java | 70 +- .../impl/StubrendererProvider.java | 10 +- tests/tox.ini | 10 + .../transportpce_tests/test_servicehandler.py | 661 ++++++++++++++++++ 27 files changed, 1160 insertions(+), 277 deletions(-) create mode 100644 tests/stubmodels/pom.xml rename {api => tests/stubmodels}/src/main/yang/stubpce.yang (84%) rename {api => tests/stubmodels}/src/main/yang/stubrenderer.yang (100%) create mode 100644 tests/transportpce_tests/test_servicehandler.py diff --git a/api/src/main/yang/servicehandler.yang b/api/src/main/yang/servicehandler.yang index c6832b0c3..b33130fa5 100644 --- a/api/src/main/yang/servicehandler.yang +++ b/api/src/main/yang/servicehandler.yang @@ -56,6 +56,23 @@ module servicehandler { "Version 1.2"; } + rpc service-state-modify { + input { + leaf service-name { + type string; + mandatory true; + } + leaf operational-state { + type org-openroadm-common-types:state; + } + } + output { + uses org-openroadm-common-service-types:configuration-response-common; + } + description + "Just to test rpc restoration from org-openroadm-service"; + } + notification service-rpc-result-sh{ description "This Notification indicates result of service RPC"; diff --git a/pom.xml b/pom.xml index 1fe836077..f1c0a4a3c 100644 --- a/pom.xml +++ b/pom.xml @@ -35,8 +35,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL impl renderer olm - servicehandler tests + servicehandler cli features karaf diff --git a/servicehandler/pom.xml b/servicehandler/pom.xml index 4ac732bf7..78aa81669 100644 --- a/servicehandler/pom.xml +++ b/servicehandler/pom.xml @@ -35,6 +35,11 @@ Author: Martial Coulibaly on behalf of Orange transportpce-ordmodels ${project.version} + + ${project.groupId} + transportpce-stubmodels + ${project.version} + diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java index c9f75cf64..ff3867441 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java @@ -343,7 +343,7 @@ public class MappingAndSendingPCRequest { RpcResult pceOutputResult = null; Boolean output = false; if (pathComputationRequestInput != null) { - LOG.info("pathComputationRequestInput : " + pathComputationRequestInput.toString()); + LOG.info("pathComputationRequestInput : {}", pathComputationRequestInput.toString()); Future> pceOutputFuture = service .pathComputationRequest(pathComputationRequestInput); try { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java index 691b156c5..8d88587f2 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrende import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services; @@ -150,7 +151,7 @@ public class MappingAndSendingSIRequest { try { tmp = pathComputationOutput.getResponseParameters().getPathDescription(); } catch (NullPointerException e) { - LOG.error("PathDescription is null : " + e.toString()); + LOG.error("PathDescription is null : {}", e.toString()); } PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); if (tmp != null) { @@ -246,7 +247,7 @@ public class MappingAndSendingSIRequest { try { tmp = pathComputationOutput.getResponseParameters().getPathDescription(); } catch (NullPointerException e) { - LOG.error("PathDescription is null : " + e.toString()); + LOG.error("PathDescription is null : {}", e.toString()); } PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); if (tmp != null) { @@ -259,7 +260,7 @@ public class MappingAndSendingSIRequest { .setServiceAEnd(serviceAEnd) .setServiceZEnd(serviceZEnd) .build(); - LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());*/ + LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/ } @@ -310,6 +311,13 @@ public class MappingAndSendingSIRequest { /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder(); + SdncRequestHeader sdnc = services.getSdncRequestHeader(); + if (sdnc != null) { + String requestId = services.getSdncRequestHeader().getRequestId(); + if (requestId != null) { + serviceHandlerHeader.setRequestId(requestId); + } + } mappingSIRequest(pathComputationOutput, serviceHandlerHeader, services.getServiceAEnd(), services.getServiceZEnd(), services.getServiceName()); /*org.opendaylight.yang.gen.v1.http.org.openroadm.common.service @@ -359,7 +367,7 @@ public class MappingAndSendingSIRequest { try { tmp = pathComputationOutput.getResponseParameters().getPathDescription(); } catch (NullPointerException e) { - LOG.error("PathDescription is null : " + e.toString()); + LOG.error("PathDescription is null : {}", e); } PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); if (tmp != null) { @@ -373,7 +381,7 @@ public class MappingAndSendingSIRequest { .setServiceAEnd(serviceAEnd) .setServiceZEnd(serviceZEnd) .build(); - LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());*/ + LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/ } /** @@ -434,7 +442,7 @@ public class MappingAndSendingSIRequest { try { tmp = pathComputationOutput.getResponseParameters().getPathDescription(); } catch (NullPointerException e) { - LOG.error("PathDescription is null : " + e.toString()); + LOG.error("PathDescription is null : {}", e.toString()); } PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); if (tmp != null) { 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 1fa5d4e04..225fa272e 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 @@ -35,6 +35,10 @@ import org.opendaylight.transportpce.servicehandler.ServicehandlerCompliancyChec import org.opendaylight.transportpce.servicehandler.ServicehandlerTxRxCheck; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultSh; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultShBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServicehandlerService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult; @@ -48,6 +52,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.ConfigurationResponseCommon; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd; @@ -119,7 +124,7 @@ import org.slf4j.LoggerFactory; * * @author Martial Coulibaly on behalf of Orange */ -public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceListener, +public class ServicehandlerImpl implements OrgOpenroadmServiceService, ServicehandlerService, StubpceListener, StubrendererListener,AutoCloseable { /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class); @@ -149,7 +154,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis private ServicePathRpcResult servicePathRpcResult = null; private ServiceRpcResultSp serviceRpcResultSp = null; - private String notificationUrl = ""; private RpcActions action; private PathDescription pathDescription; @@ -188,7 +192,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis serviceName = service.getServiceName(); } if (serviceName != null) { - LOG.info("deleting service '" + serviceName + "'from datastore ..."); + LOG.info("deleting service '{}' from datastore ...", serviceName); ServiceRpcResultSh notification = null; String message = ""; /** @@ -210,7 +214,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { LOG.error("Parameter 'ServiceName' fro deleteServiceFromDatastore is null !"); @@ -274,13 +278,13 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis } notification = new ServiceRpcResultShBuilder() .setNotificationType(notif) - .setServiceName(serviceCreateInput.getServiceName()) + .setServiceName(serviceName) .setStatus(RpcStatusEx.Successful).setStatusMessage(message) .build(); try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { message = "pathTopology not in stubrenderer notification, cancelling pce resource reserve ..."; @@ -294,7 +298,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } pceCancelResResource(); } @@ -359,7 +363,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } FutureCallback pceCallback = new FutureCallback() { String message = ""; @@ -383,7 +387,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { message = mappingAndSendingPCRequest.getError(); @@ -394,7 +398,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } } @@ -409,7 +413,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @@ -483,7 +487,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { message = mappingAndSendingPCRequest.getError(); @@ -494,7 +498,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } } @@ -510,7 +514,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @@ -536,7 +540,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis if (tmp != null && id != null) { final String serviceName = tmp; - LOG.info("stubrendererDelete service '" + serviceName + "'"); + LOG.info("stubrendererDelete service '{}'", serviceName); mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, id, serviceName); ListenableFuture renderer = mappingAndSendingSIRequest.serviceDelete(); FutureCallback rendererCallback = new FutureCallback() { @@ -554,7 +558,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @@ -570,7 +574,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { message = "deleting service failed !"; @@ -582,7 +586,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } } @@ -655,11 +659,11 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis final ServiceNotificationTypes notifType = type; if (!create) { /** ServiceReconfigure. */ if ((result = writeOrModifyOrDeleteServiceList(serviceName, pathComputationResponse,null, 1)) == null) { - LOG.info("Service '" + serviceName + "' deleted from datastore"); + LOG.info("Service '{}' deleted from datastore", serviceName); serviceName = newServiceName; delete = true; } else { - LOG.info("deleting Service '" + serviceName + "' failed !"); + LOG.info("deleting Service '{}' failed !", serviceName); } } if (delete) { @@ -682,7 +686,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } FutureCallback rendererCallback = new FutureCallback() { @@ -707,7 +711,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } else { message = mappingAndSendingSIRequest.getError(); @@ -718,7 +722,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } } @@ -733,7 +737,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } }; @@ -764,10 +768,12 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis Boolean commonId = true; Boolean coherencyHardSoft = false; - if (sdncRequestHeader != null) { + if (rpcActions.equals(RpcActions.ServiceCreate) || rpcActions.equals(RpcActions.ServiceFeasibilityCheck) + || rpcActions.equals(RpcActions.ServiceDelete)) { sdncRequest = true; - } - if (connectionType != null) { + } else if (rpcActions.equals(RpcActions.ServiceCreate) + || rpcActions.equals(RpcActions.ServiceFeasibilityCheck) + || rpcActions.equals(RpcActions.ServiceReconfigure)) { contype = true; } compliancyCheck = new ServicehandlerCompliancyCheck(sdncRequestHeader, serviceName, @@ -832,8 +838,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis pathDescription = null; pathTopology = null; action = RpcActions.ServiceCreate; - notificationUrl = null; - LOG.info("notificationUrl : " + notificationUrl); setPathDescription(null); serviceCreateInput = input; setServiceDeleteInput(null); @@ -852,21 +856,35 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis input.getConnectionType(), RpcActions.ServiceCreate, input.getServiceAEnd(), input.getServiceZEnd(), input.getCommonId(), input.getHardConstraints(), input.getSoftConstraints())) != null) { message = "Service not compliant : " + serviceCompliancy; + responseCode = "500"; LOG.info(message); } else { LOG.info("Service compliant !"); - pcePathComputation(input); - LOG.info("PCR Request in progress "); - configurationResponseCommon = new ConfigurationResponseCommonBuilder() - .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) - .setResponseMessage("Service compliant, serviceCreate in progress...") - .setResponseCode("200").build(); + String name = input.getServiceName(); + if (readServiceList(name) == null) { + pcePathComputation(input); + LOG.info("PCR Request in progress "); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) + .setResponseMessage("Service compliant, serviceCreate in progress...") + .setResponseCode("200").build(); - ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() - .setConfigurationResponseCommon(configurationResponseCommon); + ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon); - return RpcResultBuilder.success(output.build()).buildFuture(); + return RpcResultBuilder.success(output.build()).buildFuture(); + } else { + LOG.info("Service '{}' already created !", name); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId()) + .setResponseMessage("Service already created !") + .setResponseCode("500").build(); + ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon); + + return RpcResultBuilder.success(output.build()).buildFuture(); + } } /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(), input.getConnectionType(), RpcActions.ServiceCreate); @@ -921,22 +939,29 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis responseCode = "500"; }*/ - configurationResponseCommon = new ConfigurationResponseCommonBuilder() + ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("Yes") - .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message) - .setResponseCode(responseCode).build(); + .setResponseMessage(message) + .setResponseCode(responseCode); + SdncRequestHeader sdnc = input.getSdncRequestHeader(); + if (sdnc != null) { + String requestId = sdnc.getRequestId(); + if (requestId != null) { + builder.setRequestId(requestId); + } + } + configurationResponseCommon = builder.build(); ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() .setConfigurationResponseCommon(configurationResponseCommon); return RpcResultBuilder.success(output.build()).buildFuture(); - } @Override public Future> serviceDelete(ServiceDeleteInput input) { - LOG.info("RPC serviceDelete request received for Service '" + input.getServiceDeleteReqInfo().getServiceName() - + "'"); + LOG.info("RPC serviceDelete request received for Service '{}'", input.getServiceDeleteReqInfo() + .getServiceName()); setServiceDeleteInput(input); setServiceReconfigureInput(null); serviceCreateInput = null; @@ -955,7 +980,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis String serviceName = input.getServiceDeleteReqInfo().getServiceName(); Services service = readServiceList(serviceName); if (service != null) { - LOG.debug("Service '" + serviceName + "' present in datastore !"); + LOG.debug("Service '{}' present in datastore !", serviceName); stubrendererDelete(); LOG.info("ServiceDelete Request in progress ... "); ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder() @@ -1110,7 +1135,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis String serviceName = input.getServiceName(); Services service = readServiceList(serviceName); if (service != null) { - LOG.debug("Service '" + serviceName + "' present in datastore !"); + LOG.debug("Service '{}' present in datastore !", serviceName); /** * Sending cancel resource reserve request to PCE. */ @@ -1155,7 +1180,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis String serviceName = input.getServiceName(); Services service = readServiceList(serviceName); if (service != null) { - LOG.debug("Service '" + serviceName + "' present in datastore !"); + LOG.debug("Service '{}' present in datastore !", serviceName); pceCancelResResource(); ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder() .setStatus(RpcStatusEx.Pending) @@ -1163,7 +1188,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis return RpcResultBuilder.success(output).buildFuture(); } else { message = "Service '" + serviceName + "' not exists in datastore"; - LOG.error(message); + LOG.error("Service '{}' not exists in datastore", serviceName); } } } else { @@ -1176,7 +1201,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis message = compliancyCheck.getMessage(); }*/ - ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Successful) + ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Failed) .setStatusMessage(message).build(); return RpcResultBuilder.success(output).buildFuture(); } @@ -1187,7 +1212,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis ServiceRpcResultSh notification = null; setServiceDeleteInput(null); setServiceReconfigureInput(null); - notificationUrl = null; String message = ""; LOG.info("checking Service Compliancy ..."); compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), RpcActions.ServiceRestoration); @@ -1200,23 +1224,34 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis Services service = readServiceList(serviceName); if (service != null) { this.service = service; - LOG.debug("Service '" + serviceName + "' present in datastore !"); - notification = new ServiceRpcResultShBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.debug("Service '{}' present in datastore !", serviceName); + /** verify if service state is down. */ + State state = service.getOperationalState(); + if (state != null && !state.equals(State.InService)) { + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) + .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ..") + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : {}", e); + } + stubrendererDelete(); + LOG.info("PCR Request in progress "); + ServiceRestorationOutput output = new ServiceRestorationOutputBuilder() + .setStatus(RpcStatus.Successful) + .setStatusMessage("ServiceRestoration in progress...").build(); + return RpcResultBuilder.success(output).buildFuture(); + } else { + LOG.info("Service '{}' still in '{}' state", serviceName, state); + ServiceRestorationOutput output = new ServiceRestorationOutputBuilder() + .setStatus(RpcStatus.Failed) + .setStatusMessage("ServiceRestoration failed : Service still in service !") + .build(); + return RpcResultBuilder.success(output).buildFuture(); } - stubrendererDelete(); - LOG.info("PCR Request in progress "); - ServiceRestorationOutput output = new ServiceRestorationOutputBuilder() - .setStatus(RpcStatus.Successful) - .setStatusMessage("ServiceRestoration in progress...").build(); - return RpcResultBuilder.success(output).buildFuture(); } else { message = "Service '" + serviceName + "' not exists in datastore"; LOG.error(message); @@ -1226,7 +1261,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis LOG.error(message); } - ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Successful) + ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Failed) .setStatusMessage(message).build(); return RpcResultBuilder.success(output).buildFuture(); @@ -1286,15 +1321,19 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis if (serviceCreateInput != null) { aend = new ServiceAEndBuilder(serviceCreateInput.getServiceAEnd()).build(); zend = new ServiceZEndBuilder(serviceCreateInput.getServiceZEnd()).build(); - service.setServiceName(serviceCreateInput.getServiceName()).setAdministrativeState(State.OutOfService) - .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId()) - .setConnectionType(serviceCreateInput.getConnectionType()) - .setCustomer(serviceCreateInput.getCustomer()) - .setCustomerContact(serviceCreateInput.getCustomerContact()) - .setHardConstraints(serviceCreateInput.getHardConstraints()) - .setSoftConstraints(serviceCreateInput.getSoftConstraints()) - .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend) - .setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader()); + service.setServiceName(serviceCreateInput.getServiceName()) + .setAdministrativeState(State.OutOfService) + .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId()) + .setConnectionType(serviceCreateInput.getConnectionType()) + .setCustomer(serviceCreateInput.getCustomer()) + .setCustomerContact(serviceCreateInput.getCustomerContact()) + .setHardConstraints(serviceCreateInput.getHardConstraints()) + .setSoftConstraints(serviceCreateInput.getSoftConstraints()) + .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend) + .setSdncRequestHeader(new SdncRequestHeaderBuilder() + .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId()) + .setRpcAction(serviceCreateInput.getSdncRequestHeader().getRpcAction()) + .build()); } else if (serviceReconfigureInput != null) { aend = new ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build(); @@ -1307,7 +1346,11 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis .setCustomerContact(serviceReconfigureInput.getCustomerContact()) .setHardConstraints(serviceReconfigureInput.getHardConstraints()) .setSoftConstraints(serviceReconfigureInput.getSoftConstraints()) - .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend); + .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend) + .setSdncRequestHeader(new SdncRequestHeaderBuilder() + .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName()) + .setRpcAction(RpcActions.ServiceReconfigure) + .build()); } org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response @@ -1370,7 +1413,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis LOG.error("Reading service failed:", e); } if (optional.isPresent()) { - LOG.debug("Service '" + serviceName + "' present !"); + LOG.debug("Service '{}' present !", serviceName); result = new ServicesBuilder(optional.get()).build(); } return result; @@ -1391,7 +1434,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis */ private String writeOrModifyOrDeleteServiceList(String serviceName, PathComputationRequestOutput output, Topology topo, int choice) { - LOG.info("WriteOrModifyOrDeleting '" + serviceName + "' Service"); + LOG.info("WriteOrModifyOrDeleting '{}' Service", serviceName); WriteTransaction writeTx = db.newWriteOnlyTransaction(); String result = null; Services readService = readServiceList(serviceName); @@ -1407,7 +1450,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis String action = null; switch (choice) { case 0: /** Modify. */ - LOG.info("Modifying '" + serviceName + "' Service"); + LOG.info("Modifying '{}' Service", serviceName); service.setOperationalState(State.InService).setAdministrativeState(State.InService); service.setTopology(topo); writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build()); @@ -1415,7 +1458,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis break; case 1: /** Delete. */ - LOG.info("Deleting '" + serviceName + "' Service"); + LOG.info("Deleting '{}' Service", serviceName); writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid); action = "delete"; break; @@ -1428,11 +1471,11 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis try { Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { - LOG.info("Failed to " + action + " service from Service List"); + LOG.info("Failed to {} service from Service List", action); result = "Failed to " + action + " service from Service List"; } } else if (choice == 2) { /** Write Service. */ - LOG.info("Writing '" + serviceName + "' Service"); + LOG.info("Writing '{}' Service", serviceName); InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName)); Services writeService = null; @@ -1705,4 +1748,50 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceLis public void setServiceFeasibilityCheckInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) { this.serviceFeasibilityCheckInput = serviceFeasibilityCheckInput; } + + @Override + public Future> serviceStateModify(ServiceStateModifyInput input) { + LOG.info("RPC service state modify received"); + String servicename = input.getServiceName(); + String message = ""; + String responseCode = "500"; + if (servicename != null) { + Services service = readServiceList(servicename); + if (service != null) { + LOG.info("Modify '{}' Service state", servicename); + WriteTransaction writeTx = db.newWriteOnlyTransaction(); + String result = null; + Future future = null; + InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, + new ServicesKey(servicename)); + ServicesBuilder modifyService = new ServicesBuilder(service); + modifyService.setOperationalState(State.OutOfService); + writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, modifyService.build()); + future = writeTx.submit(); + try { + Futures.getChecked(future, ExecutionException.class); + } catch (ExecutionException e) { + LOG.info("Failed to {} service from Service List", action); + result = "Failed to " + action + " service from Service List"; + } + if (result == null) { + responseCode = "200"; + message = "Service state modified !"; + } + } else { + message = "Service not present in datastore ! "; + } + } else { + message = "servicename not set in ServiceStateModifyInput"; + } + ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("Yes") + .setResponseCode(responseCode) + .setResponseMessage(message) + .build(); + ServiceStateModifyOutput output = new ServiceStateModifyOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon) + .build(); + return RpcResultBuilder.success(output).buildFuture(); + } } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java index f2b9fbe51..9237fd284 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java @@ -13,6 +13,7 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServicehandlerService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService; @@ -40,6 +41,7 @@ public class ServicehandlerProvider { private ListenerRegistration stubpcelistenerRegistration; private ListenerRegistration stubrendererlistenerRegistration; private RpcRegistration rpcRegistration; + private RpcRegistration rpcRegistrationServiceHandler; public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry, @@ -59,6 +61,7 @@ public class ServicehandlerProvider { stubpcelistenerRegistration = notificationService.registerNotificationListener(consumer); stubrendererlistenerRegistration = notificationService.registerNotificationListener(consumer); rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, consumer); + rpcRegistrationServiceHandler = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer); } /** @@ -69,5 +72,6 @@ public class ServicehandlerProvider { stubpcelistenerRegistration.close(); stubrendererlistenerRegistration.close(); rpcRegistration.close(); + rpcRegistrationServiceHandler.close(); } } diff --git a/tests/pom.xml b/tests/pom.xml index ad7ee1d91..09dff6a1d 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -23,6 +23,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL pom + stubmodels stubpce stubrenderer diff --git a/tests/setup.cfg b/tests/setup.cfg index ba641a8e7..b55072092 100644 --- a/tests/setup.cfg +++ b/tests/setup.cfg @@ -5,3 +5,4 @@ home-page = https://wiki.opendaylight.org/view/TransportPCE:Main [files] packages = transportpce_tests + diff --git a/tests/stubmodels/pom.xml b/tests/stubmodels/pom.xml new file mode 100644 index 000000000..37007f599 --- /dev/null +++ b/tests/stubmodels/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + + org.opendaylight.mdsal + binding-parent + 0.12.3-SNAPSHOT + + + + org.opendaylight.transportpce + transportpce-stubmodels + 0.2.0-SNAPSHOT + bundle + + + + ${project.groupId} + transportpce-ordmodels + ${project.version} + + + ${project.groupId} + transportpce-api + ${project.version} + + + + + + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + {maven-resources},target/classes/LICENSE,META-INF/git.properties=-target/classes/META-INF/git.properties + <_exportcontents> + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.transportpce.stubrenderer.rev170403.service.implementation.request.input,* + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + */target/generated-sources/mdsal-binding/* + * + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + */target/generated-sources/mdsal-binding/* + * + + + + + + diff --git a/api/src/main/yang/stubpce.yang b/tests/stubmodels/src/main/yang/stubpce.yang similarity index 84% rename from api/src/main/yang/stubpce.yang rename to tests/stubmodels/src/main/yang/stubpce.yang index 44ba5ca08..fb142ae9b 100644 --- a/api/src/main/yang/stubpce.yang +++ b/tests/stubmodels/src/main/yang/stubpce.yang @@ -120,6 +120,35 @@ module stubpce { } } + container service-path-list { + description + "List of service paths. Can only be created, deleted, modified, etc. using special RPCs."; + list service-paths { + key "service-path-name"; + uses transportpce-common-service-path-types:service-path; + } + } + + grouping stubpce-path-description { + leaf path-name { + type string; + description + "Identifier for the pathDescription to be created in + the ROADM network, e.g., CLFI, CLCI, etc."; + mandatory true; + } + uses transportpce-pathDescription:path-description; + } + + container path-description-list { + description + "List of pathDescription. Can only be created, deleted, modified, etc. using special RPCs."; + list pathDescriptions { + key "path-name"; + uses stubpce-path-description; + } + } + notification service-path-rpc-result { description "This Notification indicates result of service RPC"; diff --git a/api/src/main/yang/stubrenderer.yang b/tests/stubmodels/src/main/yang/stubrenderer.yang similarity index 100% rename from api/src/main/yang/stubrenderer.yang rename to tests/stubmodels/src/main/yang/stubrenderer.yang diff --git a/tests/stubpce/pom.xml b/tests/stubpce/pom.xml index f67df0630..88cee40ec 100644 --- a/tests/stubpce/pom.xml +++ b/tests/stubpce/pom.xml @@ -52,6 +52,11 @@ Author: Martial Coulibaly on behalf of Orange transportpce-ordmodels ${project.version} + + ${project.groupId} + transportpce-stubmodels + ${project.version} + diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/SendingPceRPCs.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/SendingPceRPCs.java index ad867bde6..76f727f6e 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/SendingPceRPCs.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/SendingPceRPCs.java @@ -30,6 +30,15 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.transportpce.stubpce.topology.PathDescriptionsOrdered; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathDescriptionList; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathList; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptions; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePaths; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.rpc.result.PathDescriptionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ; @@ -42,18 +51,9 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.Exclude; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraints; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraints; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescriptionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.path.ServiceAEnd; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.path.ServiceZEnd; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathDescriptionList; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathList; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptions; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -144,7 +144,7 @@ public class SendingPceRPCs { private Boolean egalResource(Resource res1, Resource res2) { LOG.info("comparing resource ..."); Boolean result = false; - LOG.info(res1.getClass().getName() + " - " + res2.getClass().getName()); + LOG.info("{} - {}", res1.getClass().getName(), res2.getClass().getName()); if (res1.getClass().getName().compareToIgnoreCase(res2.getClass().getName()) == 0) { if (res1 instanceof Node && res2 instanceof Node) { Node node1 = (Node)res1; @@ -187,14 +187,14 @@ public class SendingPceRPCs { if (atoz1.getAToZ().size() == atoz2.getAToZ().size()) { int index = 0; int size = atoz1.getAToZ().size(); - LOG.info("size : " + size); + LOG.info("size : {}", size); String id1 = null; String id2 = null; while (index < size) { id1 = atoz1.getAToZ().get(index).getId(); - LOG.info("id : " + id1); + LOG.info("id : {}", id1); Resource res1 = atoz1.getAToZ().get(index).getResource().getResource(); - LOG.info("res1 : " + res1.toString()); + LOG.info("res1 : {}", res1.toString()); Resource res2 = null; if (id1 != null) { Boolean trouve = false; @@ -202,7 +202,7 @@ public class SendingPceRPCs { id2 = atoz2.getAToZ().get(loop).getId(); if (id2 != null && id2.compareTo(id1) == 0) { res2 = atoz2.getAToZ().get(loop).getResource().getResource(); - LOG.info("res2 : " + res2.toString()); + LOG.info("res2 : {}", res2.toString()); trouve = true; break; } @@ -239,14 +239,14 @@ public class SendingPceRPCs { if (ztoa1.getZToA().size() == ztoa2.getZToA().size()) { int index = 0; int size = ztoa1.getZToA().size(); - LOG.info("size : " + size); + LOG.info("size : {}", size); String id1 = null; String id2 = null; while (index < size) { id1 = ztoa1.getZToA().get(index).getId(); - LOG.info("id : " + id1); + LOG.info("id : {}", id1); Resource res1 = ztoa1.getZToA().get(index).getResource().getResource(); - LOG.info("res1 : " + res1.toString()); + LOG.info("res1 : {}", res1.toString()); Resource res2 = null; if (id1 != null) { Boolean trouve = false; @@ -254,7 +254,7 @@ public class SendingPceRPCs { id2 = ztoa2.getZToA().get(loop).getId(); if (id2 != null && id2.compareTo(id1) == 0) { res2 = ztoa2.getZToA().get(loop).getResource().getResource(); - LOG.info("res2 : " + res2.toString()); + LOG.info("res2 : {}", res2.toString()); trouve = true; break; } @@ -340,7 +340,7 @@ public class SendingPceRPCs { if (servicePathList != null && !servicePathList.isEmpty()) { for (ServicePaths service : servicePathList) { if (service.getServicePathName().compareTo(tmp) == 0) { - LOG.info("Existing Service '" + tmp + "' found in ServicePathList ..."); + LOG.info("Existing Service '{}' found in ServicePathList ...", tmp); pathDesc = service.getPathDescription(); } } @@ -366,7 +366,7 @@ public class SendingPceRPCs { break; } } else { - LOG.info("Existing Service '" + tmp + "' not found in ServicePathList !"); + LOG.info("Existing Service '{}' not found in ServicePathList !", tmp); result = true; } if (!result) { @@ -395,7 +395,7 @@ public class SendingPceRPCs { LOG.info("retrieving path from servicePath List ..."); try { if (!servicePathList.isEmpty()) { - LOG.info("ServicePathList not empty, contains " + servicePathList.size() + " paths."); + LOG.info("ServicePathList not empty, contains {} paths.", servicePathList.size()); for (ServicePaths service : servicePathList) { org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service .types.rev170426.service.path.PathDescription tmp = service.getPathDescription(); @@ -428,7 +428,7 @@ public class SendingPceRPCs { LOG.info("PathDescriptions is null !"); result = true; } - LOG.info("testPathDescription result : " + result); + LOG.info("testPathDescription result : {}", result); return result; } @@ -444,13 +444,13 @@ public class SendingPceRPCs { List result = new ArrayList(); List paths = readPathDescriptionList(); if (!paths.isEmpty() && aendNodeId != null && zendNodeId != null) { - LOG.info("retrieving paths from pathDescription List for " + aendNodeId + " / " + zendNodeId); + LOG.info("retrieving paths from pathDescription List for {} / {}", aendNodeId, zendNodeId); for (PathDescriptions tmp : paths) { Resource pathAend = null; Resource pathZend = null; String id = null; if (tmp != null) { - LOG.info("Getting Aend & ZEnd from path '" + tmp.getPathName() + "'..."); + LOG.info("Getting Aend & ZEnd from path '{}'...",tmp.getPathName()); int index = 0; int size = tmp.getAToZDirection().getAToZ().size(); while (index < size) { @@ -458,7 +458,7 @@ public class SendingPceRPCs { if (id.compareToIgnoreCase("1") == 0) { Resource resource = tmp.getAToZDirection().getAToZ().get(index).getResource() .getResource(); - LOG.info(resource.getClass().toString() + " : " + resource.toString()); + LOG.info("{} : {}", resource.getClass().toString(), resource.toString()); pathAend = resource; break; } @@ -477,8 +477,8 @@ public class SendingPceRPCs { index++; } if (pathAend != null && pathZend != null) { - LOG.info("pathAend : " + pathAend + " - pathZend: " + pathZend); - LOG.info("aendNodeId : " + aendNodeId + " - zendNodeId : " + zendNodeId); + LOG.info("pathAend : {} - pathZend: {}",pathAend, pathZend); + LOG.info("aendNodeId : {} - zendNodeId : {}", aendNodeId, zendNodeId); if (comp(pathAend, pathZend, aendNodeId, zendNodeId)) { LOG.info("PathDescription found !"); result.add(tmp); @@ -506,9 +506,9 @@ public class SendingPceRPCs { while (it.hasNext()) { PathDescriptions path = it.next(); String name = path.getPathName(); - LOG.info("path : " + name); + LOG.info("path : {}", name); if (name != null && name.contains(contain)) { - LOG.info(" path gets : " + name); + LOG.info(" path gets : {}", name); String [] split = name.split("_"); if (split.length == 3) { odr = Integer.parseInt(split[2]); @@ -628,12 +628,12 @@ public class SendingPceRPCs { /** get pathList ordered. */ pathsList = orderPathdescriptionsList(pathsList); if (!pathsList.isEmpty()) { - LOG.info(pathsList.size() + " Paths get from Pathdescription List"); + LOG.info("{} Paths get from Pathdescription List", pathsList.size()); index = 0; output = false; while (index < pathsList.size()) { path = pathsList.get(index); - LOG.info("path n°" + index + " gets : '" + path.getPathName() + "'!"); + LOG.info("path n°{} gets : '{}'!", index, path.getPathName()); if (constraints) { LOG.info("Calculating path with constraints ..."); if (inputHard.getCoRoutingOrGeneral() instanceof General) { @@ -774,7 +774,7 @@ public class SendingPceRPCs { private Boolean writeOrDeleteServicePathList(String serviceName, int choice) { Boolean result = null; if (serviceName != null && serviceName.compareTo(" ") != 0 && choice >= 0 && choice < 2) { - LOG.info("WriteOrDeleting '" + serviceName + "' ServicePaths"); + LOG.info("WriteOrDeleting '{}' ServicePaths", serviceName); WriteTransaction writeTx = db.newWriteOnlyTransaction(); result = true; String action = null; @@ -783,7 +783,7 @@ public class SendingPceRPCs { Future future = null; switch (choice) { case 0: /** Write. */ - LOG.info("Writing '" + serviceName + "' Service"); + LOG.info("Writing '{}' Service", serviceName); org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service .path.PathDescriptionBuilder path = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c ._interface.service.types.rev170426.service.path.PathDescriptionBuilder(); @@ -818,24 +818,24 @@ public class SendingPceRPCs { //CheckedFuture future = transaction.submit(); future = writeTx.submit(); try { - LOG.info("Sending '" + action + "' command to datastore !"); + LOG.info("Sending '{}' command to datastore !", action); Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { - LOG.error("Failed to " + action + " service from Service List"); + LOG.error("Failed to {} service from Service List", action); result = false; } break; case 1: /** Delete */ - LOG.info("Deleting '" + serviceName + "' Service"); + LOG.info("Deleting '{}' Service", serviceName); writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid); action = "delete"; future = writeTx.submit(); try { - LOG.info("Sending '" + action + "' command to datastore !"); + LOG.info("Sending '{}' command to datastore !", serviceName); Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { - LOG.error("Failed to " + action + " service from Service List"); + LOG.error("Failed to {} service from Service List", serviceName); result = false; } break; diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java index 89d3404f7..f8a63c269 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java @@ -33,6 +33,26 @@ import org.opendaylight.transportpce.stubpce.StubpceTxRxCheck; import org.opendaylight.transportpce.stubpce.topology.PathDescriptionsOrdered; import org.opendaylight.transportpce.stubpce.topology.SuperNodePath; import org.opendaylight.transportpce.stubpce.topology.Topology; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathDescriptionList; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathDescriptionListBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathList; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathListBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResultBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptions; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePaths; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.list.ServicePathsKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.service.path.rpc.result.PathDescriptionBuilder; 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.service.rev161014.ServiceList; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services; @@ -40,30 +60,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescriptionBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathDescriptionList; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathDescriptionListBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathList; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathListBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathRpcResult; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathRpcResultBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptions; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptionsBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptionsKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsKey; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.rpc.result.PathDescription; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -77,7 +73,7 @@ import org.slf4j.LoggerFactory; * behalf of Orange */ -public class StubpceImpl implements TransportpceServicepathService { +public class StubpceImpl implements StubpceService { /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(StubpceImpl.class); /** Permit to access database. */ @@ -115,7 +111,7 @@ public class StubpceImpl implements TransportpceServicepathService { String responseCode = ""; ConfigurationResponseCommonBuilder configurationResponseCommon = null; String serviceName = input.getServiceName(); - LOG.info("serviceName : " + serviceName); + LOG.info("serviceName : {}", serviceName); if (serviceName != null) { sendingPCE = new SendingPceRPCs(input,db,executor); FutureCallback pceCallback = new FutureCallback() { @@ -124,8 +120,7 @@ public class StubpceImpl implements TransportpceServicepathService { @Override public void onFailure(Throwable arg0) { - LOG.error(arg0.toString()); - LOG.error("Cancel resource failed !"); + LOG.error("Cancel resource failed : {}", arg0); notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) @@ -133,13 +128,13 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @Override public void onSuccess(Boolean response) { - LOG.info("response : " + response); + LOG.info("response : {}", response); if (response) { message = "Resource cancelled !"; notification = new ServicePathRpcResultBuilder() @@ -160,7 +155,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } LOG.info(message); } @@ -176,7 +171,6 @@ public class StubpceImpl implements TransportpceServicepathService { CancelResourceReserveOutputBuilder output = new CancelResourceReserveOutputBuilder() .setConfigurationResponseCommon(configurationResponseCommon.build()); - return RpcResultBuilder.success(output.build()).buildFuture(); } else { message = "serviceName / requestId is not correct !"; @@ -188,7 +182,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } configurationResponseCommon = new ConfigurationResponseCommonBuilder(); @@ -255,7 +249,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } sendingPCE = new SendingPceRPCs(input,db,executor); FutureCallback pceCallback = new FutureCallback() { @@ -264,7 +258,7 @@ public class StubpceImpl implements TransportpceServicepathService { @Override public void onFailure(Throwable arg0) { - LOG.error("Failure message : " + arg0.toString()); + LOG.error("Failure message : {}", arg0.toString()); LOG.error("Path calculation failed !"); notification = new ServicePathRpcResultBuilder() .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) @@ -272,13 +266,13 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @Override public void onSuccess(Boolean response) { - LOG.info("response : " + response); + LOG.info("response : {}", response); if (response) { message = "Path Computated !"; ServicePathRpcResultBuilder tmp = new ServicePathRpcResultBuilder() @@ -293,7 +287,10 @@ public class StubpceImpl implements TransportpceServicepathService { .setAToZDirection(pathDescriptionBuilder.getAToZDirection()) .setZToADirection(pathDescriptionBuilder.getZToADirection()) .build(); - tmp.setPathDescription(pathDescription); + tmp.setPathDescription(new PathDescriptionBuilder() + .setAToZDirection(pathDescription.getAToZDirection()) + .setZToADirection(pathDescription.getZToADirection()) + .build()); } notification = tmp.build(); } else { @@ -308,7 +305,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } LOG.info(message); } @@ -345,7 +342,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } configurationResponseCommon = new ConfigurationResponseCommonBuilder(); @@ -400,7 +397,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { - LOG.error("Failed to create ServicePathList List : " + e.toString()); + LOG.error("Failed to create ServicePathList List : {}", e.toString()); result = false; } return result; @@ -415,7 +412,7 @@ public class StubpceImpl implements TransportpceServicepathService { LOG.info("filling PathDescription List..."); Topology topo = new Topology(); topo.start(); - LOG.info("Network : " + topo.getNetwork()); + LOG.info("Network : {}", topo.getNetwork()); SuperNodePath superNodePath = new SuperNodePath(topo.getNetwork()); String aend = "NodeA"; String zend = "NodeZ"; @@ -447,7 +444,7 @@ public class StubpceImpl implements TransportpceServicepathService { try { Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { - LOG.error("Failed to write PathDescriptions to PathDescriptionsList : " + e.toString()); + LOG.error("Failed to write PathDescriptions to PathDescriptionsList : {}", e.toString()); } } else { LOG.error("PathDescriptions gets is null !"); @@ -480,7 +477,7 @@ public class StubpceImpl implements TransportpceServicepathService { LOG.error("Reading service failed:", e); } if (optional.isPresent()) { - LOG.debug("Service '" + serviceName + "' present !"); + LOG.debug("Service '{}' present !", serviceName); result = new ServicesBuilder(optional.get()).build(); } return result; @@ -508,7 +505,7 @@ public class StubpceImpl implements TransportpceServicepathService { LOG.error("Reading service failed:", e); } if (optional.isPresent()) { - LOG.debug("Service '" + serviceName + "' present !"); + LOG.debug("Service '{}' present !", serviceName); result = new ServicePathsBuilder(optional.get()).build(); } return result; @@ -536,7 +533,7 @@ public class StubpceImpl implements TransportpceServicepathService { LOG.error("Reading service failed:", e); } if (optional.isPresent()) { - LOG.debug("PathDescritions '" + pathName + "' present !"); + LOG.debug("PathDescritions '{}' present !", pathName); result = new PathDescriptionsBuilder(optional.get()).build(); } return result; @@ -553,9 +550,9 @@ public class StubpceImpl implements TransportpceServicepathService { @SuppressWarnings("unused") private String writeServicePathList(PathComputationRequestInput input) { String serviceName = input.getServiceName(); - LOG.debug("Write ServicePath '" + serviceName + "' Service"); + LOG.debug("Write ServicePath '{}' Service", serviceName); String result = null; - LOG.debug("Writing '" + serviceName + "' ServicePath"); + LOG.debug("Writing '{}' ServicePath", serviceName); InstanceIdentifier iid = InstanceIdentifier.create(ServicePathList.class) .child(ServicePaths.class, new ServicePathsKey(serviceName)); @@ -587,17 +584,4 @@ public class StubpceImpl implements TransportpceServicepathService { public void setPathDescriptionBuilder(PathDescriptionBuilder pathDescriptionBuilder) { this.pathDescriptionBuilder = pathDescriptionBuilder; } - - @Override - public Future> serviceImplementationRequest( - ServiceImplementationRequestInput input) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Future> serviceDelete(ServiceDeleteInput input) { - // TODO Auto-generated method stub - return null; - } } diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceProvider.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceProvider.java index 9ef48f373..99163c314 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceProvider.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceProvider.java @@ -14,8 +14,8 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathListener; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,8 +33,8 @@ public class StubpceProvider { private final DataBroker dataBroker; - private BindingAwareBroker.RpcRegistration rpcRegistration; - private ListenerRegistration stubPcelistenerRegistration; + private BindingAwareBroker.RpcRegistration rpcRegistration; + private ListenerRegistration stubPcelistenerRegistration; public StubpceProvider(RpcProviderRegistry rpcProviderRegistry,final DataBroker dataBroker, NotificationService notificationService, NotificationPublishService notificationPublishService) { @@ -49,7 +49,7 @@ public class StubpceProvider { public void init() { LOG.info("StubpceProvider Session Initiated"); final StubpceImpl consumer = new StubpceImpl(notificationPublishService,dataBroker); - rpcRegistration = rpcRegistry.addRpcImplementation(TransportpceServicepathService.class, consumer); + rpcRegistration = rpcRegistry.addRpcImplementation(StubpceService.class, consumer); } /** diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java index b1bd4239a..b2781d37b 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java @@ -385,7 +385,7 @@ public class InterNodePath { LOG.info("firstnodeTpId is null !"); } } - LOG.info("getAToZDirectionEndBy result size : " + result.size() + "\n " + result.toString()); + LOG.info("getAToZDirectionEndBy result size : {}\n{}", result.size(),result.toString()); return result; } @@ -445,7 +445,7 @@ public class InterNodePath { } } } else { - LOG.info("getAToZDirectionEndBy size " + tmp.size()); + LOG.info("getAToZDirectionEndBy size : {}", tmp.size()); } return result; } @@ -473,7 +473,7 @@ public class InterNodePath { if (res != null && res instanceof TerminationPoint) { TerminationPoint tp = (TerminationPoint) res; if (tp != null && tp.getTpId().contains(beginBy)) { - LOG.info("tmp : " + tmp.toString()); + LOG.info("tmp : {}", tmp.toString()); result.add(tmp); } } @@ -481,7 +481,7 @@ public class InterNodePath { } } } - LOG.info("result size : " + result.size()); + LOG.info("result size : {}", result.size()); return result; } @@ -501,7 +501,7 @@ public class InterNodePath { path.fill(); nodepaths.add(path); } - LOG.info("nodepaths size : " + nodepaths.size()); + LOG.info("nodepaths size : {}", nodepaths.size()); build(superNode.isXpdrSrgAbsent(),superNode.getSuperNodeId(), zend); } } diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/NodePath.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/NodePath.java index 634c27958..a0facda7f 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/NodePath.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/NodePath.java @@ -150,13 +150,13 @@ public class NodePath { List direction = new ArrayList(); for (Link link : links) { String linkId = link.getLinkId(); - LOG.info("LinkId : " + linkId); + LOG.info("LinkId : {}", linkId); if (!isXpdrSrgAbsent) { if (StringUtils.countMatches(link.getLinkId(), "ROADM") < 2) { if ((linkId.contains("XPDR") && linkId.startsWith("ROADM")) || ((linkId.startsWith("DEG") && linkId.contains("SRG"))) || (nodeId.contains("XPDR") && linkId.contains("TAIL-LINKS"))) { - LOG.info("reversing TpNodetp list for link '" + linkId + "'"); + LOG.info("reversing TpNodetp list for link '{}'", linkId); direction = reverseTpNodetpList(); } else { direction = tpNodeTps; @@ -289,7 +289,7 @@ public class NodePath { Network net = topo.getNetwork(); if (net != null) { SuperNode superNode = net.getSuperNodes().get(0); - LOG.info("SuperNode : " + superNode.getSuperNodeId()); + LOG.info("SuperNode : {}", superNode.getSuperNodeId()); for (org.opendaylight.transportpce.stubpce.topology.Resource res : superNode.getResources()) { LOG.info(res.toString()); diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/PathDescriptionsOrdered.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/PathDescriptionsOrdered.java index c31c55ee5..cb8c15ff1 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/PathDescriptionsOrdered.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/PathDescriptionsOrdered.java @@ -8,7 +8,7 @@ package org.opendaylight.transportpce.stubpce.topology; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptions; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptions; /** * class to create structure diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java index 732f31888..ef455f5a5 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java @@ -16,6 +16,7 @@ import java.util.ListIterator; import java.util.SortedSet; import java.util.TreeSet; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection; @@ -30,7 +31,6 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdes import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.Link; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.LinkBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptionsBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -121,7 +121,7 @@ public class SuperNodePath { for (String tmp : links) { if (tmp.contains(aend) && tmp.contains(zend)) { - LOG.info("direct path found for : " + aend + " / " + zend); + LOG.info("direct path found for : {} / {}", aend, zend); if (tmp.startsWith(aend)) { atozlink = tmp; } @@ -156,7 +156,7 @@ public class SuperNodePath { tmp = tmp.replace("Node", "ROADM"); if (tmp.compareTo(aend) != 0) { if (link.contains(aend) && link.contains(tmp)) { - LOG.info("hop : " + tmp); + LOG.info("hop : {}", tmp); result = tmp; } } @@ -226,7 +226,7 @@ public class SuperNodePath { } } else { - LOG.info(term + " links not found !"); + LOG.info("{} links not found !", term); } } @@ -257,7 +257,7 @@ public class SuperNodePath { hop = findHop(tmp, aend, supernodes); if (hop != null) { if (hop.compareTo(zend.replace("Node", "ROADM")) != 0) { - LOG.info("next hop found : " + hop); + LOG.info("next hop found : {}", hop); links.addAll(findLinks(aend,hop,roadmLinks,false)); links.addAll(findLinks(hop,zend,roadmLinks,false)); } else { @@ -501,7 +501,7 @@ public class SuperNodePath { PathDescriptionsBuilder pathDescr = new PathDescriptionsBuilder(); int size = atozDirection.size(); if (!atozDirection.isEmpty()) { - LOG.info("result list AToZDirection size : " + atozDirection.size()); + LOG.info("result list AToZDirection size : {}", atozDirection.size()); List ztoadirList = new ArrayList(); for (AToZDirection atozdir : atozDirection) { ZToADirection ztodir = convertToZtoaDirection(atozdir); @@ -515,10 +515,10 @@ public class SuperNodePath { String pathName = null; for (int indexPath = 0 ; indexPath < size ; indexPath++) { pathName = term.concat(Integer.toString(index)); - LOG.info("pathName : " + pathName); + LOG.info("pathName : {}", pathName); pathDescr.setAToZDirection(atozDirection.get(indexPath)) .setZToADirection(ztoadirList.get(indexPath)).setPathName(pathName); - LOG.info(pathDescr.build().toString()); + LOG.info("pathdesciption : {}", pathDescr.build().toString()); result.add(new PathDescriptionsOrdered(pathDescr.build(),index)); index++; } @@ -546,7 +546,7 @@ public class SuperNodePath { String aend = split[0].replaceAll("ROADM", "Node"); String zend = split[2].replaceAll("ROADM", "Node"); if (aend != null && zend != null) { - LOG.info("getting super node for : " + aend + " and " + zend); + LOG.info("getting super node for : {} and {}", aend, zend); SuperNode aendSp = getSuperNode(aend); SuperNode zendSp = getSuperNode(zend); if (aendSp != null && zendSp != null) { @@ -575,20 +575,20 @@ public class SuperNodePath { if (!paths.isEmpty()) { for (NodeLinkNode tmp : paths) { if (tmp.getDirect()) { - LOG.info("Direct NodeLinkNode : " + tmp.toString()); + LOG.info("Direct NodeLinkNode : {}", tmp.toString()); String atozLink = null; String ztoaLink = null; atozLink = tmp.getAtozLink().get(0); ztoaLink = tmp.getZtoaLink().get(0); if (atozLink != null && ztoaLink != null) { - LOG.info("atozlink : " + atozLink); - LOG.info("ztoalink : " + ztoaLink); + LOG.info("atozlink : {}", atozLink); + LOG.info("ztoalink : {}", ztoaLink); InterNodePath interAend = new InterNodePath(aendSp); interAend.buildPath(zend); InterNodePath interZend = new InterNodePath(zendSp); interZend.buildPath(zend); List deg = getDeg(atozLink,ztoaLink); - LOG.info("deg : " + deg.toString()); + LOG.info("deg : {}", deg.toString()); if (deg.size() == 2) { List cleanInterA = interAend.replaceOrRemoveAToZDirectionEndLink(deg.get(0),"",atozLink, @@ -614,7 +614,7 @@ public class SuperNodePath { LOG.info("List of direct path is empty !"); } if (!atozdirectionPaths.isEmpty()) { - LOG.info("result size : " + result.size()); + LOG.info("result size : {}", result.size()); result = buildPathDescription(atozdirectionPaths,aend.concat("To").concat(zend).concat("_direct_")); } else { LOG.info("result is empty"); @@ -638,17 +638,17 @@ public class SuperNodePath { if (!paths.isEmpty()) { for (NodeLinkNode tmp : paths) { if (!tmp.getDirect()) { - LOG.info("Indirect NodeLinkNode : " + tmp.toString()); + LOG.info("Indirect NodeLinkNode : {}", tmp.toString()); int size = tmp.getAtozLink().size(); /** must be two for now just one hop. */ - LOG.info("number of links : " + size); + LOG.info("number of links : {}", size); boolean first = true; if (size == 2) { List atozLinks = tmp.getAtozLink(); List ztoaLinks = tmp.getZtoaLink(); if (!atozLinks.isEmpty() && !ztoaLinks.isEmpty()) { - LOG.info("atozlink : " + atozLinks.toString()); - LOG.info("ztoalink : " + ztoaLinks.toString()); + LOG.info("atozlink : {}", atozLinks.toString()); + LOG.info("ztoalink : {}", ztoaLinks.toString()); int loop = 0; while (loop < 2) { List hop = getSuperNodeEndLink(atozLinks.get(loop)); @@ -657,12 +657,12 @@ public class SuperNodePath { zendSp = hop.get(1); InterNodePath interAend = new InterNodePath(aendSp); interAend.buildPath(zend); - LOG.info("interAend : " + interAend.getAtoz().toString()); + LOG.info("interAend : {}", interAend.getAtoz().toString()); InterNodePath interZend = new InterNodePath(zendSp); interZend.buildPath(zend); - LOG.info("interZend : " + interZend.getAtoz().toString()); + LOG.info("interZend : {}", interZend.getAtoz().toString()); List deg1 = getDeg(atozLinks.get(loop),ztoaLinks.get(loop)); - LOG.info("deg1 : " + deg1.toString()); + LOG.info("deg1 : {}", deg1.toString()); if (!deg1.isEmpty() && deg1.size() == 2) { List cleanInterA = null; List cleanInterZ = null; @@ -702,7 +702,7 @@ public class SuperNodePath { LOG.info("List of indirect path is empty !"); } if (!atozdirectionPaths.isEmpty()) { - LOG.info("result size : " + result.size()); + LOG.info("result size : {}", result.size()); result = buildPathDescription(atozdirectionPaths,aend.concat("To").concat(zend).concat("_indirect_")); } else { LOG.info("result is empty"); diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/Topology.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/Topology.java index 72fd5dd58..0be69bedd 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/Topology.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/Topology.java @@ -60,7 +60,7 @@ public class Topology { xml = inputStreamToString(is); if (xml != null) { setNetwork(xmlMapper.readValue(xml, Network.class)); - LOG.info("Network : " + network.toString()); + LOG.info("Network : {}", network.toString()); } else { LOG.info("String xml is null"); } diff --git a/tests/stubrenderer/pom.xml b/tests/stubrenderer/pom.xml index 5adece408..921303a53 100644 --- a/tests/stubrenderer/pom.xml +++ b/tests/stubrenderer/pom.xml @@ -35,6 +35,11 @@ Author: Martial Coulibaly on behalf of Orange transportpce-ordmodels ${project.version} + + ${project.groupId} + transportpce-stubmodels + ${project.version} + diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java index c7f587c7f..cdcdc0ec6 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java @@ -70,7 +70,7 @@ public class SendingRendererRPCs { Thread.sleep(10000); //sleep for 10s } catch (InterruptedException e) { output = false; - LOG.error(e.toString()); + LOG.error("Thread.sleep failed : {}", e.toString()); } buildAtoZ(); buildZtoA(); @@ -92,7 +92,7 @@ public class SendingRendererRPCs { Thread.sleep(10000); //sleep for 10s } catch (InterruptedException e) { output = false; - LOG.error(e.toString()); + LOG.error("Thread.sleep failed : {}", e.toString()); } buildAtoZ(); buildZtoA(); diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java index 1be07aa7b..23ae97628 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java @@ -21,25 +21,21 @@ import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.stubrenderer.SendingRendererRPCs; import org.opendaylight.transportpce.stubrenderer.StubrendererCompliancyCheck; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSp; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSpBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopology; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopologyBuilder; 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.service.TopologyBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceRpcResultSp; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceRpcResultSpBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopology; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopologyBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -52,7 +48,7 @@ import org.slf4j.LoggerFactory; * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ -public class StubrendererImpl implements TransportpceServicepathService { +public class StubrendererImpl implements StubrendererService { /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class); /** send notification. */ @@ -93,7 +89,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); @@ -104,22 +100,22 @@ public class StubrendererImpl implements TransportpceServicepathService { @Override public void onFailure(Throwable arg0) { - LOG.error("Failure message : " + arg0.toString()); + LOG.error("Failure message : {}", arg0.toString()); LOG.error("Service implementation failed !"); notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) - .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); + .setStatusMessage("PCR Request failed : {}" + arg0.getMessage()).build(); try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @Override public void onSuccess(Boolean response) { - LOG.info("response : " + response); + LOG.info("response : {}", response); if (response) { message = "Service implemented !"; TopologyBuilder topo = sendingRenderer.getTopology(); @@ -148,7 +144,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } LOG.info(message); } @@ -169,7 +165,7 @@ public class StubrendererImpl implements TransportpceServicepathService { } else { message = compliancyCheck.getMessage(); responseCode = "500"; - LOG.info("Service not compliant caused by : " + message); + LOG.info("Service not compliant caused by : {}", message); notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) @@ -178,7 +174,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } configurationResponseCommon = new ConfigurationResponseCommonBuilder() @@ -217,7 +213,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); FutureCallback rendererCallback = new FutureCallback() { @@ -226,7 +222,7 @@ public class StubrendererImpl implements TransportpceServicepathService { @Override public void onFailure(Throwable arg0) { - LOG.error("Failure message : " + arg0.toString()); + LOG.error("Failure message : {}", arg0.toString()); LOG.error("Service delete failed !"); notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) @@ -235,13 +231,13 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } @Override public void onSuccess(Boolean response) { - LOG.info("response : " + response); + LOG.info("response : {}", response); if (response) { message = "Service deleted !"; notification = new ServiceRpcResultSpBuilder() @@ -260,7 +256,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } LOG.info(message); } @@ -280,7 +276,7 @@ public class StubrendererImpl implements TransportpceServicepathService { return RpcResultBuilder.success(output).buildFuture(); } else { message = compliancyCheck.getMessage(); - LOG.info("Service not compliant caused by : " + message); + LOG.info("Service not compliant caused by : {}", message); responseCode = "500"; notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) @@ -290,7 +286,7 @@ public class StubrendererImpl implements TransportpceServicepathService { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); + LOG.info("notification offer rejected : {}", e); } } configurationResponseCommon = new ConfigurationResponseCommonBuilder() @@ -303,16 +299,4 @@ public class StubrendererImpl implements TransportpceServicepathService { .build(); return RpcResultBuilder.success(output).buildFuture(); } - - @Override - public Future> cancelResourceReserve(CancelResourceReserveInput input) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Future> pathComputationRequest(PathComputationRequestInput input) { - // TODO Auto-generated method stub - return null; - } } diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java index dff06285e..6dcdb8ebc 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java @@ -13,8 +13,8 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathListener; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,8 +30,8 @@ public class StubrendererProvider { private final NotificationPublishService notificationPublishService; - private BindingAwareBroker.RpcRegistration rpcRegistration; - private ListenerRegistration stubRendererlistenerRegistration; + private BindingAwareBroker.RpcRegistration rpcRegistration; + private ListenerRegistration stubRendererlistenerRegistration; public StubrendererProvider(RpcProviderRegistry rpcProviderRegistry, NotificationService notificationService, @@ -46,7 +46,7 @@ public class StubrendererProvider { public void init() { LOG.info("StubrendererProvider Session Initiated"); final StubrendererImpl consumer = new StubrendererImpl(notificationPublishService); - rpcRegistration = rpcRegistry.addRpcImplementation(TransportpceServicepathService.class, consumer); + rpcRegistration = rpcRegistry.addRpcImplementation(StubrendererService.class, consumer); } /** diff --git a/tests/tox.ini b/tests/tox.ini index 702fe9360..368ca4b90 100644 --- a/tests/tox.ini +++ b/tests/tox.ini @@ -11,3 +11,13 @@ commands = bash -c "(cd .. && mvn clean install -DskipTests -Dmaven.javadoc.skip=true)" ./build.sh nosetests --with-xunit transportpce_tests + +[testenv:servicehandler] +usedevelop = True +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +whitelist_externals = bash +commands = + bash -c "(cd .. && mvn clean install -DskipTests -Dmaven.javadoc.skip=true)" + nosetests --with-xunit transportpce_tests/test_servicehandler.py diff --git a/tests/transportpce_tests/test_servicehandler.py b/tests/transportpce_tests/test_servicehandler.py new file mode 100644 index 000000000..e3bdc1184 --- /dev/null +++ b/tests/transportpce_tests/test_servicehandler.py @@ -0,0 +1,661 @@ +#!/usr/bin/env python +############################################################################## +#Copyright (c) 2017 Orange, Inc. and others. All rights reserved. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import json +import os +import psutil +import requests +import signal +import shutil +import subprocess +import time +import unittest + + +class TransportPCEtesting(unittest.TestCase): + + odl_process = None + restconf_baseurl = "http://127.0.0.1:8181/restconf" + + @classmethod + def __start_odl(cls): + executable = "../karaf/target/assembly/bin/karaf" + with open('odl.log', 'w') as outfile: + cls.odl_process = subprocess.Popen( + ["bash", executable], stdout=outfile, + stdin=open(os.devnull)) + + @classmethod + def setUpClass(cls): #a class method called before tests in an individual class run. + cls.__start_odl() + time.sleep(90) + + @classmethod + def tearDownClass(cls): + for child in psutil.Process(cls.odl_process.pid).children(): + child.send_signal(signal.SIGINT) + child.wait() + cls.odl_process.send_signal(signal.SIGINT) + cls.odl_process.wait() + + def setUp(self): #instruction executed before each test method + time.sleep(1) + + #Get existing PathDesciption + def test_01_get_pathdescriptions(self): + url = ("{}/operational/stubpce:path-description-list/pathDescriptions/NodeAToNodeZ_direct_1" + .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['pathDescriptions'][0]['path-name'], + 'NodeAToNodeZ_direct_1') + time.sleep(1) + + #Get non existing PathDesciption + def test_02_get_pathdescriptions(self): + url = ("{}/operational/stubpce:path-description-list/pathDescriptions/Node" + .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) + + #Create Service 'test' with correct parameters + def test_03_create_service(self): + url = ("{}/operations/org-openroadm-service:service-create" + .format(self.restconf_baseurl)) + data = {"input": { + "sdnc-request-header": { + "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", + "rpc-action": "service-create", + "request-system-id": "appname", + "notification-url": "http://localhost:8585/NotificationServer/notify" + }, + "service-name": "test", + "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" + }, + "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('in progress', + res['output']['configuration-response-common']['response-message']) + time.sleep(30) + + #Create Service 'test' with not compliant parameter : no 'sdnc-request-header' parameter + def test_04_create_service(self): + url = ("{}/operations/org-openroadm-service:service-create" + .format(self.restconf_baseurl)) + data = {"input": { + "service-name": "test", + "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" + }, + "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 not compliant', + res['output']['configuration-response-common']['response-message']) + time.sleep(5) + + #Create Service 'test' with not compliant parameter : no 'tx-direction' for serviceAEnd + def test_05_create_service(self): + url = ("{}/operations/org-openroadm-service:service-create" + .format(self.restconf_baseurl)) + data = {"input": { + "sdnc-request-header": { + "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", + "rpc-action": "service-create", + "request-system-id": "appname", + "notification-url": "http://localhost:8585/NotificationServer/notify" + }, + "service-name": "test", + "common-id": "ASATT1234567", + "connection-type": "infrastructure", + "service-a-end": { + "service-rate": "100", + "node-id": "XPDRA", + "service-format": "Ethernet", + "clli": "SNJSCAMCJP8", + "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" + }, + "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 not compliant', + res['output']['configuration-response-common']['response-message']) + time.sleep(5) + + #Get 'test' service created + def test_06_get_service(self): + url = ("{}/operational/org-openroadm-service:service-list/services/test" + .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_07_get_service(self): + url = ("{}/operational/org-openroadm-service: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) + + #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) + + + #Delete 'test-new' service + def test_14_delete_service(self): + url = ("{}/operations/org-openroadm-service:service-delete" + .format(self.restconf_baseurl)) + data = {"input": { + "sdnc-request-header": { + "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", + "rpc-action": "service-delete", + "request-system-id": "appname", + "notification-url": "http://localhost:8585/NotificationServer/notify" + }, + "service-delete-req-info": { + "service-name": "test-new", + "due-date": "2016-11-28T00:00:01Z", + "tail-retention": "no" + } + } + } + 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']['configuration-response-common']['response-message']) + time.sleep(30) + + + #Delete non existing service + def test_15_delete_service(self): + url = ("{}/operations/org-openroadm-service:service-delete" + .format(self.restconf_baseurl)) + data = {"input": { + "sdnc-request-header": { + "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", + "rpc-action": "service-delete", + "request-system-id": "appname", + "notification-url": "http://localhost:8585/NotificationServer/notify" + }, + "service-delete-req-info": { + "service-name": "test", + "due-date": "2016-11-28T00:00:01Z", + "tail-retention": "no" + } + } + } + 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('not exists in datastore', + res['output']['configuration-response-common']['response-message']) + time.sleep(1) + + + #Verify 'test' service deleted + def test_16_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')) + self.assertEqual(response.status_code, 404) + time.sleep(1) + +if __name__ == "__main__": + unittest.main(verbosity=2) -- 2.36.6