diff options
Diffstat (limited to 'ms/blueprintsprocessor')
6 files changed, 34 insertions, 27 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 31cb9ca77..51062256d 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 @@ -1,6 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018-2019 IBM. + * Modifications Copyright © 2018-2019 IBM, Bell Canada * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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>, @@ -77,26 +77,27 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica } override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, - artifactNames: List<String>, - properties: Map<String, Any>): MutableMap<String, String> { + artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String> { val resolvedParams: MutableMap<String, String> = hashMapOf() artifactNames.forEach { artifactName -> - val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName, properties) + val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, + artifactName, properties) resolvedParams[artifactName] = resolvedContent } return resolvedParams } 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" // Resource Assignment Artifact Definition Name val artifactMapping = "$artifactPrefix-mapping" - val result = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate) + val result = resolveResources(bluePrintRuntimeService, nodeTemplateName, + artifactMapping, artifactTemplate) if (properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT) && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) { @@ -109,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)") @@ -136,9 +137,12 @@ 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) + + resolvedContent = blueprintTemplateService.generateContent(templateContent, 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 e9bb2ffe4..8dbd47cc2 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 @@ -1,6 +1,7 @@ /* * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. + * + * Modifications Copyright © 2017-2019 AT&T, Bell Canada * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ 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.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition @@ -79,11 +80,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig return resolvedInputKeyMapping } - open fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: Map<String, Any>): String { + open suspend fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: MutableMap<String, Any>): + String { if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) { return valueToResolve } - return BluePrintTemplateService.generateContent(valueToResolve, additionalContext = keyMapping) + return BluePrintVelocityTemplateService.generateContent(valueToResolve, additionalContext = keyMapping) } final override suspend fun applyNB(resourceAssignment: ResourceAssignment): Boolean { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index cd93852bd..9852e3438 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -1,6 +1,6 @@ /* * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2017-2019 AT&T, Bell Canada * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,10 +71,9 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java) val path = nullToEmpty(sourceProperties.path) - val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { - "failed to get input-key-mappings for $dName under $dSource properties" - } - val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping) + val inputKeyMapping = + checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" } + val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap() // Resolving content Variables val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping) 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 f7f4a98d1..3f251b104 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 @@ -1,9 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * - * Modifications Copyright © 2018 IBM. - * - * Modifications Copyright © 2019 IBM, Bell Canada. + * Modifications Copyright © 2018 - 2019 IBM, Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt index 5c9ae9933..dd417e56d 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt @@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts import io.mockk.every import io.mockk.mockk -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction @@ -48,7 +47,7 @@ class BlueprintJythonServiceTest { blueprintContext = mockk<BluePrintContext>() every { blueprintContext.rootPath } returns normalizedPathName("target") } - + @Test fun testGetAbstractPythonPlugin() { val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py") @@ -60,7 +59,7 @@ class BlueprintJythonServiceTest { assertNotNull(abstractPythonPlugin, "failed to get python component") } - + @Test fun testGetAbstractJythonComponent() { val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py" diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 772c73935..c9505cb94 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -2,8 +2,7 @@ <!-- ~ Copyright © 2017-2018 AT&T Intellectual Property. ~ - ~ Modifications Copyright © 2018 IBM. - ~ Modifications Copyright © 2019 Bell Canada. + ~ Modifications Copyright © 2018 - 2019 IBM, Bell Canada ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -50,6 +49,7 @@ <powermock.version>1.7.4</powermock.version> <mockk.version>1.9</mockk.version> <dmaap.client.version>1.1.5</dmaap.client.version> + <jinja.version>2.5.0</jinja.version> </properties> <dependencyManagement> <dependencies> @@ -113,6 +113,11 @@ </exclusions> </dependency> <dependency> + <groupId>com.hubspot.jinjava</groupId> + <artifactId>jinjava</artifactId> + <version>${jinja.version}</version> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> |