diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-09-07 15:24:07 +0000 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-09-07 15:24:07 +0000 |
commit | 76a5c64401739c8e3eb0d4e03465c89910424ce7 (patch) | |
tree | f987f76c03665b159f21b683f6a575e0024ccb9b /components/core/src | |
parent | b838e7802dbb719a8ee7c45b3c5a637a1120f3c7 (diff) |
Controller Blueprints Microservice
Add Capability Definition validations and add custom capabilities Types for content, mapping, netconf, ssh and sftp
Change-Id: I6a89d20280852034ce6ee56d2a9e97d3aab9c2db
Issue-ID: CCSDK-484
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core/src')
4 files changed, 69 insertions, 2 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 ffad8e56..d4bd20a6 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 @@ -16,6 +16,7 @@ */
package org.onap.ccsdk.apps.controllerblueprints.core
+
/**
* BluePrintConstants
*
@@ -94,10 +95,28 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
- const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION ="tosca.artifacts.Implementation"
+ const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"
+ const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"
+ const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"
+ const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"
+ const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"
+ // Custom capabilities
+ const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"
+ const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
+
const val EXPRESSION_GET_INPUT: String = "get_input"
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 24514db5..e25b3eea 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -50,6 +50,7 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
)
+ @Deprecated("This has to move to Relationship Types Model Drive")
@JvmStatic
val validRelationShipDerivedFroms: MutableList<String> = arrayListOf(
BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
@@ -60,6 +61,28 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
)
+ @Deprecated("This has to move to Capability Types Model Drive")
+ @JvmStatic
+ val validCapabilityTypes: MutableList<String> = arrayListOf(
+ BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP
+ )
+
@JvmStatic
fun validModelTypes(): List<String> {
val validTypes: MutableList<String> = arrayListOf()
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 ef8bbf2d..70f3c556 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 @@ -309,7 +309,7 @@ A capability definition defines a named, typed set of data that can be associate class CapabilityDefinition {
@get:JsonIgnore
var id: String? = null
- var type: String? = null
+ lateinit var type: String
var description: String? = null
var properties: MutableMap<String, PropertyDefinition>? = null
@get:JsonProperty("valid_source_types")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 8c00e0a1..3bea59f9 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -143,6 +143,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { }
nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) }
+ nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) }
nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) }
nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) }
paths.removeAt(paths.lastIndex)
@@ -432,6 +433,30 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { }
@Throws(BluePrintException::class)
+ open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) {
+ val capabilities = nodeType.capabilities
+ paths.add("capabilities")
+ capabilities?.forEach { capabilityName, capabilityDefinition ->
+ paths.add(capabilityName)
+
+ validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition)
+
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String,
+ capabilityDefinition: CapabilityDefinition) {
+ val capabilityType = capabilityDefinition.type
+ check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) {
+ throw BluePrintException(format("Failed to get CapabilityType({}) for NodeType({})",
+ capabilityType, nodeTypeName))
+ }
+ }
+
+ @Throws(BluePrintException::class)
open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) {
paths.add("requirements")
val requirements = nodeType.requirements
|