aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-05-25 11:23:21 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2020-05-27 13:19:06 -0400
commit1591ba7289f34c1c44881c169e91c3a6ceda9531 (patch)
tree3bf31ce9d1222761c59c245fd714caf30df996e6
parentd7fffebc00a236147e67ffa877016c5e6d1d911f (diff)
Fix sub-attribute parsing for accessing resolved values
Added assignment-map attribute to ResourceResolutionComponent. This attribute will hold a json object with the resolved values for each artifact-prefix. It will enable accessing any resolved value, using get_attribute with JsonPath. Issue-ID: CCSDK-2389 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: I3441569d9766fbd79703d2f224de448edd56dbb2
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt17
7 files changed, 53 insertions, 1 deletions
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
index ff1b5260e..cc2013076 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
@@ -3,8 +3,14 @@
"version": "1.0.0",
"attributes": {
"assignment-params": {
+ "description": "Holds resolved template, resolution-summary or key-value",
"required": true,
"type": "string"
+ },
+ "assignment-map": {
+ "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }",
+ "required": true,
+ "type": "map"
}
},
"capabilities": {
@@ -77,6 +83,10 @@
"required": true,
"type": "string"
},
+ "resource-assignment-map" : {
+ "required": true,
+ "type": "string"
+ },
"status": {
"required": true,
"type": "string"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 3c95ea7bb..e15705a7e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -51,6 +51,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
const val ATTRIBUTE_STATUS = "status"
const val OUTPUT_RESOURCE_ASSIGNMENT_PARAMS = "resource-assignment-params"
+ const val OUTPUT_RESOURCE_ASSIGNMENT_MAP = "resource-assignment-map"
const val OUTPUT_STATUS = "status"
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
index fd104d3ad..8c854b840 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
@@ -116,6 +116,10 @@ fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType {
true, "Output Response"
)
property(
+ ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_MAP, BluePrintConstants.DATA_TYPE_MAP,
+ true, "Output Resolved Values"
+ )
+ property(
ResourceResolutionComponent.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
true, "Status of the Component Execution ( success or failure )"
)
@@ -229,6 +233,13 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
property(ResourceResolutionComponent.OUTPUT_STATUS, status)
}
+ fun resourceAssignmentMap(resourceAssignmentMap: String) =
+ resourceAssignmentMap(resourceAssignmentMap.asJsonType())
+
+ fun resourceAssignmentMap(resourceAssignmentMap: JsonNode) {
+ property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_MAP, resourceAssignmentMap)
+ }
+
fun resourceAssignmentParams(resourceAssignmentParams: String) =
resourceAssignmentParams(resourceAssignmentParams.asJsonType())
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index b934940b1..e2a8920f5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -23,6 +23,7 @@ object ResourceResolutionConstants {
const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val OUTPUT_ASSIGNMENT_MAP = "assignment-map"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 15fd1d673..4ad86b4ad 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.OUTPUT_ASSIGNMENT_MAP
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolution
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionDBService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService
@@ -185,6 +186,12 @@ open class ResourceResolutionServiceImpl(
properties
)
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ OUTPUT_ASSIGNMENT_MAP,
+ ResourceAssignmentUtils.generateAssignmentMap(artifactPrefix, resourceAssignments)
+ )
+
val resolutionSummary = properties.getOrDefault(
ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY,
false
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 1be9649b9..f97c669d6 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -274,6 +274,13 @@ class ResourceAssignmentUtils {
return JacksonUtils.getJson(data, includeNull = true)
}
+ fun generateAssignmentMap(
+ artifactPrefix: String,
+ resourceAssignments: List<ResourceAssignment>
+ ): ObjectNode = resourceAssignments.associateBy({ it.name }, { it.property?.value })
+ .let { mutableMapOf(artifactPrefix to it) }
+ .let { JacksonUtils.objectNodeFromObject(it) }
+
private fun useDefaultValueIfNull(
resourceAssignment: ResourceAssignment,
resourceAssignmentName: String
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
index b4befc26d..6734613fc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
@@ -22,6 +22,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
import io.mockk.every
import io.mockk.spyk
@@ -167,7 +168,7 @@ class ResourceAssignmentUtilsTest {
}
@Test
- fun generate() {
+ fun generateResolutionSummaryDataTest() {
val resourceAssignment = createResourceAssignmentForTest(null)
val resourceDefinition = ResourceDefinition()
val nodeTemplate = NodeTemplate().apply {
@@ -206,6 +207,20 @@ class ResourceAssignmentUtilsTest {
""".replace("\n|\\s".toRegex(), ""), result)
}
+ @Test
+ fun generateAssignmentMapTest() {
+ val artifactPrefix = "vdns"
+ val resourceAssignments = mutableListOf(
+ createResourceAssignmentForTest("abc-123", "vnf-id"),
+ createResourceAssignmentForTest(null, "vf-module-name")
+ )
+
+ val result: ObjectNode = ResourceAssignmentUtils.generateAssignmentMap(artifactPrefix, resourceAssignments)
+
+ assertEquals("abc-123", result["vdns"]["vnf-id"].textValue())
+ assertEquals(JacksonUtils.getJsonNode(null), result["vdns"]["vf-module-name"])
+ }
+
private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
val resourceAssignmentForTest = ResourceAssignment().apply {