diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-19 12:48:31 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-28 19:46:23 -0500 |
commit | e96fa50ce96890932c2ed38c86ba0f42945c1623 (patch) | |
tree | c32ad96538155410931dba17788c536688d64b0a /ms/blueprintsprocessor/modules/services/workflow-service | |
parent | deb4aafefd02910d14746e70e391b057546ebd08 (diff) |
Implement Base Jython Executor function.
Change-Id: I3fb066a021de4a7b3aa1fce7f6c191bc3944fb51
Issue-ID: CCSDK-696
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/workflow-service')
3 files changed, 33 insertions, 10 deletions
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt index 8750d98b..0600f62d 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt @@ -125,12 +125,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext { MDC.put("currentGraph", graph.toString()) - val ctx = svcLogicContext as BlueprintSvcLogicContext - - val blueprintRuntimeService = ctx.getBluePrintService() - - log.info("Blueprint Runtime Service : ${blueprintRuntimeService}") - var curNode: SvcLogicNode? = graph.getRootNode() log.info("About to execute graph {}", graph.toString()) @@ -138,7 +132,7 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { while (curNode != null) { MDC.put("nodeId", curNode.nodeId.toString() + " (" + curNode.nodeType + ")") log.info("About to execute node # {} ({})", curNode.nodeId, curNode.nodeType) - val nextNode = this.executeNode(curNode, ctx) + val nextNode = this.executeNode(curNode, svcLogicContext) curNode = nextNode } } catch (var5: ExitNodeException) { @@ -147,6 +141,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { MDC.remove("nodeId") MDC.remove("currentGraph") - return ctx + return svcLogicContext } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt index 125a1ff6..ace9f278 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt @@ -60,6 +60,8 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() { log.info("executing node template($nodeTemplateName) component($componentName)") // Get the Component Instance val plugin = this.getComponentFunction(componentName) + // Set the Blueprint Service + plugin.bluePrintRuntimeService = ctx.getBluePrintService() val executionInput = ctx.getRequest() as ExecutionServiceInput // Get the Request from the Context and Set to the Function Input and Invoke the function diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt index 5c90852e..6fe767ce 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt @@ -16,11 +16,16 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow +import com.fasterxml.jackson.databind.JsonNode import org.junit.Test import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -45,7 +50,7 @@ class BlueprintServiceLogicTest { val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml") val svcLogicContext = BlueprintSvcLogicContext() svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) - svcLogicContext.setRequest(ExecutionServiceInput()) + svcLogicContext.setRequest(getDefaultExecutionServiceInput()) blueprintSvcLogicService.execute(graph, svcLogicContext) } @@ -55,8 +60,30 @@ class BlueprintServiceLogicTest { val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml") val svcLogicContext = BlueprintSvcLogicContext() svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) - svcLogicContext.setRequest(ExecutionServiceInput()) + svcLogicContext.setRequest(getDefaultExecutionServiceInput()) blueprintSvcLogicService.execute(graph, svcLogicContext) } + + private fun getDefaultExecutionServiceInput(): ExecutionServiceInput { + val executionServiceInput = ExecutionServiceInput() + val commonHeader = CommonHeader() + commonHeader.requestId = "1234" + executionServiceInput.commonHeader = commonHeader + + val actionIdentifiers = ActionIdentifiers() + actionIdentifiers.blueprintName = "baseconfiguration" + actionIdentifiers.blueprintVersion = "1.0.0" + actionIdentifiers.actionName = "activate" + executionServiceInput.actionIdentifiers = actionIdentifiers + + val metaData: MutableMap<String, JsonNode> = hashMapOf() + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP,"resource-assignment-py") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "DefaultComponentNode") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + executionServiceInput.metadata = metaData + + return executionServiceInput + } }
\ No newline at end of file |