diff options
author | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-02-25 16:03:16 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-03-01 15:54:08 -0500 |
commit | f355d071c1eeafb1533ef0ae46fd4a7962dfbe93 (patch) | |
tree | 5e0eb64911c4444dc10394ca88f9395973cb5284 /ms/controllerblueprints/modules | |
parent | 86dc3b395c89773968d2737d52318a2f2090d8ce (diff) |
Get DSL Property in Resource Resolution
Change-Id: I768c2515bc4b0eaa829213ac4d045628ca960adb
Issue-ID: CCSDK-1106
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules')
3 files changed, 31 insertions, 16 deletions
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<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 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 } |