aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-04-04 14:39:36 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-04 14:39:36 +0000
commit4002c9b2afb3f6c71ad97c5031e98c72940e256f (patch)
tree6e8b8957b74932c4f2c6acf54c47a8606de8a537 /ms/blueprintsprocessor/modules
parent835c347f632c32d67ad5051b8dd93b059e1eadaf (diff)
parent0007063cc856483e36dd49718dea5dda80ed6809 (diff)
Merge "Improve step data access."
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt28
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt4
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt18
4 files changed, 35 insertions, 39 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index badd70065..c2698c026 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -18,6 +18,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.core.api.data
import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
import java.util.*
@@ -35,6 +36,7 @@ open class ExecutionServiceInput {
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
+ var stepData: StepData? = null
}
open class ExecutionServiceOutput {
@@ -46,6 +48,7 @@ open class ExecutionServiceOutput {
lateinit var status: Status
@get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
+ var stepData: StepData? = null
}
const val ACTION_MODE_ASYNC = "async"
@@ -96,28 +99,9 @@ open class Status {
var message: String = "success"
}
-open class BluePrintManagementInput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = false)
- lateinit var blueprintName: String
- @get:ApiModelProperty(required = false)
- lateinit var blueprintVersion: String
- @get:ApiModelProperty(required = true)
- lateinit var fileChunk: FileChunk
-}
-
-open class FileChunk {
- @get:ApiModelProperty(required = true)
- lateinit var chunk: ByteArray
-}
-
-open class BluePrintManagementOutput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
- var status: Status = Status()
+open class StepData {
+ lateinit var name: String
+ var properties: MutableMap<String, JsonNode> = mutableMapOf()
}
-
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index 14feb28bf..12f6bc47f 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -22,14 +22,14 @@ import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
/**
@@ -57,8 +57,13 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
override suspend fun prepareRequestNB(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
+ checkNotNull(executionRequest.stepData) { "failed to get step info" }
- check(stepName.isNotEmpty()) { "failed to assign step name" }
+ // Get the Step Name and Step Inputs
+ this.stepName = executionRequest.stepData!!.name
+ this.operationInputs = executionRequest.stepData!!.properties
+
+ checkNotEmpty(stepName) { "failed to get step name from step data" }
this.executionServiceInput = executionRequest
@@ -70,13 +75,6 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")
- val stepInputs = bluePrintRuntimeService.get("$stepName-step-inputs")
- ?: JacksonUtils.objectMapper.createObjectNode()
-
- stepInputs.fields().forEach {
- this.operationInputs[it.key] = it.value
- }
-
nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }
@@ -104,7 +102,11 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
val stepOutputs = bluePrintRuntimeService
.resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
- bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asObjectNode())
+ val stepOutputData = StepData().apply {
+ name = stepName
+ properties = stepOutputs
+ }
+ executionServiceOutput.stepData = stepOutputData
// Set the Default Step Status
status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
} catch (e: Exception) {
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index 586888bab..814054804 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
@@ -100,7 +100,7 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
- checkNotEmptyOrThrow(content, "artifact ($artifactName) content is empty")
+ checkNotEmpty(content){ "artifact ($artifactName) content is empty"}
val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
pythonPath.add(blueprintBasePath)
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
index 8f47a0460..5ed280cb5 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -19,9 +19,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.slf4j.LoggerFactory
@@ -53,16 +53,26 @@ open class NodeTemplateExecutionService(private val applicationContext: Applicat
plugin.bluePrintRuntimeService = bluePrintRuntimeService
plugin.stepName = nodeTemplateName
+ // Parent request shouldn't tamper, so need to clone the request and send to the actual component.
+ val clonedExecutionServiceInput = ExecutionServiceInput().apply {
+ commonHeader = executionServiceInput.commonHeader
+ actionIdentifiers = executionServiceInput.actionIdentifiers
+ payload = executionServiceInput.payload
+ }
+
// Populate Step Meta Data
val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
-
- plugin.bluePrintRuntimeService.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+ val stepInputData = StepData().apply {
+ name = nodeTemplateName
+ properties = stepInputs
+ }
+ clonedExecutionServiceInput.stepData = stepInputData
// Get the Request from the Context and Set to the Function Input and Invoke the function
- return plugin.apply(executionServiceInput)
+ return plugin.applyNB(clonedExecutionServiceInput)
}
} \ No newline at end of file