Add netconf script component function

Change-Id: I094025fba5626bae0b4b13320f1cbbb76cda3bfd
Issue-ID: CCSDK-790
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index 5af64ca..637b589 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -190,8 +190,7 @@
                 },
                 "inputs": {
                   "instance-dependencies": [
-                    "json-parser-service",
-                    "netconf-rpc-service"
+                    "json-parser-service"
                   ]
                 },
                 "outputs": {
@@ -220,8 +219,7 @@
                 },
                 "inputs": {
                   "instance-dependencies": [
-                    "json-parser-service",
-                    "netconf-rpc-service"
+                    "json-parser-service"
                   ]
                 },
                 "outputs": {
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py
index e2f5655..c966b1a 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py
@@ -1,28 +1,21 @@
 import  netconf_constant
 from netconfclient import NetconfClient
 from java.lang import Exception
-from abstract_blueprint_function import AbstractPythonComponentFunction
-from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfComponentFunction
 
+class DefaultGetNetConfig(NetconfComponentFunction):
 
-
-class DefaultGetNetConfig(AbstractPythonComponentFunction):
     def process(self, execution_request):
         try:
             log = globals()[netconf_constant.SERVICE_LOG]
             print(globals())
             #requestId = globals()[netconf_constant.PARAM_REQUEST_ID]
             requestId = '1234'
+            nc = NetconfClient(log, self)
 
-            bluePrintRuntimeService = globals()['bluePrintRuntimeService']
+            # Create RPC Serivice
+            nc.createRPCServiceFromRequirement("netconf-connection")
 
-            capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf")
-
-            log.info("capabilityProperty {}",capabilityProperty)
-            netconfService = NetconfRpcService()
-            nc = NetconfClient(log, netconfService)
-
-            nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty))
             runningConfigTemplate = "runningconfig-template"
 
             runningConfigMessageId = "get-config-" + requestId
@@ -38,7 +31,7 @@
                     errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
 
         except Exception, err:
-            log.info("Exception in the script {}",err.getMessage())
+            log.error("Exception in the script {}",err.getMessage())
             status = netconf_constant.STATUS_FAILURE
             errorMessage = "Get Running Config Failure ::"+err.getMessage()
 
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
index 448e03d..421e500 100644
--- a/components/scripts/python/ccsdk_netconf/netconfclient.py
+++ b/components/scripts/python/ccsdk_netconf/netconfclient.py
@@ -4,15 +4,19 @@
 
 class NetconfClient:
 
-    def __init__(self, log, nc):
+    def __init__(self, log, componentFunction):
         self.log = log
-        self.nc = nc
+        self.componentFunction = componentFunction
+        self.nc = None
+
+    def createRPCServiceFromRequirement(self, requirementName):
+        self.nc = self.componentFunction.netconfRpcClientService(requirementName)
 
     def disconnect(self):
         self.nc.disconnect()
         return
 
-    def connect(self,deviceInfo):
+    def connect(self, deviceInfo):
         self.nc.connect(deviceInfo)
         return
 
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
index c007914..ab3372e 100644
--- 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
@@ -19,33 +19,42 @@
 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.BlueprintPythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.ComponentJythonExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.slf4j.LoggerFactory
 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-netconf-executor")
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentNetconfExecutor(private var applicationContext: ApplicationContext, private val netconfExecutorConfiguration: NetconfExecutorConfiguration,
-                                    private val blueprintPythonService: BlueprintPythonService)
-    : ComponentJythonExecutor(applicationContext, blueprintPythonService) {
+open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService)
+    : AbstractComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ComponentNetconfExecutor::class.java)
-    lateinit var deviceInfo: DeviceInfo
 
+    lateinit var scriptComponent: NetconfComponentFunction
 
     override fun process(executionServiceInput: ExecutionServiceInput) {
 
-         super.process(executionServiceInput)
+        scriptComponent = blueprintJythonService.jythonComponentInstance(this) as NetconfComponentFunction
+        checkNotNull(scriptComponent) { "failed to get netconf script component" }
 
+        scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
+        scriptComponent.processId = processId
+        scriptComponent.workflowName = workflowName
+        scriptComponent.stepName = stepName
+        scriptComponent.interfaceName = interfaceName
+        scriptComponent.operationName = operationName
+        scriptComponent.nodeTemplateName = nodeTemplateName
+        scriptComponent.operationInputs = operationInputs
 
+        scriptComponent.process(executionServiceInput)
     }
 
-    fun setdeviceInfo(deviceInfo: DeviceInfo) {
-        this.deviceInfo = deviceInfo
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        scriptComponent.recover(runtimeException, executionRequest)
     }
+
+
 }
\ 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/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
new file mode 100644
index 0000000..d480bdd
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -0,0 +1,63 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfRpcClientService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+
+
+abstract class NetconfComponentFunction : AbstractComponentFunction() {
+
+    fun deviceProperties(requirementName: String): DeviceInfo {
+
+        val blueprintContext = bluePrintRuntimeService.bluePrintContext()
+
+        val requirement = blueprintContext.nodeTemplateRequirement(nodeTemplateName, requirementName)
+
+        val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(requirement
+                .node!!, requirement.capability!!)
+
+        return deviceProperties(capabilityProperties)
+    }
+
+    fun deviceProperties(capabilityProperty: MutableMap<String, JsonNode>): DeviceInfo {
+        return JacksonUtils.getInstanceFromMap(capabilityProperty, DeviceInfo::class.java)
+    }
+
+    fun netconfRpcClientService(): NetconfRpcClientService {
+        return NetconfRpcService()
+    }
+
+    fun netconfRpcClientService(requirementName: String): NetconfRpcClientService {
+        val deviceProperties = deviceProperties(requirementName)
+        val netconfRpcClientService = NetconfRpcService()
+        netconfRpcClientService.connect(deviceProperties)
+        return netconfRpcClientService
+    }
+
+    fun generateMessage(): String {
+        TODO()
+    }
+
+    fun resolveAndGenerateMesssage(): String {
+        TODO()
+    }
+
+}
\ 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
index d538505..0e264bc 100644
--- 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
@@ -16,8 +16,6 @@
 
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
 
-import com.fasterxml.jackson.databind.JsonNode
-import com.google.common.base.Preconditions
 import org.apache.commons.collections.CollectionUtils
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionFactory
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data.DeviceResponse
@@ -26,7 +24,6 @@
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfRpcClientService
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfSession
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.RpcMessageUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.config.ConfigurableBeanFactory
 import org.springframework.context.annotation.Scope
@@ -48,37 +45,20 @@
     private val recordedApplyConfigIds = ArrayList<String>()
     private val DEFAULT_MESSAGE_TIME_OUT = 30
 
-    @Throws(NetconfException::class)
-    fun NetconfRpcService(capabilityProperty: MutableMap<String, JsonNode> ) {
-        try {
-             Preconditions.checkNotNull(capabilityProperty, "missing netconfDeviceInfo in netconf rpc client")
-             connect(getNetconfDeviceInfo(capabilityProperty))
-             log.info("NetconfRpcService initialised with deviceInfo {}", deviceInfo)
-            //configPersistService = ConfigPersistService(configResourceService)
 
+    override fun connect(deviceInfo: DeviceInfo): NetconfSession {
+        try {
+
+            this.deviceInfo = deviceInfo
+
+            log.info("Connecting Netconf Device .....")
+            this.netconfSession = NetconfSessionFactory.instance("DEFAULT_NETCONF_SESSION", deviceInfo)
+            publishMessage("Netconf Device Connection Established")
+            return this.netconfSession
         } catch (e: NetconfException) {
             publishMessage(String.format("Netconf Device Connection Failed, %s", e.message))
             throw NetconfException("Netconf Device Connection Failed,$deviceInfo",e)
         }
-
-    }
-
-    fun setdeviceInfo(deviceInfo: DeviceInfo) {
-        this.deviceInfo = deviceInfo
-    }
-
-    fun getNetconfDeviceInfo(capabilityProperty: MutableMap<String, JsonNode> ):DeviceInfo{
-        val netconfDeviceInfo = JacksonUtils.getInstanceFromMap(capabilityProperty, DeviceInfo::class.java)
-        this.deviceInfo = netconfDeviceInfo
-        return netconfDeviceInfo
-    }
-
-    fun connect(netconfDeviceInfo: DeviceInfo) {
-        log.info("in the connect method")
-        setdeviceInfo(netconfDeviceInfo)
-        netconfSession = NetconfSessionFactory.instance("DEFAULT_NETCONF_SESSION", netconfDeviceInfo)
-        publishMessage("Netconf Device Connection Established");
-
     }
 
     override  fun disconnect() {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt
index 0b63ea5..f66c14a 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt
@@ -17,25 +17,9 @@
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data
 
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
-import java.io.IOException
 import java.util.*
 
 
-
-
-class NetconfExecutionRequest {
-    lateinit var requestId: String
-    val action: String? = null
-    val source: String? = null
-    val loginKey: String? = null
-    val loginAccount: String? = null
-    val targetIP: String? = null
-    val port: Int = 0
-    val connectionTimeoutSec: Int = 0
-    val implementationScript: String? = null
-    val context: MutableMap<String, Any> = mutableMapOf()
-}
-
 class DeviceResponse {
     lateinit var deviceInfo: DeviceInfo
     lateinit var status: String
@@ -52,13 +36,6 @@
     }
 }
 
-class NetconfExecutionResponse {
-    val status: String? = null
-    val errorMessage: String? = null
-    val responseData: Any = Any()
-}
-
-
 class NetconfDeviceOutputEvent {
 
         private var type: NetconfDeviceOutputEvent.Type
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfSshClientLib.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfSshClientLib.kt
index 0a51787..f21cce4 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfSshClientLib.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfSshClientLib.kt
@@ -16,8 +16,8 @@
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data
 
 enum class NetconfSshClientLib(val sshClientString :String) {
-     APACHE_MINA("apache-mina"),
-     ETHZ_SSH2("ethz-ssh2");
+    APACHE_MINA("apache-mina"),
+    ETHZ_SSH2("ethz-ssh2");
 
     fun getEnum(valueOf: String): NetconfSshClientLib {
         return NetconfSshClientLib.valueOf(valueOf.toUpperCase().replace('-', '_'))
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt
index ca67b34..f4360c7 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt
@@ -19,27 +19,25 @@
 import com.fasterxml.jackson.annotation.JsonIgnore
 import com.fasterxml.jackson.annotation.JsonProperty
 
-data class DeviceInfo (
-        @get:JsonProperty("login-account")
-        var name: String? = null,
-        @get:JsonProperty("login-key")
-        var pass: String? = null,
-        @get:JsonProperty("target-ip-address")
-        var ipAddress: String? = null,
-        @get:JsonProperty("port-number")
-        var port: Int = 0,
-        @get:JsonIgnore
-        var key: String? = null,
-        @get:JsonProperty("source")
-        var source: String? = null,
-       // var sshClientLib: NetconfSshClientLib = NetconfSshClientLib,
-        @get:JsonProperty("connection-time-out")
-        var connectTimeoutSec: Long = 30,
-        @get:JsonIgnore
-        var replyTimeout: Int = 60,
-        @get:JsonIgnore
-        var idleTimeout: Int = 45,
-        @get:JsonIgnore
-        var deviceId: String =  ipAddress + ":" + port
-){
-    }
\ No newline at end of file
+class DeviceInfo {
+    @get:JsonProperty("login-account")
+    var name: String? = null
+    @get:JsonProperty("login-key")
+    var pass: String? = null
+    @get:JsonProperty("target-ip-address")
+    var ipAddress: String? = null
+    @get:JsonProperty("port-number")
+    var port: Int = 0
+    @get:JsonIgnore
+    var key: String? = null
+    @get:JsonProperty("source")
+    var source: String? = null
+    @get:JsonProperty("connection-time-out")
+    var connectTimeoutSec: Long = 30
+    @get:JsonIgnore
+    var replyTimeout: Int = 60
+    @get:JsonIgnore
+    var idleTimeout: Int = 45
+    @get:JsonIgnore
+    var deviceId: String = "$ipAddress:$port"
+}
\ 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/interfaces/NetconfRpcClientService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt
index 17a2448..668fb55 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt
@@ -19,6 +19,13 @@
 
 interface NetconfRpcClientService {
 
+    /**
+     * @param deviceProperties deviceProperties
+     * @return NetconfSession
+     */
+    fun connect(deviceInfo: DeviceInfo): NetconfSession
+
+
     fun disconnect()
 
 
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/NetconfDeviceProperties.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/NetconfDeviceProperties.kt
deleted file mode 100644
index 4073351..0000000
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/NetconfDeviceProperties.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils
-
-data class NetconfDeviceProperties(val loginKey:String,val loginAccount:String,val targetIpAddress:String,val portNumber:Int,val connectiontimeOut:Int) {
-
-
-
-}
\ 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
index c33bfcf..d6f737f 100644
--- 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
@@ -22,7 +22,7 @@
 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.functions.python.executor.BlueprintPythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
 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.asJsonNode
@@ -35,10 +35,10 @@
 import org.springframework.test.context.junit4.SpringRunner
 
 @RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, BlueprintPythonService::class,
+@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, BlueprintJythonService::class,
     PythonExecutorProperty::class])
 @TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf;./../../../../components/scripts/python/ccsdk_blueprints",
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
     "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"])
 class ComponentNetconfExecutorTest {
 
@@ -70,9 +70,7 @@
 
         componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
         componentNetconfExecutor.stepName = "activate-netconf"
-        
-        //TODO to fix build issue
-        //componentNetconfExecutor.apply(executionServiceInput)
+        componentNetconfExecutor.apply(executionServiceInput)
 
     }
 }
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt
index eefead2..4ee48bc 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt
@@ -18,7 +18,6 @@
 import org.junit.After
 import org.junit.Assert
 import org.junit.Before
-import org.junit.Test
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDeviceSimulator
@@ -31,7 +30,13 @@
 
     @Before
     fun before() {
-        deviceInfo =DeviceInfo("name", "password", "localhost", 2224, "10")
+        deviceInfo = DeviceInfo().apply {
+            name = "name"
+            pass = "password"
+            ipAddress = "localhost"
+            port = 2224
+            connectTimeoutSec = 10
+        }
 
         device = NetconfDeviceSimulator(deviceInfo!!.port)
         device!!.start()
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt
new file mode 100644
index 0000000..fcaa57b
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt
@@ -0,0 +1,105 @@
+/*
+ * 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 com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.apache.commons.io.FilenameUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin.BlueprintPythonHost
+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.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
+                             private val applicationContext: ApplicationContext) {
+
+    val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::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)
+
+        val blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
+
+        val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
+        val pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
+
+        log.info("Component Object {}", pyObject)
+
+        return pyObject.__tojava__(T::class.java) as T
+    }
+
+    fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
+
+        val bluePrintRuntimeService = abstractComponentFunction.bluePrintRuntimeService
+        val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+        val nodeTemplateName: String = abstractComponentFunction.nodeTemplateName
+        val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs
+
+        val operationAssignment: OperationAssignment = bluePrintContext
+                .nodeTemplateInterfaceOperation(abstractComponentFunction.nodeTemplateName,
+                        abstractComponentFunction.interfaceName, abstractComponentFunction.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)")
+
+        val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+
+        val pythonFileName = artifactDefinition.file
+                ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+
+        val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
+        log.info("Getting Jython Script Class($pythonClassName)")
+
+        val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
+
+        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 scriptComponentFunction = jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName,
+                content!!, jythonInstances)
+
+        return scriptComponentFunction
+
+    }
+
+}
\ 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/BlueprintPythonService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
deleted file mode 100644
index 21adcd5..0000000
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonService.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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)
-
-        val blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
-
-        val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
-        val 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 ba55638..a74a779 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,7 +26,6 @@
 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
@@ -35,7 +34,7 @@
 @Component("component-jython-executor")
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class ComponentJythonExecutor(private var applicationContext: ApplicationContext,
-                                   private val blueprintPythonService: BlueprintPythonService) : AbstractComponentFunction() {
+                                   private val blueprintJythonService: BlueprintJythonService) : AbstractComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
 
@@ -91,7 +90,7 @@
         }
 
         // Setup componentFunction
-        componentFunction = blueprintPythonService.jythonInstance(bluePrintContext, pythonClassName,
+        componentFunction = blueprintJythonService.jythonInstance(bluePrintContext, pythonClassName,
                 content!!, jythonInstance)
         componentFunction?.bluePrintRuntimeService = bluePrintRuntimeService
         componentFunction?.executionServiceInput = executionServiceInput
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/BlueprintJythonServiceTest.kt
similarity index 91%
rename from ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt
rename to ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt
index 0e85680..8e52a9f 100644
--- 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/BlueprintJythonServiceTest.kt
@@ -28,14 +28,14 @@
 import kotlin.test.assertNotNull
 
 @RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BlueprintPythonService::class, PythonExecutorProperty::class])
+@ContextConfiguration(classes = [BlueprintJythonService::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 {
+class BlueprintJythonServiceTest {
 
     @Autowired
-    private lateinit var blueprintPythonService: BlueprintPythonService
+    private lateinit var blueprintJythonService: BlueprintJythonService
 
     @Test
     fun testGetAbstractPythonPlugin() {
@@ -46,7 +46,7 @@
 
         val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
 
-        val abstractComponentFunction = blueprintPythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SampleBlueprintComponent", content, dependencies)
+        val abstractComponentFunction = blueprintJythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SampleBlueprintComponent", content, dependencies)
 
         assertNotNull(abstractComponentFunction, "failed to get python component")
 
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
index 013039d..162a7b4 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
@@ -18,7 +18,7 @@
 
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
 
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintPythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
@@ -33,7 +33,7 @@
 @Service("resource-assignment-processor-capability")
 open class CapabilityResourceAssignmentProcessor(private var applicationContext: ApplicationContext,
                                                  private val bluePrintScriptsService: BluePrintScriptsService,
-                                                 private val bluePrintPythonService: BlueprintPythonService) :
+                                                 private val bluePrintJythonService: BlueprintJythonService) :
         ResourceAssignmentProcessor() {
 
     companion object {
@@ -167,7 +167,7 @@
                                                      dependencyInstances: MutableMap<String, Any>):
             ResourceAssignmentProcessor {
 
-        val resourceAssignmentProcessor = bluePrintPythonService
+        val resourceAssignmentProcessor = bluePrintJythonService
                 .jythonInstance<ResourceAssignmentProcessor>(raRuntimeService.bluePrintContext(), pythonClassName,
                         content, dependencyInstances)
 
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
index 3dda795..f884456 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
@@ -20,7 +20,7 @@
 
 import org.junit.Test
 import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintPythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
 import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
@@ -37,7 +37,7 @@
 
 @RunWith(SpringRunner::class)
 @ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
-    BlueprintPythonService::class, PythonExecutorProperty::class, MockCapabilityService::class])
+    BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::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"])