diff options
Diffstat (limited to 'ms')
14 files changed, 196 insertions, 72 deletions
diff --git a/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh index 88497156f..d1e09ddc3 100644 --- a/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh +++ b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh @@ -5,4 +5,6 @@ nodeName=BlueprintsProcessor_1.0.0_$(cat /proc/self/cgroup | grep docker | sed s echo "APP Config HOME : ${APP_CONFIG_HOME}" export APP_HOME=/opt/app/onap +keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias ONAP -import -file $APP_CONFIG_HOME/ONAP_RootCA.cer + source /etc/run.source diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kts b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt index 32f04e6a0..32f04e6a0 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kts +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt index 1950b71aa..829fdda8e 100644 --- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt @@ -52,7 +52,8 @@ open class BluePrintSshLibPropertyService(private var bluePrintProperties: BlueP } fun sshClientProperties(jsonNode: JsonNode): SshClientProperties { - val type = jsonNode.get("type").textValue() + val type = jsonNode.get("type")?.textValue() + ?: throw BluePrintProcessorException("missing type field in ssh client properties") return when (type) { SshLibConstants.TYPE_BASIC_AUTH -> { JacksonUtils.readValue(jsonNode, diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index 60016fb98..d48f0c7e4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -26,7 +26,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -37,36 +38,37 @@ import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/api/v1/execution-service") @Api(value = "/api/v1/execution-service", - description = "Interaction with CBA.") + description = "Interaction with CBA.") open class ExecutionServiceController { @Autowired lateinit var executionServiceHandler: ExecutionServiceHandler @RequestMapping(path = ["/health-check"], - method = [RequestMethod.GET], - produces = [MediaType.APPLICATION_JSON_VALUE]) + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @ApiOperation(value = "Health Check", hidden = true) fun executionServiceControllerHealthCheck(): JsonNode = runBlocking { - JacksonUtils.getJsonNode("Success") + "Success".asJsonPrimitive() } @PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) @ResponseBody @PreAuthorize("hasRole('USER')") @ApiOperation(value = "Upload a CBA", - notes = "Upload the CBA package. This will also run validation on the CBA.", - produces = MediaType.APPLICATION_JSON_VALUE) + notes = "Upload the CBA package. This will also run validation on the CBA.", + produces = MediaType.APPLICATION_JSON_VALUE) fun upload(@ApiParam(value = "The ZIP file containing the overall CBA package.", required = true) @RequestPart("file") filePart: FilePart): JsonNode = runBlocking { - JacksonUtils.getJsonNode(executionServiceHandler.upload(filePart)) + val uploadId = executionServiceHandler.upload(filePart) + """{"upload-id" : "$uploadId"}""".asJsonType() } @DeleteMapping("/name/{name}/version/{version}") @ApiOperation(value = "Delete a CBA", - notes = "Delete the CBA package identified by its name and version.", - produces = MediaType.APPLICATION_JSON_VALUE) + notes = "Delete the CBA package identified by its name and version.", + produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("hasRole('USER')") fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true) @PathVariable(value = "name") name: String, @@ -77,18 +79,18 @@ open class ExecutionServiceController { @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE]) @ApiOperation(value = "Execute a CBA workflow (action)", - notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", - produces = MediaType.APPLICATION_JSON_VALUE, - response = ExecutionServiceOutput::class) + notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", + produces = MediaType.APPLICATION_JSON_VALUE, + response = ExecutionServiceOutput::class) @ResponseBody @PreAuthorize("hasRole('USER')") fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true) @RequestBody executionServiceInput: ExecutionServiceInput): ResponseEntity<ExecutionServiceOutput> = - runBlocking { - if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { - throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.") + runBlocking { + if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { + throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.") + } + val processResult = executionServiceHandler.doProcess(executionServiceInput) + ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code)) } - val processResult = executionServiceHandler.doProcess(executionServiceInput) - ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code)) - } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt index b5dac5a39..95b2afc4c 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt @@ -16,13 +16,16 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution +import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation +import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.cds.controllerblueprints.core.dsl.ArtifactDefinitionBuilder +import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType -import org.onap.ccsdk.cds.controllerblueprints.core.getAsString import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope import org.springframework.stereotype.Component @@ -76,7 +79,7 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService fun BluePrintTypes.componentScriptExecutor(): NodeType { return nodeType(id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, description = "Generic Script Component Executor") { attribute(ComponentScriptExecutor.RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false) attribute(ComponentScriptExecutor.STATUS, BluePrintConstants.DATA_TYPE_STRING, true) @@ -105,4 +108,101 @@ fun BluePrintTypes.componentScriptExecutor(): NodeType { } } } +} + +/** Component Builder */ + +fun componentScriptExecutor(id: String, description: String, + block: ComponentScriptExecutorBuilder.() -> Unit): NodeTemplate { + return ComponentScriptExecutorBuilder(id, description).apply(block).build() +} + +class ComponentScriptExecutorBuilder(private val id: String, private val description: String) { + private var implementation: Implementation? = null + private var inputs: MutableMap<String, JsonNode>? = null + private var outputs: MutableMap<String, JsonNode>? = null + private var artifacts: MutableMap<String, ArtifactDefinition>? = null + + fun implementation(timeout: Int, operationHost: String? = BluePrintConstants.PROPERTY_SELF) { + val implementation = Implementation().apply { + this.operationHost = operationHost!! + this.timeout = timeout + } + this.implementation = implementation + } + + fun inputs(block: InputAssignmentBuilder.() -> Unit) { + this.inputs = InputAssignmentBuilder().apply(block).build() + } + + fun outputs(block: OutputAssignmentBuilder.() -> Unit) { + this.outputs = OutputAssignmentBuilder().apply(block).build() + } + + fun artifact(id: String, type: String, file: String) { + if (artifacts == null) + artifacts = hashMapOf() + artifacts!![id] = ArtifactDefinitionBuilder(id, type, file).build() + } + + fun artifact(id: String, type: String, file: String, block: ArtifactDefinitionBuilder.() -> Unit) { + if (artifacts == null) + artifacts = hashMapOf() + artifacts!![id] = ArtifactDefinitionBuilder(id, type, file).apply(block).build() + } + + fun build(): NodeTemplate { + return nodeTemplate(id, "component-script-executor", description) { + operation("ComponentScriptExecutor") { + implementation(implementation) + inputs(inputs) + outputs(outputs) + } + artifacts(artifacts) + } + } + + class InputAssignmentBuilder { + val properties: MutableMap<String, JsonNode> = hashMapOf() + + fun type(type: String) { + properties[ComponentScriptExecutor.SCRIPT_TYPE] = type.asJsonPrimitive() + } + + fun scriptClassReference(scriptClassReference: String) { + properties[ComponentScriptExecutor.SCRIPT_CLASS_REFERENCE] = scriptClassReference.asJsonPrimitive() + } + + fun dynamicProperty(dynamicProperty: Any) { + dynamicProperty(dynamicProperty.asJsonType()) + } + + fun dynamicProperty(dynamicProperty: JsonNode) { + properties[ComponentScriptExecutor.DYNAMIC_PROPERTIES] = dynamicProperty + } + + fun build(): MutableMap<String, JsonNode> { + return properties + } + } + + class OutputAssignmentBuilder { + val properties: MutableMap<String, JsonNode> = hashMapOf() + + fun status(status: String) { + properties[ComponentScriptExecutor.STATUS] = status.asJsonPrimitive() + } + + fun responseData(responseData: Any) { + responseData(responseData.asJsonType()) + } + + fun responseData(responseData: JsonNode) { + properties[ComponentScriptExecutor.RESPONSE_DATA] = responseData + } + + fun build(): MutableMap<String, JsonNode> { + return properties + } + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index b03c7b4d7..1ed0a6570 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.cds</groupId> @@ -28,11 +29,6 @@ <description>Blueprints Processor Parent</description> <properties> <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget> - <spring.boot.version>2.1.3.RELEASE</spring.boot.version> - <spring.version>5.1.5.RELEASE</spring.version> - <kotlin.version>1.3.21</kotlin.version> - <kotlin.maven.version>1.3.21</kotlin.maven.version> - <kotlin.couroutines.version>1.1.1</kotlin.couroutines.version> <grpc.version>1.18.0</grpc.version> <sshd.version>2.2.0</sshd.version> <jsch.version>0.1.55</jsch.version> diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt index 3415be8f3..c9f7d507c 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt @@ -54,14 +54,14 @@ class ServiceTemplateBuilder(private val name: String, imports.add(importDefinition) } - fun dsl(id: String, json: String) { - dsl(id, json.asJsonType()) + fun dsl(id: String, content: Any) { + dsl(id, content.asJsonType()) } fun dsl(id: String, json: JsonNode) { if (dslDefinitions == null) dslDefinitions = hashMapOf() - dslDefinitions!![id] = json.asJsonType() + dslDefinitions!![id] = json } fun dataTypes(dataTypes: MutableMap<String, DataType>) { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt index fd747f09c..93b6f4e4e 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt @@ -32,6 +32,12 @@ class TopologyTemplateBuilder { nodeTemplates!![id] = NodeTemplateBuilder(id, type, description).apply(block).build() } + fun nodeTemplate(nodeTemplate: NodeTemplate) { + if (nodeTemplates == null) + nodeTemplates = hashMapOf() + nodeTemplates!![nodeTemplate.id!!] = nodeTemplate + } + fun nodeTemplateOperation(nodeTemplateName: String, type: String, interfaceName: String, description: String, operationBlock: OperationAssignmentBuilder.() -> Unit) { if (nodeTemplates == null) @@ -48,6 +54,12 @@ class TopologyTemplateBuilder { workflows!![id] = WorkflowBuilder(id, description).apply(block).build() } + fun workflow(workflow: Workflow) { + if (workflows == null) + workflows = hashMapOf() + workflows!![workflow.id!!] = workflow + } + //TODO("populate inputs, outputs") fun workflowNodeTemplate(actionName: String, nodeTemplateType: String, description: String, block: NodeTemplateBuilder.() -> Unit) { @@ -113,18 +125,30 @@ class NodeTemplateBuilder(private val id: String, artifacts!![id] = ArtifactDefinitionBuilder(id, type, file).apply(block).build() } + fun artifacts(artifacts: MutableMap<String, ArtifactDefinition>?) { + this.artifacts = artifacts + } + fun capability(id: String, block: CapabilityAssignmentBuilder.() -> Unit) { if (capabilities == null) capabilities = hashMapOf() capabilities!![id] = CapabilityAssignmentBuilder(id).apply(block).build() } + fun capabilities(capabilities: MutableMap<String, CapabilityAssignment>?) { + this.capabilities = capabilities + } + fun requirement(id: String, capability: String, node: String, relationship: String) { if (requirements == null) requirements = hashMapOf() requirements!![id] = RequirementAssignmentBuilder(id, capability, node, relationship).build() } + fun requirements(requirements: MutableMap<String, RequirementAssignment>?) { + this.requirements = requirements + } + fun build(): NodeTemplate { nodeTemplate.id = id nodeTemplate.type = type diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt index 8afe695ca..6dc5647da 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt @@ -384,6 +384,10 @@ class PropertyDefinitionBuilder(private val id: String, propertyDefinition.defaultValue = defaultValue } + fun value(value: Any) { + value(value.asJsonType()) + } + fun value(value: JsonNode) { propertyDefinition.value = value } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt index 05a147171..d35f2b49b 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt @@ -31,14 +31,13 @@ val blueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfigura open class BlueprintScriptingHost(evaluator: ScriptEvaluator) : BasicScriptingHost(blueprintScriptCompiler, evaluator) { - override fun eval(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration, - configuration: ScriptEvaluationConfiguration?): ResultWithDiagnostics<EvaluationResult> = + override fun eval(script: SourceCode, compilationConfiguration: ScriptCompilationConfiguration, + evaluationConfiguration: ScriptEvaluationConfiguration?): ResultWithDiagnostics<EvaluationResult> = runInCoroutineContext { - - blueprintScriptCompiler(script, scriptCompilationConfiguration) - .onSuccess { - evaluator(it, configuration) + blueprintScriptCompiler(script, compilationConfiguration) + .onSuccess { compiledScript -> + evaluator(compiledScript, evaluationConfiguration ?: ScriptEvaluationConfiguration.Default) }.onFailure { failedResult -> val messages = failedResult.reports.joinToString("\n") throw BluePrintProcessorException(messages) @@ -51,7 +50,7 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip private val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!! override suspend operator fun invoke(compiledScript: CompiledScript<*>, - scriptEvaluationConfiguration: ScriptEvaluationConfiguration? + scriptEvaluationConfiguration: ScriptEvaluationConfiguration ): ResultWithDiagnostics<EvaluationResult> = try { log.debug("Getting script class name($scriptClassName) from the compiled sources ") @@ -59,20 +58,19 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip val bluePrintCompiledScript = compiledScript as BluePrintCompiledScript bluePrintCompiledScript.scriptClassFQName = scriptClassName - val classResult = compiledScript.getClass(scriptEvaluationConfiguration) - when (classResult) { + when (val classResult = compiledScript.getClass(scriptEvaluationConfiguration)) { is ResultWithDiagnostics.Failure -> classResult is ResultWithDiagnostics.Success -> { val scriptClass = classResult.value val args = ArrayList<Any?>() - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { args.add(it.value) } - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { args.addAll(it) } - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.constructorArgs)?.let { args.addAll(it) } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt index de6d4d8e4..ce41cfa1f 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt @@ -20,11 +20,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import kotlinx.coroutines.runBlocking import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.springframework.test.context.junit4.SpringRunner import kotlin.test.BeforeTest import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -58,7 +55,7 @@ class BluePrintTemplateServiceTest { val template = JacksonUtils.getClassPathFileContent("templates/master.jinja") val json = JacksonUtils.getClassPathFileContent("templates/base-config-data-jinja.json") - var element: MutableMap<String, Any> = mutableMapOf() + val element: MutableMap<String, Any> = mutableMapOf() element["additional_array"] = arrayListOf(hashMapOf("name" to "Element1", "location" to "Region0"), hashMapOf("name" to "Element2", "location" to "Region1")) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt index 3cec5af7b..5a9736bc8 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -17,7 +17,6 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition @@ -25,6 +24,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.format import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope import org.springframework.stereotype.Service @@ -50,6 +50,9 @@ open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeVa BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { // Do Nothing } + BluePrintTypes.validComplexTypes().contains(dataType) -> { + // Do Nothing + } BluePrintTypes.validCollectionTypes().contains(dataType) -> { val entrySchemaType: String = attributeDefinition.entrySchema?.type ?: throw BluePrintException("Entry schema for DataType ($dataType) for the property ($name) not found") diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt index b4c29dec3..1f872c2da 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt @@ -19,15 +19,12 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer import kotlinx.coroutines.runBlocking import org.junit.Assert -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.onap.ccsdk.cds.controllerblueprints.core.compress import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.service.load.ModelTypeLoadService import org.onap.ccsdk.cds.controllerblueprints.service.load.ResourceDictionaryLoadService @@ -53,8 +50,11 @@ class BluePrintEnhancerServiceImplTest { @Autowired lateinit var bluePrintValidatorService: BluePrintValidatorService - @Before - fun init() { + + @Test + @Throws(Exception::class) + fun testEnhancementAndValidation() { + runBlocking { modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type") @@ -62,46 +62,48 @@ class BluePrintEnhancerServiceImplTest { dictPaths.add("./../../../../components/model-catalog/resource-dictionary/starter-dictionary") dictPaths.add("./../../../../components/model-catalog/resource-dictionary/test-dictionary") resourceDictionaryLoadService.loadPathsResourceDictionary(dictPaths) + + testBaseConfigEnhancementAndValidation() + testVFWEnhancementAndValidation() + testGoldenEnhancementAndValidation() + testCapabilityRestconfEnhancementAndValidation() + testRemoteScriptsEnhancementAndValidation() + testCapabilityCliEnhancementAndValidation() } } - @Test - @Throws(Exception::class) - fun testEnhancementAndValidation() { + fun testBaseConfigEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" testComponentInvokeEnhancementAndValidation(basePath, "base-enhance") } - @Test - @Throws(Exception::class) fun testVFWEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/service-blueprint/vFW" testComponentInvokeEnhancementAndValidation(basePath, "vFW-enhance") } - @Test - @Throws(Exception::class) fun testGoldenEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/golden" testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance") } - @Test - @Throws(Exception::class) fun testCapabilityRestconfEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_restconf" testComponentInvokeEnhancementAndValidation(basePath, "capability_restconf-enhance") } - @Test - @Throws(Exception::class) fun testRemoteScriptsEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts" testComponentInvokeEnhancementAndValidation(basePath, "remote_scripts-enhance") } + fun testCapabilityCliEnhancementAndValidation() { + val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_cli" + testComponentInvokeEnhancementAndValidation(basePath, "capability_cli-enhance") + } + private fun testComponentInvokeEnhancementAndValidation(basePath: String, targetDirName: String) { runBlocking { val targetPath = normalizedPathName("target/blueprints/enrichment", targetDirName) diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 6ff76e944..4b571191d 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -29,11 +29,6 @@ <packaging>pom</packaging> <properties> <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget> - <spring.boot.version>2.1.3.RELEASE</spring.boot.version> - <spring.version>5.1.5.RELEASE</spring.version> - <kotlin.version>1.3.21</kotlin.version> - <kotlin.maven.version>1.3.21</kotlin.maven.version> - <kotlin.couroutines.version>1.1.1</kotlin.couroutines.version> <grpc.version>1.18.0</grpc.version> <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version> <eelf.version>1.0.0</eelf.version> |