summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/main
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2019-05-17 10:07:14 -0400
committerSteve Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-05-23 00:15:54 -0400
commitbcc6c4dfe9db06e0dab22472b11a4939255091e5 (patch)
tree62a4bbcf1ec53d9cbc165bcf7dfc9a04211f67de /ms/blueprintsprocessor/functions/resource-resolution/src/main
parent145662ff6a41e0e46a23e8eedf53f30581f8ab64 (diff)
Add cli test blueprints
Change-Id: Ieab385f5e4ae60cca3d86f22c4304e4867e6fa96 Issue-ID: CCSDK-1335 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt6
2 files changed, 12 insertions, 10 deletions
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 51062256d..ebff47899 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
@@ -46,10 +46,10 @@ interface ResourceResolutionService {
artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String
+ artifactPrefix: String, properties: Map<String, Any>): String
suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String
+ artifactMapping: String, artifactTemplate: String?): String
suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
resourceDefinitions: MutableMap<String, ResourceDefinition>,
@@ -89,7 +89,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String {
+ artifactPrefix: String, properties: Map<String, Any>): String {
// Velocity Artifact Definition Name
val artifactTemplate = "$artifactPrefix-template"
@@ -110,7 +110,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String {
+ artifactMapping: String, artifactTemplate: String?): String {
val resolvedContent: String
log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
@@ -137,11 +137,9 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
// Check Template is there
if (artifactTemplate != null) {
- val blueprintTemplateService = BluePrintTemplateService(bluePrintRuntimeService, nodeTemplateName, artifactTemplate)
- val templateContent =
- bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
-
- resolvedContent = blueprintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
+ val blueprintTemplateService = BluePrintTemplateService()
+ resolvedContent = blueprintTemplateService.generateContent(bluePrintRuntimeService, nodeTemplateName,
+ artifactTemplate, resolvedParamJsonContent)
} else {
resolvedContent = resolvedParamJsonContent
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 8dbd47cc2..3482d4534 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
@@ -25,6 +25,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.util
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -67,6 +68,7 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
}
+ //TODO("Convert return Map<String, JsonNode>")
open fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, Any> {
val resolvedInputKeyMapping = HashMap<String, Any>()
if (MapUtils.isNotEmpty(inputKeyMapping)) {
@@ -80,12 +82,14 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return resolvedInputKeyMapping
}
+ //TODO("Convert keyMapping = MutableMap<String, JsonNode>")
open suspend fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: MutableMap<String, Any>):
String {
if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) {
return valueToResolve
}
- return BluePrintVelocityTemplateService.generateContent(valueToResolve, additionalContext = keyMapping)
+ //TODO("Optimize to JSON Node directly")
+ return BluePrintVelocityTemplateService.generateContent(valueToResolve, keyMapping.asJsonNode().toString())
}
final override suspend fun applyNB(resourceAssignment: ResourceAssignment): Boolean {