summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>2020-02-13 17:06:28 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-13 17:06:28 +0000
commite7e6a525ed0371bf4c3b67ec6221c823b6f9617f (patch)
tree85a024b57b44f0d3fb68f97d36823f93d66d8697 /ms/blueprintsprocessor
parent374f3b91ec119d5eee2ca946b33b4b4fa232e4d4 (diff)
parent86a67360c6cd076c91954892b5c0c49b4cbc1dfa (diff)
Merge "Refactoring Resource Resolution Service"
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt26
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt10
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt2
4 files changed, 40 insertions, 30 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 51e93a3c1..7272a3d63 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
@@ -152,8 +152,7 @@ open class ResourceResolutionServiceImpl(
// Resource Assignment Artifact Definition Name
val artifactMapping = "$artifactPrefix-mapping"
- val resolvedContent: String
- log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
+ log.info("Resolving resource with resource assignment artifact($artifactMapping)")
val resourceAssignmentContent =
bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
@@ -189,14 +188,20 @@ open class ResourceResolutionServiceImpl(
val resolvedParamJsonContent =
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
- resolvedContent = blueprintTemplateService.generateContent(
- bluePrintRuntimeService, nodeTemplateName,
- artifactTemplate, resolvedParamJsonContent, false,
- mutableMapOf(
- ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ val artifactTemplateDefinition = bluePrintRuntimeService.bluePrintContext().checkNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
+
+ val resolvedContent = if (artifactTemplateDefinition != null) {
+ blueprintTemplateService.generateContent(
+ bluePrintRuntimeService, nodeTemplateName,
+ artifactTemplate, resolvedParamJsonContent, false,
+ mutableMapOf(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
)
- )
+ } else {
+ resolvedParamJsonContent
+ }
if (isToStore(properties)) {
templateResolutionDBService.write(properties, resolvedContent, bluePrintRuntimeService, artifactPrefix)
@@ -211,8 +216,7 @@ open class ResourceResolutionServiceImpl(
resourceDefinitions: MutableMap<String, ResourceDefinition>,
resolveDefinition: String,
sources: List<String>
- ):
- MutableMap<String, JsonNode> {
+ ): MutableMap<String, JsonNode> {
// Populate Dummy Resource Assignments
val resourceAssignments = createResourceAssignments(resourceDefinitions, resolveDefinition, sources)
@@ -397,8 +401,10 @@ open class ResourceResolutionServiceImpl(
if (resourceResolution.status == BluePrintConstants.STATUS_SUCCESS) {
resourceAssignmentList.forEach {
if (compareOne(resourceResolution, it)) {
- log.info("Resource ({}) already resolved: value=({})", it.name,
- if (hasLogProtect(it.property)) LOG_REDACTED else resourceResolution.value)
+ log.info(
+ "Resource ({}) already resolved: value=({})", it.name,
+ if (hasLogProtect(it.property)) LOG_REDACTED else resourceResolution.value
+ )
// Make sure to recreate value as per the defined type.
val value = resourceResolution.value!!.asJsonType(it.property!!.type)
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 264b45789..2f338a3a1 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
@@ -202,20 +202,20 @@ class ResourceResolutionServiceTest {
"resource-assignment"
)
- resourceResolutionService.resolveResources(
- resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props
+ assertNotNull(
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ ), "Couldn't Resolve Resources for artifact $artifactPrefix"
)
}
}
@Test
fun testResolveResourcesWithResourceIdAndResourceType() {
-
props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = ""
-
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
@@ -245,11 +245,13 @@ class ResourceResolutionServiceTest {
"resource-assignment"
)
- resourceResolutionService.resolveResources(
- resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props
+ assertNotNull(
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ ), "Couldn't Resolve Resources for artifact $artifactPrefix"
)
}
}
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
index a112b6e6c..7c0970202 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
@@ -231,15 +231,17 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
return nodeTemplateByName(nodeTemplateName).artifacts
}
- fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition {
+ fun checkNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition? {
return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName)
+ }
+
+ fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition {
+ return checkNodeTemplateArtifact(nodeTemplateName, artifactName)
?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")
}
fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition {
- return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(
- 0
- )
+ return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0)
?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)")
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
index ebd9d553d..06100f1fc 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
@@ -144,7 +144,7 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
nodeInput: ExecutionServiceInput,
nodeOutput: ExecutionServiceOutput
): EdgeLabel {
- log.info("Executing workflow($workflowName[${this.workflowId}])'s step($${node.id})")
+ log.info("Executing workflow($workflowName[${this.workflowId}])'s step(${node.id})")
val step = bluePrintRuntimeService.bluePrintContext().workflowStepByName(this.workflowName, node.id)
checkNotEmpty(step.target) { "couldn't get step target for workflow(${this.workflowName})'s step(${node.id})" }
val nodeTemplateName = step.target!!