diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-06-27 07:11:24 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-07-04 15:53:42 -0400 |
commit | c48ca03872b11a54cf898c93d4a62ef220f3c55f (patch) | |
tree | 4c9fa45b6ce5b80fc40b1acb596ede7f35d94d64 /ms/blueprintsprocessor/functions/resource-resolution/src/main | |
parent | 2791db21e7d7f7d31ea402fe978dab216a41367f (diff) |
Share RR context within node template
Also, mark resolution as failed for capability when failure.
Change-Id: I3c1704b5b99ace7096f1d9e1cd9bb7f5b595db13
Issue-ID: CCSDK-1422
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main')
4 files changed, 30 insertions, 18 deletions
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 c98c6d6bd..2039d2e5a 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 @@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution import com.fasterxml.jackson.databind.node.JsonNodeFactory import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode @@ -50,12 +51,15 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES) val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java) + val resourceAssignmentRuntimeService = + ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactPrefixNames.toString()) + val jsonResponse = JsonNodeFactory.instance.objectNode() for (j in 1..occurrence.asInt()) { val key = resolutionKey?.asText() + "-" + j properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY] = key - val response = resourceResolutionService.resolveResources(bluePrintRuntimeService, + val response = resourceResolutionService.resolveResources(resourceAssignmentRuntimeService, nodeTemplateName, artifactPrefixNames, properties) 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 ba0adf967..1270298a8 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 @@ -26,6 +26,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.proc import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService @@ -148,8 +149,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica properties: Map<String, Any>) { val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments) - val resourceAssignmentRuntimeService = - ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, artifactPrefix) + val resourceAssignmentRuntimeService = blueprintRuntimeService as ResourceAssignmentRuntimeService coroutineScope { bulkSequenced.forEach { batchResourceAssignments -> @@ -159,9 +159,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica async { val dictionaryName = resourceAssignment.dictionaryName val dictionarySource = resourceAssignment.dictionarySource - /** - * Get the Processor name - */ + val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDefinitions) val resourceAssignmentProcessor = @@ -176,9 +174,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica // Invoke Apply Method resourceAssignmentProcessor.applyNB(resourceAssignment) - if (BluePrintConstants.STATUS_FAILURE != resourceAssignment.status - && properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT) - && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) { + if (isToStore(properties)) { resourceResolutionDBService.write(properties, blueprintRuntimeService, artifactPrefix, @@ -201,6 +197,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica } + private fun isToStore(properties: Map<String, Any>): Boolean { + return properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT) + && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean + } + /** * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt index 81239be30..c6ffde742 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt @@ -62,14 +62,15 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso suspend fun readWithResourceIdAndResourceType(blueprintName: String, blueprintVersion: String, resourceId: String, - resourceType: String): List<ResourceResolution> = withContext(Dispatchers.IO) { - - resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType( - blueprintName, - blueprintVersion, - resourceId, - resourceType) - } + resourceType: String): List<ResourceResolution> = + withContext(Dispatchers.IO) { + + resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType( + blueprintName, + blueprintVersion, + resourceId, + resourceType) + } suspend fun write(properties: Map<String, Any>, bluePrintRuntimeService: BluePrintRuntimeService<*>, @@ -112,7 +113,11 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso resourceResolution.resolutionKey = resolutionKey resourceResolution.resourceType = resourceType resourceResolution.resourceId = resourceId - resourceResolution.value = JacksonUtils.getValue(resourceAssignment.property?.value!!).toString() + if (BluePrintConstants.STATUS_FAILURE == resourceAssignment.status) { + resourceResolution.value = "" + } else { + resourceResolution.value = JacksonUtils.getValue(resourceAssignment.property?.value!!).toString() + } resourceResolution.name = resourceAssignment.name resourceResolution.dictionaryName = resourceAssignment.dictionaryName resourceResolution.dictionaryVersion = resourceAssignment.version diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt index 7a8d6ec5c..49cb83e09 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt @@ -20,6 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -82,6 +83,7 @@ open class CapabilityResourceResolutionProcessor(private val applicationContext: override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { raRuntimeService.getBluePrintError() .addError("Failed in CapabilityResourceResolutionProcessor : ${runtimeException.message}") + ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, runtimeException.message) } suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>) |