aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt1
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt51
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt23
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt32
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json41
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json27
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json8
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json4
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/dg-generic.json8
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt39
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt13
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt26
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt13
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt11
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt17
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt17
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt130
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt13
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java6
20 files changed, 315 insertions, 170 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 167496eb..fd6a8db1 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -55,6 +55,7 @@ object BluePrintConstants {
const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
const val PATH_METADATA: String = "metadata"
const val PATH_NODE_TYPES: String = "node_types"
+ const val PATH_POLICY_TYPES: String = "policy_types"
const val PATH_ARTIFACT_TYPES: String = "artifact_types"
const val PATH_DATA_TYPES: String = "data_types"
const val PATH_INPUTS: String = "inputs"
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
index cb835d73..f6659e7d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
@@ -16,13 +16,13 @@
package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
interface BluePrintEnhancer<T> {
- fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
+ fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T)
}
interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate>
@@ -49,9 +49,6 @@ interface BluePrintEnhancerService {
@Throws(BluePrintException::class)
fun enhance(basePath: String): BluePrintContext
-
- @Throws(BluePrintException::class)
- fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
}
interface BluePrintTypeEnhancerService {
@@ -72,63 +69,63 @@ interface BluePrintTypeEnhancerService {
fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer>
- fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
+ fun enhanceServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) {
val enhancers = getServiceTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, serviceTemplate, enhancers)
}
- fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
+ fun enhanceTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) {
val enhancers = getTopologyTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers)
}
- fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
val enhancers = getWorkflowEnhancers()
- doEnhancement(bluePrintContext, error, name, workflow, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, workflow, enhancers)
}
- fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+ fun enhanceNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
val enhancers = getNodeTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers)
}
- fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
+ fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
val enhancers = getNodeTypeEnhancers()
- doEnhancement(bluePrintContext, error, name, nodeType, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers)
}
- fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) {
+ fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) {
val enhancers = getPolicyTypeEnhancers()
- doEnhancement(bluePrintContext, error, name, policyType, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, policyType, enhancers)
}
- fun enhancePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap<String, PropertyDefinition>) {
+ fun enhancePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition>) {
properties.forEach { propertyName, propertyDefinition ->
- enhancePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition)
+ enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition)
}
}
- fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
+ fun enhancePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
val enhancers = getPropertyDefinitionEnhancers()
- doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, propertyDefinition, enhancers)
}
- fun enhanceAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap<String, AttributeDefinition>) {
+ fun enhanceAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition>) {
attributes.forEach { attributeName, attributeDefinition ->
- enhanceAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition)
+ enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition)
}
}
- fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
+ fun enhanceAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) {
val enhancers = getAttributeDefinitionEnhancers()
- doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, attributeDefinition, enhancers)
}
@Suppress("UNCHECKED_CAST")
- private fun <T> doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
+ private fun <T> doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
if (enhancers.isNotEmpty()) {
enhancers.forEach {
- it.enhance(bluePrintContext, error, name, definition as T)
+ it.enhance(bluePrintRuntimeService, name, definition as T)
}
}
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index 448a06a8..cf518bd1 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
@@ -55,6 +56,10 @@ interface BluePrintRuntimeService<T> {
fun getAsDouble(key: String): Double?
+ fun getBluePrintError(): BluePrintError
+
+ fun setBluePrintError(bluePrintError: BluePrintError)
+
/*
Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
*/
@@ -113,6 +118,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
private var store: MutableMap<String, JsonNode> = hashMapOf()
+ private var bluePrintError = BluePrintError()
+
override fun id(): String {
return id
}
@@ -162,9 +169,17 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return get(key).asDouble()
}
+ override fun getBluePrintError(): BluePrintError {
+ return this.bluePrintError
+ }
+
+ override fun setBluePrintError(bluePrintError: BluePrintError) {
+ this.bluePrintError = bluePrintError
+ }
+
/*
- Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
- */
+ Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
+ */
override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode> {
log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
@@ -439,11 +454,11 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
setInputValue(propertyName, property, valueNode)
}
}
-
+ // Load Dynamic data Types
val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName)
workflowDynamicInputs?.let {
- bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property ->
+ bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property ->
val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName)
?: NullNode.getInstance()
setInputValue(propertyName, property, valueNode)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
index d9222d75..4cb247b5 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -89,25 +89,37 @@ class BluePrintFileUtils {
throw BluePrintException("couldn't get definition file under path(${definitionDir.absolutePath})")
}
- blueprintContext.dataTypes.let {
- val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, blueprintContext.dataTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
+ blueprintContext.serviceTemplate.dataTypes?.let {
+ val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
+ }
+ blueprintContext.serviceTemplate.artifactTypes?.let {
+ val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
}
- blueprintContext.artifactTypes.let {
- val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, blueprintContext.artifactTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
+ blueprintContext.serviceTemplate.nodeTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent)
}
- blueprintContext.nodeTypes.let {
- val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, blueprintContext.nodeTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent)
+ blueprintContext.serviceTemplate.policyTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent)
}
+ }
+ fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking {
+ val definitionFile = File(definitionFile)
+
+ Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE)
+ check(definitionFile.exists()) {
+ throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})")
+ }
}
- private fun writeFile(definitionPath: String, type: String, content: String) = runBlocking {
+ private fun writeTypeFile(definitionPath: String, type: String, content: String) = runBlocking {
val typeFile = File(definitionPath.plus(File.separator).plus("$type.json"))
Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW)
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index f756ef7e..ec229df2 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -12,10 +12,13 @@
"file": "Definitions/data_types.json"
},
{
+ "file": "Definitions/artifact_types.json"
+ },
+ {
"file": "Definitions/node_types.json"
},
{
- "file": "Definitions/artifact_types.json"
+ "file": "Definitions/policy_types.json"
}
],
"topology_template": {
@@ -46,7 +49,10 @@
"SELF",
"dg-resource-assignment-process"
]
- }
+ },
+ "dependency-node-templates": [
+ "resource-assignment"
+ ]
},
"artifacts": {
"dg-resource-assignment-process": {
@@ -63,7 +69,10 @@
"SELF",
"dg-activate-process"
]
- }
+ },
+ "dependency-node-templates": [
+ "activate-jython"
+ ]
},
"artifacts": {
"dg-activate-process": {
@@ -80,7 +89,11 @@
"SELF",
"dg-assign-activate-process"
]
- }
+ },
+ "dependency-node-templates": [
+ "resource-assignment",
+ "activate-jython"
+ ]
},
"artifacts": {
"dg-assign-activate-process": {
@@ -217,7 +230,7 @@
"inputs": {
"resource-assignment-properties": {
"required": true,
- "type": "resource-assignment-properties"
+ "type": "dt-resource-assignment-properties"
}
},
"steps": {
@@ -234,9 +247,21 @@
},
"activate": {
"inputs": {
- "activate-properties": {
+ "request-id": {
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "required": true,
+ "type": "string"
+ },
+ "scope-type": {
+ "required": true,
+ "type": "string"
+ },
+ "hostname": {
"required": true,
- "type": "activate-properties"
+ "type": "string"
}
},
"steps": {
@@ -255,7 +280,7 @@
"inputs": {
"assign-activate-properties": {
"required": true,
- "type": "assign-activate-properties"
+ "type": "dt-assign-activate-properties"
}
},
"steps": {
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
index 3ea494ac..7d850f20 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
@@ -20,7 +20,7 @@
},
"derived_from": "tosca.datatypes.Root"
},
- "activate-properties": {
+ "dt-resource-assignment-properties": {
"description": "This is Dynamically generated data type for workflow activate",
"version": "1.0.0",
"properties": {
@@ -43,30 +43,7 @@
},
"derived_from": "tosca.datatypes.Dynamic"
},
- "resource-assignment-properties": {
- "description": "This is Dynamically generated data type for workflow activate",
- "version": "1.0.0",
- "properties": {
- "request-id": {
- "required": true,
- "type": "string"
- },
- "action-name": {
- "required": true,
- "type": "string"
- },
- "scope-type": {
- "required": true,
- "type": "string"
- },
- "hostname": {
- "required": true,
- "type": "string"
- }
- },
- "derived_from": "tosca.datatypes.Dynamic"
- },
- "assign-activate-properties": {
+ "dt-assign-activate-properties": {
"description": "This is Dynamically generated data type for workflow assign-activate",
"version": "1.0.0",
"properties": {
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
index 8227b82f..8f242efb 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
@@ -7,6 +7,14 @@
"content": {
"required": true,
"type": "string"
+ },
+ "dependency-node-templates": {
+ "required": true,
+ "description": "Dependent Step Components",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
"derived_from": "tosca.nodes.DG"
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json
new file mode 100644
index 00000000..0c9b9925
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json
@@ -0,0 +1,4 @@
+{
+ "policy_types": {
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json
index 6274445c..ec9904bf 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json
@@ -5,6 +5,14 @@
"content": {
"required": true,
"type": "string"
+ },
+ "dependency-node-templates": {
+ "required": true,
+ "description": "Dependent Step Components NodeTemplate name.",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
"derived_from": "tosca.nodes.DG"
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
index 68a00eb0..9f579bc5 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
@@ -16,18 +16,17 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintAttributeDefinitionEnhancer {
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index 17dfb1b7..0b42a26e 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -19,9 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -29,6 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.springframework.stereotype.Service
+import java.util.*
@Service
open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePrintRepoService,
@@ -37,9 +36,16 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePr
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
override fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {
+ // Copy the Blueprint Content to Target Location
BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath)
- BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)
+
+ // Enhance the Blueprint
val enhancedBluePrintContext = enhance(enrichedBasePath)
+
+ // Delete the Old Type files
+ BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)
+
+ // Write the Type File Definitions
BluePrintFileUtils.writeBluePrintTypes(enhancedBluePrintContext)
return enhancedBluePrintContext
}
@@ -47,20 +53,21 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePr
@Throws(BluePrintException::class)
override fun enhance(basePath: String): BluePrintContext {
log.info("Enhancing blueprint($basePath)")
- val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(basePath)
- val error = BluePrintError()
- bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",
- bluePrintContext.serviceTemplate)
- return bluePrintContext
- }
+ val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
+ try {
- @Throws(BluePrintException::class)
- override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {
- val bluePrintContext = BluePrintContext(serviceTemplate)
- val error = BluePrintError()
- bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",
- bluePrintContext.serviceTemplate)
- return bluePrintContext.serviceTemplate
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",
+ blueprintRuntimeService.bluePrintContext().serviceTemplate)
+
+ if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) {
+ throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString())
+ }
+ } catch (e: Exception) {
+ log.error("failed in blueprint enhancement", e)
+ }
+
+ return blueprintRuntimeService.bluePrintContext()
}
+
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
index f87721f1..cfbfab71 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
@@ -28,6 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTem
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -40,20 +41,22 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
log.info("Enhancing NodeTemplate($name)")
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = populateNodeType(nodeTypeName)
// Enrich NodeType
- bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
//Enrich Node Template Artifacts
enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
index f9ed0e6f..941be07f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
@@ -18,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.InterfaceDefinition
@@ -26,9 +25,10 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -40,19 +40,21 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTypeEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
val derivedFrom = nodeType.derivedFrom
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
val derivedFromNodeType = populateNodeType(name)
// Enrich NodeType
- enhance(bluePrintContext, error, derivedFrom, derivedFromNodeType)
+ enhance(bluePrintRuntimeService, derivedFrom, derivedFromNodeType)
}
// NodeType Property Definitions
@@ -71,7 +73,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
nodeType.properties?.let {
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, nodeType.properties!!)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
}
}
@@ -83,7 +85,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
// Get Requirement NodeType from Repo and Update Service Template
val requirementNodeType = populateNodeType(requirementNodeTypeName)
// Enhanypece Node T
- enhance(bluePrintContext, error, requirementNodeTypeName, requirementNodeType)
+ enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
}
}
}
@@ -91,7 +93,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
nodeType.capabilities?.forEach { _, capabilityDefinition ->
capabilityDefinition.properties?.let { properties ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, properties)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, properties)
}
}
}
@@ -115,13 +117,13 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
operation.inputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
operation.outputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
index 13cbc48c..7a9fbb67 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
@@ -19,9 +19,9 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.PolicyType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -32,13 +32,12 @@ class BluePrintPolicyTypeEnhancerImpl(private val bluePrintRepoService: BluePrin
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintPolicyTypeEnhancer {
- lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: PolicyType) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: PolicyType) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
index aea36231..ee3e6c37 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
@@ -26,6 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropert
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -37,12 +37,13 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
: BluePrintPropertyDefinitionEnhancer {
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val propertyType = propertyDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
index 2cd9e328..6a4f6232 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
@@ -16,12 +16,14 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -31,13 +33,16 @@ import org.springframework.stereotype.Service
open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintServiceTemplateEnhancer {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: ServiceTemplate) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: ServiceTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
initialCleanUp()
enhanceTopologyTemplate()
}
@@ -57,7 +62,7 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService
open fun enhanceTopologyTemplate() {
bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
- bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintContext, error, "default", topologyTemplate)
+ bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "default", topologyTemplate)
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
index 58d8f878..6b72d420 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
@@ -16,12 +16,11 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -31,12 +30,10 @@ import org.springframework.stereotype.Service
open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintTopologyTemplateEnhancer {
- lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: TopologyTemplate) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: TopologyTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
enhanceTopologyTemplateInputs(type)
enhanceTopologyTemplateNodeTemplates(type)
@@ -45,19 +42,19 @@ open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoServic
open fun enhanceTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
topologyTemplate.inputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
open fun enhanceTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
- bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, nodeTemplateName, nodeTemplate)
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate)
}
}
open fun enhanceTopologyTemplateWorkflowss(topologyTemplate: TopologyTemplate) {
topologyTemplate.workflows?.forEach { workflowName, workflow ->
- bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintContext, error, workflowName, workflow)
+ bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow)
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
index 80967f29..e3a8f222 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -18,14 +18,17 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -40,61 +43,140 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
: BluePrintWorkflowEnhancer {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+
+ val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
+
private val workflowDataTypes: MutableMap<String, DataType> = hashMapOf()
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
log.info("Enhancing Workflow($name)")
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val dynamicPropertyName = "$name-properties"
+ if (workflow.inputs == null) {
+ workflow.inputs = hashMapOf()
+ }
+ // Clean Dynamic Property Field, If present
+ workflow.inputs?.remove(dynamicPropertyName)
// Enrich Only for Resource Assignment and Dynamic Input Properties if any
- //enhanceStepTargets(workflow)
+ enhanceStepTargets(name, workflow)
// Enrich Workflow Inputs
- //enhanceWorkflowInputs(name, workflow)
+ enhanceWorkflowInputs(name, workflow)
}
open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
- val dynamicPropertyName = "$name-properties"
+
workflow.inputs?.let { inputs ->
- // TODO("Filter Dynamic Properties")
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
- private fun enhanceStepTargets(workflow: Workflow) {
+ private fun enhanceStepTargets(name: String, workflow: Workflow) {
+
+ // Get the first Step Target NodeTemplate name( Since that is the DG Node Template)
+ val dgNodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(name)
+
+ val dgNodeTemplate = bluePrintContext.nodeTemplateByName(dgNodeTemplateName)
- val workflowNodeTemplates = workflowTargets(workflow)
+ // Get the Dependent Component Node Template Names
+ val dependencyNodeTemplateNodes = dgNodeTemplate.properties?.get(PROPERTY_DEPENDENCY_NODE_TEMPLATES)
+ ?: throw BluePrintException("couldn't get property($PROPERTY_DEPENDENCY_NODE_TEMPLATES) ")
- workflowNodeTemplates.forEach { nodeTemplate ->
- val artifactFiles = bluePrintContext.nodeTemplateByName(nodeTemplate).artifacts?.filter {
+ val dependencyNodeTemplates = JacksonUtils.getListFromJsonNode(dependencyNodeTemplateNodes, String::class.java)
+
+ log.info("workflow($name) dependent component NodeTemplates($dependencyNodeTemplates)")
+
+ // Check and Get Resource Assignment File
+ val resourceAssignmentArtifacts = dependencyNodeTemplates?.mapNotNull { componentNodeTemplateName ->
+ log.info("Identified workflow($name) targets($componentNodeTemplateName")
+ val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName)
+ .artifacts?.filter {
it.value.type == "artifact-mapping-resource"
}?.map {
+ log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})")
it.value.file
}
+ resourceAssignmentArtifacts
+ }?.flatten()
+
+ log.info("Workflow($name) resource assignment files($resourceAssignmentArtifacts")
+
+ if (resourceAssignmentArtifacts != null && resourceAssignmentArtifacts.isNotEmpty()) {
+
+ // Add Workflow Dynamic Property
+ addWorkFlowDynamicPropertyDefinitions(name, workflow)
+
+ resourceAssignmentArtifacts.forEach { fileName ->
- artifactFiles?.let { fileName ->
val absoluteFilePath = "${bluePrintContext.rootPath}/$fileName"
- // Enhance Resource Assignment File
- enhanceResourceAssignmentFile(absoluteFilePath)
+ log.info("enriching workflow($name) artifacts file(${absoluteFilePath}")
+ // Enhance Resource Assignment File
+ val resourceAssignmentProperties = enhanceResourceAssignmentFile(absoluteFilePath)
+ // Add Workflow Dynamic DataType
+ addWorkFlowDynamicDataType(name, resourceAssignmentProperties)
}
}
}
- private fun workflowTargets(workflow: Workflow): List<String> {
- return workflow.steps?.map {
- it.value.target
- }?.filterNotNull() ?: arrayListOf()
- }
+ private fun enhanceResourceAssignmentFile(filePath: String): MutableMap<String, PropertyDefinition> {
+
+ val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
- open fun enhanceResourceAssignmentFile(filePath: String) {
val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
as? MutableList<ResourceAssignment>
?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
- resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintContext, error, resourceAssignments)
+
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+
+ resourceAssignments.forEach { resourceAssignment ->
+ resourceAssignmentProperties[resourceAssignment.name] = resourceAssignment.property!!
+ }
+ return resourceAssignmentProperties
+ }
+
+ private fun addWorkFlowDynamicPropertyDefinitions(name: String, workflow: Workflow) {
+ val dynamicPropertyName = "$name-properties"
+ val propertyDefinition = PropertyDefinition()
+ propertyDefinition.description = "Dynamic PropertyDefinition for workflow($name)."
+ propertyDefinition.type = "dt-$dynamicPropertyName"
+ propertyDefinition.required = true
+ // Add to Workflow Inputs
+ workflow.inputs?.put(dynamicPropertyName, propertyDefinition)
+ }
+
+ private fun addWorkFlowDynamicDataType(workflowName: String, mappingProperties: MutableMap<String, PropertyDefinition>) {
+
+ val dataTypeName = "dt-$workflowName-properties"
+
+ var recipeDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+
+ if (recipeDataType == null) {
+ log.info("DataType not present for the recipe({})", dataTypeName)
+ recipeDataType = DataType()
+ recipeDataType.version = "1.0.0"
+ recipeDataType.description = "Dynamic DataType definition for workflow($workflowName)."
+ recipeDataType.derivedFrom = ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC
+
+ val dataTypeProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
+ recipeDataType.properties = dataTypeProperties
+
+ // Overwrite WorkFlow DataType
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, recipeDataType)
+
+ } else {
+ log.info("Dynamic dataType($dataTypeName) already present for workflow($workflowName).")
+ }
+ // Merge all the Recipe Properties
+ mappingProperties.forEach { propertyName, propertyDefinition ->
+ recipeDataType.properties?.put(propertyName, propertyDefinition)
+ }
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
index d6f346ec..d6a00ae1 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
@@ -18,12 +18,11 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
@@ -42,7 +41,7 @@ interface ResourceAssignmentEnhancerService {
@Throws(BluePrintException::class)
fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintContext: BluePrintContext, error: BluePrintError,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
resourceAssignments: List<ResourceAssignment>)
}
@@ -62,7 +61,7 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
* then get the NodeType of the Sources assigned
*/
override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintContext: BluePrintContext, error: BluePrintError,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
resourceAssignments: List<ResourceAssignment>) {
val uniqueSourceNodeTypeNames = hashSetOf<String>()
@@ -81,7 +80,7 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
// TODO("Candidate for Optimisation")
if (checkResourceDefinitionNeeded(resourceAssignment)) {
- bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintContext, error, resourceAssignment.name,
+ bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name,
resourceAssignment.property!!);
// Get the Resource Definition from Repo
@@ -91,13 +90,13 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
// Enrich as NodeTemplate
- bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, dictionarySource, sourceNodeTemplate)
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)
}
}
// Enrich the ResourceSource NodeTypes
uniqueSourceNodeTypeNames.map { nodeTypeName ->
val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)
- bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
}
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
index 01b51762..abc3d56f 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
+import java.nio.file.Paths;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {TestApplication.class})
@@ -55,8 +56,11 @@ public class BluePrintEnhancerServiceImplTest {
String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
- BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath);
+ String targetPath = Paths.get("target", "bp-enhance").toUri().getPath();
+
+ BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath);
Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext);
+
}
} \ No newline at end of file