aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt31
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt2
2 files changed, 20 insertions, 13 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 fa5d882b0..0f35e6338 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
@@ -44,6 +44,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
const val INPUT_ARGUMENT_PROPERTIES = "argument-properties"
const val INPUT_COMMAND = "command"
const val INPUT_PACKAGES = "packages"
+ const val DEFAULT_SELECTOR = "remote-python"
const val ATTRIBUTE_PREPARE_ENV_LOG = "prepare-environment-logs"
const val ATTRIBUTE_EXEC_CMD_LOG = "execute-command-logs"
@@ -58,13 +59,13 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
val blueprintVersion = bluePrintContext.version()
val operationAssignment: OperationAssignment = bluePrintContext
- .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+ .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
val artifactName: String = operationAssignment.implementation?.primary
- ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
val artifactDefinition =
- bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+ bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
checkNotBlank(artifactDefinition.file) { "couldn't get python script path($artifactName)" }
@@ -90,14 +91,20 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
try {
// Open GRPC Connection
- remoteScriptExecutionService.init(endPointSelector.asText())
+ if (DEFAULT_SELECTOR == endPointSelector.asText()) {
+ remoteScriptExecutionService.init(endPointSelector.asText())
+ } else {
+ // Get endpoint from DSL
+ val endPointSelectorJson = bluePrintRuntimeService.resolveDSLExpression(endPointSelector.asText())
+ remoteScriptExecutionService.init(endPointSelectorJson)
+ }
// If packages are defined, then install in remote server
if (packages != null) {
val prepareEnvInput = PrepareRemoteEnvInput(requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
- blueprintVersion = blueprintVersion),
- packages = packages
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
+ blueprintVersion = blueprintVersion),
+ packages = packages
)
val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput)
log.info("$ATTRIBUTE_PREPARE_ENV_LOG - ${prepareEnvOutput.response}")
@@ -111,10 +118,10 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
val remoteExecutionInput = RemoteScriptExecutionInput(
- requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
- command = scriptCommand,
- properties = properties)
+ requestId = processId,
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
+ command = scriptCommand,
+ properties = properties)
val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
log.info("$ATTRIBUTE_EXEC_CMD_LOG - ${remoteExecutionOutput.response}")
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response))
@@ -131,7 +138,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
+ .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
}
private fun formatNestedJsonNode(node: JsonNode): String {
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 31aa7c7c1..13202c6ea 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
@@ -185,7 +185,7 @@ class ComponentRemotePythonExecutorTest {
}
class MockRemoteScriptExecutionService : RemoteScriptExecutionService {
- override suspend fun init(selector: String) {
+ override suspend fun init(selector: Any) {
}
override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput {