aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/core/load/model_type/node_type/component-resource-assignment.json2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt7
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt1
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt29
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt129
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt21
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt44
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt33
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt30
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt38
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt298
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt155
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt84
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt105
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt75
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt40
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt56
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt59
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt8
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt43
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json4
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json68
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json45
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json24
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json (renamed from components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json)108
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json3
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml34
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py14
-rw-r--r--components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json8
-rw-r--r--components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json2
-rw-r--r--components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json8
-rw-r--r--components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json2
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json2
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json40
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json4
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json2
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json5
-rw-r--r--components/parent/pom.xml28
-rw-r--r--components/scripts/python/ccsdk_blueprints/__init__.py0
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py11
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_constants.py23
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py13
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py12
44 files changed, 1585 insertions, 136 deletions
diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json
index 1389bc32..2a903561 100644
--- a/components/core/load/model_type/node_type/component-resource-assignment.json
+++ b/components/core/load/model_type/node_type/component-resource-assignment.json
@@ -7,7 +7,7 @@
}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
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 84d2befc..2908a632 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
@@ -48,6 +48,12 @@ object BluePrintConstants {
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_ARTIFACT_TYPES: String = "artifact_types"
+ const val PATH_DATA_TYPES: String = "data_types"
const val PATH_INPUTS: String = "inputs"
const val PATH_NODE_WORKFLOWS: String = "workflows"
const val PATH_NODE_TEMPLATES: String = "node_templates"
@@ -93,6 +99,7 @@ object BluePrintConstants {
const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
+ const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
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 a971898d..64797ed4 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
@@ -37,6 +37,7 @@ object BluePrintTypes {
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT
)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt
new file mode 100644
index 00000000..3ec0691f
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core
+
+class BluePrintValidationError {
+ var errors: MutableList<String> = arrayListOf()
+
+ fun addError(type: String, name: String, error: String) {
+ this.errors.add("$type : $name : $error")
+ }
+
+ fun addError(error: String) {
+ this.errors.add(error)
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
new file mode 100644
index 00000000..322f6574
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
@@ -0,0 +1,129 @@
+package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+
+interface BluePrintValidator<T> {
+
+ fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: T)
+
+}
+
+
+interface BluePrintServiceTemplateValidator : BluePrintValidator<ServiceTemplate>
+
+interface BluePrintTopologyTemplateValidator : BluePrintValidator<TopologyTemplate>
+
+interface BluePrintArtifactTypeValidator : BluePrintValidator<ArtifactType>
+
+interface BluePrintDataTypeValidator : BluePrintValidator<DataType>
+
+interface BluePrintNodeTypeValidator : BluePrintValidator<NodeType>
+
+interface BluePrintNodeTemplateValidator : BluePrintValidator<NodeTemplate>
+
+interface BluePrintWorkflowValidator : BluePrintValidator<Workflow>
+
+interface BluePrintPropertyDefinitionValidator : BluePrintValidator<PropertyDefinition>
+
+interface BluePrintAttributeDefinitionValidator : BluePrintValidator<AttributeDefinition>
+
+/**
+ * Blueprint Validation Interface.
+ */
+interface BluePrintValidatorService {
+
+ @Throws(BluePrintException::class)
+ fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>) : Boolean
+}
+
+
+interface BluePrintTypeValidatorService {
+
+ fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator>
+
+ fun getDataTypeValidators(): List<BluePrintDataTypeValidator>
+
+ fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator>
+
+ fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator>
+
+ fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator>
+
+ fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator>
+
+ fun getWorkflowValidators(): List<BluePrintWorkflowValidator>
+
+ fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator>
+
+ fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator>
+
+ fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ val validators = getServiceTemplateValidators()
+ doValidation(bluePrintContext, error, name, serviceTemplate, validators)
+ }
+
+ fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ val validators = getArtifactTypeValidators()
+ doValidation(bluePrintContext, error, name, artifactType, validators)
+ }
+
+ fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ val validators = getDataTypeValidators()
+ doValidation(bluePrintContext, error, name, dataType, validators)
+ }
+
+ fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeType: NodeType) {
+ val validators = getNodeTypeValidators()
+ doValidation(bluePrintContext, error, name, nodeType, validators)
+ }
+
+ fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ val validators = getTopologyTemplateValidators()
+ doValidation(bluePrintContext, error, name, topologyTemplate, validators)
+ }
+
+ fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeTemplate: NodeTemplate) {
+ val validators = getNodeTemplateValidators()
+ doValidation(bluePrintContext, error, name, nodeTemplate, validators)
+ }
+
+ fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, workflow: Workflow) {
+ val validators = getWorkflowValidators()
+ doValidation(bluePrintContext, error, name, workflow, validators)
+ }
+
+ fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, properties: MutableMap<String, PropertyDefinition>) {
+ properties.forEach { propertyName, propertyDefinition ->
+ validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition)
+ }
+ }
+
+ fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ val validators = getPropertyDefinitionValidators()
+ doValidation(bluePrintContext, error, name, propertyDefinition, validators)
+ }
+
+ fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, attributes: MutableMap<String, AttributeDefinition>) {
+ attributes.forEach { attributeName, attributeDefinition ->
+ validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition)
+ }
+ }
+
+ fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, attributeDefinition: AttributeDefinition) {
+ val validators = getAttributeDefinitionValidators()
+ doValidation(bluePrintContext, error, name, attributeDefinition, validators)
+ }
+
+ private fun <T> doValidation(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
+ validators.forEach {
+ it.validate(bluePrintContext, error, name, definition as T)
+ }
+ }
+}
+
+
+
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
index 4764479a..cce6d904 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
@@ -32,6 +32,11 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ /**
+ * Blueprint CBA extracted file location
+ */
+ var rootPath = "."
+
val imports: List<ImportDefinition>? = serviceTemplate.imports
val metadata: MutableMap<String, String>? = serviceTemplate.metadata
@@ -57,10 +62,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")
}
- fun workflowStepNodeTemplate(workFlowName: String, stepName: String): NodeTemplate {
- val nodeTemplateName = workflowStepByName(workFlowName, stepName).target
+ fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String {
+ return workflowStepByName(workFlowName, stepName).target
?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)")
- return nodeTemplateByName(nodeTemplateName)
+ }
+
+ fun workflowFirstStepNodeTemplate(workFlowName: String): String {
+ val firstStepName = workflowByName(workFlowName).steps?.keys?.first()
+ ?: throw BluePrintException("could't get first step for workflow($workFlowName)")
+ return workflowStepNodeTemplate(workFlowName, firstStepName)
}
fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String {
@@ -156,6 +166,11 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")
}
+ fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition {
+ return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0)
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)")
+ }
+
fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment {
return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first()
?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index f84b2c56..84ba1047 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -48,6 +48,14 @@ interface BluePrintRuntimeService<T> {
fun cleanRuntime()
+ fun getAsString(key: String): String?
+
+ fun getAsBoolean(key: String): Boolean?
+
+ fun getAsInt(key: String): Int?
+
+ fun getAsDouble(key: String): Double?
+
/*
Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
*/
@@ -59,6 +67,8 @@ interface BluePrintRuntimeService<T> {
fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String
+ fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition
+
fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
@@ -137,9 +147,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return get(key)
}
+ override fun getAsString(key: String): String? {
+ return get(key).asText()
+ }
+
+ override fun getAsBoolean(key: String): Boolean? {
+ return get(key).asBoolean()
+ }
+
+ override fun getAsInt(key: String): Int? {
+ return get(key).asInt()
+ }
+
+ override fun getAsDouble(key: String): Double? {
+ return get(key).asDouble()
+ }
+
/*
- Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
- */
+ Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
+ */
override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode> {
log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
@@ -269,15 +295,19 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return propertyAssignmentValue
}
- override fun resolveNodeTemplateArtifact(nodeTemplateName: String,
- artifactName: String): String {
+ override fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String {
+ val artifactDefinition: ArtifactDefinition = resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+ val propertyAssignmentExpression = PropertyAssignmentService(this)
+ return propertyAssignmentExpression.artifactContent(artifactDefinition)
+ }
+
+ override fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition {
val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
- val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)
+ return nodeTemplate.artifacts?.get(artifactName)
?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"
, artifactName))
- val propertyAssignmentExpression = PropertyAssignmentService(this)
- return propertyAssignmentExpression.artifactContent(artifactDefinition)
+
}
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 320c306c..0092b702 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
@@ -103,6 +103,8 @@ object BluePrintMetadataUtils {
// Recursively Import Template files
val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath)
val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()
- return BluePrintContext(completeServiceTemplate)
+ val blueprintContext = BluePrintContext(completeServiceTemplate)
+ blueprintContext.rootPath = basePath
+ return blueprintContext
}
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
new file mode 100644
index 00000000..9208bdac
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator {
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ artifactType.properties?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!)
+ }
+ // TODO ("Files Present ")
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
new file mode 100644
index 00000000..d0faf1c2
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: AttributeDefinition) {
+ //TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
new file mode 100644
index 00000000..c8d8a74d
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString())
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ log.trace("Validating DataType($name)")
+
+ dataType.properties?.let {
+
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, dataType.properties!!)
+ }
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
new file mode 100644
index 00000000..94d6251c
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -0,0 +1,298 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+
+
+open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
+
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ log.trace("Validating NodeTemplate($nodeTemplateName)")
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ paths.add(nodeTemplateName)
+
+ val type: String = nodeTemplate.type
+
+ val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type)
+ ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)")
+
+ nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
+ nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) }
+ nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) }
+ nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) }
+ nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }
+
+ paths.removeAt(paths.lastIndex)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateArtifactDefinitions(artifacts: MutableMap<String, ArtifactDefinition>) {
+ paths.add("artifacts")
+ artifacts.forEach { artifactDefinitionName, artifactDefinition ->
+ paths.add(artifactDefinitionName)
+ val type: String = artifactDefinition.type
+ ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)")
+ // Check Artifact Type
+ checkValidArtifactType(artifactDefinitionName, type)
+
+ val file: String = artifactDefinition.file
+ ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)")
+
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+
+ @Throws(BluePrintException::class)
+ open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+ properties: MutableMap<String, JsonNode>) {
+ properties.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
+ ?: throw BluePrintException("failed to get definition for the property ($propertyName)")
+
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
+ propertyAssignment: JsonNode) {
+ // Check and Validate if Expression Node
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ 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("Failed to get NodeTemplate($nodeTemplateName) capability definition ($capabilityName) " +
+ "from NodeType(${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!!) }
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ val requirements = nodeTemplate.requirements
+ paths.add("requirements")
+ requirements?.forEach { requirementName, requirementAssignment ->
+ paths.add(requirementName)
+ val requirementDefinition = nodeType.requirements?.get(requirementName)
+ ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) requirement definition ($requirementName) from" +
+ " NodeType(${nodeTemplate.type})")
+ // Validate Requirement Assignment
+ validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment)
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String,
+ requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) {
+ log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName)
+ val requirementNodeTemplateName = requirementAssignment.node!!
+ val capabilityName = requirementAssignment.capability
+ val relationship = requirementAssignment.relationship!!
+
+ check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) {
+ throw BluePrintException("Failed to get relationship type ($relationship) for NodeTemplate($nodeTemplateName)'s requirement($requirementAssignmentName)")
+ }
+
+ val relationShipNodeTemplate = bluePrintContext!!.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName)
+ ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " +
+ "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)")
+
+ relationShipNodeTemplate.capabilities?.get(capabilityName)
+ ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " +
+ "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)")
+
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+
+ val interfaces = nodeTemplate.interfaces
+ paths.add("interfaces")
+ interfaces?.forEach { interfaceAssignmentName, interfaceAssignment ->
+ paths.add(interfaceAssignmentName)
+ val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName)
+ ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) interface definition ($interfaceAssignmentName) from" +
+ " NodeType(${nodeTemplate.type})")
+
+ validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
+ interfaceAssignment)
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String,
+ interfaceDefinition: InterfaceDefinition,
+ interfaceAssignment: InterfaceAssignment) {
+
+ val operations = interfaceAssignment.operations
+ operations?.let {
+ validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
+ interfaceAssignment)
+ }
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String,
+ interfaceDefinition: InterfaceDefinition,
+ interfaceAssignment: InterfaceAssignment) {
+
+ val operations = interfaceAssignment.operations
+ operations?.let {
+ it.forEach { operationAssignmentName, operationAssignments ->
+
+ val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName)
+ ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)")
+
+ log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName,
+ interfaceAssignmentName, operationAssignmentName)
+
+ val inputs = operationAssignments.inputs
+ val outputs = operationAssignments.outputs
+
+ inputs?.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition = operationDefinition.inputs?.get(propertyName)
+ ?: throw BluePrintException("Failed to get NodeTemplate(nodeTemplateName) operation " +
+ "definition (operationAssignmentName) property definition(propertyName)")
+ // Check the property values with property definition
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ }
+
+ outputs?.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition = operationDefinition.outputs?.get(propertyName)
+ ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " +
+ "output property definition($propertyName)")
+ // Check the property values with property definition
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ }
+
+ }
+ }
+
+ }
+
+ open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
+
+ val artifactType = bluePrintContext!!.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
+
+ checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition")
+ }
+ }
+
+ open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
+ val propertyType = propertyDefinition.type
+ val isValid: Boolean
+
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+ isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
+
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+
+ val entrySchemaType = propertyDefinition.entrySchema?.type
+ ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
+
+ if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
+ checkPropertyDataType(entrySchemaType, propertyName)
+ }
+ isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
+ } else {
+ checkPropertyDataType(propertyType, propertyName)
+ isValid = true
+ }
+
+ check(isValid) {
+ throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)")
+ }
+ }
+
+ private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found")
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+
+ }
+
+ private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
+ }
+
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
new file mode 100644
index 00000000..86bf521f
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
@@ -0,0 +1,155 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+
+open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) {
+ log.trace("Validating NodeType($nodeTypeName)")
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ paths.add(nodeTypeName)
+
+ val derivedFrom: String = nodeType.derivedFrom
+ //Check Derived From
+ checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom)
+
+ if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
+ bluePrintContext.serviceTemplate.nodeTypes?.get(derivedFrom)
+ ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)")
+ }
+
+ nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, nodeType.properties!!) }
+ nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) }
+ nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) }
+ nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) }
+
+ paths.removeAt(paths.lastIndex)
+ }
+
+ fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get node type ($nodeTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
+ }
+
+ 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)
+ }
+
+ open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String,
+ capabilityDefinition: CapabilityDefinition) {
+ val capabilityType = capabilityDefinition.type
+ check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) {
+ throw BluePrintException("failed to get CapabilityType($capabilityType) for NodeType($nodeTypeName)")
+ }
+ }
+
+ open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) {
+ paths.add("requirements")
+ val requirements = nodeType.requirements
+
+ requirements?.forEach { requirementDefinitionName, requirementDefinition ->
+ paths.add(requirementDefinitionName)
+ validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition)
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String,
+ requirementDefinition: RequirementDefinition) {
+
+ log.info("validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName)
+ val requirementNodeTypeName = requirementDefinition.node!!
+ val capabilityName = requirementDefinition.capability
+ val relationship = requirementDefinition.relationship!!
+
+ check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) {
+ throw BluePrintException("failed to get relationship($relationship) for NodeType($nodeTypeName)'s requirement($requirementDefinitionName)")
+ }
+
+ val relationShipNodeType = bluePrintContext!!.serviceTemplate.nodeTypes?.get(requirementNodeTypeName)
+ ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s for requirement($requirementDefinitionName) ")
+
+ relationShipNodeType.capabilities?.get(capabilityName)
+ ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s " +
+ "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) ")
+
+ }
+
+ open fun validateInterfaceDefinitions(interfaces: MutableMap<String, InterfaceDefinition>) {
+ paths.add("interfaces")
+ interfaces.forEach { interfaceName, interfaceDefinition ->
+ paths.add(interfaceName)
+ interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) }
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ open fun validateOperationDefinitions(operations: MutableMap<String, OperationDefinition>) {
+ paths.add("operations")
+ operations.forEach { opertaionName, operationDefinition ->
+ paths.add(opertaionName)
+ operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) }
+
+ operationDefinition.inputs?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.inputs!!)
+ }
+
+ operationDefinition.outputs?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.outputs!!)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ open fun validateImplementation(implementation: Implementation) {
+ checkNotEmptyNThrow(implementation.primary)
+ }
+
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
new file mode 100644
index 00000000..f4804d4c
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ log.trace("Validating PropertyDefinition($name)")
+
+ val dataType: String = propertyDefinition.type
+
+ when {
+ BluePrintTypes.validPrimitiveTypes().contains(dataType) -> {
+ // Do Nothing
+ }
+ BluePrintTypes.validCollectionTypes().contains(dataType) -> {
+ val entrySchemaType: String = propertyDefinition.entrySchema?.type
+ ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, name))
+ checkPrimitiveOrComplex(entrySchemaType, name)
+ }
+ else -> checkPropertyDataType(dataType, name)
+ }
+ }
+
+
+ private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) {
+ return true
+ } else {
+ throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName))
+ }
+ }
+
+ private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+ }
+
+ private fun checkDataType(key: String): Boolean {
+ return bluePrintContext!!.serviceTemplate.dataTypes?.containsKey(key) ?: false
+ }
+
+ open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom))
+ }
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
new file mode 100644
index 00000000..66c504de
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import com.google.common.base.Preconditions
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ log.trace("Validating Service Template..")
+ try {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) }
+ serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) }
+ serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) }
+ serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) }
+ serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) }
+ } catch (e: Exception) {
+ error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
+ }
+ }
+
+ fun validateMetadata(metaDataMap: MutableMap<String, String>) {
+
+ paths.add(BluePrintConstants.PATH_METADATA)
+
+ val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME]
+ val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS]
+ val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata")
+ Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata")
+ Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata")
+ Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata")
+
+ paths.removeAt(paths.lastIndex)
+ }
+
+
+ fun validateDataTypes(dataTypes: MutableMap<String, DataType>) {
+
+ paths.add(BluePrintConstants.PATH_DATA_TYPES)
+ dataTypes.forEach { dataTypeName, dataType ->
+ // Validate Single Data Type
+ bluePrintTypeValidatorService.validateDataType(bluePrintContext!!, error!!, dataTypeName, dataType)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ fun validateArtifactTypes(artifactTypes: MutableMap<String, ArtifactType>) {
+ paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES)
+ artifactTypes.forEach { artifactName, artifactType ->
+ // Validate Single Artifact Type
+ bluePrintTypeValidatorService.validateArtifactType(bluePrintContext!!, error!!, artifactName, artifactType)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ fun validateNodeTypes(nodeTypes: MutableMap<String, NodeType>) {
+ paths.add(BluePrintConstants.PATH_NODE_TYPES)
+ nodeTypes.forEach { nodeTypeName, nodeType ->
+ // Validate Single Node Type
+ bluePrintTypeValidatorService.validateNodeType(bluePrintContext!!, error!!, nodeTypeName, nodeType)
+ }
+ paths.removeAt(paths.lastIndex)
+ }
+
+ fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) {
+ paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE)
+ bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintContext!!, error!!, "topologyTemplate", topologyTemplate)
+ paths.removeAt(paths.lastIndex)
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
new file mode 100644
index 00000000..411cdb4d
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ log.trace("Validating Topology Template..")
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ // Validate Inputs
+ topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) }
+ // Validate Node Templates
+ topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) }
+ // Validate Workflow
+ topologyTemplate.workflows?.let { validateWorkflows(topologyTemplate.workflows!!) }
+ }
+
+ @Throws(BluePrintException::class)
+ fun validateInputs(inputs: MutableMap<String, PropertyDefinition>) {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, inputs)
+ }
+
+
+ @Throws(BluePrintException::class)
+ fun validateNodeTemplates(nodeTemplates: MutableMap<String, NodeTemplate>) {
+
+ nodeTemplates.forEach { nodeTemplateName, nodeTemplate ->
+ // Validate Single Node Template
+ bluePrintTypeValidatorService.validateNodeTemplate(bluePrintContext!!, error!!, nodeTemplateName, nodeTemplate)
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ open fun validateWorkflows(workflows: MutableMap<String, Workflow>) {
+
+ workflows.forEach { workflowName, workflow ->
+ // Validate Single workflow
+ bluePrintTypeValidatorService.validateWorkflow(bluePrintContext!!, error!!, workflowName, workflow)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
new file mode 100644
index 00000000..10e8d65b
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+
+open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
+
+ override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>): Boolean {
+ val error = BluePrintValidationError()
+ bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate)
+ if (error.errors.size > 0) {
+ throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}")
+ }
+ return true
+ }
+}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
new file mode 100644
index 00000000..8ba6f720
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+ var bluePrintContext: BluePrintContext? = null
+ var error: BluePrintValidationError? = null
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, workflowName: String, workflow: Workflow) {
+ log.info("Validating Workflow($workflowName)")
+
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ paths.add(workflowName)
+ paths.joinToString(BluePrintConstants.PATH_DIVIDER)
+
+ // Step Validation Start
+ paths.add("steps")
+ workflow.steps?.forEach { stepName, _ ->
+ paths.add(stepName)
+ paths.joinToString(BluePrintConstants.PATH_DIVIDER)
+ // TODO("Step Validation")
+ paths.removeAt(paths.lastIndex)
+ }
+ paths.removeAt(paths.lastIndex)
+ // Step Validation Ends
+ paths.removeAt(paths.lastIndex)
+ }
+} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt
new file mode 100644
index 00000000..4c174f92
--- /dev/null
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.mock
+
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.*
+
+class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
+
+ override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
+ return listOf(BluePrintServiceTemplateValidatorImpl(this))
+ }
+
+ override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
+ return listOf(BluePrintDataTypeValidatorImpl(this))
+ }
+
+ override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
+ return listOf(BluePrintArtifactTypeValidatorImpl(this))
+ }
+
+ override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
+ return listOf(BluePrintNodeTypeValidatorImpl(this))
+ }
+
+ override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
+ return listOf(BluePrintTopologyTemplateValidatorImpl(this))
+ }
+
+ override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
+ return listOf(BluePrintNodeTemplateValidatorImpl(this))
+ }
+
+ override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
+ return listOf(BluePrintWorkflowValidatorImpl(this))
+ }
+
+ override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
+ return listOf(BluePrintPropertyDefinitionValidatorImpl(this))
+ }
+
+ override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
+ return listOf(BluePrintAttributeDefinitionValidatorImpl(this))
+ }
+} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 19c6c2f9..2f519802 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -69,7 +69,7 @@ class BluePrintRuntimeServiceTest {
"data/default-context.json", executionContext)
val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment",
- "DefaultComponentNode", "process")
+ "ResourceAssignmentComponent", "process")
assertNotNull(inContext, "Failed to populate interface input property values")
assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
@@ -86,14 +86,14 @@ class BluePrintRuntimeServiceTest {
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance())
bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment",
- "DefaultComponentNode", "process")
+ "ResourceAssignmentComponent", "process")
val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
- "DefaultComponentNode", "process", "status")
+ "ResourceAssignmentComponent", "process", "status")
assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status")
val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
- "DefaultComponentNode", "process", "resource-assignment-params")
+ "ResourceAssignmentComponent", "process", "resource-assignment-params")
assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params")
}
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
new file mode 100644
index 00000000..ca238db5
--- /dev/null
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.validation
+
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import kotlin.test.assertTrue
+
+class BluePrintValidatorServiceImplTest {
+
+ val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+
+ @Test
+ fun testValidateOfType() {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
+
+ val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+
+ val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+
+ val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintContext, hashMapOf())
+
+ assertTrue(valid, "failed in blueprint Validation")
+
+ }
+}
+
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
index d5416c0e..1137c1d5 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
+++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
@@ -40,7 +40,7 @@
"resource-assignment-ra-component": {
"type": "component-resource-assignment",
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
@@ -3337,7 +3337,7 @@
}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
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 ee02b3a7..9d1172fc 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
@@ -9,7 +9,13 @@
},
"imports": [
{
- "file": "Definitions/types.json"
+ "file": "Definitions/data-types.json"
+ },
+ {
+ "file": "Definitions/node-types.json"
+ },
+ {
+ "file": "Definitions/artifact-types.json"
}
],
"topology_template": {
@@ -54,7 +60,7 @@
"artifacts": {
"dg-activate-process": {
"type": "artifact-directed-graph",
- "file": "Plans/ActivateProcess.bpmn"
+ "file": "Plans/CONFIG_ActivateNetconf_1.0.0.xml"
}
}
},
@@ -64,7 +70,7 @@
"request-id": "1234"
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
@@ -121,7 +127,7 @@
"request-id": "1234"
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"implementation": {
@@ -142,8 +148,32 @@
},
"artifacts": {
"component-script": {
- "type": "artifact-script-python",
- "file": "Scripts/baseconfig-template.vtl"
+ "type": "artifact-script-jython",
+ "file": "Scripts/SamplePythonComponentNode.py"
+ }
+ }
+ },
+ "activate-jython": {
+ "type": "component-jython-executor",
+ "interfaces": {
+ "JythonExecutorComponent": {
+ "operations": {
+ "process": {
+ "implementation": {
+ "primary": "component-script"
+ },
+ "outputs": {
+ "response-data": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "artifacts": {
+ "component-script": {
+ "type": "artifact-script-jython",
+ "file": "Scripts/SamplePythonComponentNode.py"
}
}
}
@@ -174,20 +204,38 @@
"target": "resource-assignment",
"activities": [
{
- "call_operation": "ResourceAssignmentNode.process"
+ "call_operation": "ResourceAssignmentComponent.process"
}
]
}
}
},
"activate": {
+ "inputs": {
+ "request-id": {
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "required": true,
+ "type": "string"
+ },
+ "scope-type": {
+ "required": true,
+ "type": "string"
+ },
+ "hostname": {
+ "required": true,
+ "type": "string"
+ }
+ },
"steps": {
- "call-resource-assignment": {
+ "activate-process": {
"description": "Netconf Activation Workflow",
- "target": "resource-assignment",
+ "target": "activate-process",
"activities": [
{
- "call_operation": "ResourceAssignmentNode.process"
+ "call_operation": "ResourceAssignmentComponent.process"
}
]
}
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json
new file mode 100644
index 00000000..d741d151
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json
@@ -0,0 +1,45 @@
+{
+ "artifact_types": {
+ "artifact-template-velocity": {
+ "description": "Velocity Template used for Configuration",
+ "version": "1.0.0",
+ "file_ext": [
+ "vtl"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-mapping-resource": {
+ "description": "Velocity Template Resource Mapping File used along with Configuration template",
+ "version": "1.0.0",
+ "file_ext": [
+ "json"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-script-jython": {
+ "description": "Jython Script File",
+ "version": "1.0.0",
+ "file_ext": [
+ "py"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-directed-graph": {
+ "description": "Directed Graph File",
+ "version": "1.0.0",
+ "file_ext": [
+ "json",
+ "xml"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-component-jar": {
+ "description": "Component Jar",
+ "version": "1.0.0",
+ "file_ext": [
+ "jar"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json
new file mode 100644
index 00000000..6ca1ffde
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json
@@ -0,0 +1,24 @@
+{
+ "data_types": {
+ "sample-property": {
+ "description": "This is sample data type",
+ "version": "1.0.0",
+ "properties": {
+ "content": {
+ "required": false,
+ "type": "string"
+ },
+ "process-name": {
+ "required": false,
+ "type": "string"
+ },
+ "version": {
+ "required": false,
+ "type": "string",
+ "default": "LATEST"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json
index 056d5f18..139ebb1a 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json
@@ -1,55 +1,4 @@
{
- "artifact_types": {
- "artifact-template-velocity": {
- "description": " Velocity Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "vtl"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-mapping-resource": {
- "description": " Velocity Template Resource Mapping File used along with Configuration template",
- "version": "1.0.0",
- "file_ext": [
- "json"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-script-kotlin": {
- "description": " Kotlin Script Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "kt"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-script-python": {
- "description": " Kotlin Script Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "py"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-directed-graph": {
- "description": "Directed Graph File",
- "version": "1.0.0",
- "file_ext": [
- "json",
- "xml"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-component-jar": {
- "description": "Component Jar",
- "version": "1.0.0",
- "file_ext": [
- "jar"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- }
- },
"node_types": {
"dg-activate": {
"description": "This is BPMN Activate node type",
@@ -81,8 +30,8 @@
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
- "tosca.nodes.component.Python": {
- "description": "This is Resource Assignment Python Component API",
+ "tosca.nodes.component.Jython": {
+ "description": "This is Resource Assignment Jython Component API",
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
@@ -97,7 +46,7 @@
}
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
@@ -147,33 +96,26 @@
},
"derived_from": "tosca.nodes.Component"
},
- "component-resource-assignment-python": {
- "description": "This is Resource Assignment Component API",
+ "component-jython-executor": {
+ "description": "This is Jython Execution Component.",
"version": "1.0.0",
- "properties": {
- "request-id": {
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",
- "required": true,
- "type": "string"
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
}
},
"interfaces": {
- "DefaultComponentNode": {
+ "JythonExecutorComponent": {
"operations": {
"process": {
- "inputs": {
- "action-name": {
- "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- }
- },
"outputs": {
- "resource-assignment-params": {
- "required": true,
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
"type": "string"
},
"status": {
+ "description": "Status of the Component Execution ( success or failure )",
"required": true,
"type": "string"
}
@@ -182,29 +124,7 @@
}
}
},
- "derived_from": "tosca.nodes.component.Python"
- }
- },
- "data_types": {
- "sample-property": {
- "description": "This is sample data type",
- "version": "1.0.0",
- "properties": {
- "content": {
- "required": false,
- "type": "string"
- },
- "process-name": {
- "required": false,
- "type": "string"
- },
- "version": {
- "required": false,
- "type": "string",
- "default": "LATEST"
- }
- },
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.nodes.component.Jython"
}
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json
new file mode 100644
index 00000000..0e0dcd23
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json
@@ -0,0 +1,3 @@
+{
+
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml
new file mode 100644
index 00000000..d256bbd2
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<service-logic
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
+ <method rpc='ActivateNetconf' mode='sync'>
+ <block atomic="true">
+ <execute plugin="resource-assignment" method="process">
+ <outcome value='failure'>
+ <return status="failure">
+ </return>
+ </outcome>
+ <outcome value='success'>
+ <return status='success'>
+ </return>
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py
index fc515133..0a583dc5 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py
@@ -1,8 +1,12 @@
-from com.brvith.orchestrator.core.interfaces import ComponentNode
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
-class SamplePythonComponentNode(ComponentNode):
- def prepare(self, context, componentContext):
+class SamplePythonComponentNode(AbstractPythonComponentFunction):
+
+ def process(self, execution_request):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
return None
- def prepare(self, context, componentContext):
- return None \ No newline at end of file
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json
new file mode 100644
index 00000000..ccc15985
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json
@@ -0,0 +1,8 @@
+{
+ "description": "Resource Dictionary File used along with Configuration template",
+ "version": "1.0.0",
+ "file_ext": [
+ "json"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json
index 0a3261b0..ea3aa232 100644
--- a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json
+++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json
@@ -1,5 +1,5 @@
{
- "description": " Velocity Template Resource Mapping File used along with Configuration template",
+ "description": "Resource Mapping File used along with Configuration template",
"version": "1.0.0",
"file_ext": [
"json"
diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json
new file mode 100644
index 00000000..969662ab
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json
@@ -0,0 +1,8 @@
+{
+ "description": "Jython Script File",
+ "version": "1.0.0",
+ "file_ext": [
+ "py"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json
index b48d2b62..b42f7156 100644
--- a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json
+++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json
@@ -1,5 +1,5 @@
{
- "description": " Kotlin Script Template used for Configuration",
+ "description": "Python Script file",
"version": "1.0.0",
"file_ext": [
"py"
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json
index 764f9e89..ba142600 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json
@@ -7,7 +7,7 @@
}
},
"interfaces": {
- "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": {
+ "ConfigGeneratorComponent": {
"operations": {
"process": {
"inputs": {
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json
new file mode 100644
index 00000000..4959a9dd
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json
@@ -0,0 +1,40 @@
+{
+ "description": "This is Jython Execution Component.",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "JythonExecutorComponent": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "instance-dependencies": {
+ "required": true,
+ "description": "Instance Names to Inject to Jython Script.",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "outputs": {
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.component.Jython"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
index 240caf3f..7e1d8134 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
@@ -14,7 +14,7 @@
}
},
"interfaces": {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {
+ "NetconfExecutorComponent": {
"operations": {
"process": {
"inputs": {
@@ -75,5 +75,5 @@
}
}
},
- "derived_from": "tosca.nodes.Component"
+ "derived_from": "tosca.nodes.component.Jython"
} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
index d424a8e4..a29a875c 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
@@ -7,7 +7,7 @@
}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json
new file mode 100644
index 00000000..8e194f6d
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json
@@ -0,0 +1,5 @@
+{
+ "description": "This is Jython Component",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+} \ No newline at end of file
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
index 71310f1e..39f2d101 100644
--- a/components/parent/pom.xml
+++ b/components/parent/pom.xml
@@ -32,8 +32,9 @@
<spring.boot.version>2.0.6.RELEASE</spring.boot.version>
<spring.version>5.0.10.RELEASE</spring.version>
<kotlin.version>1.3.10</kotlin.version>
- <kotlin.maven.version>1.3.0</kotlin.maven.version>
+ <kotlin.maven.version>1.3.10</kotlin.maven.version>
<kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
+ <grpc.version>1.16.1</grpc.version>
<eelf.version>1.0.0</eelf.version>
<guava.version>26.0-jre</guava.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
@@ -108,8 +109,8 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlinx-couroutines-core</artifactId>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-core</artifactId>
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
@@ -128,6 +129,23 @@
<version>${kotlin.version}</version>
</dependency>
+ <!-- GRPC Dependencies -->
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+
<!-- Database -->
<dependency>
@@ -211,6 +229,10 @@
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-core</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
diff --git a/components/scripts/python/ccsdk_blueprints/__init__.py b/components/scripts/python/ccsdk_blueprints/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/__init__.py
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
new file mode 100644
index 00000000..0ddab16e
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
@@ -0,0 +1,11 @@
+from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction
+
+class AbstractPythonComponentFunction(AbstractComponentFunction):
+
+ def process(self, execution_request):
+ print "Processing calling.."
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.."
+ return None
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py
new file mode 100644
index 00000000..2ec95f31
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py
@@ -0,0 +1,23 @@
+
+PROPERTY_BLUEPRINT_PROCESS_ID= "blueprint-process-id"
+PROPERTY_BLUEPRINT_BASE_PATH= "blueprint-basePath"
+PROPERTY_BLUEPRINT_RUNTIME= "blueprint-runtime"
+PROPERTY_BLUEPRINT_INPUTS_DATA= "blueprint-inputs-data"
+PROPERTY_BLUEPRINT_CONTEXT= "blueprint-context"
+PROPERTY_BLUEPRINT_NAME= "template_name"
+PROPERTY_BLUEPRINT_VERSION= "template_version"
+
+METADATA_USER_GROUPS = "user-groups"
+METADATA_TEMPLATE_NAME = "template_name"
+METADATA_TEMPLATE_VERSION = "template_version"
+METADATA_TEMPLATE_AUTHOR = "template_author"
+METADATA_TEMPLATE_TAGS = "template_tags"
+METADATA_WORKFLOW_NAME = "workflow_name"
+
+PAYLOAD_DATA = "payload-data"
+PROPERTY_CURRENT_STEP = "current-step"
+PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
+PROPERTY_CURRENT_INTERFACE = "current-interface"
+PROPERTY_CURRENT_OPERATION = "current-operation"
+PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
+PROPERTY_EXECUTION_REQUEST = "execution-request"
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py
new file mode 100644
index 00000000..022b4724
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py
@@ -0,0 +1,13 @@
+class BluePrintRuntimeService:
+
+ def __init__(self, bps):
+ self.bps = bps
+
+ def resolveNodeTemplateArtifact(self, node_template_name, artifact_name):
+ return self.bps.resolveNodeTemplateArtifact(node_template_name, artifact_name)
+
+ def setNodeTemplateAttributeValue(self, nodeTemplateName, attributeName, value):
+ return self.bps.setNodeTemplateAttributeValue(nodeTemplateName, attributeName, value)
+
+ def setNodeTemplatePropertyValue(self, nodeTemplateName, propertyName, value):
+ return self.bps.setNodeTemplatePropertyValue(nodeTemplateName, propertyName, value)
diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
new file mode 100644
index 00000000..62665dc8
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
@@ -0,0 +1,12 @@
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
+
+class SampleBlueprintComponent(AbstractPythonComponentFunction):
+
+ def process(self, execution_request):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None