summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/python-executor/src
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-02-11 17:23:48 -0500
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-02-12 14:12:44 -0500
commit7aa5df8cb06e0197d0d750f479c7b09b695b534c (patch)
treeb3e12fd047de978be49fcc61364b3666c4ce51c9 /ms/blueprintsprocessor/functions/python-executor/src
parent45b260c81451f74bfd763186d5ff42e777077d2b (diff)
Fixes: manual integration test of CDS
- support to overwrite cba - fix map to json - finish meshing - fix python context not having the bluePrintRuntimeService injected - load all properties in the properties store Issue-ID: CCSDK-414 Change-Id: I6b65201529d0ffd9c3e18023a33e0081236b01de Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/python-executor/src')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt4
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt64
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt3
5 files changed, 40 insertions, 35 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
index cea02fb79..21adcd5f7 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
@@ -34,10 +34,10 @@ class BlueprintPythonService(val pythonExecutorProperty: PythonExecutorProperty)
pythonPath.add(blueprintBasePath)
pythonPath.addAll(pythonExecutorProperty.modulePaths)
- var blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
+ val blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
- var pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
+ val pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
log.info("Component Object {}", pyObject)
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
index 4a3ad6b25..ba556381f 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
@@ -26,6 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Scope
@@ -40,7 +41,25 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
private var componentFunction: AbstractComponentFunction? = null
- fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
+ override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
+ val request = super.prepareRequest(executionRequest)
+ // Populate Component Instance
+ populateJythonComponentInstance()
+ return request
+ }
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing : $operationInputs")
+ // Invoke Jython Component Script
+ componentFunction!!.process(executionServiceInput)
+
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ componentFunction!!.recover(runtimeException, executionRequest)
+ }
+
+ private fun populateJythonComponentInstance() {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
@@ -63,36 +82,23 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
- val jythonContextInstance: MutableMap<String, Any> = hashMapOf()
- jythonContextInstance["log"] = LoggerFactory.getLogger(pythonClassName)
- jythonContextInstance["bluePrintRuntimeService"] = bluePrintRuntimeService
- instanceDependenciesNode?.forEach { instanceName ->
- val instance = instanceName.textValue()
- val value = applicationContext.getBean(instance)
- ?: throw BluePrintProcessorException("couldn't get the dependency instance($instance)")
- jythonContextInstance[instance] = value
+ val jythonInstance: MutableMap<String, Any> = hashMapOf()
+ jythonInstance["log"] = LoggerFactory.getLogger(pythonClassName)
+ jythonInstance["bluePrintRuntimeService"] = bluePrintRuntimeService
+
+ instanceDependenciesNode.forEach { instanceName ->
+ jythonInstance[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
}
+ // Setup componentFunction
componentFunction = blueprintPythonService.jythonInstance(bluePrintContext, pythonClassName,
- content!!, jythonContextInstance)
- }
-
-
- override fun process(executionServiceInput: ExecutionServiceInput) {
-
- log.info("Processing : $operationInputs")
- checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
-
- // Populate Component Instance
- populateJythonComponentInstance(executionServiceInput)
-
- // Invoke Jython Component Script
- componentFunction!!.process(executionServiceInput)
-
+ content!!, jythonInstance)
+ componentFunction?.bluePrintRuntimeService = bluePrintRuntimeService
+ componentFunction?.executionServiceInput = executionServiceInput
+ componentFunction?.stepName = stepName
+ componentFunction?.interfaceName = interfaceName
+ componentFunction?.operationName = operationName
+ componentFunction?.processId = processId
+ componentFunction?.workflowName = workflowName
}
-
- override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
- componentFunction!!.recover(runtimeException, executionRequest)
- }
-
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt
index ca0a7158a..7278ced51 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt
@@ -38,7 +38,7 @@ open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
fun getPythonComponent(content: String?, interfaceName: String, properties: MutableMap<String, Any>?): PyObject {
bluePrintPython.content = content!!
bluePrintPython.pythonClassName = interfaceName
- bluePrintPython.moduleName = "Blueprint Python Scripting [Class Name = $interfaceName]"
+ bluePrintPython.moduleName = "Blueprint Python Script [Class Name = $interfaceName]"
return blueprintPythonInterpreterProxy.getPythonInstance(properties)
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
index ad35c91db..d3b433af9 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
@@ -28,7 +28,7 @@ open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrin
this.exec("import sys")
- bluePrintPython.content?.let {
+ bluePrintPython.content.let {
this.exec(bluePrintPython.content)
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
index 34d5119a6..67a3d9558 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
@@ -42,7 +42,6 @@ class ComponentJythonExecutorTest {
@Test
fun testPythonComponentInjection() {
-
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json",
ExecutionServiceInput::class.java)!!
@@ -51,7 +50,7 @@ class ComponentJythonExecutorTest {
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
- stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentJythonExecutor")
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())