aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json8
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json4
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json15
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/transform-mapping.json51
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt55
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt19
7 files changed, 153 insertions, 1 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index c506ad05e..e1509a6f0 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -188,6 +188,14 @@
"type": "artifact-mapping-resource",
"file": "Definitions/maxoccurrence-mapping.json"
},
+ "transform-template": {
+ "type": "artifact-template-velocity",
+ "file": "Templates/baseconfig-template.vtl"
+ },
+ "transform-mapping": {
+ "type": "artifact-mapping-resource",
+ "file": "Definitions/transform-mapping.json"
+ },
"notemplate-mapping": {
"type": "artifact-mapping-resource",
"file": "Definitions/notemplate-mapping.json"
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json
index 94c587af7..1dd0f5280 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json
@@ -52,6 +52,10 @@
"required": true,
"type": "string"
},
+ "private_net_id": {
+ "required": true,
+ "type": "string"
+ },
"firmware-version": {
"type" : "string"
},
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 757210167..9e69462f7 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,21 @@
}
}
},
+ "int_pktgen_private_net_id": {
+ "tags": "int_pktgen_private_net_id",
+ "name": "int_pktgen_private_net_id",
+ "property": {
+ "description": "int_pktgen_private_net_id",
+ "type": "string"
+ },
+ "updated-by": "Lukasz Rajewski <lukasz.rajewski@t-mobile.pl>",
+ "sources": {
+ "default": {
+ "type": "source-default",
+ "properties": {}
+ }
+ }
+ },
"vnf_parameter": {
"tags": "vnf_parameter",
"name": "vnf_parameter",
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/transform-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/transform-mapping.json
new file mode 100644
index 000000000..14dec0942
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/transform-mapping.json
@@ -0,0 +1,51 @@
+[
+ {
+ "name": "service-instance-id",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": [
+ ]
+ },
+ {
+ "name": "vnf-id",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "vnf-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "vnf_name",
+ "input-param": false,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "vnf_name",
+ "dictionary-source": "sdnc",
+ "dependencies": [
+ "service-instance-id",
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "private_net_id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "metadata": {
+ "transform-template": "${vnf_name}_private2"
+ }
+ },
+ "dictionary-name": "int_pktgen_private_net_id",
+ "dictionary-source": "default",
+ "dependencies": [
+ "vnf_name"
+ ]
+ }
+] \ No newline at end of file
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 7ab3126bb..8bc78dd40 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
@@ -136,7 +136,7 @@ class ResourceAssignmentUtils {
?.let { if (it.contains("$")) it else null }
?.let { template ->
val resolutionStore = raRuntimeService.getResolutionStore()
- .mapValues { e -> e.value.asText() } as MutableMap<String, Any>
+ .mapValues { e -> if (e.value.isTextual) e.value.asText() else JacksonUtils.getJson(e.value) } as MutableMap<String, Any>
val newValue: JsonNode
try {
newValue = BluePrintVelocityTemplateService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index b39e709d0..9a021e8f6 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -153,6 +153,61 @@ class ResourceResolutionServiceTest {
}
}
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResourceWithTransform() {
+ runBlocking {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
+
+ val executionServiceInput =
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
+
+ val resourceAssignmentRuntimeService =
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourceWithTransform"
+ )
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ "transform",
+ props
+ )
+ }.let { (templateMap, assignmentList) ->
+ assertEquals("This is Sample Velocity Template", templateMap)
+
+ val expectedAssignmentList = mutableListOf(
+ "service-instance-id" to "siid_1234",
+ "vnf-id" to "vnf_1234",
+ "vnf_name" to "temp_vnf",
+ "private_net_id" to "temp_vnf_private2"
+ )
+ assertEquals(expectedAssignmentList.size, assignmentList.size)
+
+ val areEqual = expectedAssignmentList.zip(assignmentList).all { (it1, it2) ->
+ it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
+ }
+ assertEquals(true, areEqual)
+ }
+ }
+
/**
* Always perform new resolution even if resolution exists in the database.
*/
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 2f07e3b9a..541d017b9 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
@@ -362,10 +362,29 @@ class ResourceAssignmentUtilsTest {
ResourceAssignmentUtils
.setResourceDataValue(resourceAssignment, resourceAssignmentRuntimeService, value)
+ val valueJson = "{\"config\":{\"parameter\":\"address\",\"value\":\"0.0.0.0\"}}"
+ resourceAssignmentRuntimeService.putResolutionStore("vnf_config", JacksonUtils.objectMapper.readTree(valueJson))
+ val resourceAssignmentJson = ResourceAssignment()
+ resourceAssignmentJson.name = "vendor_vnf_configuration"
+ resourceAssignmentJson.property = PropertyDefinition()
+ resourceAssignmentJson.property!!.type = "json"
+
+ // Enable transform template
+ resourceAssignmentJson.property!!.metadata =
+ mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_config}")
+
+ ResourceAssignmentUtils
+ .setResourceDataValue(resourceAssignmentJson, resourceAssignmentRuntimeService, JacksonUtils.objectMapper.createObjectNode())
+
assertEquals(
"abc-vnf_private2",
resourceAssignment.property!!.value!!.asText()
)
+
+ assertEquals(
+ valueJson,
+ resourceAssignmentJson.property!!.value!!.toString()
+ )
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {