From: Dan Timoney Date: Mon, 12 Aug 2019 13:14:12 +0000 (+0000) Subject: Merge "Resource resolution should return a string" X-Git-Tag: 0.5.2~4 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d9034b6d720df4718b8d455949c17051ecae0558;hp=-c;p=ccsdk%2Fcds.git Merge "Resource resolution should return a string" --- d9034b6d720df4718b8d455949c17051ecae0558 diff --combined ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index d3b69c713,6514df249..641175ca2 --- 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 @@@ -26,7 -26,6 +26,7 @@@ import org.onap.ccsdk.cds.blueprintspro import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceDefinitionUtils.createResourceAssignments import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService @@@ -37,7 -36,6 +37,7 @@@ import org.onap.ccsdk.cds.controllerblu import org.slf4j.LoggerFactory import org.springframework.context.ApplicationContext import org.springframework.stereotype.Service +import java.util.* interface ResourceResolutionService { @@@ -47,19 -45,11 +47,19 @@@ resolutionKey: String): String suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, - artifactNames: List, properties: Map): MutableMap + artifactNames: List, properties: Map): MutableMap suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactPrefix: String, properties: Map): String + /** Resolve resources for all the sources defined in a particular resource Definition[resolveDefinition] + * with other [resourceDefinitions] dependencies for the sources [sources] + * Used to get the same resource values from multiple sources. **/ + suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>, + resourceDefinitions: MutableMap, + resolveDefinition: String, sources: List) + : MutableMap + suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>, resourceDefinitions: MutableMap, resourceAssignments: MutableList, @@@ -93,17 -83,17 +93,17 @@@ open class ResourceResolutionServiceImp override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactNames: List, - properties: Map): MutableMap { + properties: Map): MutableMap { val resourceAssignmentRuntimeService = - ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString()) + ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString()) - val resolvedParams: MutableMap = hashMapOf() + val resolvedParams: MutableMap = hashMapOf() artifactNames.forEach { artifactName -> val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName, - artifactName, properties) + artifactName, properties) - resolvedParams[artifactName] = resolvedContent.asJsonType() + resolvedParams[artifactName] = resolvedContent } return resolvedParams } @@@ -161,21 -151,6 +161,21 @@@ return resolvedContent } + override suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>, + resourceDefinitions: MutableMap, + resolveDefinition: String, sources: List) + : MutableMap { + + // Populate Dummy Resource Assignments + val resourceAssignments = createResourceAssignments(resourceDefinitions, resolveDefinition, sources) + + resolveResourceAssignments(blueprintRuntimeService, resourceDefinitions, resourceAssignments, + UUID.randomUUID().toString(), hashMapOf()) + + // Get the data from Resource Assignments + return ResourceAssignmentUtils.generateResourceForAssignments(resourceAssignments) + } + /** * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the @@@ -190,7 -165,7 +190,7 @@@ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments) // Check the BlueprintRuntime Service Should be ResourceAssignmentRuntimeService - val resourceAssignmentRuntimeService = if (!(blueprintRuntimeService is ResourceAssignmentRuntimeService)) { + val resourceAssignmentRuntimeService = if (blueprintRuntimeService !is ResourceAssignmentRuntimeService) { ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, artifactPrefix) } else { blueprintRuntimeService