summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt6
-rwxr-xr-xcomponents/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt103
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json3
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json9
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json5
9 files changed, 80 insertions, 64 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 fd6a8db10..102e2ebd3 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
@@ -45,17 +45,13 @@ object BluePrintConstants {
const val USER_SYSTEM: String = "System"
- const val MODEL_CONTENT_TYPE_JSON: String = "JSON"
- const val MODEL_CONTENT_TYPE_YAML: String = "YAML"
- const val MODEL_CONTENT_TYPE_YANG: String = "YANG"
- const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA"
-
const val PATH_DIVIDER: String = "/"
const val PATH_SERVICE_TEMPLATE: String = "service_template"
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_RELATIONSHIP_TYPES: String = "relationship_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/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index 19f09432d..9767b2e17 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -598,6 +598,8 @@ class ServiceTemplate : Cloneable {
var artifactTypes: MutableMap<String, ArtifactType>? = null
@get:JsonProperty("data_types")
var dataTypes: MutableMap<String, DataType>? = null
+ @get:JsonProperty("relationship_types")
+ var relationshipTypes: MutableMap<String, RelationshipType>? = null
@get:JsonProperty("node_types")
var nodeTypes: MutableMap<String, NodeType>? = null
@get:JsonProperty("policy_types")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
index fce06f3f5..26eb19de1 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
@@ -28,11 +28,13 @@ import java.net.URLDecoder
import java.nio.charset.Charset
class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) {
+ companion object {
+ private const val PARENT_SERVICE_TEMPLATE: String = "parent"
+ }
private val log: Logger = LoggerFactory.getLogger(this::class.toString())
- val PARENT_SERVICE_TEMPLATE: String = "parent"
- var importServiceTemplateMap: MutableMap<String, ServiceTemplate> = hashMapOf()
+ private var importServiceTemplateMap: MutableMap<String, ServiceTemplate> = hashMapOf()
fun getImportResolvedServiceTemplate(): ServiceTemplate {
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 18896f51d..5a10e43f4 100755
--- 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
@@ -33,12 +33,6 @@ import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
-import java.text.MessageFormat
-import java.time.Instant
-import java.time.temporal.ChronoUnit
-import java.time.ZoneId
-import java.time.format.DateTimeFormatter
-
class BluePrintFileUtils {
@@ -56,8 +50,9 @@ class BluePrintFileUtils {
val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR))
Files.createDirectories(metaDataDir.toPath())
- val metafile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE))
- Files.write(metafile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW)
+ val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants
+ .TOSCA_METADATA_ENTRY_DEFINITION_FILE))
+ Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW)
val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR))
Files.createDirectories(definitionsDir.toPath())
@@ -92,35 +87,6 @@ class BluePrintFileUtils {
}
}
- fun populateDefaultImports(blueprintContext: BluePrintContext) {
- // Get the Default Types
- val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_ARTIFACT_TYPES,
- BluePrintConstants.PATH_NODE_TYPES, BluePrintConstants.PATH_POLICY_TYPES)
-
- // Clean Type Imports
- cleanImportTypes(blueprintContext.serviceTemplate)
-
- val imports = mutableListOf<ImportDefinition>()
- types.forEach { typeName ->
- val import = ImportDefinition()
- import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json")
- imports.add(import)
- }
-
- blueprintContext.serviceTemplate.imports = imports
- }
-
- fun cleanImportTypes(serviceTemplate: ServiceTemplate) {
- // Clean the Type imports
- val toDeleteTypes = serviceTemplate.imports?.filter {
- it.file.endsWith("_types.json")
- }
-
- if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) {
- serviceTemplate.imports?.removeAll(toDeleteTypes)
- }
- }
-
fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) {
// Write Blueprint Types
@@ -147,6 +113,11 @@ class BluePrintFileUtils {
writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
}
+ blueprintContext.serviceTemplate.relationshipTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent)
+ }
+
blueprintContext.serviceTemplate.artifactTypes?.let {
val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true)
writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
@@ -163,7 +134,40 @@ class BluePrintFileUtils {
}
}
- fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) {
+ private fun populateDefaultImports(blueprintContext: BluePrintContext) {
+ // Get the Default Types
+ val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES,
+ BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES,
+ BluePrintConstants.PATH_POLICY_TYPES)
+
+ // Clean Type Imports
+ cleanImportTypes(blueprintContext.serviceTemplate)
+
+ val imports = mutableListOf<ImportDefinition>()
+ types.forEach { typeName ->
+ val import = ImportDefinition()
+ import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json")
+ imports.add(import)
+ }
+
+ blueprintContext.serviceTemplate.imports = imports
+ }
+
+ fun cleanImportTypes(serviceTemplate: ServiceTemplate) {
+ // Clean the Type imports
+ val toDeleteTypes = serviceTemplate.imports?.filter {
+ it.file.endsWith("_types.json")
+ }
+
+ if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) {
+ serviceTemplate.imports?.removeAll(toDeleteTypes)
+ }
+ }
+
+ /**
+ * Re Generate the Blueprint Service Template Definition file based on BluePrint Context.
+ */
+ private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) {
val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition)
@@ -174,14 +178,15 @@ class BluePrintFileUtils {
writeServiceTemplate.dataTypes = null
writeServiceTemplate.artifactTypes = null
writeServiceTemplate.policyTypes = null
+ writeServiceTemplate.relationshipTypes = null
writeServiceTemplate.nodeTypes = null
- // Write the Serivice Template
+ // Write the Service Template
writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true))
}
- fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking {
- val definitionFile = File(definitionFile)
+ fun writeDefinitionFile(definitionFileName: String, content: String) = runBlocking {
+ val definitionFile = File(definitionFileName)
// Delete the File If exists
Files.deleteIfExists(definitionFile.toPath())
@@ -207,22 +212,6 @@ class BluePrintFileUtils {
"\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
"\nTemplate-Tags: <TAGS>"
}
-
- fun getBluePrintFile(fileName: String, targetPath: Path) : File {
- val filePath = targetPath.resolve(fileName).toString()
- val file = File(filePath)
- check(file.exists()) {
- throw BluePrintException("couldn't get definition file under path(${file.absolutePath})")
- }
- return file
- }
-
- fun getCBAGeneratedFileName(fileName: String, prefix: String): String {
- val DATE_FORMAT = "yyyyMMddHHmmss"
- val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT)
- val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter)
- return MessageFormat.format(prefix, datePrefix, fileName)
- }
fun getCbaStorageDirectory(path: String): Path {
check(StringUtils.isNotBlank(path)) {
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 6a446355f..a3bf546d6 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,6 +12,9 @@
"file": "Definitions/data_types.json"
},
{
+ "file": "Definitions/relationship_types.json"
+ },
+ {
"file": "Definitions/artifact_types.json"
},
{
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json
new file mode 100644
index 000000000..87d2dc586
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json
@@ -0,0 +1,9 @@
+{
+ "relationship_types": {
+ "tosca.relationships.ConnectsTo": {
+ "description": "Relationship tosca.relationships.ConnectsTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json
new file mode 100644
index 000000000..bcfb65eee
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.AttachesTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json
new file mode 100644
index 000000000..a8337cd15
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.HostedOn",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json
new file mode 100644
index 000000000..1da73cdea
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.RoutesTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file