aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json32
-rw-r--r--components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt20
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt18
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt3
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/resources/validation/success.json7
11 files changed, 102 insertions, 45 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
index 98f77266a..757210167 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
@@ -100,6 +100,38 @@
}
}
},
+ "vnf_parameter": {
+ "tags": "vnf_parameter",
+ "name": "vnf_parameter",
+ "property": {
+ "description": "vnf_parameter",
+ "type": "string"
+ },
+ "updated-by": "Rajewski, Lukasz <lukasz.rajewski@t-mobile.pl>",
+ "sources": {
+ "sdnc": {
+ "type": "source-rest",
+ "properties": {
+ "verb": "GET",
+ "type": "JSON",
+ "url-path": "/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/$parameter-name",
+ "path": "/param/0/value",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "vnf-id": "vnf-id",
+ "parameter-name": "parameter-name"
+ },
+ "output-key-mapping": {
+ "vnf_name": "value"
+ },
+ "key-dependencies": [
+ "service-instance-id",
+ "vnf-id"
+ ]
+ }
+ }
+ }
+ },
"aai-get-resource": {
"tags": "aai-get",
"name": "aai-get-resource",
diff --git a/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json b/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json
index 8fa595a15..67c3e3ce7 100644
--- a/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json
+++ b/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json
@@ -18,6 +18,13 @@
"required": false,
"type": "string"
},
+ "templating-constants": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"dependencies": {
"required": true,
"type": "list",
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt
index 71cf6ceea..9388c280a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt
@@ -68,14 +68,18 @@ open class IpAssignResolutionCapability : ResourceAssignmentProcessor() {
as MutableMap<String, String>
// Get the values from runtime store
- val resolvedKeyValues = resolveInputKeyMappingVariables(inputKeyMapping)
- log.info("\nResolved Input Key mappings: \n{}", resolvedKeyValues)
-
- resolvedKeyValues?.map { KeyIdentifier(it.key, it.value) }
- ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(
+ inputKeyMapping,
+ resourceAssignment.templatingConstants
+ ).toMutableMap()
+ log.info("\nResolved Input Key mappings: \n$resolvedInputKeyMapping")
+
+ resolvedInputKeyMapping.map { KeyIdentifier(it.key, it.value) }.let {
+ resourceAssignment.keyIdentifiers.addAll(it)
+ }
// Generate the payload using already resolved value
- val generatedPayload = generatePayload(resolvedKeyValues, groupResourceAssignments)
+ val generatedPayload = generatePayload(resolvedInputKeyMapping, groupResourceAssignments)
log.info("\nIP Assign mS Request Payload: \n{}", generatedPayload.asJsonType().toPrettyString())
resourceSourceProperties["resolved-payload"] = JacksonUtils.jsonNode(generatedPayload)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt
index 139d8232f..bc6983bd1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt
@@ -69,14 +69,18 @@ open class NamingResolutionCapability : ResourceAssignmentProcessor() {
log.info("\nResolving Input Key mappings: \n{}", inputKeyMapping)
// Get the values from runtime store
- val resolvedKeyValues = resolveInputKeyMappingVariables(inputKeyMapping)
- log.info("\nResolved Input Key mappings: \n{}", resolvedKeyValues)
-
- resolvedKeyValues?.map { KeyIdentifier(it.key, it.value) }
- ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(
+ inputKeyMapping,
+ resourceAssignment.templatingConstants
+ ).toMutableMap()
+ log.info("\nResolved Input Key mappings: \n$resolvedInputKeyMapping")
+
+ resolvedInputKeyMapping.map { KeyIdentifier(it.key, it.value) }.let {
+ resourceAssignment.keyIdentifiers.addAll(it)
+ }
// Generate the payload using already resolved value
- val generatedPayload = generatePayload(resolvedKeyValues, groupResourceAssignments)
+ val generatedPayload = generatePayload(resolvedInputKeyMapping, groupResourceAssignments)
log.info("\nNaming mS Request Payload: \n{}", generatedPayload.asJsonType().toPrettyString())
resourceSourceProperties["resolved-payload"] = JacksonUtils.jsonNode(generatedPayload)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index 25d19cff5..6072a9233 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
@@ -100,10 +101,15 @@ open class DatabaseResourceAssignmentProcessor(
"failed to get input-key-mappings for $dName under $dSource properties"
}
- sourceProperties.inputKeyMapping
- ?.mapValues { raRuntimeService.getResolutionStore(it.value) }
- ?.map { KeyIdentifier(it.key, it.value) }
- ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(
+ inputKeyMapping,
+ resourceAssignment.templatingConstants
+ ).toMutableMap()
+ logger.info("\nResolved Input Key mappings: \n$resolvedInputKeyMapping")
+
+ resolvedInputKeyMapping.map { KeyIdentifier(it.key, it.value) }.let {
+ resourceAssignment.keyIdentifiers.addAll(it)
+ }
logger.info(
"DatabaseResource ($dSource) dictionary information: " +
@@ -111,7 +117,7 @@ open class DatabaseResourceAssignmentProcessor(
)
val jdbcTemplate = blueprintDBLibService(sourceProperties, dSource)
- val rows = jdbcTemplate.query(sql, populateNamedParameter(inputKeyMapping))
+ val rows = jdbcTemplate.query(sql, populateNamedParameter(resolvedInputKeyMapping))
if (rows.isEmpty()) {
logger.warn("Emptyset from dictionary-source($dSource) for dictionary name ($dName) the query ($sql).")
}
@@ -145,10 +151,10 @@ open class DatabaseResourceAssignmentProcessor(
.resourceSourceMappings.filterValues { it == "source-db" }.keys.toTypedArray()
}
- open fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> {
+ open fun populateNamedParameter(inputKeyMapping: Map<String, JsonNode>): Map<String, Any> {
val namedParameters = HashMap<String, Any>()
inputKeyMapping.forEach {
- val expressionValue = raRuntimeService.getResolutionStore(it.value).textValue()
+ val expressionValue = it.value.textValue()
logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)")
namedParameters[it.key] = expressionValue
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index e96083f95..fb9997c47 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -19,7 +19,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.JsonNode
-import org.apache.commons.collections.MapUtils
+import com.fasterxml.jackson.databind.node.TextNode
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -32,7 +32,6 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTem
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
-import java.util.HashMap
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, Boolean> {
@@ -93,15 +92,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return if (resourceDictionaries.containsKey(name)) resourceDictionaries[name] else null
}
- open fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, JsonNode> {
- val resolvedInputKeyMapping = HashMap<String, JsonNode>()
- if (MapUtils.isNotEmpty(inputKeyMapping)) {
- for ((key, value) in inputKeyMapping) {
- val resultValue = raRuntimeService.getResolutionStore(value)
- resolvedInputKeyMapping[key] = resultValue
- }
- }
- return resolvedInputKeyMapping
+ open fun resolveInputKeyMappingVariables(
+ inputKeyMapping: Map<String, String>,
+ templatingConstants: Map<String, String>?
+ ): Map<String, JsonNode> {
+ val const = templatingConstants?.mapValues { TextNode(it.value) as JsonNode }
+ return inputKeyMapping.mapValues { const?.get(it.value) ?: raRuntimeService.getResolutionStore(it.value) }
}
open suspend fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: MutableMap<String, JsonNode>):
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 479be6923..c53c56806 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -81,7 +81,11 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
val inputKeyMapping =
checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
- val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap()
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(
+ inputKeyMapping,
+ resourceAssignment.templatingConstants
+ ).toMutableMap()
+ logger.info("\nResolved Input Key mappings: \n$resolvedInputKeyMapping")
resolvedInputKeyMapping.map { KeyIdentifier(it.key, it.value) }.let {
resourceAssignment.keyIdentifiers.addAll(it)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
index f9a41cead..d161f64ec 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock
import com.fasterxml.jackson.databind.JsonNode
-import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
@@ -24,7 +23,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
-import java.util.HashMap
class MockRestResourceResolutionProcessor(
private val blueprintRestLibPropertyService:
@@ -33,15 +31,14 @@ class MockRestResourceResolutionProcessor(
private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java)
- override fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, JsonNode> {
- val resolvedInputKeyMapping = HashMap<String, JsonNode>()
- if (MapUtils.isNotEmpty(inputKeyMapping)) {
-
- resolvedInputKeyMapping["service-instance-id"] = "10".asJsonPrimitive()
- resolvedInputKeyMapping["vnf_name"] = "vnf1".asJsonPrimitive()
- resolvedInputKeyMapping["vnf-id"] = "123456".asJsonPrimitive()
- }
- return resolvedInputKeyMapping
+ override fun resolveInputKeyMappingVariables(
+ inputKeyMapping: Map<String, String>,
+ templatingConstants: Map<String, String>?
+ ): Map<String, JsonNode> {
+ this.raRuntimeService.putResolutionStore("service-instance-id", "10".asJsonPrimitive())
+ this.raRuntimeService.putResolutionStore("vnf_name", "vnf1".asJsonPrimitive())
+ this.raRuntimeService.putResolutionStore("vnf-id", "123456".asJsonPrimitive())
+ return super.resolveInputKeyMappingVariables(inputKeyMapping, templatingConstants)
}
override fun getName(): String {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
index 56ce3f65d..75c12a0f2 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
@@ -97,8 +97,9 @@ class RestResourceResolutionProcessorTest {
runBlocking {
val resourceAssignment = ResourceAssignment().apply {
name = "vnf_name"
- dictionaryName = "vnf_name"
+ dictionaryName = "vnf_parameter"
dictionarySource = "sdnc"
+ templatingConstants = mutableMapOf("parameter-name" to "vnf_name")
property = PropertyDefinition().apply {
type = "string"
required = true
diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
index f92548612..50330fa68 100644
--- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
@@ -83,6 +83,9 @@ open class ResourceAssignment {
@JsonProperty("dependencies")
var dependencies: MutableList<String>? = null
+ @JsonProperty("templating-constants")
+ var templatingConstants: MutableMap<String, String>? = null
+
@JsonProperty("version")
var version: Int = 0
diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/resources/validation/success.json b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/resources/validation/success.json
index 79925bfac..23d2a0d95 100644
--- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/resources/validation/success.json
+++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/resources/validation/success.json
@@ -79,8 +79,11 @@
"type": "string",
"required": true
},
- "dictionary-name": "vnf-name",
- "dictionary-source": "input",
+ "templating-constants": {
+ "parameter-name": "vnf-name"
+ },
+ "dictionary-name": "vnf-param",
+ "dictionary-source": "sdnc",
"dependencies": []
},
{