diff options
Diffstat (limited to 'components')
3 files changed, 56 insertions, 9 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 0092b702..9dbe15ef 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -64,20 +64,24 @@ object BluePrintMetadataUtils { }
@JvmStatic
- fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
+ fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+ val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
- log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+ val context: MutableMap<String, JsonNode> = hashMapOf()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
- return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+ val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ bluePrintRuntimeService.setExecutionContext(context)
+
+ return bluePrintRuntimeService
}
@JvmStatic
- fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
-
- val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
+ fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath)
val context: MutableMap<String, JsonNode> = hashMapOf()
context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
@@ -97,6 +101,31 @@ object BluePrintMetadataUtils { }
@JvmStatic
+ fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
+
+ val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+
+ log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+
+ return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+ }
+
+ fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext {
+ val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+ // Clean Type files
+ BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath)
+ val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions)
+ val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
+
+ // Clean the Import Definitions
+ rootServiceTemplate.imports?.clear()
+
+ val blueprintContext = BluePrintContext(rootServiceTemplate)
+ blueprintContext.rootPath = blueprintBasePath
+ return blueprintContext
+ }
+
+ @JvmStatic
fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)
val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index aa6a9fb6..a39139ed 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -31,4 +31,6 @@ object ResourceDictionaryConstants { const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies" + + const val PATH_RESOURCE_DEFINITION_TYPE = "resource_definition_types" }
\ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index a3456cd4..1aeda0ba 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -17,16 +17,20 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils +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.ResourceDefinition import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants -import com.att.eelf.configuration.EELFManager +import java.io.File object ResourceDictionaryUtils { @@ -49,7 +53,7 @@ object ResourceDictionaryUtils { resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT } log.info("auto map resourceAssignment : {}", resourceAssignment) - }else { + } else { resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT } } @@ -75,4 +79,16 @@ object ResourceDictionaryUtils { context[path] = valueNode } } + + fun getResourceAssignmentFromFile(filePath: String): List<ResourceAssignment> { + return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") + } + + fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map<String, ResourceDefinition>) { + val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") + val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true) + BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent) + } }
\ No newline at end of file |