From 791e8adde4228c29eb515689397dfb642c8b1969 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sun, 17 Feb 2019 09:31:35 -0500 Subject: Netconf resolution service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0346c88cd11136561426260a206bd7bf07f90dd3 Issue-ID: CCSDK-1086 Signed-off-by: Alexis de Talhouët --- .../functions/netconf-executor/pom.xml | 20 ++++++-------------- .../netconf/executor/ComponentNetconfExecutor.kt | 6 +++++- .../netconf/executor/NetconfComponentFunction.kt | 17 +++++++++++++---- .../netconf/executor/ComponentNetconfExecutorTest.kt | 4 +++- 4 files changed, 27 insertions(+), 20 deletions(-) (limited to 'ms') diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml index 51c625025..df566de44 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml @@ -29,7 +29,7 @@ org.onap.ccsdk.apps.blueprintsprocessor.functions - python-executor + resource-resolution org.codehaus.jettison @@ -42,18 +42,10 @@ sshd-core 1.7.0 - - - com.jcraft - jsch - 0.1.54 - - + + com.jcraft + jsch + 0.1.54 + - - 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 c32aa9d51..ecf90a281 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 @@ -20,6 +20,7 @@ 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.BlueprintJythonService +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory @@ -28,7 +29,8 @@ import org.springframework.stereotype.Component @Component("component-netconf-executor") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService) +open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService, + private var resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() { private val log = LoggerFactory.getLogger(ComponentNetconfExecutor::class.java) @@ -41,6 +43,8 @@ open class ComponentNetconfExecutor(private val blueprintJythonService: Blueprin checkNotNull(scriptComponent) { "failed to get netconf script component" } 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 c98009fe6..e1160acf5 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,23 +18,32 @@ 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.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 + // Called from python script fun initializeNetconfConnection(requirementName: String): NetconfDevice { val deviceInfo = deviceProperties(requirementName) return NetconfDevice(deviceInfo) } - fun generateMessage(): String { - TODO() + fun generateMessage(artifactName: String): String { + return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName) + } + + fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String { + return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName, + artifactMapping, artifactTemplate) } - fun resolveAndGenerateMesssage(): String { - TODO() + fun resolveAndGenerateMessage(artifactPrefix: String): String { + return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName, + artifactPrefix) } private fun deviceProperties(requirementName: String): DeviceInfo { 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 7b31610c2..5b7b14ad0 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 @@ -24,6 +24,7 @@ import org.junit.runner.RunWith 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.python.executor.PythonExecutorProperty +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement @@ -35,7 +36,8 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class, ComponentNetconfExecutor::class, JsonParserService::class]) +@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class, + ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class]) @TestPropertySource(properties = ["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"]) -- cgit 1.2.3-korg