+ operationResult = this.serviceDataStoreOperations.createService(input.getServiceCreateInput());
+ if (!operationResult.isSuccess()) {
+ LOG.error("Service not created in datastore !");
+ }
+ }
+ ResponseParameters responseParameters = new ResponseParametersBuilder()
+ .setPathDescription(new org.opendaylight.yang.gen.v1.http
+ .org.transportpce.b.c._interface.service.types.rev200128
+ .response.parameters.sp.response.parameters.PathDescriptionBuilder(pathDescription).build())
+ .build();
+ PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder()
+ .setResponseParameters(responseParameters).build();
+ OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations
+ .createServicePath(input, pceResponse);
+ if (!operationServicePathSaveResult.isSuccess()) {
+ LOG.error("Service Path not created in datastore !");
+ }
+ ServiceImplementationRequestInput serviceImplementationRequest = ModelMappingUtils
+ .createServiceImplementationRequest(input, pathDescription);
+ LOG.info("Sending serviceImplementation request : {}", serviceImplementationRequest);
+ this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest);
+ }
+
+ /**
+ * Check status of notification and send nbi notification.
+ * @param notification ServicePathRpcResult the notification to check.
+ * @return true is status is Successful, false otherwise.
+ */
+ private boolean checkStatus(ServicePathRpcResult notification) {
+ PublishNotificationProcessService nbiNotification = getPublishNotificationProcessService(notification);
+ PublishNotificationProcessServiceBuilder publishNotificationProcessServiceBuilder =
+ new PublishNotificationProcessServiceBuilder(nbiNotification);
+ switch (servicePathRpcResult.getStatus()) {
+ case Failed:
+ LOG.error("PCE path computation failed !");
+ nbiNotification = publishNotificationProcessServiceBuilder
+ .setMessage("ServiceCreate request failed ...")
+ .setResponseFailed("PCE path computation failed !")
+ .setOperationalState(State.Degraded).build();
+ sendNbiNotification(nbiNotification);
+ return false;
+ case Pending:
+ LOG.warn("PCE path computation returned a Pending RpcStatusEx code!");
+ return false;
+ case Successful:
+ LOG.info("PCE calculation done OK !");
+ return true;
+ default:
+ LOG.error("PCE path computation returned an unknown RpcStatusEx code {}",
+ servicePathRpcResult.getStatus());
+ nbiNotification = publishNotificationProcessServiceBuilder
+ .setMessage("ServiceCreate request failed ...")
+ .setResponseFailed("PCE path computation returned an unknown RpcStatusEx code!")
+ .setOperationalState(State.Degraded).build();
+ sendNbiNotification(nbiNotification);
+ return false;
+ }
+ }
+
+ private PublishNotificationProcessService getPublishNotificationProcessService(ServicePathRpcResult notification) {
+ PublishNotificationProcessServiceBuilder nbiNotificationBuilder =
+ new PublishNotificationProcessServiceBuilder();
+ if (input != null) {
+ nbiNotificationBuilder.setServiceName(input.getServiceName())
+ .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+ .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+ .setCommonId(input.getCommonId())
+ .setConnectionType(input.getConnectionType());
+ } else {
+ nbiNotificationBuilder.setServiceName(notification.getServiceName());
+ }
+ nbiNotificationBuilder.setPublisherName(PUBLISHER);
+ return nbiNotificationBuilder.build();
+ }
+
+ /**
+ * Process cancel resource result.
+ */
+ private void onCancelResourceResult() {
+ if (servicePathRpcResult.getStatus() == RpcStatusEx.Pending) {
+ LOG.warn("PCE cancel returned a Pending RpcStatusEx code !");
+ return;
+ } else if (servicePathRpcResult.getStatus() != RpcStatusEx.Successful
+ && servicePathRpcResult.getStatus() != RpcStatusEx.Failed) {
+ LOG.error("PCE cancel returned an unknown RpcStatusEx code !");
+ return;
+ }
+ Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
+ PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder()
+ .setServiceName(service.getServiceName())
+ .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
+ .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
+ .setCommonId(service.getCommonId())
+ .setConnectionType(service.getConnectionType())
+ .setPublisherName(PUBLISHER);
+ if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
+ LOG.info("PCE cancel resource failed !");
+ sendNbiNotification(nbiNotificationBuilder
+ .setResponseFailed("PCE cancel resource failed !")
+ .setMessage("ServiceDelete request failed ...")
+ .setOperationalState(service.getOperationalState())
+ .build());
+ return;
+ }
+ LOG.info("PCE cancel resource done OK !");
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore !");
+ }
+ OperationResult deleteServiceOperationResult;
+ String serviceType = "";
+ if (tempService) {
+ deleteServiceOperationResult = this.serviceDataStoreOperations.deleteTempService(input.getServiceName());
+ serviceType = "Temp ";
+ } else {
+ deleteServiceOperationResult = this.serviceDataStoreOperations.deleteService(input.getServiceName());
+ }
+ if (deleteServiceOperationResult.isSuccess()) {
+ sendNbiNotification(nbiNotificationBuilder
+ .setResponseFailed("")
+ .setMessage("Service deleted !")
+ .setOperationalState(State.Degraded)
+ .build());
+ } else {
+ LOG.warn("{}Service was not removed from datastore !", serviceType);
+ sendNbiNotification(nbiNotificationBuilder
+ .setResponseFailed(serviceType + "Service was not removed from datastore !")
+ .setMessage("ServiceDelete request failed ...")
+ .setOperationalState(service.getOperationalState())
+ .build());
+ }
+ /**
+ * if it was an RPC serviceReconfigure, re-launch PCR.
+ */
+ if (this.serviceReconfigure) {
+ LOG.info("cancel resource reserve done, relaunching PCE path computation ...");
+ this.pceServiceWrapper.performPCE(input.getServiceCreateInput(), true);
+ this.serviceReconfigure = false;