aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/main
diff options
context:
space:
mode:
authorkuldipr <kuldip.rai@amdocs.com>2020-12-03 13:21:59 -0500
committerKAPIL SINGAL <ks220y@att.com>2020-12-04 14:26:39 +0000
commitd6c8cdf8e0edbe1af0f813a4a135ee5f354639e6 (patch)
tree7c49f1a6111283daad3fbc2746cb87650b688c18 /ms/blueprintsprocessor/functions/resource-resolution/src/main
parent4e62d2653db35c295e2697398dd3c4278ed56009 (diff)
ResourceResolution should fail if required resource did not resolve
Issue-ID: CCSDK-3022 Signed-off-by: kuldipr <kuldip.rai@amdocs.com> Change-Id: I6ca858988f0b11bdf3bbde07e8f4bde939342aa2 Signed-off-by: kuldipr <kuldip.rai@amdocs.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.kt22
1 files changed, 15 insertions, 7 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 07eb15dda..38c5c99fb 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
@@ -73,7 +73,7 @@ interface ResourceResolutionService {
nodeTemplateName: String,
artifactPrefix: String,
properties: Map<String, Any>
- ): Pair<String, JsonNode>
+ ): Pair<String, MutableList<ResourceAssignment>>
/** Resolve resources for all the sources defined in a particular resource Definition[resolveDefinition]
* with other [resourceDefinitions] dependencies for the sources [sources]
@@ -137,12 +137,22 @@ open class ResourceResolutionServiceImpl(
val templateMap: MutableMap<String, String> = hashMapOf()
val assignmentMap: MutableMap<String, JsonNode> = hashMapOf()
artifactNames.forEach { artifactName ->
- val (resolvedStringContent, resolvedJsonContent) = resolveResources(
+ val (resolvedStringContent, resourceAssignmentList) = resolveResources(
resourceAssignmentRuntimeService, nodeTemplateName,
artifactName, properties
)
+ val resolvedJsonContent = resourceAssignmentList
+ .associateBy({ it.name }, { it.property?.value })
+ .asJsonNode()
+
templateMap[artifactName] = resolvedStringContent
assignmentMap[artifactName] = resolvedJsonContent
+
+ val failedResolution = resourceAssignmentList.filter { it.status != "success" && it.property?.required == true }.map { it.name }
+ if (failedResolution.isNotEmpty()) {
+ log.error("Failed to resolve required resources($failedResolution)")
+ bluePrintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
+ }
}
return ResourceResolutionResult(templateMap, assignmentMap)
}
@@ -152,7 +162,7 @@ open class ResourceResolutionServiceImpl(
nodeTemplateName: String,
artifactPrefix: String,
properties: Map<String, Any>
- ): Pair<String, JsonNode> {
+ ): Pair<String, MutableList<ResourceAssignment>> {
// Template Artifact Definition Name
val artifactTemplate = "$artifactPrefix-template"
@@ -196,9 +206,7 @@ open class ResourceResolutionServiceImpl(
ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY,
false
) as Boolean
- val assignmentMap = resourceAssignments
- .associateBy({ it.name }, { it.property?.value })
- .asJsonNode()
+
val resolvedParamJsonContent =
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
val artifactTemplateDefinition =
@@ -229,7 +237,7 @@ open class ResourceResolutionServiceImpl(
log.info("Template resolution saved into database successfully : ($properties)")
}
- return Pair(resolvedContent, assignmentMap)
+ return Pair(resolvedContent, resourceAssignments)
}
override suspend fun resolveResourceDefinition(