import org.opendaylight.transportpce.servicehandler.ServicehandlerTxRxCheck;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultSh;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultShBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceStateModifyOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServicehandlerService;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEndBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd;
*
* @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
*/
-public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceListener,
+public class ServicehandlerImpl implements OrgOpenroadmServiceService, ServicehandlerService, StubpceListener,
StubrendererListener,AutoCloseable {
/** Logging. */
private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
private ServicePathRpcResult servicePathRpcResult = null;
private ServiceRpcResultSp serviceRpcResultSp = null;
- private String notificationUrl = "";
private RpcActions action;
private PathDescription pathDescription;
serviceName = service.getServiceName();
}
if (serviceName != null) {
- LOG.info("deleting service '" + serviceName + "'from datastore ...");
+ LOG.info("deleting service '{}' from datastore ...", serviceName);
ServiceRpcResultSh notification = null;
String message = "";
/**
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
LOG.error("Parameter 'ServiceName' fro deleteServiceFromDatastore is null !");
}
notification = new ServiceRpcResultShBuilder()
.setNotificationType(notif)
- .setServiceName(serviceCreateInput.getServiceName())
+ .setServiceName(serviceName)
.setStatus(RpcStatusEx.Successful).setStatusMessage(message)
.build();
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
message = "pathTopology not in stubrenderer notification, cancelling pce resource reserve ...";
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
pceCancelResResource();
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
String message = "";
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
message = mappingAndSendingPCRequest.getError();
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
message = mappingAndSendingPCRequest.getError();
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
if (tmp != null && id != null) {
final String serviceName = tmp;
- LOG.info("stubrendererDelete service '" + serviceName + "'");
+ LOG.info("stubrendererDelete service '{}'", serviceName);
mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, id, serviceName);
ListenableFuture<Boolean> renderer = mappingAndSendingSIRequest.serviceDelete();
FutureCallback<Boolean> rendererCallback = new FutureCallback<Boolean>() {
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
message = "deleting service failed !";
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
}
final ServiceNotificationTypes notifType = type;
if (!create) { /** ServiceReconfigure. */
if ((result = writeOrModifyOrDeleteServiceList(serviceName, pathComputationResponse,null, 1)) == null) {
- LOG.info("Service '" + serviceName + "' deleted from datastore");
+ LOG.info("Service '{}' deleted from datastore", serviceName);
serviceName = newServiceName;
delete = true;
} else {
- LOG.info("deleting Service '" + serviceName + "' failed !");
+ LOG.info("deleting Service '{}' failed !", serviceName);
}
}
if (delete) {
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
FutureCallback<Boolean> rendererCallback = new FutureCallback<Boolean>() {
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
} else {
message = mappingAndSendingSIRequest.getError();
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
}
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.info("notification offer rejected : {}", e);
}
}
};
Boolean commonId = true;
Boolean coherencyHardSoft = false;
- if (sdncRequestHeader != null) {
+ if (rpcActions.equals(RpcActions.ServiceCreate) || rpcActions.equals(RpcActions.ServiceFeasibilityCheck)
+ || rpcActions.equals(RpcActions.ServiceDelete)) {
sdncRequest = true;
- }
- if (connectionType != null) {
+ } else if (rpcActions.equals(RpcActions.ServiceCreate)
+ || rpcActions.equals(RpcActions.ServiceFeasibilityCheck)
+ || rpcActions.equals(RpcActions.ServiceReconfigure)) {
contype = true;
}
compliancyCheck = new ServicehandlerCompliancyCheck(sdncRequestHeader, serviceName,
pathDescription = null;
pathTopology = null;
action = RpcActions.ServiceCreate;
- notificationUrl = null;
- LOG.info("notificationUrl : " + notificationUrl);
setPathDescription(null);
serviceCreateInput = input;
setServiceDeleteInput(null);
input.getConnectionType(), RpcActions.ServiceCreate, input.getServiceAEnd(), input.getServiceZEnd(),
input.getCommonId(), input.getHardConstraints(), input.getSoftConstraints())) != null) {
message = "Service not compliant : " + serviceCompliancy;
+ responseCode = "500";
LOG.info(message);
} else {
LOG.info("Service compliant !");
- pcePathComputation(input);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, serviceCreate in progress...")
- .setResponseCode("200").build();
+ String name = input.getServiceName();
+ if (readServiceList(name) == null) {
+ pcePathComputation(input);
+ LOG.info("PCR Request in progress ");
+ configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
+ .setResponseMessage("Service compliant, serviceCreate in progress...")
+ .setResponseCode("200").build();
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon);
+ ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon);
- return RpcResultBuilder.success(output.build()).buildFuture();
+ return RpcResultBuilder.success(output.build()).buildFuture();
+ } else {
+ LOG.info("Service '{}' already created !", name);
+ configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId())
+ .setResponseMessage("Service already created !")
+ .setResponseCode("500").build();
+ ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon);
+
+ return RpcResultBuilder.success(output.build()).buildFuture();
+ }
}
/*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(),
input.getConnectionType(), RpcActions.ServiceCreate);
responseCode = "500";
}*/
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator("Yes")
- .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message)
- .setResponseCode(responseCode).build();
+ .setResponseMessage(message)
+ .setResponseCode(responseCode);
+ SdncRequestHeader sdnc = input.getSdncRequestHeader();
+ if (sdnc != null) {
+ String requestId = sdnc.getRequestId();
+ if (requestId != null) {
+ builder.setRequestId(requestId);
+ }
+ }
+ configurationResponseCommon = builder.build();
ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon);
return RpcResultBuilder.success(output.build()).buildFuture();
-
}
@Override
public Future<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
- LOG.info("RPC serviceDelete request received for Service '" + input.getServiceDeleteReqInfo().getServiceName()
- + "'");
+ LOG.info("RPC serviceDelete request received for Service '{}'", input.getServiceDeleteReqInfo()
+ .getServiceName());
setServiceDeleteInput(input);
setServiceReconfigureInput(null);
serviceCreateInput = null;
String serviceName = input.getServiceDeleteReqInfo().getServiceName();
Services service = readServiceList(serviceName);
if (service != null) {
- LOG.debug("Service '" + serviceName + "' present in datastore !");
+ LOG.debug("Service '{}' present in datastore !", serviceName);
stubrendererDelete();
LOG.info("ServiceDelete Request in progress ... ");
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
String serviceName = input.getServiceName();
Services service = readServiceList(serviceName);
if (service != null) {
- LOG.debug("Service '" + serviceName + "' present in datastore !");
+ LOG.debug("Service '{}' present in datastore !", serviceName);
/**
* Sending cancel resource reserve request to PCE.
*/
String serviceName = input.getServiceName();
Services service = readServiceList(serviceName);
if (service != null) {
- LOG.debug("Service '" + serviceName + "' present in datastore !");
+ LOG.debug("Service '{}' present in datastore !", serviceName);
pceCancelResResource();
ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder()
.setStatus(RpcStatusEx.Pending)
return RpcResultBuilder.success(output).buildFuture();
} else {
message = "Service '" + serviceName + "' not exists in datastore";
- LOG.error(message);
+ LOG.error("Service '{}' not exists in datastore", serviceName);
}
}
} else {
message = compliancyCheck.getMessage();
}*/
- ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Successful)
+ ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Failed)
.setStatusMessage(message).build();
return RpcResultBuilder.success(output).buildFuture();
}
ServiceRpcResultSh notification = null;
setServiceDeleteInput(null);
setServiceReconfigureInput(null);
- notificationUrl = null;
String message = "";
LOG.info("checking Service Compliancy ...");
compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), RpcActions.ServiceRestoration);
Services service = readServiceList(serviceName);
if (service != null) {
this.service = service;
- LOG.debug("Service '" + serviceName + "' present in datastore !");
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
+ LOG.debug("Service '{}' present in datastore !", serviceName);
+ /** verify if service state is down. */
+ State state = service.getOperationalState();
+ if (state != null && !state.equals(State.InService)) {
+ notification = new ServiceRpcResultShBuilder()
+ .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult)
+ .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
+ .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ..")
+ .build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info("notification offer rejected : {}", e);
+ }
+ stubrendererDelete();
+ LOG.info("PCR Request in progress ");
+ ServiceRestorationOutput output = new ServiceRestorationOutputBuilder()
+ .setStatus(RpcStatus.Successful)
+ .setStatusMessage("ServiceRestoration in progress...").build();
+ return RpcResultBuilder.success(output).buildFuture();
+ } else {
+ LOG.info("Service '{}' still in '{}' state", serviceName, state);
+ ServiceRestorationOutput output = new ServiceRestorationOutputBuilder()
+ .setStatus(RpcStatus.Failed)
+ .setStatusMessage("ServiceRestoration failed : Service still in service !")
+ .build();
+ return RpcResultBuilder.success(output).buildFuture();
}
- stubrendererDelete();
- LOG.info("PCR Request in progress ");
- ServiceRestorationOutput output = new ServiceRestorationOutputBuilder()
- .setStatus(RpcStatus.Successful)
- .setStatusMessage("ServiceRestoration in progress...").build();
- return RpcResultBuilder.success(output).buildFuture();
} else {
message = "Service '" + serviceName + "' not exists in datastore";
LOG.error(message);
LOG.error(message);
}
- ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Successful)
+ ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Failed)
.setStatusMessage(message).build();
return RpcResultBuilder.success(output).buildFuture();
if (serviceCreateInput != null) {
aend = new ServiceAEndBuilder(serviceCreateInput.getServiceAEnd()).build();
zend = new ServiceZEndBuilder(serviceCreateInput.getServiceZEnd()).build();
- service.setServiceName(serviceCreateInput.getServiceName()).setAdministrativeState(State.OutOfService)
- .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId())
- .setConnectionType(serviceCreateInput.getConnectionType())
- .setCustomer(serviceCreateInput.getCustomer())
- .setCustomerContact(serviceCreateInput.getCustomerContact())
- .setHardConstraints(serviceCreateInput.getHardConstraints())
- .setSoftConstraints(serviceCreateInput.getSoftConstraints())
- .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend)
- .setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader());
+ service.setServiceName(serviceCreateInput.getServiceName())
+ .setAdministrativeState(State.OutOfService)
+ .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId())
+ .setConnectionType(serviceCreateInput.getConnectionType())
+ .setCustomer(serviceCreateInput.getCustomer())
+ .setCustomerContact(serviceCreateInput.getCustomerContact())
+ .setHardConstraints(serviceCreateInput.getHardConstraints())
+ .setSoftConstraints(serviceCreateInput.getSoftConstraints())
+ .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend)
+ .setSdncRequestHeader(new SdncRequestHeaderBuilder()
+ .setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId())
+ .setRpcAction(serviceCreateInput.getSdncRequestHeader().getRpcAction())
+ .build());
} else if (serviceReconfigureInput != null) {
aend = new ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build();
.setCustomerContact(serviceReconfigureInput.getCustomerContact())
.setHardConstraints(serviceReconfigureInput.getHardConstraints())
.setSoftConstraints(serviceReconfigureInput.getSoftConstraints())
- .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
+ .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend)
+ .setSdncRequestHeader(new SdncRequestHeaderBuilder()
+ .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName())
+ .setRpcAction(RpcActions.ServiceReconfigure)
+ .build());
}
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
LOG.error("Reading service failed:", e);
}
if (optional.isPresent()) {
- LOG.debug("Service '" + serviceName + "' present !");
+ LOG.debug("Service '{}' present !", serviceName);
result = new ServicesBuilder(optional.get()).build();
}
return result;
*/
private String writeOrModifyOrDeleteServiceList(String serviceName, PathComputationRequestOutput output,
Topology topo, int choice) {
- LOG.info("WriteOrModifyOrDeleting '" + serviceName + "' Service");
+ LOG.info("WriteOrModifyOrDeleting '{}' Service", serviceName);
WriteTransaction writeTx = db.newWriteOnlyTransaction();
String result = null;
Services readService = readServiceList(serviceName);
String action = null;
switch (choice) {
case 0: /** Modify. */
- LOG.info("Modifying '" + serviceName + "' Service");
+ LOG.info("Modifying '{}' Service", serviceName);
service.setOperationalState(State.InService).setAdministrativeState(State.InService);
service.setTopology(topo);
writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build());
break;
case 1: /** Delete. */
- LOG.info("Deleting '" + serviceName + "' Service");
+ LOG.info("Deleting '{}' Service", serviceName);
writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
action = "delete";
break;
try {
Futures.getChecked(future, ExecutionException.class);
} catch (ExecutionException e) {
- LOG.info("Failed to " + action + " service from Service List");
+ LOG.info("Failed to {} service from Service List", action);
result = "Failed to " + action + " service from Service List";
}
} else if (choice == 2) { /** Write Service. */
- LOG.info("Writing '" + serviceName + "' Service");
+ LOG.info("Writing '{}' Service", serviceName);
InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
new ServicesKey(serviceName));
Services writeService = null;
public void setServiceFeasibilityCheckInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) {
this.serviceFeasibilityCheckInput = serviceFeasibilityCheckInput;
}
+
+ @Override
+ public Future<RpcResult<ServiceStateModifyOutput>> serviceStateModify(ServiceStateModifyInput input) {
+ LOG.info("RPC service state modify received");
+ String servicename = input.getServiceName();
+ String message = "";
+ String responseCode = "500";
+ if (servicename != null) {
+ Services service = readServiceList(servicename);
+ if (service != null) {
+ LOG.info("Modify '{}' Service state", servicename);
+ WriteTransaction writeTx = db.newWriteOnlyTransaction();
+ String result = null;
+ Future<Void> future = null;
+ InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
+ new ServicesKey(servicename));
+ ServicesBuilder modifyService = new ServicesBuilder(service);
+ modifyService.setOperationalState(State.OutOfService);
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, modifyService.build());
+ future = writeTx.submit();
+ try {
+ Futures.getChecked(future, ExecutionException.class);
+ } catch (ExecutionException e) {
+ LOG.info("Failed to {} service from Service List", action);
+ result = "Failed to " + action + " service from Service List";
+ }
+ if (result == null) {
+ responseCode = "200";
+ message = "Service state modified !";
+ }
+ } else {
+ message = "Service not present in datastore ! ";
+ }
+ } else {
+ message = "servicename not set in ServiceStateModifyInput";
+ }
+ ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator("Yes")
+ .setResponseCode(responseCode)
+ .setResponseMessage(message)
+ .build();
+ ServiceStateModifyOutput output = new ServiceStateModifyOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon)
+ .build();
+ return RpcResultBuilder.success(output).buildFuture();
+ }
}