summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt22
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt18
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt34
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt103
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt15
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt31
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt2
8 files changed, 211 insertions, 31 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index e2c9bf90..55085216 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -67,9 +67,29 @@ interface NetconfRpcService {
/**
* Commit
*
+ * @param confirmed Perform a confirmed <commit> operation. If flag set to true,
+ * then it is expected to have a follow-up <commit> operation to confirm the request
+ * @param confirmTimeout Timeout period for confirmed commit, in seconds.
+ * @param persist Make the confirmed commit survive a session termination, and
+ * set a token on the ongoing confirmed commit.
+ * @param persistId Used to issue a follow-up confirmed commit or a confirming
+ * commit from any session, with the token from the previous <commit> operation.
+ * If unspecified, the confirm timeout defaults to 600 seconds.
* @return Device response
*/
- fun commit(): DeviceResponse
+ fun commit(confirmed: Boolean = false, confirmTimeout: Int = 60, persist: String = "",
+ persistId: String = ""): DeviceResponse
+
+ /**
+ * Cancels an ongoing confirmed commit. If the <persist-id> parameter is not given,
+ * the <cancel-commit> operation MUST be issued on the same session that issued
+ * the confirmed commit.
+ *
+ * @param persistId Cancels a persistent confirmed commit. The value MUST be equal
+ * to the value given in the <persist> parameter to the <commit> operation.
+ * If the value does not match, the operation fails with an "invalid-value" error.
+ */
+ fun cancelCommit(persistId: String = ""): DeviceResponse
/**
* Unlock
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index be835557..8d8e0ea4 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -101,12 +101,12 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun commit(): DeviceResponse {
+ override fun commit(confirmed: Boolean, confirmTimeout: Int, persist: String, persistId: String): DeviceResponse {
var output = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: commit: messageId($messageId)")
try {
- val messageContent = NetconfMessageUtils.commit(messageId)
+ val messageContent = NetconfMessageUtils.commit(messageId, confirmed, confirmTimeout, persist, persistId)
output = asyncRpc(messageContent, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
@@ -115,6 +115,20 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
+ override fun cancelCommit(persistId: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: cancelCommit: messageId($messageId)")
+ try {
+ val messageContent = NetconfMessageUtils.cancelCommit(messageId, persistId)
+ output = asyncRpc(messageContent, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in cancelCommit command $e.message"
+ }
+ return output
+ }
+
override fun discardConfig(): DeviceResponse {
var output = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index 7e48912d..4de3860c 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -115,15 +115,45 @@ class NetconfMessageUtils {
return doWrappedRpc(messageId, request.toString())
}
- fun commit(messageId: String): String {
- val request = StringBuilder()
+ fun commit(messageId: String, confirmed: Boolean, confirmTimeout: Int, persist: String,
+ persistId: String): String {
+
+ if (!persist.isEmpty() && !persistId.isEmpty()) {
+ throw NetconfException("Can't proceed <commit> with both persist($persist) and " +
+ "persistId($persistId) specified. Only one should be specified.")
+ }
+ if (confirmed && !persistId.isEmpty()) {
+ throw NetconfException("Can't proceed <commit> with both confirmed flag and " +
+ "persistId($persistId) specified. Only one should be specified.")
+ }
+ val request = StringBuilder()
request.append("<commit>").append(NEW_LINE)
+ if (confirmed) {
+ request.append("<confirmed/>")
+ request.append("<confirm-timeout>$confirmTimeout</confirm-timeout>")
+ if (!persist.isEmpty()) {
+ request.append("<persist>$persist</persist>")
+ }
+ }
+ if (!persistId.isEmpty()) {
+ request.append("<persist-id>$persistId</persist-id>")
+ }
request.append("</commit>").append(NEW_LINE)
return doWrappedRpc(messageId, request.toString())
}
+ fun cancelCommit(messageId: String, persistId: String): String {
+ val request = StringBuilder()
+ request.append("<cancel-commit>").append(NEW_LINE)
+ if (!persistId.isEmpty()) {
+ request.append("<persist-id>$persistId</persist-id>")
+ }
+ request.append("</cancel-commit>").append(NEW_LINE)
+
+ return doWrappedRpc(messageId, request.toString())
+ }
fun unlock(messageId: String, configType: String): String {
val request = StringBuilder()
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
index 2cd2d109..d4c27b1c 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
@@ -18,6 +18,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils
import org.junit.Assert
import org.junit.Assert.assertTrue
import org.junit.Test
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfException
+import kotlin.test.fail
class RpcMessageUtilsTest {
@@ -32,14 +34,14 @@ class RpcMessageUtilsTest {
val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
- val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
+ val result =
+ NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
Assert.assertEquals(checkString, result)
}
-
@Test
fun editConfig() {
val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -51,7 +53,8 @@ class RpcMessageUtilsTest {
val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
- val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
+ val result =
+ NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
Assert.assertEquals(checkString, result)
@@ -73,6 +76,40 @@ class RpcMessageUtilsTest {
}
@Test
+ fun cancelCommit() {
+ val checkString =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<cancel-commit>" +
+ "<persist-id>1234</persist-id>" +
+ "</cancel-commit></rpc>")
+
+ val messageId = "Test-Message-ID"
+
+ val cancelCommitPersistId =
+ NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "")
+
+ assertTrue(NetconfMessageUtils.validateRPCXML(cancelCommitPersistId))
+ Assert.assertEquals(checkString, cancelCommitPersistId)
+ }
+
+ @Test
+ fun cancelCommitNoPersistId() {
+ val checkString =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<cancel-commit>" +
+ "</cancel-commit></rpc>")
+
+ val messageId = "Test-Message-ID"
+
+ val cancelCommitNoPersistId = NetconfMessageUtils.cancelCommit(messageId, "").replace("[\n\r\t]".toRegex(), "")
+
+ assertTrue(NetconfMessageUtils.validateRPCXML(cancelCommitNoPersistId))
+ Assert.assertEquals(checkString, cancelCommitNoPersistId)
+ }
+
+ @Test
fun commit() {
val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
@@ -80,11 +117,69 @@ class RpcMessageUtilsTest {
val messageId = "Test-Message-ID"
- val result = NetconfMessageUtils.commit(messageId).replace("[\n\r\t]".toRegex(), "")
+ val commit = NetconfMessageUtils.commit(messageId, false, 0, "", "").replace("[\n\r\t]".toRegex(), "")
+
+ val commitWithPersistButNotConfirmed =
+ NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "")
+
+ assertTrue(NetconfMessageUtils.validateRPCXML(commit))
+ Assert.assertEquals(checkString, commit)
+ Assert.assertEquals(checkString, commitWithPersistButNotConfirmed)
+
+ }
+
+ @Test
+ fun commitPersistId() {
+ val checkString =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<commit>" +
+ "<persist-id>1234</persist-id>" +
+ "</commit></rpc>")
+
+ val messageId = "Test-Message-ID"
+
+ val result = NetconfMessageUtils.commit(messageId, false, 30, "", "1234").replace("[\n\r\t]".toRegex(), "")
+ assertTrue(NetconfMessageUtils.validateRPCXML(result))
+ Assert.assertEquals(checkString, result)
+
+ try {
+ NetconfMessageUtils.commit(messageId, true, 30, "", "1234").replace("[\n\r\t]".toRegex(), "")
+ } catch (e: NetconfException) {
+ Assert.assertEquals("Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.",
+ e.message)
+ return
+ }
+
+ fail()
+ }
+
+ @Test
+ fun commitPersist() {
+ val checkString =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<commit>" +
+ "<confirmed/>" +
+ "<confirm-timeout>30</confirm-timeout>" +
+ "<persist>1234</persist>" +
+ "</commit></rpc>")
+
+ val messageId = "Test-Message-ID"
+
+ val result = NetconfMessageUtils.commit(messageId, true, 30, "1234", "").replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
Assert.assertEquals(checkString, result)
+ try {
+ NetconfMessageUtils.commit(messageId, false, 30, "1234", "1234").replace("[\n\r\t]".toRegex(), "")
+ } catch (e: NetconfException) {
+ Assert.assertEquals("Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.",
+ e.message)
+ return
+ }
+ fail()
}
@Test
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
index 453306de..cf6776c5 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
@@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.grpc.stub.StreamObserver
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toJava
-import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
@@ -32,14 +31,14 @@ class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: Blu
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
- override fun process(responseObserver: StreamObserver<ExecutionServiceOutput>?): StreamObserver<ExecutionServiceInput> {
+ override fun process(
+ responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
try {
- val output = executionServiceHandler.process(executionServiceInput.toJava())
- .toProto(executionServiceInput.payload)
- responseObserver?.onNext(output)
+ val inputPayload = executionServiceInput.payload
+ executionServiceHandler.process(executionServiceInput.toJava(), responseObserver, inputPayload)
} catch (e: Exception) {
onError(e)
}
@@ -47,13 +46,13 @@ class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: Blu
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
- responseObserver?.onError(io.grpc.Status.INTERNAL
- .withDescription(error.message)
- .asException())
+ responseObserver.onError(io.grpc.Status.INTERNAL
+ .withDescription(error.message)
+ .asException())
}
override fun onCompleted() {
- responseObserver?.onCompleted()
+ log.info("Completed")
}
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index e4734c44..6477c067 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.swagger.annotations.ApiOperation
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.springframework.beans.factory.annotation.Autowired
@@ -49,15 +50,19 @@ class ExecutionServiceController {
@ResponseBody
fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
return parts
- .filter { it is FilePart }
- .ofType(FilePart::class.java)
- .flatMap(executionServiceHandler::upload)
+ .filter { it is FilePart }
+ .ofType(FilePart::class.java)
+ .flatMap(executionServiceHandler::upload)
}
@RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Resolve Resource Mappings", notes = "Takes the blueprint information and process as per the payload")
+ @ApiOperation(value = "Resolve Resource Mappings",
+ notes = "Takes the blueprint information and process as per the payload")
@ResponseBody
fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- return executionServiceHandler.process(executionServiceInput)
+ if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
+ throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
+ }
+ return executionServiceHandler.processSync(executionServiceInput)
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index ec605c1d..262c33f9 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -16,6 +16,8 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+import com.google.protobuf.Struct
+import io.grpc.stub.StreamObserver
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@@ -26,6 +28,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
@@ -56,20 +59,33 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
}
}
- fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- return when {
+ fun process(executionServiceInput: ExecutionServiceInput,
+ responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>,
+ inputPayload: Struct) {
+ when {
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
- // TODO post result in DMaaP
val executionServiceOutput = doProcess(executionServiceInput)
+ responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onCompleted()
}
- response(executionServiceInput)
+ responseObserver.onNext(response(executionServiceInput).toProto(inputPayload))
}
- executionServiceInput.actionIdentifiers.mode == ACTION_MODE_SYNC -> doProcess(executionServiceInput)
- else -> response(executionServiceInput, "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", true)
+ executionServiceInput.actionIdentifiers.mode == ACTION_MODE_SYNC -> {
+ val executionServiceOutput = doProcess(executionServiceInput)
+ responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onCompleted()
+ }
+ else -> responseObserver.onNext(response(executionServiceInput,
+ "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
+ true).toProto(inputPayload));
}
}
+ fun processSync(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ return doProcess(executionServiceInput)
+ }
+
private fun doProcess(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
val requestId = executionServiceInput.commonHeader.requestId
log.info("processing request id $requestId")
@@ -87,7 +103,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
}
- fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "", failure: Boolean = false): ExecutionServiceOutput {
+ private fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "",
+ failure: Boolean = false): ExecutionServiceOutput {
val executionServiceOutput = ExecutionServiceOutput()
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
index 220a6fd6..c8ce1c30 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
@@ -139,7 +139,7 @@ fun Flag.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags {
fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status.toProto(): Status {
val status = Status.newBuilder()
status.code = this.code
- status.errorMessage = this.errorMessage
+ status.errorMessage = this.errorMessage ?: ""
status.message = this.message
status.timestamp = this.timestamp.toString()
status.eventType = this.eventType