aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/netconf-executor/src/main
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-18 15:10:25 -0500
committerAlexis de Talhouƫt <adetalhouet89@gmail.com>2019-02-20 21:02:05 +0000
commit0613ae8f927834f7621011fda3f0cb1b7f8e07ad (patch)
tree79010a222bfb62ad2cb61d88cccfea8f76dfc186 /ms/blueprintsprocessor/functions/netconf-executor/src/main
parent183e2b48ceb4ae58b85f76f9bf182a5958fc92e6 (diff)
Add component function scripting service
Change-Id: I7c5b49617823dd623566fb4be4d431012420e17c Issue-ID: CCSDK-959 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/main')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt35
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt9
2 files changed, 33 insertions, 11 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 06c9b7b2c..60f1e4f82 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
@@ -18,10 +18,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+import com.fasterxml.jackson.databind.node.ArrayNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -29,23 +31,40 @@ import org.springframework.stereotype.Component
@Component("component-netconf-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService,
- private var resourceResolutionService: ResourceResolutionService)
+open class ComponentNetconfExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService)
: AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentNetconfExecutor::class.java)
+ companion object {
+ const val SCRIPT_TYPE = "script-type"
+ const val SCRIPT_CLASS_REFERENCE = "script-class-reference"
+ const val INSTANCE_DEPENDENCIES = "instance-dependencies"
+ }
+
+
lateinit var scriptComponent: NetconfComponentFunction
override fun process(executionRequest: ExecutionServiceInput) {
- scriptComponent = blueprintJythonService.jythonComponentInstance(this) as NetconfComponentFunction
+ val scriptType = operationInputs.getAsString(SCRIPT_TYPE)
+ val scriptClassReference = operationInputs.getAsString(SCRIPT_CLASS_REFERENCE)
+ val instanceDependenciesNode = operationInputs.get(INSTANCE_DEPENDENCIES) as? ArrayNode
+
+ val scriptDependencies: MutableList<String> = arrayListOf()
+ scriptDependencies.add(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+
+ instanceDependenciesNode?.forEach { instanceName ->
+ scriptDependencies.add(instanceName.textValue())
+ }
+
+ scriptComponent = componentFunctionScriptingService.scriptInstance<NetconfComponentFunction>(this, scriptType,
+ scriptClassReference, scriptDependencies)
+
+
checkNotNull(scriptComponent) { "failed to get netconf script component" }
- // FIXME("Populate the reference in Abstract Script Instance Injection map")
scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
- scriptComponent.resourceResolutionService = resourceResolutionService
-
scriptComponent.processId = processId
scriptComponent.workflowName = workflowName
scriptComponent.stepName = stepName
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
index e1160acf5..26e51ec09 100644
--- 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
@@ -18,13 +18,16 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
abstract class NetconfComponentFunction : AbstractComponentFunction() {
- lateinit var resourceResolutionService: ResourceResolutionService
+
+ open fun resourceResolutionService(): ResourceResolutionService =
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
// Called from python script
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
@@ -37,12 +40,12 @@ abstract class NetconfComponentFunction : AbstractComponentFunction() {
}
fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactMapping, artifactTemplate)
}
fun resolveAndGenerateMessage(artifactPrefix: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactPrefix)
}