import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraintsBuilder;
private ModelMappingUtils() {
}
- public static ServiceImplementationRequestInput createServiceImplementationRequest(ServiceCreateInput input,
+ public static ServiceImplementationRequestInput createServiceImplementationRequest(ServiceInput input,
PathComputationRequestOutput pceResponse) {
ServiceImplementationRequestInputBuilder serviceImplementationRequestInputBuilder =
new ServiceImplementationRequestInputBuilder();
return serviceImplementationRequestInputBuilder.build();
}
-
public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput createServiceDeleteInput(ServiceDeleteInput serviceDeleteInput) {
+ .ServiceDeleteInput createServiceDeleteInput(ServiceInput serviceInput) {
ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder();
- builder.setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
+ builder.setServiceName(serviceInput.getServiceName());
builder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
- .setRequestId(serviceDeleteInput.getSdncRequestHeader().getRequestId()).build());
+ .setRequestId(serviceInput.getSdncRequestHeader().getRequestId()).build());
return builder.build();
}
return builder.build();
}
- public static ServiceAEnd createServiceAEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
- .service.create.input.ServiceAEnd serviceAEnd) {
+ public static ServiceAEnd createServiceAEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types
+ .rev161014.ServiceEndpoint serviceAEnd) {
ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder();
serviceAEndBuilder.setClli(serviceAEnd.getClli());
serviceAEndBuilder.setNodeId(serviceAEnd.getNodeId());
return serviceAEndBuilder.build();
}
- public static ServiceZEnd createServiceZEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
- .service.create.input.ServiceZEnd serviceZEnd) {
+ public static ServiceZEnd createServiceZEnd(org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types
+ .rev161014.ServiceEndpoint serviceZEnd) {
ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder();
serviceZEndBuilder.setClli(serviceZEnd.getClli());
serviceZEndBuilder.setNodeId(serviceZEnd.getNodeId());
return RpcResultBuilder.success(output).buildFuture();
}
+ public static ListenableFuture<RpcResult<TempServiceDeleteOutput>> createDeleteServiceReply(
+ TempServiceDeleteInput input, String finalAck, String message, String responseCode) {
+ ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(finalAck).setResponseMessage(message).setResponseCode(responseCode);
+ builder.setRequestId(null);
+ ConfigurationResponseCommon configurationResponseCommon = builder.build();
+ TempServiceDeleteOutput output = new TempServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+
public static ListenableFuture<RpcResult<ServiceCreateOutput>> createCreateServiceReply(ServiceCreateInput input,
String finalAck, String message, String responseCode) {
ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
return RpcResultBuilder.success(output.build()).buildFuture();
}
+ public static ListenableFuture<RpcResult<TempServiceCreateOutput>> createCreateServiceReply(
+ TempServiceCreateInput input, String finalAck, String message, String responseCode) {
+ ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
+ ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(finalAck).setResponseMessage(message).setResponseCode(responseCode);
+ if (input.getSdncRequestHeader() != null) {
+ configurationResponseCommon.setRequestId(input.getSdncRequestHeader().getRequestId());
+ } else {
+ configurationResponseCommon.setRequestId(null);
+ }
+ TempServiceCreateOutputBuilder output =
+ new TempServiceCreateOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon.build())
+ .setResponseParameters(responseParameters.build());
+ return RpcResultBuilder.success(output.build()).buildFuture();
+ }
+
public static ListenableFuture<RpcResult<ServiceRerouteOutput>> createRerouteServiceReply(ServiceRerouteInput input,
String finalAckYes, String message, RpcStatus status) {
ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
return RpcResultBuilder.success(output.build()).buildFuture();
}
- /*
- * Map Input (ServiceCreateInmput, ServiceReconfigureInput) & output
- * (PathComputationRequestOutput) to Service.
- *
- * @param serviceCreateInput ServiceCreateInput parameter
- *
- * @param serviceReconfigureInput serviceReconfigureInput parameter
- *
- * @param output PathComputationRequestOutput parameter
- *
- * @return Services Service data
- */
public static Services mappingServices(ServiceCreateInput serviceCreateInput,
ServiceReconfigureInput serviceReconfigureInput) {
org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd aend = null;
.setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader())
.setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
} else if (serviceReconfigureInput != null) {
- aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014
- .service.ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build();
+ aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build();
zend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
.ServiceZEndBuilder(serviceReconfigureInput.getServiceZEnd()).build();
- service.setServiceName(serviceReconfigureInput.getNewServiceName())
- .setAdministrativeState(State.OutOfService).setOperationalState(State.OutOfService)
- .setCommonId(serviceReconfigureInput.getCommonId())
+ service.setServiceName(serviceReconfigureInput.getServiceName()).setAdministrativeState(State.OutOfService)
+ .setOperationalState(State.OutOfService).setCommonId(serviceReconfigureInput.getCommonId())
.setConnectionType(serviceReconfigureInput.getConnectionType())
.setCustomer(serviceReconfigureInput.getCustomer())
.setCustomerContact(serviceReconfigureInput.getCustomerContact())
return service.build();
}
- /*
- * Map Input (ServiceCreateInmput, ServiceReconfigureInput) & output
- * (PathComputationRequestOutput) to ServicePath.
- *
- * @param serviceCreateInput ServiceCreateInput parameter
- *
- * @param serviceReconfigureInput serviceReconfigureInput parameter
- *
- * @param output PathComputationRequestOutput parameter
- *
- * @return ServicesPaths Service Path data
- */
- public static ServicePaths mappingServicePaths(ServiceCreateInput serviceCreateInput,
- ServiceReconfigureInput serviceReconfigureInput, PathComputationRequestOutput output) {
+ public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services mappingServices(TempServiceCreateInput tempServiceCreateInput) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd aend = null;
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd zend = null;
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .ServicesBuilder service = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+ .service.list.ServicesBuilder();
+ aend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceAEndBuilder(tempServiceCreateInput.getServiceAEnd()).build();
+ zend = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .ServiceZEndBuilder(tempServiceCreateInput.getServiceZEnd()).build();
+ service.setServiceName(tempServiceCreateInput.getCommonId()).setAdministrativeState(State.OutOfService)
+ .setOperationalState(State.OutOfService).setCommonId(tempServiceCreateInput.getCommonId())
+ .setConnectionType(tempServiceCreateInput.getConnectionType())
+ .setCustomer(tempServiceCreateInput.getCustomer())
+ .setCustomerContact(tempServiceCreateInput.getCustomerContact())
+ .setHardConstraints(tempServiceCreateInput.getHardConstraints())
+ .setSoftConstraints(tempServiceCreateInput.getSoftConstraints())
+ .setSdncRequestHeader(tempServiceCreateInput.getSdncRequestHeader())
+ .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
+ return service.build();
+ }
+
+ public static ServicePaths mappingServicePaths(ServiceInput serviceInput, PathComputationRequestOutput output) {
ServicePathsBuilder servicePathBuilder = new ServicePathsBuilder();
- if (serviceCreateInput != null) {
+ if (serviceInput != null) {
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.service.types.rev171016.service.path.ServiceAEndBuilder serviceAEnd =
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.service.types.rev171016.service.path.ServiceAEndBuilder();
- serviceAEnd.setServiceFormat(serviceCreateInput.getServiceAEnd().getServiceFormat())
- .setServiceRate(serviceCreateInput.getServiceAEnd().getServiceRate())
- .setClli(serviceCreateInput.getServiceAEnd().getClli())
- .setNodeId(serviceCreateInput.getServiceAEnd().getNodeId())
+ serviceAEnd.setServiceFormat(serviceInput.getServiceAEnd().getServiceFormat())
+ .setServiceRate(serviceInput.getServiceAEnd().getServiceRate())
+ .setClli(serviceInput.getServiceAEnd().getClli())
+ .setNodeId(serviceInput.getServiceAEnd().getNodeId())
.setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
.rev171016.service.endpoint.sp.TxDirectionBuilder()
- .setPort(serviceCreateInput.getServiceAEnd().getTxDirection().getPort()).build())
+ .setPort(serviceInput.getServiceAEnd().getTxDirection().getPort()).build())
.setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
.rev171016.service.endpoint.sp.RxDirectionBuilder()
- .setPort(serviceCreateInput.getServiceAEnd().getRxDirection().getPort()).build());
+ .setPort(serviceInput.getServiceAEnd().getRxDirection().getPort()).build());
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.service.types.rev171016.service.path.ServiceZEndBuilder serviceZEnd =
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.service.types.rev171016.service.path.ServiceZEndBuilder();
- serviceZEnd.setServiceFormat(serviceCreateInput.getServiceZEnd().getServiceFormat())
- .setServiceRate(serviceCreateInput.getServiceZEnd().getServiceRate())
- .setClli(serviceCreateInput.getServiceZEnd().getClli())
- .setNodeId(serviceCreateInput.getServiceZEnd().getNodeId())
+ serviceZEnd.setServiceFormat(serviceInput.getServiceZEnd().getServiceFormat())
+ .setServiceRate(serviceInput.getServiceZEnd().getServiceRate())
+ .setClli(serviceInput.getServiceZEnd().getClli())
+ .setNodeId(serviceInput.getServiceZEnd().getNodeId())
.setTxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
.rev171016.service.endpoint.sp.TxDirectionBuilder()
- .setPort(serviceCreateInput.getServiceZEnd().getTxDirection().getPort()).build())
+ .setPort(serviceInput.getServiceZEnd().getTxDirection().getPort()).build())
.setRxDirection(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
.rev171016.service.endpoint.sp.RxDirectionBuilder()
- .setPort(serviceCreateInput.getServiceZEnd().getRxDirection().getPort()).build());
+ .setPort(serviceInput.getServiceZEnd().getRxDirection().getPort()).build());
servicePathBuilder.setServiceAEnd(serviceAEnd.build());
servicePathBuilder.setServiceZEnd(serviceZEnd.build());
- MappingConstraints mapConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
- serviceCreateInput.getSoftConstraints());
+ MappingConstraints mapConstraints = new MappingConstraints(serviceInput.getHardConstraints(),
+ serviceInput.getSoftConstraints());
mapConstraints.serviceToServicePathConstarints();
if (mapConstraints.getServicePathHardConstraints() != null) {
HardConstraintsBuilder hardConstraintBuilder = new HardConstraintsBuilder();
- hardConstraintBuilder.setCustomerCode(serviceCreateInput.getHardConstraints().getCustomerCode());
+ hardConstraintBuilder.setCustomerCode(serviceInput.getHardConstraints().getCustomerCode());
hardConstraintBuilder
.setCoRoutingOrGeneral(mapConstraints.getServicePathHardConstraints().getCoRoutingOrGeneral());
servicePathBuilder.setHardConstraints(hardConstraintBuilder.build());
.setCoRoutingOrGeneral(mapConstraints.getServicePathSoftConstraints().getCoRoutingOrGeneral());
servicePathBuilder.setSoftConstraints(softConstraintBuilder.build());
}
- servicePathBuilder.setServicePathName(serviceCreateInput.getServiceName());
+ servicePathBuilder.setServicePathName(serviceInput.getServiceName());
servicePathBuilder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()
- .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId()).build());
+ .setRequestId(serviceInput.getSdncRequestHeader().getRequestId()).build());
PathDescriptionBuilder pathDescBuilder =
new PathDescriptionBuilder(output.getResponseParameters().getPathDescription());
servicePathBuilder.setPathDescription(pathDescBuilder.build());
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler;
+
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+
+/**
+ * Super class of {@link ServiceCreateInput} and {@link TempServiceCreateInput}.
+ *
+ * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
+ *
+ */
+public class ServiceInput {
+ private String serviceName;
+ private String commonId;
+ private ConnectionType connectionType;
+ private SdncRequestHeader sdncRequestHeader;
+ private HardConstraints hardConstraints;
+ private SoftConstraints softConstraints;
+ private ServiceEndpoint serviceAEnd;
+ private ServiceEndpoint serviceZEnd;
+ private String customer;
+ private String customerContact;
+
+ public ServiceInput(TempServiceCreateInput tempServiceCreateInput) {
+ setServiceName(tempServiceCreateInput.getCommonId());
+ setCommonId(tempServiceCreateInput.getCommonId());
+ setConnectionType(tempServiceCreateInput.getConnectionType());
+ setSdncRequestHeader(tempServiceCreateInput.getSdncRequestHeader());
+ setHardConstraints(tempServiceCreateInput.getHardConstraints());
+ setSoftConstraints(tempServiceCreateInput.getSoftConstraints());
+ setServiceAEnd(tempServiceCreateInput.getServiceAEnd());
+ setServiceZEnd(tempServiceCreateInput.getServiceZEnd());
+ setCustomer(tempServiceCreateInput.getCustomer());
+ setCustomerContact(tempServiceCreateInput.getCustomerContact());
+ }
+
+ public ServiceInput(ServiceCreateInput serviceCreateInput) {
+ setServiceName(serviceCreateInput.getServiceName());
+ setCommonId(serviceCreateInput.getCommonId());
+ setConnectionType(serviceCreateInput.getConnectionType());
+ setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader());
+ setHardConstraints(serviceCreateInput.getHardConstraints());
+ setSoftConstraints(serviceCreateInput.getSoftConstraints());
+ setServiceAEnd(serviceCreateInput.getServiceAEnd());
+ setServiceZEnd(serviceCreateInput.getServiceZEnd());
+ setCustomer(serviceCreateInput.getCustomer());
+ setCustomerContact(serviceCreateInput.getCustomerContact());
+ }
+
+ public ServiceInput(ServiceDeleteInput serviceDeleteInput) {
+ setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
+ setSdncRequestHeader(serviceDeleteInput.getSdncRequestHeader());
+ }
+
+ public ServiceInput(TempServiceDeleteInput tempServiceDeleteInput) {
+ String comId = tempServiceDeleteInput.getCommonId();
+ setServiceName(comId);
+ setCommonId(comId);
+ setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId(comId).build());
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getCommonId() {
+ return commonId;
+ }
+
+ public void setCommonId(String commonId) {
+ this.commonId = commonId;
+ }
+
+ public ConnectionType getConnectionType() {
+ return connectionType;
+ }
+
+ public void setConnectionType(ConnectionType connectionType) {
+ this.connectionType = connectionType;
+ }
+
+ public SdncRequestHeader getSdncRequestHeader() {
+ return sdncRequestHeader;
+ }
+
+ public void setSdncRequestHeader(SdncRequestHeader sdncRequestHeader) {
+ this.sdncRequestHeader = sdncRequestHeader;
+ }
+
+ public ServiceEndpoint getServiceAEnd() {
+ return serviceAEnd;
+ }
+
+ public void setServiceAEnd(ServiceEndpoint serviceAEnd) {
+ this.serviceAEnd = serviceAEnd;
+ }
+
+ public ServiceEndpoint getServiceZEnd() {
+ return serviceZEnd;
+ }
+
+ public void setServiceZEnd(ServiceEndpoint serviceZEnd) {
+ this.serviceZEnd = serviceZEnd;
+ }
+
+ public HardConstraints getHardConstraints() {
+ return hardConstraints;
+ }
+
+ public void setHardConstraints(HardConstraints hardConstraints) {
+ this.hardConstraints = hardConstraints;
+ }
+
+ public SoftConstraints getSoftConstraints() {
+ return softConstraints;
+ }
+
+ public void setSoftConstraints(SoftConstraints softConstraints) {
+ this.softConstraints = softConstraints;
+ }
+
+ public String getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(String customer) {
+ this.customer = customer;
+ }
+
+ public String getCustomerContact() {
+ return customerContact;
+ }
+
+ public void setCustomerContact(String customerContact) {
+ this.customerContact = customerContact;
+ }
+}
package org.opendaylight.transportpce.servicehandler.impl;
import com.google.common.util.concurrent.ListenableFuture;
+
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
LOG.info("RPC service creation received");
// Validation
- OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
+ new ServiceInput(input), RpcActions.ServiceCreate);
if (! validationResult.isSuccess()) {
LOG.warn("Aborting service create because validation of service create request failed: {}",
validationResult.getResultMessage());
ResponseCodes.RESPONSE_FAILED);
}
- OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(input,
- pceResponse);
+ OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
+ new ServiceInput(input), pceResponse);
if (!operationServicePathSaveResult.isSuccess()) {
String message = "Service Path not updated in datastore !";
LOG.info(message);
}
ServiceImplementationRequestInput serviceImplementationRequest =
- ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
+ ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
.serviceImplementation(serviceImplementationRequest);
if (ResponseCodes.RESPONSE_OK
LOG.debug("Service '{}' present in datastore !", serviceName);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
+ .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(input));
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
.ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
@Override
public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
- // TODO Auto-generated method stub
- return null;
+ LOG.info("RPC temp serviceDelete request received for {}", input.getCommonId());
+ String message = "";
+
+ /*
+ * Upon receipt of service-deleteService RPC, service header and sdnc-request
+ * header compliancy are verified.
+ */
+ LOG.info("checking Service Compliancy ...");
+ ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(input.getCommonId(),
+ null, null, RpcActions.ServiceDelete, false, false);
+ if (serviceHandlerCheckResult.hasPassed()) {
+ LOG.info("Service compliant !");
+ } else {
+ LOG.info("Service is not compliant !");
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ "Service not compliant !", ResponseCodes.RESPONSE_FAILED);
+ }
+
+ //Check presence of service to be deleted
+ String commonId = input.getCommonId();
+ LOG.info("service common-id : {}", commonId);
+ try {
+ Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> service = this.serviceDataStoreOperations.getTempService(commonId);
+ if (!service.isPresent()) {
+ message = "Service '" + commonId + "' does not exist in datastore";
+ LOG.error(message);
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ message, ResponseCodes.RESPONSE_FAILED);
+ }
+ } catch (NullPointerException e) {
+ LOG.info("failed to get service '{}' from datastore : ", commonId, e);
+ }
+
+ LOG.debug("Service '{}' present in datastore !", commonId);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(input));
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
+
+ if (!ResponseCodes.RESPONSE_OK
+ .equals(output.getConfigurationResponseCommon().getResponseCode())) {
+ message = "Service delete failed!";
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
+ }
+
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
+ }
+
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteTempService(input.getCommonId());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
+ }
+
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ "Service delete was successful!", ResponseCodes.RESPONSE_OK);
}
@Override
public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
- // TODO Auto-generated method stub
- return null;
+ LOG.info("RPC temp service creation received");
+ // Validation
+ OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
+ new ServiceInput(input), RpcActions.TempServiceCreate);
+ if (! validationResult.isSuccess()) {
+ LOG.warn("Aborting service create because validation of service create request failed: {}",
+ validationResult.getResultMessage());
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
+ }
+
+ // Starting service create operation
+ LOG.info("Commencing PCE");
+ //TODO: createService service status into datastore
+ PathComputationRequestOutput pceResponse = this.pceServiceWrapper.performPCE(input, true);
+ String pceResponseCode = pceResponse.getConfigurationResponseCommon().getResponseCode();
+ if (!ResponseCodes.RESPONSE_OK.equals(pceResponseCode)) {
+ LOG.info("PCE calculation failed {}", pceResponseCode);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ pceResponse.getConfigurationResponseCommon().getResponseMessage(), ResponseCodes.RESPONSE_FAILED);
+ }
+
+ LOG.info("PCE calculation done OK {}", pceResponseCode);
+
+ OperationResult operationResult = this.serviceDataStoreOperations.createTempService(input, pceResponse);
+ if (!operationResult.isSuccess()) {
+ String message = "Service status not updated in datastore !";
+ LOG.info(message);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
+ }
+
+ OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations.createServicePath(
+ new ServiceInput(input), pceResponse);
+ if (!operationServicePathSaveResult.isSuccess()) {
+ String message = "Service Path not updated in datastore !";
+ LOG.info(message);
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
+ }
+
+ ServiceImplementationRequestInput serviceImplementationRequest =
+ ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
+ ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
+ .serviceImplementation(serviceImplementationRequest);
+ if (ResponseCodes.RESPONSE_OK
+ .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
+ String message = "Service rendered successfully !";
+ LOG.info(message);
+ operationResult = this.serviceDataStoreOperations.modifyTempService(input.getCommonId(), State.InService,
+ State.InService);
+ if (!operationResult.isSuccess()) {
+ LOG.warn("Service status not updated in datastore !");
+ }
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_OK);
+ } else {
+ String message = "Service rendering has failed !";
+ LOG.warn(message);
+
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getCommonId());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
+ }
+
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteService(input.getCommonId());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
+ }
+
+ return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, message,
+ ResponseCodes.RESPONSE_FAILED);
+ }
}
}
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp.PceMetric;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraints;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.SoftConstraints;
}
public PathComputationRequestOutput performPCE(ServiceCreateInput serviceCreateInput, boolean reserveResource) {
- MappingConstraints mappingConstraints = new MappingConstraints(serviceCreateInput.getHardConstraints(),
- serviceCreateInput.getSoftConstraints());
+ return performPCE(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints(),
+ serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader(),
+ serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd(), reserveResource);
+ }
+
+ public PathComputationRequestOutput performPCE(TempServiceCreateInput tempServiceCreateInput,
+ boolean reserveResource) {
+ return performPCE(tempServiceCreateInput.getHardConstraints(), tempServiceCreateInput.getSoftConstraints(),
+ tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader(),
+ tempServiceCreateInput.getServiceAEnd(), tempServiceCreateInput.getServiceZEnd(), reserveResource);
+ }
+
+ private PathComputationRequestOutput performPCE(org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains
+ .rev161014.routing.constraints.HardConstraints hardConstraints, org.opendaylight.yang.gen.v1.http.org
+ .openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints softConstraints,
+ String serviceName, SdncRequestHeader sdncRequestHeader, ServiceEndpoint serviceAEnd,
+ ServiceEndpoint serviceZEnd, boolean reserveResource) {
+ MappingConstraints mappingConstraints = new MappingConstraints(hardConstraints, softConstraints);
mappingConstraints.serviceToServicePathConstarints();
PathComputationRequestInput pathComputationRequestInput =
- createPceRequestInput(serviceCreateInput, mappingConstraints.getServicePathHardConstraints(),
- mappingConstraints.getServicePathSoftConstraints(), reserveResource);
+ createPceRequestInput(serviceName, sdncRequestHeader,mappingConstraints.getServicePathHardConstraints(),
+ mappingConstraints.getServicePathSoftConstraints(), reserveResource, serviceAEnd,
+ serviceZEnd);
LOG.debug("Calling path computation.");
PathComputationRequestOutput pathComputationRequestOutput
= this.pathComputationService.pathComputationRequest(pathComputationRequestInput);
return pathComputationRequestOutput;
}
- private PathComputationRequestInput createPceRequestInput(ServiceCreateInput serviceCreateInput,
- HardConstraints hardConstraints,
- SoftConstraints softConstraints,
- Boolean reserveResource) {
+ private PathComputationRequestInput createPceRequestInput(String serviceName,
+ SdncRequestHeader serviceHandler, HardConstraints hardConstraints,
+ SoftConstraints softConstraints, Boolean reserveResource, ServiceEndpoint serviceAEnd,
+ ServiceEndpoint serviceZEnd) {
LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
+ "requests");
ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
- if (serviceCreateInput.getSdncRequestHeader() != null) {
- serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
+ if (serviceHandler != null) {
+ serviceHandlerHeader.setRequestId(serviceHandler.getRequestId());
}
return new PathComputationRequestInputBuilder()
- .setServiceName(serviceCreateInput.getServiceName())
- .setResourceReserve(reserveResource)
- .setServiceHandlerHeader(serviceHandlerHeader.build())
- .setHardConstraints(hardConstraints)
- .setSoftConstraints(softConstraints)
- .setPceMetric(PceMetric.TEMetric)
- .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceCreateInput.getServiceAEnd()))
- .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceCreateInput.getServiceZEnd()))
- .build();
+ .setServiceName(serviceName)
+ .setResourceReserve(reserveResource)
+ .setServiceHandlerHeader(serviceHandlerHeader.build())
+ .setHardConstraints(hardConstraints)
+ .setSoftConstraints(softConstraints)
+ .setPceMetric(PceMetric.TEMetric)
+ .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceAEnd))
+ .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceZEnd))
+ .build();
}
private CancelResourceReserveInput mappingCancelResourceReserve(String serviceName,
import java.util.Optional;
import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
/**
*/
Optional<Services> getService(String serviceName);
+ /**
+ * get temp service by common-id.
+ *
+ * @param commonId
+ * unique common-id of the service
+ * @return Optional of Services
+ */
+ Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> getTempService(String commonId);
+
/**
* deleteService service by name.
*
*/
OperationResult deleteService(String serviceName);
+ /**
+ * deleteService service by common-id.
+ *
+ * @param commonId
+ * unique common-id of the service
+ * @return result of Delete operation
+ */
+ OperationResult deleteTempService(String commonId);
+
/**
* modifyService service attributes.
*
*/
OperationResult modifyService(String serviceName, State operationalState, State administrativeState);
+ /**
+ * modify Temp Service.
+ *
+ * @param commonId unique common-id of the service
+ * @param operationalState operational state of service
+ * @param administrativeState administrative state of service
+ * @return result of modifyTempService operation
+ */
+ OperationResult modifyTempService(String commonId, State operationalState, State administrativeState);
+
/**
* create new service entry.
*
/**
* create new servicePath entry.
*
- * @param serviceCreateInput
- * serviceCreateInput data for creation of service
+ * @param serviceInput
+ * ServiceInput data for creation of service
* @param outputFromPce
* output from pce request which is used as input for creating of service.
* @return result of createServicePath operation
*/
- OperationResult createServicePath(ServiceCreateInput serviceCreateInput,
+ OperationResult createServicePath(ServiceInput serviceInput, PathComputationRequestOutput outputFromPce);
+
+ /**
+ * create new Temp service entry.
+ *
+ * @param tempServiceCreateInput
+ * tempServiceCreateInput data for creation of service
+ * @param outputFromPce
+ * output from pce request which is used as input for creating of service.
+ * @return result of createTempService operation
+ */
+ OperationResult createTempService(TempServiceCreateInput tempServiceCreateInput,
PathComputationRequestOutput outputFromPce);
/**
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceListBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey;
import org.slf4j.LoggerFactory;
public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperations {
-
private static final Logger LOG = LoggerFactory.getLogger(ServiceDataStoreOperationsImpl.class);
private static final String SUCCESSFUL_MESSAGE = "Successful";
-
private DataBroker dataBroker;
public ServiceDataStoreOperationsImpl(DataBroker dataBroker) {
@Override
public void initialize() {
+ initializeServiceList();
+ initializeTempServiceList();
+ }
+
+ private void initializeServiceList() {
try {
LOG.info("initializing service registry");
WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
}
}
+ private void initializeTempServiceList() {
+ try {
+ LOG.info("initializing temp service registry");
+ WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<TempServiceList> iid = InstanceIdentifier.create(TempServiceList.class);
+ TempServiceList initialRegistry = new TempServiceListBuilder().build();
+ transaction.put(LogicalDatastoreType.OPERATIONAL, iid, initialRegistry);
+ Future<Void> future = transaction.submit();
+ future.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("init failed: {}", e.getMessage());
+ }
+ }
+
@Override
public Optional<Services> getService(String serviceName) {
try {
ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction();
- InstanceIdentifier<Services> iid = InstanceIdentifier
- .create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
- Future<com.google.common.base.Optional<Services>> future
- = readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
+ InstanceIdentifier<Services> iid =
+ InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
+ Future<com.google.common.base.Optional<Services>> future =
+ readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
+ return future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil();
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("Reading service {} failed:", serviceName, e);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> getTempService(String serviceName) {
+ try {
+ ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction();
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> iid = InstanceIdentifier.create(TempServiceList.class).child(org.opendaylight.yang.gen.v1
+ .http.org.openroadm.service.rev161014.temp.service.list.Services.class,
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .ServicesKey(serviceName));
+ Future<com.google.common.base.Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+ .temp.service.list.Services>> future = readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
return future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil();
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Reading service {} failed:", serviceName, e);
LOG.debug("Deleting '{}' Service", serviceName);
try {
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
- .child(Services.class, new ServicesKey(serviceName));
+ InstanceIdentifier<Services> iid =
+ InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
writeTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
return OperationResult.ok(SUCCESSFUL_MESSAGE);
}
}
+ @Override
+ public OperationResult deleteTempService(String commonId) {
+ LOG.debug("Deleting '{}' Service", commonId);
+ try {
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> iid = InstanceIdentifier.create(TempServiceList.class).child(org.opendaylight.yang.gen.v1
+ .http.org.openroadm.service.rev161014.temp.service.list.Services.class,
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .ServicesKey(commonId));
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
+ writeTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to delete service " + commonId + " from Service List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
@Override
public OperationResult modifyService(String serviceName, State operationalState, State administrativeState) {
LOG.debug("Modifying '{}' Service", serviceName);
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
.child(Services.class, new ServicesKey(serviceName));
- Services services = new ServicesBuilder(readService.get())
- .setOperationalState(operationalState)
- .setAdministrativeState(administrativeState)
- .build();
+ Services services = new ServicesBuilder(readService.get()).setOperationalState(operationalState)
+ .setAdministrativeState(administrativeState).build();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, services);
writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
return OperationResult.ok(SUCCESSFUL_MESSAGE);
}
}
+ @Override
+ public OperationResult modifyTempService(String serviceName, State operationalState, State administrativeState) {
+ LOG.debug("Modifying '{}' Temp Service", serviceName);
+ Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> readService = getTempService(serviceName);
+ if (readService.isPresent()) {
+ try {
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> iid = InstanceIdentifier.create(TempServiceList.class)
+ .child(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services.class, new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+ .temp.service.list.ServicesKey(serviceName));
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services services = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+ .service.list.ServicesBuilder(readService.get()).setOperationalState(operationalState)
+ .setAdministrativeState(administrativeState)
+ .build();
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, services);
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to modify temp service " + serviceName + " from Temp Service List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ } else {
+ String message = "Temp Service " + serviceName + " is not present!";
+ LOG.warn(message);
+ return OperationResult.failed(message);
+ }
+ }
+
@Override
public OperationResult createService(ServiceCreateInput serviceCreateInput,
PathComputationRequestOutput outputFromPce) {
LOG.debug("Writing '{}' Service", serviceCreateInput.getServiceName());
try {
- InstanceIdentifier<Services> iid = InstanceIdentifier
- .create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceCreateInput.getServiceName()));
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+ .child(Services.class, new ServicesKey(serviceCreateInput.getServiceName()));
Services service = ModelMappingUtils.mappingServices(serviceCreateInput, null);
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
}
@Override
- public OperationResult createServicePath(ServiceCreateInput serviceCreateInput,
+ public OperationResult createTempService(TempServiceCreateInput tempServiceCreateInput,
PathComputationRequestOutput outputFromPce) {
- LOG.debug("Writing '{}' Service", serviceCreateInput.getServiceName());
+ LOG.debug("Writing '{}' Temp Service", tempServiceCreateInput.getCommonId());
+ try {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> iid = InstanceIdentifier.create(TempServiceList.class)
+ .child(org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services.class, new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+ .service.list.ServicesKey(tempServiceCreateInput.getCommonId()));
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services service = ModelMappingUtils.mappingServices(tempServiceCreateInput);
+ WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
+ writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+ return OperationResult.ok(SUCCESSFUL_MESSAGE);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ String message = "Failed to create Temp service " + tempServiceCreateInput.getCommonId()
+ + " to TempService List";
+ LOG.warn(message, e);
+ return OperationResult.failed(message);
+ }
+ }
+
+ @Override
+ public OperationResult createServicePath(ServiceInput serviceInput, PathComputationRequestOutput outputFromPce) {
+ LOG.debug("Writing '{}' ServicePath ", serviceInput.getServiceName());
try {
- InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier
- .create(ServicePathList.class)
- .child(ServicePaths.class, new ServicePathsKey(serviceCreateInput.getServiceName()));
- ServicePaths servicePath = ModelMappingUtils.mappingServicePaths(serviceCreateInput, null, outputFromPce);
+ InstanceIdentifier<ServicePaths> servicePathsIID = InstanceIdentifier.create(ServicePathList.class)
+ .child(ServicePaths.class, new ServicePathsKey(serviceInput.getServiceName()));
+ ServicePaths servicePath = ModelMappingUtils.mappingServicePaths(serviceInput, outputFromPce);
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, servicePathsIID, servicePath);
writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
return OperationResult.ok(SUCCESSFUL_MESSAGE);
} catch (TimeoutException | InterruptedException | ExecutionException e) {
- String message = "Failed to create servicePath " + serviceCreateInput.getServiceName()
- + " to ServicePath List";
+ String message = "Failed to create servicePath " + serviceInput.getCommonId() + " to ServicePath List";
LOG.warn(message, e);
return OperationResult.failed(message);
}
/*
* Write or Modify or Delete Service from/to SreviceList.
*
- * @param serviceName
- * Name of service
- * @param input
- * ServiceCreateInput
- * @param output
- * PathComputationRequestOutput
- * @param choice
- * 0 - Modify 1 - Delete 2 - Write
+ * @param serviceName Name of service
+ *
+ * @param input ServiceCreateInput
+ *
+ * @param output PathComputationRequestOutput
+ *
+ * @param choice 0 - Modify 1 - Delete 2 - Write
+ *
* @return String operations result, null if ok or not otherwise
*/
@Deprecated
@Override
public String writeOrModifyOrDeleteServiceList(String serviceName, ServiceCreateInput input,
- PathComputationRequestOutput output, int choice) {
- LOG.debug("WriteOrModifyOrDeleting '{}' Service",serviceName);
+ PathComputationRequestOutput output, int choice) {
+ LOG.debug("WriteOrModifyOrDeleting '{}' Service", serviceName);
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
String result = null;
Optional<Services> readService = getService(serviceName);
/*
* Modify / Delete Service.
*/
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceName));
+ InstanceIdentifier<Services> iid =
+ InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
ServicesBuilder service = new ServicesBuilder(readService.get());
-
String action = null;
switch (choice) {
- case 0: /* Modify. */
+ case 0 : /* Modify. */
LOG.debug("Modifying '{}' Service", serviceName);
service.setOperationalState(State.InService).setAdministrativeState(State.InService);
writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build());
action = "modifyService";
break;
-
- case 1: /* Delete */
+ case 1 : /* Delete */
LOG.debug("Deleting '{}' Service", serviceName);
writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
action = "deleteService";
break;
-
default:
LOG.debug("No choice found");
break;
-
}
try {
writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
} else {
if (choice == 2) { /* Write Service */
LOG.debug("Writing '{}' Service", serviceName);
- InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
- new ServicesKey(serviceName));
-
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
+ .child(Services.class, new ServicesKey(serviceName));
Services service = ModelMappingUtils.mappingServices(input, null);
writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
try {
}
return result;
}
-
}
package org.opendaylight.transportpce.servicehandler.stub;
import com.google.common.util.concurrent.ListenableFuture;
+
+import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
} catch (InterruptedException e) {
message = "deleting service failed !";
LOG.error("deleting service failed !", e);
- responseCode = "500";
+ responseCode = ResponseCodes.RESPONSE_FAILED;
}
+ responseCode = ResponseCodes.RESPONSE_OK;
ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("yes")
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
.setRequestId(input.getServiceHandlerHeader().getRequestId())
.setResponseCode(responseCode)
.setResponseMessage(message);
} catch (InterruptedException e) {
message = "implementing service failed !";
LOG.error(message);
- responseCode = "500";
+ responseCode = ResponseCodes.RESPONSE_FAILED;
}
+ responseCode = ResponseCodes.RESPONSE_OK;
ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("yes")
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
.setRequestId(input.getServiceHandlerHeader().getRequestId())
.setResponseCode(responseCode)
.setResponseMessage(message);
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.validation.checks.CheckCoherencyHardSoft;
import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ServiceCreateValidation {
private static final Logger LOG = LoggerFactory.getLogger(ServiceCreateValidation.class);
- public static OperationResult validateServiceCreateRequest(ServiceCreateInput input) {
+ public static OperationResult validateServiceCreateRequest(ServiceInput input, RpcActions rpcActions) {
/*
* Upon receipt of service
* -create RPC, service header and sdnc
SdncRequestHeader sdncRequestHeader = input.getSdncRequestHeader();
ConnectionType conType = input.getConnectionType();
ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerCompliancyCheck.check(
- serviceNmame, sdncRequestHeader, conType, RpcActions.ServiceCreate, true, true);
+ serviceNmame, sdncRequestHeader, conType, rpcActions, true, true);
if (serviceHandlerCheckResult.hasPassed()) {
LOG.debug("Service request compliant !");
} else {
String message = "";
if (!checkString(serviceName)) {
result = false;
- message = "Service Name is not set";
+ message = "Service Name (common-id for Temp service) is not set";
} else if (contype && (conType == null)) {
result = false;
message = "Service ConnectionType is not set";
@Test
public void mappingServicesPathNullServiceCreateInput() {
- ServicePaths services = ModelMappingUtils.mappingServicePaths(null, null,
- this.pathComputationRequestOutput);
+ ServicePaths services = ModelMappingUtils.mappingServicePaths(null, this.pathComputationRequestOutput);
Assert.assertEquals(new ServicePathsBuilder().build(), services);
}
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
Assert.assertEquals(0, output0.get().getErrors().size());
}
+ @Test
+ public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
+ ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+ PathComputationRequestOutput pathComputationRequestOutput =
+ new PathComputationRequestOutputBuilder(PceTestData.getPCE_simpletopology_test1_result((long) 5))
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
+ .thenReturn(pathComputationRequestOutput);
+ Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
+ Mockito.when(
+ this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
+ .thenReturn(new ServiceImplementationRequestOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon2).build());
+ Mockito.when(this.serviceDataStoreOperationsMock.modifyTempService(serviceInput.getCommonId(), State.InService,
+ State.InService)).thenReturn(OperationResult.ok("successful"));
+ Future<RpcResult<TempServiceCreateOutput>> output0 =
+ this.serviceHandlerImplMock.tempServiceCreate(serviceInput);
+ Assert.assertNotNull(output0);
+ Assert.assertTrue(output0.get().isSuccessful());
+ Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
+ ResponseCodes.FINAL_ACK_YES, "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get()
+ .getResult());
+ Assert.assertEquals(0, output0.get().getErrors().size());
+ }
+
@Test
public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
emptyServiceNameInput = builtInput.setServiceName("").build();
Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
- "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
}
@Test
nullServiceNameInput = builtInput.setServiceName(null).build();
Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
- "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
+ }
+
+ @Test
+ public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+ TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+ emptyServiceNameInput = builtInput.setCommonId("").build();
+ Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+ ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
+ }
+
+ @Test
+ public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+ TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+ emptyServiceNameInput = builtInput.setCommonId(null).build();
+ Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+ ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
+ .get().getResult());
}
@Test
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class)))
.thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
+ " to ServicePath List"));
Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
ResponseCodes.FINAL_ACK_YES);
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
- verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
+ verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class));
}
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
}
+ @Test
+ public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+ serviceDeleteInput = builder.setCommonId("").build();
+ TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
+ @Test
+ public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+ serviceDeleteInput = builder.setCommonId(null).build();
+ TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
@Test
public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
}
+ @Test
+ public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
+ TempServiceDeleteOutput result =
+ this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
@Test
public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
}
+ @Test
+ public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
+
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+ .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
+ Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
+ ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+ .rev171017.ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteServicePath(serviceDeleteInput.getCommonId()))
+ .thenReturn(OperationResult.ok("success"));
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteTempService(serviceDeleteInput.getCommonId()))
+ .thenReturn(OperationResult.ok("success"));
+ TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
+ .getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
+ }
+
@Test
public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
+
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResult;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResultBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.service.path.rpc.result.PathDescription;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
.ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service
.create.input.ServiceZEndBuilder()
.setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
- .setTxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.TxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
- .setRxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.RxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection())
.build();
builtInput.setCommonId("commonId");
return builtInput.build();
}
+ public static TempServiceCreateInput buildTempServiceCreateInput() {
+
+ TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
+ .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+ .temp.service.create.input.ServiceAEndBuilder()
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection())
+ .build();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
+ .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
+ .service.create.input.ServiceZEndBuilder()
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection())
+ .build();
+
+ builtInput.setCommonId("commonId");
+ builtInput.setConnectionType(ConnectionType.Service);
+ builtInput.setCustomer("Customer");
+ builtInput.setServiceAEnd(serviceAEnd);
+ builtInput.setServiceZEnd(serviceZEnd);
+ builtInput.setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
+ .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
+
+ return builtInput.build();
+ }
+
public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
.ServiceAEndBuilder getServiceAEndBuild() {
return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
.ServiceAEndBuilder()
.setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
- .setTxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.TxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
- .setRxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.RxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build());
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection());
}
public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
.ServiceZEndBuilder()
.setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
- .setTxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.TxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
- .setRxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.RxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build());
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection());
+ }
+
+ private static TxDirection getTxDirection() {
+ return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
+ .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
+ .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
+ .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
+ .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
+ .build();
+ }
+
+ private static RxDirection getRxDirection() {
+ return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+ .endpoint.RxDirectionBuilder()
+ .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+ .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+ .setPortSubSlot("port subslot").setPortType("port type").build())
+ .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+ .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+ .setLgxPortShelf("lgx port shelf").build())
+ .build();
}
public static ServiceDeleteInput buildServiceDeleteInput() {
return deleteInputBldr.build();
}
+ public static TempServiceDeleteInput buildTempServiceDeleteInput() {
+ TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder();
+ deleteInputBldr.setCommonId("service 1");
+ return deleteInputBldr.build();
+ }
+
public static ServiceRerouteInput buildServiceRerouteInput() {
ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder();
builder.setServiceName("service 1");
return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
.ServiceAEndBuilder()
.setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
- .setTxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.TxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
- .setRxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.RxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build());
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection());
}
public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
.ServiceZEndBuilder()
.setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
- .setTxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.TxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build())
- .setRxDirection(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
- .endpoint.RxDirectionBuilder()
- .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
- .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
- .setPortSubSlot("port subslot").setPortType("port type").build())
- .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
- .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
- .setLgxPortShelf("lgx port shelf").build())
- .build());
+ .setTxDirection(getTxDirection())
+ .setRxDirection(getRxDirection());
}
private ServiceDataUtils() {
package org.opendaylight.transportpce.servicehandler.validation;
import java.util.Arrays;
+
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRoutingBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraintsBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraintsBuilder;
public void validateServiceCreateRequestIfCommonIdNull() {
ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
.setCommonId(null).build();
- OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult result =
+ ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
Assert.assertEquals(true, result.isSuccess());
}
.build())
.setCustomerCode(Arrays.asList("Some customer-code"))
.build()).build();
- OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult result =
+ ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
Assert.assertEquals(false, result.isSuccess());
}
public void validateServiceCreateRequestIfConstraintsNull() {
ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
.setSoftConstraints(null).setHardConstraints(null).build();
- OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult result =
+ ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
Assert.assertEquals(true, result.isSuccess());
}
.build())
.setCustomerCode(Arrays.asList("Some customer-code"))
.build()).setHardConstraints(null).build();
- OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult result =
+ ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
Assert.assertEquals(true, result.isSuccess());
}
.build())
.setCustomerCode(Arrays.asList("Some customer-code"))
.build()).build();
- OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+ OperationResult result =
+ ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
Assert.assertEquals(true, result.isSuccess());
}
}
diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-index ccd0f14..8219393 100644
+index 44ef53a..810f093 100644
--- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
+++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
-@@ -22,6 +22,7 @@ import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
+@@ -25,6 +25,7 @@ import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
-@@ -84,6 +85,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -87,6 +88,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
private DataBroker db;
private ServiceDataStoreOperations serviceDataStoreOperations;
private RendererServiceOperations rendererServiceOperations;
private PCEServiceWrapper pceServiceWrapper;
//TODO: remove private request fields as they are in global scope
-@@ -92,6 +94,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -95,6 +97,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
RendererServiceOperations rendererServiceOperations) {
this.db = databroker;
this.rendererServiceOperations = rendererServiceOperations;
this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.db);
this.serviceDataStoreOperations.initialize();
this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
-@@ -141,8 +144,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -145,7 +148,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
ServiceImplementationRequestInput serviceImplementationRequest =
- ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
+ ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
- ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
-- .serviceImplementation(serviceImplementationRequest);
+ ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
-+ .serviceImplementation(serviceImplementationRequest);
+ .serviceImplementation(serviceImplementationRequest);
if (ResponseCodes.RESPONSE_OK
.equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
- String message = "Service rendered successfully !";
-@@ -216,8 +219,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+@@ -221,7 +224,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+ .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(input));
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
+- .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
++ .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
+
+ if (!ResponseCodes.RESPONSE_OK
+ .equals(output.getConfigurationResponseCommon().getResponseCode())) {
+@@ -406,7 +409,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+ .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(input));
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
- .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
--
+ .ServiceDeleteOutput output = this.stubRendererServiceOperations.serviceDelete(serviceDeleteInput);
+
if (!ResponseCodes.RESPONSE_OK
.equals(output.getConfigurationResponseCommon().getResponseCode())) {
- message = "Service delete failed!";
-diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-index 630fb67..2cc2bdf 100644
---- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-+++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
-@@ -51,6 +51,8 @@ public final class StubrendererImpl {
- LOG.error("deleting service failed !", e);
- responseCode = "500";
- }
-+ responseCode = "200";
-+ message = "Service deleted";
- ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("yes")
- .setRequestId(input.getServiceHandlerHeader().getRequestId())
-@@ -75,6 +77,8 @@ public final class StubrendererImpl {
- LOG.error(message);
- responseCode = "500";
- }
-+ responseCode = "200";
-+ message = "Service implemented";
- ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("yes")
- .setRequestId(input.getServiceHandlerHeader().getRequestId())
+@@ -476,7 +479,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
+
+ ServiceImplementationRequestInput serviceImplementationRequest =
+ ModelMappingUtils.createServiceImplementationRequest(new ServiceInput(input), pceResponse);
+- ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
++ ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubRendererServiceOperations
+ .serviceImplementation(serviceImplementationRequest);
+ if (ResponseCodes.RESPONSE_OK
+ .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
# 'inService')
# time.sleep(1)
- # Delete non existing service
+ # Delete service
def test_12_delete_service(self):
url = ("{}/operations/org-openroadm-service:service-delete"
.format(self.restconf_baseurl))
self.assertEqual(response.status_code, 404)
time.sleep(1)
+ # Create Temp Service 'ASATT1234567' with correct parameters
+ def test_14_create_temp_service(self):
+ url = ("{}/operations/org-openroadm-service:temp-service-create"
+ .format(self.restconf_baseurl))
+ data = {
+ "input": {
+ "sdnc-request-header": {
+ "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
+ "rpc-action": "temp-service-create",
+ "request-system-id": "appname",
+ "notification-url": "http://localhost:8585/NotificationServer/notify"
+ },
+ "common-id": "ASATT1234567",
+ "connection-type": "infrastructure",
+ "service-a-end": {
+ "service-rate": "100",
+ "node-id": "ROADMA",
+ "service-format": "Ethernet",
+ "clli": "SNJSCAMCJP8",
+ "tx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+ "lgx-port-name": "LGX Back.3",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "rx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+ "lgx-port-name": "LGX Back.4",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "optic-type": "gray"
+ },
+ "service-z-end": {
+ "service-rate": "100",
+ "node-id": "ROADMC",
+ "service-format": "Ethernet",
+ "clli": "SNJSCAMCJT4",
+ "tx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+ "lgx-port-name": "LGX Back.29",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "rx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+ "lgx-port-name": "LGX Back.30",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "optic-type": "gray"
+ },
+ "due-date": "2016-11-28T00:00:01Z",
+ "operator-contact": "pw1234"
+ }
+ }
+ headers = {'content-type': 'application/json',
+ "Accept": "application/json"}
+ response = requests.request(
+ "POST", url, data=json.dumps(data), headers=headers,
+ auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, requests.codes.ok)
+ res = response.json()
+ self.assertIn('Service rendered successfully !',
+ res['output']['configuration-response-common']['response-message'])
+ time.sleep(10)
+
+
+ # Create Temp Service not compliant with no common-id
+ def test_15_create_temp_service(self):
+ url = ("{}/operations/org-openroadm-service:temp-service-create"
+ .format(self.restconf_baseurl))
+ data = {
+ "input": {
+ "sdnc-request-header": {
+ "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
+ "rpc-action": "temp-service-create",
+ "request-system-id": "appname",
+ "notification-url": "http://localhost:8585/NotificationServer/notify"
+ },
+ "connection-type": "infrastructure",
+ "service-a-end": {
+ "service-rate": "100",
+ "node-id": "ROADMA",
+ "service-format": "Ethernet",
+ "clli": "SNJSCAMCJP8",
+ "tx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+ "lgx-port-name": "LGX Back.3",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "rx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+ "lgx-port-name": "LGX Back.4",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "optic-type": "gray"
+ },
+ "service-z-end": {
+ "service-rate": "100",
+ "node-id": "ROADMC",
+ "service-format": "Ethernet",
+ "clli": "SNJSCAMCJT4",
+ "tx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+ "lgx-port-name": "LGX Back.29",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "rx-direction": {
+ "port": {
+ "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+ "port-type": "router",
+ "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
+ "port-rack": "000000.00",
+ "port-shelf": "00"
+ },
+ "lgx": {
+ "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+ "lgx-port-name": "LGX Back.30",
+ "lgx-port-rack": "000000.00",
+ "lgx-port-shelf": "00"
+ }
+ },
+ "optic-type": "gray"
+ },
+ "due-date": "2016-11-28T00:00:01Z",
+ "operator-contact": "pw1234"
+ }
+ }
+ headers = {'content-type': 'application/json',
+ "Accept": "application/json"}
+ response = requests.request(
+ "POST", url, data=json.dumps(data), headers=headers,
+ auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, requests.codes.ok)
+ res = response.json()
+ self.assertIn('Service Name (common-id for Temp service) is not set',
+ res['output']['configuration-response-common']['response-message'])
+ time.sleep(5)
+
+ # Get 'ASATT1234567' temp service created
+ def test_16_get_temp_service(self):
+ url = ("{}/operational/org-openroadm-service:temp-service-list/services/ASATT1234567"
+ .format(self.restconf_baseurl))
+ headers = {'content-type': 'application/json',
+ "Accept": "application/json"}
+ response = requests.request(
+ "GET", url, headers=headers, auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, requests.codes.ok)
+ res = response.json()
+ self.assertEqual(
+ res['services'][0]['administrative-state'],
+ 'inService')
+ time.sleep(1)
+
+ # get non existing service
+ def test_17_get_temp_service(self):
+ url = ("{}/operational/org-openroadm-service:temp-service-list/services/test1"
+ .format(self.restconf_baseurl))
+ headers = {'content-type': 'application/json',
+ "Accept": "application/json"}
+ response = requests.request(
+ "GET", url, headers=headers, auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, 404)
+ time.sleep(1)
+
+ # Delete temp service
+ def test_18_delete_temp_service(self):
+ url = ("{}/operations/org-openroadm-service:temp-service-delete"
+ .format(self.restconf_baseurl))
+ data = {"input": {
+ "common-id": "ASATT1234567"
+ }
+ }
+ headers = {'content-type': 'application/json'}
+ response = requests.request(
+ "POST", url, data=json.dumps(data), headers=headers,
+ auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, requests.codes.ok)
+ res = response.json()
+ self.assertIn('Service delete was successful!',
+ res['output']['configuration-response-common']['response-message'])
+ time.sleep(1)
+
+# Verify 'test' service deleted
+ def test_13_verify_temp_service_deleted(self):
+ url = ("{}/operational/org-openroadm-service:service-list/services/ASATT1234567"
+ .format(self.restconf_baseurl))
+ headers = {'content-type': 'application/json',
+ "Accept": "application/json"}
+ response = requests.request(
+ "GET", url, headers=headers, auth=('admin', 'admin'))
+ self.assertEqual(response.status_code, 404)
+ time.sleep(1)
+
if __name__ == "__main__":
unittest.main(verbosity=2)