From f355d071c1eeafb1533ef0ae46fd4a7962dfbe93 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 25 Feb 2019 16:03:16 -0500 Subject: Get DSL Property in Resource Resolution Change-Id: I768c2515bc4b0eaa829213ac4d045628ca960adb Issue-ID: CCSDK-1106 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/BluePrintConstants.kt | 12 +++++------ .../core/service/BluePrintRuntimeService.kt | 11 +++++----- .../core/service/PropertyAssignmentService.kt | 24 ++++++++++++++++++---- 3 files changed, 31 insertions(+), 16 deletions(-) (limited to 'ms/controllerblueprints/modules') 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 2c2e67dce..e3545dff3 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 f8ac5d612..80ad3f2a8 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 { fun setBluePrintError(bluePrintError: BluePrintError) - fun loadEnvironments(fileName: String) + fun loadEnvironments(type: String, fileName: String) fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, propertyDefinitions: MutableMap, @@ -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 ae4f40b81..7905b8fb4 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 } -- cgit 1.2.3-korg