summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json14
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt58
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt)37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt)28
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt)20
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json4
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt33
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt12
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt11
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt24
18 files changed, 214 insertions, 104 deletions
diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
index 4d9488cb..e0c44064 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
@@ -2,22 +2,22 @@
"description": "This is Component Resource Source Node Type",
"version": "1.0.0",
"properties": {
- "type": {
+ "script-type": {
"required": true,
"type": "string",
- "default": "KOTLIN-COMPONENT",
+ "default": "kotlin",
"constraints": [
{
"valid_values": [
- "KOTLIN-COMPONENT",
- "JAVA-COMPONENT",
- "JYTHON-COMPONENT"
+ "kotlin",
+ "internal",
+ "jython"
]
}
]
},
- "instance-name": {
- "description": "Capability component instance reference name for JAVA-COMPONENT, Script Class name for KOTLIN-COMPONENT.",
+ "script-class-reference": {
+ "description": "Capability reference name for internal and kotlin, for jython script file path",
"required": true,
"type": "string"
},
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 5765609b..ca92e96d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -20,7 +20,7 @@ class ResourceResolutionConstants {
companion object {
const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 24401ccf..48415efa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -59,8 +60,8 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
@@ -123,6 +124,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
+ /**
+ * 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
+ * request.
+ */
override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
resourceDictionaries: MutableMap<String, ResourceDefinition>,
resourceAssignments: MutableList<ResourceAssignment>,
@@ -133,12 +139,17 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .map { resourceAssignment ->
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
-
- val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
"for resource assignment(${resourceAssignment.name})")
try {
// Set BluePrint Runtime Service
@@ -155,4 +166,37 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
}
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 0f1267cb..1c357446 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -36,6 +36,8 @@ open class DefaultResourceSource : ResourceSourceProperties() {
open class DatabaseResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
lateinit var query: String
@get:JsonProperty("input-key-mapping")
var inputKeyMapping: MutableMap<String, String>? = null
@@ -47,6 +49,8 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
open class RestResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
@get:JsonProperty("url-path")
lateinit var urlPath: String
lateinit var path: String
@@ -61,9 +65,10 @@ open class RestResourceSource : ResourceSourceProperties() {
}
open class CapabilityResourceSource : ResourceSourceProperties() {
- lateinit var type: String
- @get:JsonProperty("instance-name")
- lateinit var instanceName: String
+ @get:JsonProperty("script-type")
+ lateinit var scriptType: String
+ @get:JsonProperty("script-class-reference")
+ lateinit var scriptClassReference: String
@get:JsonProperty("instance-dependencies")
var instanceDependencies: List<String>? = null
@get:JsonProperty("key-dependencies")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 489645fd..c6b7d77e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -18,30 +18,27 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.io.File
-@Service("resource-assignment-processor-capability")
-open class CapabilityResourceAssignmentProcessor(private var applicationContext: ApplicationContext,
+@Service("rr-processor-source-capability")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
private val bluePrintScriptsService: BluePrintScriptsService,
private val bluePrintJythonService: BlueprintJythonService) :
ResourceAssignmentProcessor() {
- companion object {
- const val CAPABILITY_TYPE_KOTLIN_COMPONENT = "KOTLIN-COMPONENT"
- const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
- const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
- }
-
override fun getName(): String {
return "resource-assignment-processor-capability"
}
@@ -62,28 +59,28 @@ open class CapabilityResourceAssignmentProcessor(private var applicationContext:
val capabilityResourceSourceProperty = JacksonUtils
.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java)
- val instanceType = capabilityResourceSourceProperty.type
- val instanceName = capabilityResourceSourceProperty.instanceName
+ val scriptType = capabilityResourceSourceProperty.scriptType
+ val scriptClassReference = capabilityResourceSourceProperty.scriptClassReference
var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
- when (instanceType) {
- CAPABILITY_TYPE_KOTLIN_COMPONENT -> {
- componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(instanceName,
+ when (scriptType) {
+ BluePrintConstants.SCRIPT_KOTLIN -> {
+ componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(scriptClassReference,
capabilityResourceSourceProperty.instanceDependencies)
}
- CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ BluePrintConstants.SCRIPT_INTERNAL -> {
// Initialize Capability Resource Assignment Processor
- componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ componentResourceAssignmentProcessor = applicationContext.getBean(scriptClassReference, ResourceAssignmentProcessor::class.java)
}
- CAPABILITY_TYPE_JYTHON_COMPONENT -> {
- val content = getJythonContent(instanceName)
- componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(instanceName,
+ BluePrintConstants.SCRIPT_JYTHON -> {
+ val content = getJythonContent(scriptClassReference)
+ componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(scriptClassReference,
content, capabilityResourceSourceProperty.instanceDependencies)
}
}
- checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($scriptClassReference)" }
// Assign Current Blueprint runtime and ResourceDictionaries
componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index e389f362..f23ada98 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -22,20 +22,23 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.uti
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * DefaultResourceAssignmentProcessor
+ * DefaultResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-default")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(DefaultResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-default"
+ return "rr-processor-source-default"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index 5757de2a..ed6b09fc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -23,20 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * InputResourceAssignmentProcessor
+ * InputResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-input")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(InputResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-input"
+ return "rr-processor-source-input"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
index 876c75fa..7da22b03 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
@@ -28,22 +28,25 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.util.*
/**
- * PrimaryDataResourceAssignmentProcessor
+ * PrimaryDataResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-db")
-open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
+@Service("rr-processor-source-primary-db")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(PrimaryDataResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(PrimaryDataResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-db"
+ return "rr-processor-source-primary-db"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index b07155a3..9b7c70aa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -57,9 +57,13 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return ResourceAssignment()
}
- override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
+ override fun apply(resourceAssignment: ResourceAssignment): ResourceAssignment {
+ try {
+ prepareRequest(resourceAssignment)
+ process(resourceAssignment)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, resourceAssignment)
+ }
return prepareResponse()
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index a264ba50..4daa46e5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -24,26 +24,30 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * SimpleRestResourceAssignmentProcessor
+ * RestResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-config-data")
-open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
+@Service("rr-processor-source-rest")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(SimpleRestResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(RestResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-config-data"
+ return "rr-processor-source-rest"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -70,8 +74,8 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
- // TODO("Dynamic Rest Client Service, call (blueprintDynamicWebClientService || blueprintWebClientService")
- val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
+ // Get the Rest Client Service
+ val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.getResource(urlPath, String::class.java)
if (response.isNotBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
@@ -87,6 +91,16 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
}
}
+ open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
+ return if (checkNotEmpty(restResourceSource.endpointSelector)) {
+ val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
+ blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
+ } else {
+ blueprintRestLibPropertyService.blueprintWebClientService(resourceAssignment.dictionarySource!!)
+ }
+ }
+
@Throws(BluePrintProcessorException::class)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
val dName = resourceAssignment.dictionaryName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index fbecb55c..c3b10184 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -42,9 +42,9 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index d0d3a13f..6d2d3f2d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -47,9 +47,9 @@ import kotlin.test.assertTrue
*/
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
@@ -66,7 +66,8 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "primary-config-data")), "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-primary-db",
+ "source-rest")), "failed to get registered sources")
}
@Test
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 0dbd0f6e..f779054e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -20,9 +20,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -36,15 +36,15 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
+@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, BluePrintScriptsServiceImpl::class,
BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class])
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
-class CapabilityResourceAssignmentProcessorTest {
+class CapabilityResourceResolutionProcessorTest {
@Autowired
- lateinit var capabilityResourceAssignmentProcessor: CapabilityResourceAssignmentProcessor
+ lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor
@Test
fun `test kotlin capability`() {
@@ -54,15 +54,15 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- capabilityResourceAssignmentProcessor.resourceDictionaries = hashMapOf()
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.resourceDictionaries = hashMapOf()
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
scriptPropertyInstances["mock-service2"] = MockCapabilityService()
- val resourceAssignmentProcessor = capabilityResourceAssignmentProcessor
+ val resourceAssignmentProcessor = capabilityResourceResolutionProcessor
.getKotlinResourceAssignmentProcessorInstance(
"ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", scriptPropertyInstances)
@@ -90,14 +90,14 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
val resourceDefinition = JacksonUtils
.readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json",
ResourceDefinition::class.java)!!
val resourceDefinitions: MutableMap<String, ResourceDefinition> = mutableMapOf()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
- capabilityResourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+ capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -108,7 +108,7 @@ class CapabilityResourceAssignmentProcessorTest {
}
}
- val processorName = capabilityResourceAssignmentProcessor.apply(resourceAssignment)
+ val processorName = capabilityResourceResolutionProcessor.apply(resourceAssignment)
assertNotNull(processorName, "couldn't get Jython script resource assignment processor name")
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
index d3780e0a..fe89291c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
@@ -10,8 +10,8 @@
"capability": {
"type": "source-capability",
"properties": {
- "type": "JYTHON-COMPONENT",
- "instance-name": "SampleRAProcessor",
+ "script-type": "jython",
+ "script-class-reference": "SampleRAProcessor",
"instance-dependencies": []
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
index 47577b39..705caa2e 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -17,15 +17,16 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
- @Throws(BluePrintProcessorException::class)
fun restClientProperties(prefix: String): RestClientProperties {
val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
return when (type) {
@@ -47,19 +48,39 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- @Throws(BluePrintProcessorException::class)
+ fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
+ val type = jsonNode.get("type").textValue()
+ return when (type) {
+ RestLibConstants.TYPE_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, SSLBasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_DME2_PROXY -> {
+ JacksonUtils.readValue(jsonNode, DME2RestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_POLICY_MANAGER -> {
+ JacksonUtils.readValue(jsonNode, PolicyManagerRestClientProperties::class.java)!!
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+
fun blueprintWebClientService(selector: String): BlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
return blueprintWebClientService(restClientProperties)
}
-
- fun blueprintDynamicWebClientService(sourceType: String, selector: String): BlueprintWebClientService {
- TODO()
+ fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
+ val restClientProperties = restClientProperties(jsonNode)
+ return blueprintWebClientService(restClientProperties)
}
- @Throws(BluePrintProcessorException::class)
fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
when (restClientProperties) {
is BasicAuthRestClientProperties -> {
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 2c2e67dc..e3545dff 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -159,7 +159,11 @@ object BluePrintConstants {
const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin"
const val TOSCA_SCRIPTS_JYTHON_DIR: String = "$TOSCA_SCRIPTS_DIR/python"
- const val METADATA_USER_GROUPS = "user-groups"
+ const val PROPERTY_ENV = "ENV"
+ const val PROPERTY_APP = "APP"
+ const val PROPERTY_BPP = "BPP"
+ const val PROPERTY_SELF = "SELF"
+
const val METADATA_TEMPLATE_NAME = "template_name"
const val METADATA_TEMPLATE_VERSION = "template_version"
const val METADATA_TEMPLATE_AUTHOR = "template_author"
@@ -174,11 +178,5 @@ object BluePrintConstants {
const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
const val PROPERTY_EXECUTION_REQUEST = "execution-request"
- const val OPERATION_PROCESS = "process"
- const val OPERATION_PREPARE = "prepare"
-
- const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
- const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
- const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index f8ac5d61..80ad3f2a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -62,7 +62,7 @@ interface BluePrintRuntimeService<T> {
fun setBluePrintError(bluePrintError: BluePrintError)
- fun loadEnvironments(fileName: String)
+ fun loadEnvironments(type: String, fileName: String)
fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String,
propertyDefinitions: MutableMap<String, PropertyDefinition>,
@@ -135,11 +135,11 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
init {
/**
- * Load Default Environments Properties
+ * Load Blueprint Environments Properties
*/
val absoluteEnvFilePath = bluePrintContext.rootPath.plus(File.separator)
.plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
- loadEnvironments(absoluteEnvFilePath)
+ loadEnvironments(BluePrintConstants.PROPERTY_BPP, absoluteEnvFilePath)
}
@@ -204,9 +204,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
this.bluePrintError = bluePrintError
}
- override fun loadEnvironments(fileName: String) {
+ override fun loadEnvironments(type: String, fileName: String) {
BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
- setNodeTemplateAttributeValue("ENV", key.toString(), value.toString().asJsonPrimitive())
+ setNodeTemplateAttributeValue(type, key.toString(), value.toString()
+ .asJsonPrimitive())
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
index ae4f40b8..7905b8fb 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -109,13 +110,27 @@ If Property Assignment is Expression.
val subAttributeName: String? = attributeExpression.subAttributeName
var attributeNodeTemplateName = nodeTemplateName
+ /**
+ * Attributes are dynamic runtime properties information. There are multiple types of Attributes,
+ * ENV : Environment Variables
+ * APP : Application properties ( ie Spring resolved properties )
+ * BPP : Blueprint Properties, Specific to Blue Print execution.
+ * SELF : Current Node Template properties.
+ */
when (attributeExpression.modelableEntityName) {
- "ENV" -> {
+ BluePrintConstants.PROPERTY_ENV -> {
val environmentValue = System.getProperty(attributeName)
- valueNode = JacksonUtils.jsonNode(environmentValue)
+ valueNode = environmentValue.asJsonPrimitive()
+ }
+ BluePrintConstants.PROPERTY_APP -> {
+ TODO("Get property from application properties")
+ }
+ BluePrintConstants.PROPERTY_BPP -> {
+ valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(BluePrintConstants.PROPERTY_BPP, attributeName)
+ ?: throw BluePrintException("failed to get env attribute name ($attributeName) ")
}
else -> {
- if (!attributeExpression.modelableEntityName.equals("SELF", true)) {
+ if (!attributeExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) {
attributeNodeTemplateName = attributeExpression.modelableEntityName
}
@@ -146,7 +161,8 @@ If Property Assignment is Expression.
val subPropertyName: String? = propertyExpression.subPropertyName
var propertyNodeTemplateName = nodeTemplateName
- if (!propertyExpression.modelableEntityName.equals("SELF", true)) {
+
+ if (!propertyExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) {
propertyNodeTemplateName = propertyExpression.modelableEntityName
}