aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt31
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt63
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt36
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt23
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfSshClientLib.kt4
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt46
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt7
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/NetconfDeviceProperties.kt7
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt10
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt9
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt105
-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.kt5
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintPythonServiceTest.kt)8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt4
16 files changed, 249 insertions, 162 deletions
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 c007914a..ab3372e9 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 00000000..d480bdd4
--- /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 d5385054..0e264bcb 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.interf
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 @@ class NetconfRpcService : NetconfRpcClientService {
private val recordedApplyConfigIds = ArrayList<String>()
private val DEFAULT_MESSAGE_TIME_OUT = 30
- @Throws(NetconfException::class)
- fun NetconfRpcService(capabilityProperty: MutableMap<String, JsonNode> ) {
+
+ override fun connect(deviceInfo: DeviceInfo): NetconfSession {
try {
- Preconditions.checkNotNull(capabilityProperty, "missing netconfDeviceInfo in netconf rpc client")
- connect(getNetconfDeviceInfo(capabilityProperty))
- log.info("NetconfRpcService initialised with deviceInfo {}", deviceInfo)
- //configPersistService = ConfigPersistService(configResourceService)
+ 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 0b63ea58..f66c14a5 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 DeviceResponse {
}
}
-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 0a517871..f21cce4a 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 ca67b341..f4360c7e 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 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.inter
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 17a24488..668fb552 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 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data.D
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 4073351c..00000000
--- 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 c33bfcfa..d6f737fd 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 com.fasterxml.jackson.databind.JsonNode
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.TestPropertySource
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 @@ class ComponentNetconfExecutorTest {
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 eefead21..4ee48bc8 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 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
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 @@ class NetconfSessionImplTest {
@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 00000000..fcaa57b3
--- /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 21adcd5f..00000000
--- 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 ba556381..a74a7790 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.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
@@ -35,7 +34,7 @@ import org.springframework.stereotype.Component
@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 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
}
// 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
index 0e856808..8e52a9f4 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 org.springframework.test.context.junit4.SpringRunner
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 @@ class BlueprintPythonServiceTest {
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 013039d6..162a7b49 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 @@ import java.io.File
@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 @@ open class CapabilityResourceAssignmentProcessor(private var applicationContext:
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 3dda7955..f884456e 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 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
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 @@ import kotlin.test.assertNotNull
@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"])