aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/python-executor
diff options
context:
space:
mode:
authorSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-02-11 23:35:16 -0500
committerSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-02-12 08:07:00 -0500
commit6cd702b68bb4e0a479dcaf27b5d75a65982f6fe5 (patch)
treec6bca1f1065190d6d9f174c26653b3565f9921fb /ms/blueprintsprocessor/functions/python-executor
parent071eb99857706fdb0b4e400c8f81a6cb4804b5d5 (diff)
Jython execution component and service
Change-Id: I2610e73a9c7ba073b5fa9d148dcd6fb5b9ad9ae3 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/python-executor')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt47
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt33
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt52
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt28
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt47
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt41
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt78
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt56
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt15
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt52
10 files changed, 232 insertions, 217 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
new file mode 100644
index 000000000..cea02fb79
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin.BlueprintPythonHost
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service("jython-executor-service")
+class BlueprintPythonService(val pythonExecutorProperty: PythonExecutorProperty){
+
+ val log: Logger = LoggerFactory.getLogger(BlueprintPythonService::class.java)
+
+ inline fun <reified T> jythonInstance(blueprintContext: BluePrintContext, pythonClassName: String, content: String,
+ dependencyInstanceNames: MutableMap<String, Any>?): T {
+
+ val blueprintBasePath: String = blueprintContext.rootPath
+ val pythonPath: MutableList<String> = arrayListOf()
+ pythonPath.add(blueprintBasePath)
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+ var blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
+
+ val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
+ var pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
+
+ log.info("Component Object {}", pyObject)
+
+ return pyObject.__tojava__(T::class.java) as T
+ }
+
+} \ 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/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
index 9e2ba0b94..4a3ad6b25 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
@@ -1,6 +1,8 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
*
+ * Modifications Copyright © 2019 IBM, Bell Canada.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -19,13 +21,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
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
@@ -33,23 +33,19 @@ import org.springframework.stereotype.Component
@Component("component-jython-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+open class ComponentJythonExecutor(private var applicationContext: ApplicationContext,
+ private val blueprintPythonService: BlueprintPythonService) : AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
private var componentFunction: AbstractComponentFunction? = null
- @Autowired
- lateinit var applicationContext: ApplicationContext
-
fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
.nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
- val blueprintBasePath: String = bluePrintContext.rootPath
-
val artifactName: String = operationAssignment.implementation?.primary
?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
@@ -64,22 +60,21 @@ open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExe
checkNotEmptyOrThrow(content, "artifact ($artifactName) content is empty")
- val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
- pythonPath.add(blueprintBasePath)
- pythonPath.addAll(pythonExecutorProperty.modulePaths)
-
- val jythonInstances: MutableMap<String, Any> = hashMapOf()
- jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
-
val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
- instanceDependenciesNode.forEach { instanceName ->
- jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
+ 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
}
- componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
- pythonPath, content, pythonClassName, jythonInstances)
+ componentFunction = blueprintPythonService.jythonInstance(bluePrintContext, pythonClassName,
+ content!!, jythonContextInstance)
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
deleted file mode 100644
index 6618d13c3..000000000
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
-
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.context.ApplicationContext
-import org.springframework.stereotype.Service
-
-@Service
-class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorProperty) {
-
-
- private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
-
- @Autowired
- lateinit var applicationContext: ApplicationContext
-
-
- fun getJythonComponentFunction(pythonClassName: String, content: String, pythonPath: MutableList<String>,
- jythonContextInstance: MutableMap<String, Any>,
- dependencyInstanceNames: List<String>): AbstractComponentFunction {
-
- pythonPath.addAll(pythonExecutorProperty.modulePaths)
-
- dependencyInstanceNames.forEach { instanceName ->
- jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
-
- }
-
- return PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
- pythonPath, content, pythonClassName, jythonContextInstance)
-
- }
-
-} \ 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/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
index be7374c5a..6d17f9320 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
@@ -1,6 +1,8 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
*
+ * Modifications Copyright © 2019 IBM, Bell Canada.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,6 +22,8 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
+import java.io.File
+import java.util.*
@Configuration
@ComponentScan
@@ -32,11 +36,33 @@ open class PythonExecutorProperty {
lateinit var executionPath: String
@Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
lateinit var modulePaths: List<String>
-
}
class PythonExecutorConstants {
companion object {
const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
}
+}
+
+open class BluePrintPython(executablePath: String, blueprintPythonPlatform: MutableList<String>,
+ val argv: MutableList<String>){
+ lateinit var moduleName: String
+ lateinit var pythonClassName: String
+ lateinit var content: String
+ var props: Properties = Properties()
+
+ init {
+ // Build up the python.path
+ val sb = StringBuilder()
+ sb.append(System.getProperty("java.class.path"))
+
+ for (p in blueprintPythonPlatform) {
+ sb.append(File.pathSeparator).append(p)
+ }
+
+ props["python.import.site"] = "true"
+ props.setProperty("python.path", sb.toString())
+ props.setProperty("python.verbose", "error")
+ props.setProperty("python.executable", executablePath)
+ }
} \ 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
new file mode 100644
index 000000000..ca0a7158a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BluePrintPython
+import org.python.core.PyObject
+import org.python.util.PythonInterpreter
+
+open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
+ private val blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
+
+ init {
+ PythonInterpreter.initialize(System.getProperties(), bluePrintPython.props, bluePrintPython.argv.toTypedArray())
+ blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(bluePrintPython)
+ }
+
+ /**
+ * getPythonComponent Purpose: execute the python script and return the python interpreter object
+ *
+ * @param content String
+ * @param interfaceName String
+ * @param properties MutableMap<String, Any>
+ * @return pyObject PyObject
+ */
+ 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]"
+
+ return blueprintPythonInterpreterProxy.getPythonInstance(properties)
+ }
+
+ //TODO Check potential errors in python scripts
+} \ 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/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
new file mode 100644
index 000000000..ad35c91db
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BluePrintPython
+import org.python.core.PyObject
+import org.python.util.PythonInterpreter
+
+open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrintPython): PythonInterpreter(){
+
+ fun getPythonInstance(properties: MutableMap<String, Any>?): PyObject{
+ properties?.forEach { (name, value) ->
+ this.set(name, value)
+ }
+
+ this.exec("import sys")
+
+ bluePrintPython.content?.let {
+ this.exec(bluePrintPython.content)
+ }
+
+ val initCommand = bluePrintPython.pythonClassName.plus(" = ").plus(
+ bluePrintPython.pythonClassName).plus("()")
+ this.exec(initCommand)
+
+ return this.get(bluePrintPython.pythonClassName)
+ }
+} \ 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/utils/PythonExecutorUtils.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
deleted file mode 100644
index 341ede585..000000000
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils
-
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.python.core.PyObject
-import org.python.util.PythonInterpreter
-import org.slf4j.LoggerFactory
-import java.io.File
-import java.util.*
-
-class PythonExecutorUtils {
- companion object {
-
- private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java)
-
- fun getPythonComponent(executePath: String, pythonPath: MutableList<String>, content: String?, interfaceName: String,
- properties: MutableMap<String, Any>): AbstractComponentFunction {
-
- initPython(executePath, pythonPath, arrayListOf())
- val pythonInterpreter = PythonInterpreter()
-
- properties.forEach { (name, value) ->
- pythonInterpreter.set(name, value)
- }
-
- pythonInterpreter.exec("import sys")
-
- content?.let {
- pythonInterpreter.exec(content)
- }
-
- val initCommand = interfaceName.plus(" = ").plus(interfaceName).plus("()")
- pythonInterpreter.exec(initCommand)
- val pyObject: PyObject = pythonInterpreter.get(interfaceName)
-
- log.info("Component Object {}", pyObject)
-
- return pyObject.__tojava__(AbstractComponentFunction::class.java) as AbstractComponentFunction
- }
-
- private fun initPython(executablePath: String,
- pythonPath: MutableList<String>, argv: MutableList<String>) {
-
- val props = Properties()
- // Build up the python.path
- val sb = StringBuilder()
- sb.append(System.getProperty("java.class.path"))
-
- for (p in pythonPath) {
- sb.append(File.pathSeparator).append(p)
- }
- log.debug("Python Paths : $sb")
-
- props["python.import.site"] = "true"
- props.setProperty("python.path", sb.toString())
- props.setProperty("python.verbose", "error")
- props.setProperty("python.executable", executablePath)
-
- PythonInterpreter.initialize(System.getProperties(), props, argv.toTypedArray())
- }
-
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt
new file mode 100644
index 000000000..0e8568089
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BlueprintPythonService::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+class BlueprintPythonServiceTest {
+
+ @Autowired
+ private lateinit var blueprintPythonService: BlueprintPythonService
+
+ @Test
+ fun testGetAbstractPythonPlugin() {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val dependencies: MutableMap<String, Any> = hashMapOf()
+
+ val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
+
+ val abstractComponentFunction = blueprintPythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SampleBlueprintComponent", content, dependencies)
+
+ assertNotNull(abstractComponentFunction, "failed to get python component")
+
+ abstractComponentFunction.process(ExecutionServiceInput())
+
+ }
+} \ No newline at end of file
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 837be81f5..34d5119a6 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,21 +42,6 @@ class ComponentJythonExecutorTest {
@Test
fun testPythonComponentInjection() {
- /*
- val executionServiceInput = ExecutionServiceInput()
- executionServiceInput.payload = JsonNodeFactory.instance.objectNode()
-
- val commonHeader = CommonHeader()
- commonHeader.requestId = "1234"
- executionServiceInput.commonHeader = commonHeader
-
- val actionIdentifiers = ActionIdentifiers()
- actionIdentifiers.blueprintName = "baseconfiguration"
- actionIdentifiers.blueprintVersion = "1.0.0"
- actionIdentifiers.actionName = "activate"
- executionServiceInput.actionIdentifiers = actionIdentifiers
-
- */
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json",
ExecutionServiceInput::class.java)!!
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
deleted file mode 100644
index c4fd54673..000000000
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils
-
-import org.junit.Test
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.slf4j.LoggerFactory
-import kotlin.test.assertNotNull
-
-
-class PythonExecutorUtilsTest {
-
- private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java)
-
- @Test
- fun testGetPythonComponent() {
-
- val pythonPath: MutableList<String> = mutableListOf()
- pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints")
-
- val properties: MutableMap<String, Any> = hashMapOf()
- properties["logger"] = log
-
- val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
-
- val abstractComponentFunction = PythonExecutorUtils.getPythonComponent("./../../../../components/scripts/python/ccsdk_blueprints", pythonPath, content,
- "SampleBlueprintComponent", properties)
-
- assertNotNull(abstractComponentFunction, "failed to get python component")
-
- abstractComponentFunction.process(ExecutionServiceInput())
-
- }
-
-
-}
-