diff options
author | Brinda Santh <brindasanth@in.ibm.com> | 2018-09-07 09:00:40 -0400 |
---|---|---|
committer | Brinda Santh <brindasanth@in.ibm.com> | 2018-09-07 09:00:40 -0400 |
commit | 7f52a96672beabb6b1f8ccfa1417307ccdbb40e8 (patch) | |
tree | 56b325795ba056a29e8d22d8feefa9034ab4d2fe /components | |
parent | c8c4cd151732fa6e9be45f403244de307456b923 (diff) |
Controller Blueprints Microservice
Add Controller Blueprint Capabily Assignment and their properies validation.
Change-Id: I845fec3d307414b2caeb1d577308a17656ff194a
Issue-ID: CCSDK-484
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'components')
-rw-r--r-- | components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt | 36 |
1 files changed, 33 insertions, 3 deletions
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 2b11589d4..8c00e0a15 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 @@ -136,7 +136,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { //Check Derived From
checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom)
- if(!BluePrintTypes.rootNodeTypes().contains(derivedFrom)){
+ if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
serviceTemplate.nodeTypes?.get(derivedFrom)
?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ",
derivedFrom, nodeTypeName))
@@ -193,7 +193,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }
nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
- nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) }
+ nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) }
nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) }
nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) }
paths.removeAt(paths.lastIndex)
@@ -291,7 +291,28 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { }
@Throws(BluePrintException::class)
- open fun validateCapabilityAssignments(capabilities: MutableMap<String, CapabilityAssignment>) {
+ open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ val capabilities = nodeTemplate.capabilities
+ paths.add("capabilities")
+ capabilities?.forEach { capabilityName, capabilityAssignment ->
+ paths.add(capabilityName)
+
+ val capabilityDefinition = nodeType.capabilities?.get(capabilityName)
+ ?: throw BluePrintException(format("Failed to get NodeTemplate({}) capability definition ({}) " +
+ "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type))
+
+ validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment)
+
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String,
+ capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) {
+
+ capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) }
}
@@ -396,6 +417,15 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
+ outputs?.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition = operationDefinition.outputs?.get(propertyName)
+ ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " +
+ "output property definition({})", nodeTemplateName, operationAssignmentName,
+ propertyName))
+ // Check the property values with property definition
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ }
+
}
}
|