diff options
Diffstat (limited to 'ms/blueprintsprocessor')
4 files changed, 23 insertions, 24 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt index 6437cdf03..17d5fc76d 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor +import com.fasterxml.jackson.databind.node.MissingNode +import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.* import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceConstant @@ -47,6 +49,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic const val INPUT_ENDPOINT_SELECTOR = "endpoint-selector" const val INPUT_DYNAMIC_PROPERTIES = "dynamic-properties" const val INPUT_COMMAND = "command" + const val INPUT_PACKAGES = "packages" } override suspend fun processNB(executionRequest: ExecutionServiceInput) { @@ -75,11 +78,12 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic val endPointSelector = getOperationInput(INPUT_ENDPOINT_SELECTOR) val dynamicProperties = getOperationInput(INPUT_DYNAMIC_PROPERTIES) val command = getOperationInput(INPUT_COMMAND).asText() + val packages = getOperationInput(INPUT_PACKAGES) // TODO("Python execution command and Resolve some expressions with dynamic properties") val scriptCommand = command.replace(pythonScript.name, pythonScript.absolutePath) - val dependencies = operationAssignment.implementation?.dependencies +// val dependencies = operationAssignment.implementation?.dependencies try { // Open GRPC Connection @@ -87,13 +91,12 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic var executionLogs = "" - // If dependencies are defined, then install in remote server - if (dependencies != null && dependencies.isNotEmpty()) { + // If packages are defined, then install in remote server + if (packages !is MissingNode && packages !is NullNode) { val prepareEnvInput = PrepareRemoteEnvInput(requestId = processId, remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion), - remoteScriptType = RemoteScriptType.PYTHON, - packages = dependencies + packages = packages ) val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput) executionLogs = prepareEnvOutput.response @@ -106,7 +109,6 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic val remoteExecutionInput = RemoteScriptExecutionInput( requestId = processId, remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion), - remoteScriptType = RemoteScriptType.PYTHON, command = scriptCommand) val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput) executionLogs += remoteExecutionOutput.response diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt index 7cd5d5cac..03616d5e4 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt @@ -68,7 +68,6 @@ class MockRemoteScriptExecutionService : RemoteScriptExecutionService { override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput { assertEquals(prepareEnvInput.requestId, "123456-1000", "failed to match request id") - assertEquals(prepareEnvInput.remoteScriptType, RemoteScriptType.PYTHON, "failed to match script type") assertNotNull(prepareEnvInput.packages, "failed to get packages") val remoteScriptExecutionOutput = mockk<RemoteScriptExecutionOutput>() @@ -78,7 +77,6 @@ class MockRemoteScriptExecutionService : RemoteScriptExecutionService { override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput): RemoteScriptExecutionOutput { assertEquals(remoteExecutionInput.requestId, "123456-1000", "failed to match request id") - assertEquals(remoteExecutionInput.remoteScriptType, RemoteScriptType.PYTHON, "failed to match script type") val remoteScriptExecutionOutput = mockk<RemoteScriptExecutionOutput>() every { remoteScriptExecutionOutput.status } returns StatusType.SUCCESS diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt index da952c034..83254cecc 100644 --- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt @@ -19,10 +19,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.core.api.data import com.fasterxml.jackson.databind.JsonNode import java.util.* -enum class RemoteScriptType { - PYTHON, ANSIBLE, KOTLIN, SH -} - enum class StatusType { SUCCESS, FAILURE } @@ -34,7 +30,6 @@ data class RemoteIdentifier(var blueprintName: String, data class RemoteScriptExecutionInput(var requestId: String, var correlationId: String? = null, var remoteIdentifier: RemoteIdentifier? = null, - var remoteScriptType: RemoteScriptType, var command: String, var timeOut: Long = 30, var properties: MutableMap<String, JsonNode> = hashMapOf() @@ -49,8 +44,6 @@ data class RemoteScriptExecutionOutput(var requestId: String, data class PrepareRemoteEnvInput(var requestId: String, var correlationId: String? = null, var remoteIdentifier: RemoteIdentifier? = null, - var remoteScriptType: RemoteScriptType, - var packages: MutableList<String>?, + var packages: JsonNode, var timeOut: Long = 120, - var properties: MutableMap<String, JsonNode> = hashMapOf() -)
\ No newline at end of file + var properties: MutableMap<String, JsonNode> = hashMapOf())
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt index 7db5f52a4..99d4f8c24 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt @@ -49,7 +49,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!! private var channel: ManagedChannel? = null - private lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceFutureStub + private lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceBlockingStub override suspend fun init(selector: String) { // Get the GRPC Client Service based on selector @@ -57,7 +57,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi // Get the GRPC Channel channel = grpcClientService.channel() // Create Non Blocking Stub - commandExecutorServiceGrpc = CommandExecutorServiceGrpc.newFutureStub(channel) + commandExecutorServiceGrpc = CommandExecutorServiceGrpc.newBlockingStub(channel) checkNotNull(commandExecutorServiceGrpc) { "failed to create command executor grpc client for selector($selector)" @@ -66,7 +66,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput) : RemoteScriptExecutionOutput { - val grpResponse = commandExecutorServiceGrpc.prepareEnv(prepareEnvInput.asGrpcData()).get() + val grpResponse = commandExecutorServiceGrpc.prepareEnv(prepareEnvInput.asGrpcData()) checkNotNull(grpResponse.status) { "failed to get GRPC prepare env response status for requestId($prepareEnvInput.requestId)" @@ -81,7 +81,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput) : RemoteScriptExecutionOutput { - val grpResponse = commandExecutorServiceGrpc.executeCommand(remoteExecutionInput.asGrpcData()).get() + val grpResponse = commandExecutorServiceGrpc.executeCommand(remoteExecutionInput.asGrpcData()) checkNotNull(grpResponse.status) { "failed to get GRPC response status for requestId($remoteExecutionInput.requestId)" @@ -101,13 +101,20 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi fun PrepareRemoteEnvInput.asGrpcData(): PrepareEnvInput { val correlationId = this.correlationId ?: this.requestId + val packageList = mutableListOf<Packages>() + + this.packages.toList().forEach { + val pckage = Packages.newBuilder() + JsonFormat.parser().merge(it.toString(), pckage) + packageList.add(pckage.build()) + } + return PrepareEnvInput.newBuilder() .setIdentifiers(this.remoteIdentifier!!.asGrpcData()) .setRequestId(this.requestId) .setCorrelationId(correlationId) - .setScriptType(ScriptType.valueOf(this.remoteScriptType.name)) .setTimeOut(this.timeOut.toInt()) - .addAllPackages(this.packages) + .addAllPackages(packageList) .setProperties(this.properties.asGrpcData()) .build() } @@ -118,7 +125,6 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi .setRequestId(this.requestId) .setCorrelationId(correlationId) .setIdentifiers(this.remoteIdentifier!!.asGrpcData()) - .setScriptType(ScriptType.valueOf(this.remoteScriptType.name)) .setCommand(this.command) .setTimeOut(this.timeOut.toInt()) .setProperties(this.properties.asGrpcData()) |