summaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-09-07 09:00:40 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-09-07 09:00:40 -0400
commitb838e7802dbb719a8ee7c45b3c5a637a1120f3c7 (patch)
treeae0158e781ceeffcb2de68527d7d52e4a8a2a566 /components/core
parent44bff49a6a45f2c4d31020501cb1c0b2eeb1b0fd (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/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt36
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 2b11589d..8c00e0a1 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)
+ }
+
}
}