From cc96f30a504aa32030eafefdba69d635869c7949 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 18 Apr 2019 16:27:20 -0400 Subject: Add support for Ansible packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rework how to provide packages - support proxy as parameters Change-Id: I1d10d921ead0837aa0f74b965cadf985424ceedc Issue-ID: CCCSDK-1215 Signed-off-by: Alexis de Talhouët --- .../core/api/data/BlueprintRemoteProcessorData.kt | 11 ++--------- .../execution/RemoteScriptExecutionService.kt | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'ms/blueprintsprocessor/modules') 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 = 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?, + var packages: JsonNode, var timeOut: Long = 120, - var properties: MutableMap = hashMapOf() -) \ No newline at end of file + var properties: MutableMap = 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() + + 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()) -- cgit 1.2.3-korg