Add Netconf Executor Function module
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Wed, 5 Dec 2018 01:53:22 +0000 (20:53 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Wed, 5 Dec 2018 01:53:22 +0000 (20:53 -0500)
Change-Id: If264e63d4fc4305bc26dc6b249a462afefcbfe1e
Issue-ID: CCSDK-790
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
25 files changed:
ms/blueprintsprocessor/functions/netconf-executor/pom.xml [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/functions/pom.xml
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt with 82% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt with 90% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt with 96% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt with 93% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt with 91% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt with 91% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt with 93% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt with 87% similarity]
ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
ms/blueprintsprocessor/parent/pom.xml

diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
new file mode 100644 (file)
index 0000000..94103b5
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>functions</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+    <artifactId>netconf-executor</artifactId>
+    <name>Blueprints Processor Function - Netconf Executor</name>
+    <description>Blueprints Processor Function - Netconf Executor</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+            <artifactId>python-executor</artifactId>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
new file mode 100644 (file)
index 0000000..e0fd735
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.netconf.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.ComponentJythonExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-netconf-executor")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentNetconfExecutor(private val netconfExecutorConfiguration: NetconfExecutorConfiguration,
+                                    private val pythonExecutorProperty: PythonExecutorProperty)
+    : ComponentJythonExecutor(pythonExecutorProperty) {
+
+    private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+    override fun process(executionServiceInput: ExecutionServiceInput) {
+        super.process(executionServiceInput)
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
new file mode 100644 (file)
index 0000000..1117366
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.netconf.executor
+
+import org.springframework.stereotype.Service
+
+@Service("json-parser-service")
+class JsonParserService {
+
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
new file mode 100644 (file)
index 0000000..267a49a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.netconf.executor
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class NetconfExecutorConfiguration
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
new file mode 100644 (file)
index 0000000..f481810
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.netconf.executor
+
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service("netconf-rpc-service")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class NetconfRpcService {
+
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
new file mode 100644 (file)
index 0000000..90a5ea0
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.netconf.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+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
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [NetconfExecutorConfiguration::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 ComponentNetconfExecutorTest {
+
+    @Autowired
+    lateinit var componentNetconfExecutor: ComponentNetconfExecutor
+
+    @Test
+    fun testComponentNetconfExecutor() {
+
+        val executionServiceInput = ExecutionServiceInput()
+        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 bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+                "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+
+
+        val metaData: MutableMap<String, JsonNode> = hashMapOf()
+        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "activate-jython")
+
+        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_OPERATION, "process")
+        metaData.putJsonElement("activate-jython-step-inputs", stepMetaData)
+        executionServiceInput.metadata = metaData
+
+        componentNetconfExecutor.apply(executionServiceInput)
+
+    }
+}
+
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..f9ec9fe
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+    <logger name="org.springframework.test" level="warn"/>\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index efd550d..e4f8c84 100644 (file)
@@ -32,6 +32,7 @@
     <modules>
         <module>resource-resolution</module>
         <module>python-executor</module>
+        <module>netconf-executor</module>
     </modules>
 
     <dependencies>
index 2965cb5..166af0f 100644 (file)
 
 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.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
 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
 import org.springframework.stereotype.Component
 
 @Component("component-jython-executor")
-class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
 
     private var componentFunction: AbstractComponentFunction? = null
 
+    @Autowired
+    lateinit var applicationContext: ApplicationContext
 
-    override fun process(executionServiceInput: ExecutionServiceInput) {
-
-        log.info("Processing : ${executionServiceInput.metadata}")
-        checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
-
+    fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
         val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
 
         val operationAssignment: OperationAssignment = bluePrintContext
                 .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
 
-        val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
-                ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)")
+        val blueprintBasePath: String = bluePrintContext.rootPath
 
         val artifactName: String = operationAssignment.implementation?.primary
                 ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
@@ -66,12 +68,30 @@ class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutor
         pythonPath.add(blueprintBasePath)
         pythonPath.addAll(pythonExecutorProperty.modulePaths)
 
-        val properties: MutableMap<String, Any> = hashMapOf()
-        properties["log"] = log
+        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())
+        }
 
         componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
-                pythonPath, content, pythonClassName, properties)
+                pythonPath, content, pythonClassName, jythonInstances)
+    }
+
+
+    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)
 
     }
index dc372af..6618d13 100644 (file)
@@ -33,10 +33,11 @@ class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorP
     lateinit var applicationContext: ApplicationContext
 
 
-    fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
-                                  jythonContextInstance: MutableMap<String, Any>,
-                                  dependencyInstanceNames: List<String>): AbstractComponentFunction {
+    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)
index dd80fb0..be7374c 100644 (file)
@@ -33,4 +33,10 @@ open class PythonExecutorProperty {
     @Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
     lateinit var modulePaths: List<String>
 
+}
+
+class PythonExecutorConstants {
+    companion object {
+        const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
+    }
 }
\ No newline at end of file
index 23da74a..7087974 100644 (file)
@@ -35,13 +35,11 @@ import org.springframework.test.context.junit4.SpringRunner
 @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 ComponentJythonExecutorTest {
 
     @Autowired
     lateinit var componentJythonExecutor: ComponentJythonExecutor
 
-
     @Test
     fun testPythonComponentInjection() {
 
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
new file mode 100644 (file)
index 0000000..41250e0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.mock
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+open class MockInstanceConfiguration {
+    @Bean(name = ["json-parser-service", "netconf-rpc-service"])
+    open fun createComponentFunction(): MockJythonService {
+        return MockJythonService()
+    }
+}
+
+class MockJythonService {
+
+}
\ No newline at end of file
  * limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
 \r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
+import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
+import org.springframework.context.annotation.Scope\r
 import org.springframework.stereotype.Component\r
 \r
 @Component("component-resource-resolution")\r
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
 open class ResourceResolutionComponent : AbstractComponentFunction() {\r
     override fun process(executionRequest: ExecutionServiceInput) {\r
         TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
  * limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
 
 class ResourceResolutionConstants {
     companion object {
         const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
-
     }
 
 }
\ No newline at end of file
@@ -15,7 +15,7 @@
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
 \r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput\r
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
 
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
@@ -15,7 +15,7 @@
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
 \r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
@@ -15,7 +15,7 @@
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
 \r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
 
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
 
 import com.fasterxml.jackson.databind.node.ObjectNode
 import org.apache.commons.collections.CollectionUtils
@@ -23,10 +23,10 @@ import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 import org.slf4j.LoggerFactory
index 8aeb415..0f3b4a8 100644 (file)
@@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.resource.api;
 import io.swagger.annotations.ApiOperation;\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.ResourceResolutionService;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService;\r
 import org.springframework.http.MediaType;\r
 import org.springframework.web.bind.annotation.*;\r
 import reactor.core.publisher.Mono;\r
index 2c1c40c..7312d2d 100644 (file)
@@ -20,12 +20,16 @@ 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.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
 import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
 
 @RunWith(SpringRunner::class)
 @ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
@@ -33,6 +37,9 @@ class BlueprintServiceLogicTest {
 
     private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
 
+    @Autowired
+    lateinit var applicationContext: ApplicationContext
+
     @Autowired
     lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
 
@@ -61,4 +68,26 @@ class BlueprintServiceLogicTest {
 
     }
 
+    @Test
+    fun testSingleton() {
+        val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
+        singleton1.stepName = "step1"
+        val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
+        assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
+    }
+
+    @Test
+    fun testProtoTypeFunction() {
+        val stepName1 = "step1"
+        val stepName2 = "step2"
+        val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+        proto1.stepName = stepName1
+
+        val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+        proto2.stepName = stepName2
+
+        assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
+        assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
+    }
+
 }
\ No newline at end of file
index 9f7a9c9..1d738ee 100644 (file)
@@ -20,8 +20,11 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
 import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
 
 @Configuration
 open class MockComponentConfiguration {
@@ -43,6 +46,36 @@ class MockComponentFunction : AbstractComponentFunction() {
                 "assignment-params", "params".asJsonPrimitive())
     }
 
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("Recovering component..")
+    }
+}
+
+@Component("singleton-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+class SingletonComponentFunction : AbstractComponentFunction() {
+
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+    override fun process(executionRequest: ExecutionServiceInput) {
+        log.info("Processing component : ${operationInputs}")
+    }
+
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("Recovering component..")
+    }
+}
+
+@Component("prototype-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class PrototypeComponentFunction : AbstractComponentFunction() {
+
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+    override fun process(executionRequest: ExecutionServiceInput) {
+        log.info("Processing component : ${operationInputs}")
+    }
+
     override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
         log.info("Recovering component..")
     }
index 3ad3fef..796aef1 100644 (file)
                 <artifactId>resource-resolution</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+                <artifactId>python-executor</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+                <artifactId>netconf-executor</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- Application Component Dependency -->
             <dependency>