summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt7
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt31
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/pom.xml7
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml7
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt13
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/pom.xml3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt39
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt23
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt25
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt161
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt25
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt1
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt36
24 files changed, 317 insertions, 121 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index a9552510d..e4129932b 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -17,8 +17,7 @@
~ 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.blueprintsprocessor</groupId>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
index bac211ab2..510621b2e 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2019 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,4 +51,8 @@ fun AbstractComponentFunction.netconfDeviceInfo(requirementName: String): Device
private fun AbstractComponentFunction.netconfDeviceInfo(capabilityProperty: MutableMap<String, JsonNode>): DeviceInfo {
return JacksonUtils.getInstanceFromMap(capabilityProperty, DeviceInfo::class.java)
-} \ No newline at end of file
+}
+
+/**
+ * Blocking Methods called from Jython Scripts
+ */ \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
index fa5d882b0..0f35e6338 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
@@ -44,6 +44,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
const val INPUT_ARGUMENT_PROPERTIES = "argument-properties"
const val INPUT_COMMAND = "command"
const val INPUT_PACKAGES = "packages"
+ const val DEFAULT_SELECTOR = "remote-python"
const val ATTRIBUTE_PREPARE_ENV_LOG = "prepare-environment-logs"
const val ATTRIBUTE_EXEC_CMD_LOG = "execute-command-logs"
@@ -58,13 +59,13 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
val blueprintVersion = bluePrintContext.version()
val operationAssignment: OperationAssignment = bluePrintContext
- .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+ .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
val artifactName: String = operationAssignment.implementation?.primary
- ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
val artifactDefinition =
- bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+ bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
checkNotBlank(artifactDefinition.file) { "couldn't get python script path($artifactName)" }
@@ -90,14 +91,20 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
try {
// Open GRPC Connection
- remoteScriptExecutionService.init(endPointSelector.asText())
+ if (DEFAULT_SELECTOR == endPointSelector.asText()) {
+ remoteScriptExecutionService.init(endPointSelector.asText())
+ } else {
+ // Get endpoint from DSL
+ val endPointSelectorJson = bluePrintRuntimeService.resolveDSLExpression(endPointSelector.asText())
+ remoteScriptExecutionService.init(endPointSelectorJson)
+ }
// If packages are defined, then install in remote server
if (packages != null) {
val prepareEnvInput = PrepareRemoteEnvInput(requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
- blueprintVersion = blueprintVersion),
- packages = packages
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
+ blueprintVersion = blueprintVersion),
+ packages = packages
)
val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput)
log.info("$ATTRIBUTE_PREPARE_ENV_LOG - ${prepareEnvOutput.response}")
@@ -111,10 +118,10 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
val remoteExecutionInput = RemoteScriptExecutionInput(
- requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
- command = scriptCommand,
- properties = properties)
+ requestId = processId,
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
+ command = scriptCommand,
+ properties = properties)
val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
log.info("$ATTRIBUTE_EXEC_CMD_LOG - ${remoteExecutionOutput.response}")
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response))
@@ -131,7 +138,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
+ .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
}
private fun formatNestedJsonNode(node: JsonNode): String {
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
index 31aa7c7c1..13202c6ea 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
@@ -185,7 +185,7 @@ class ComponentRemotePythonExecutorTest {
}
class MockRemoteScriptExecutionService : RemoteScriptExecutionService {
- override suspend fun init(selector: String) {
+ override suspend fun init(selector: Any) {
}
override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index b38ebb1b0..df7e0482c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -51,6 +51,9 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
val jsonResponse = JsonNodeFactory.instance.objectNode()
+ // Initialize Output Attribute to empty JSON
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
// validate inputs if we need to store the resource and template resolution.
if (storeResult) {
@@ -84,7 +87,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
}
- // Set Output Attributes
+ // Set Output Attributes with resolved value
bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 0e97267da..938affc82 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
+import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
@@ -25,10 +26,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.R
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -47,7 +45,7 @@ interface ResourceResolutionService {
resolutionKey: String): String
suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+ artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, JsonNode>
suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
artifactPrefix: String, properties: Map<String, Any>): String
@@ -85,17 +83,19 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
artifactNames: List<String>,
- properties: Map<String, Any>): MutableMap<String, String> {
+ properties: Map<String, Any>): MutableMap<String, JsonNode> {
val resourceAssignmentRuntimeService =
ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
- val resolvedParams: MutableMap<String, String> = hashMapOf()
+ val resolvedParams: MutableMap<String, JsonNode> = hashMapOf()
artifactNames.forEach { artifactName ->
val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName,
artifactName, properties)
- resolvedParams[artifactName] = resolvedContent
+
+ resolvedParams[artifactName] = resolvedContent.asJsonType()
+
}
return resolvedParams
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index 560bc4142..b63fa6798 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -71,6 +71,8 @@ class ResourceResolutionComponentTest {
resourceResolutionComponent.stepName = "step"
resourceResolutionComponent.interfaceName = "interfaceName"
resourceResolutionComponent.operationName = "operationName"
+
+ every { bluePrintRuntimeService.setNodeTemplateAttributeValue(any(), any(), any()) } returns Unit
}
@Test
@@ -139,7 +141,6 @@ class ResourceResolutionComponentTest {
any<List<String>>(),
any<MutableMap<String, Any>>())
} returns mutableMapOf()
- every { bluePrintRuntimeService.setNodeTemplateAttributeValue(any(), any(), any()) } returns Unit
runBlocking {
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/message-lib/pom.xml
index d423dfd06..65d1474f3 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/pom.xml
@@ -14,10 +14,7 @@
~ 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">
<parent>
<artifactId>commons</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
@@ -47,4 +44,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml
index 6949c4f43..1ba04033d 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml
@@ -14,10 +14,7 @@
~ 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">
<parent>
<artifactId>commons</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
@@ -43,4 +40,4 @@
<artifactId>sshd-core</artifactId>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
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 056f7e96d..b5dac5a39 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
@@ -86,7 +86,7 @@ fun BluePrintTypes.componentScriptExecutor(): NodeType {
property(ComponentScriptExecutor.SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING, true,
"Script Type") {
defaultValue(BluePrintConstants.SCRIPT_INTERNAL)
- constrains {
+ constrain {
validValues(listOf(BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(),
BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()))
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
index 3af57a22b..d4195ae45 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
@@ -22,6 +22,7 @@ import com.google.protobuf.Timestamp
import com.google.protobuf.util.JsonFormat
import io.grpc.ManagedChannel
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
import org.onap.ccsdk.cds.controllerblueprints.command.api.*
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -31,9 +32,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
-
interface RemoteScriptExecutionService {
- suspend fun init(selector: String)
+ suspend fun init(selector: Any)
suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput
suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput): RemoteScriptExecutionOutput
suspend fun close()
@@ -51,9 +51,14 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
private var channel: ManagedChannel? = null
private lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceBlockingStub
- override suspend fun init(selector: String) {
+ override suspend fun init(selector: Any) {
// Get the GRPC Client Service based on selector
- val grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector)
+ val grpcClientService: BluePrintGrpcClientService
+ if (selector is JsonNode) {
+ grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector)
+ } else {
+ grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector.toString())
+ }
// Get the GRPC Channel
channel = grpcClientService.channel()
// Create Non Blocking Stub
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index dc689ece0..4d05550ef 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -14,8 +14,7 @@
~ 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>
diff --git a/ms/controllerblueprints/modules/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml
index d0710b238..f18821e2c 100644
--- a/ms/controllerblueprints/modules/blueprint-core/pom.xml
+++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml
@@ -15,8 +15,7 @@
~ 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.controllerblueprints</groupId>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
index 4832970f3..a5b18a1f6 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
@@ -64,8 +64,33 @@ fun Double.asJsonPrimitive(): DoubleNode {
return DoubleNode.valueOf(this)
}
+/**
+ * Utility to convert Primitive object to Json Type Primitive.
+ */
+fun <T : Any?> T.asJsonPrimitive(): JsonNode {
+ return if (this == null || this is MissingNode || this is NullNode) {
+ NullNode.instance
+ } else {
+ when (this) {
+ is String ->
+ this.asJsonPrimitive()
+ is Boolean ->
+ this.asJsonPrimitive()
+ is Int ->
+ this.asJsonPrimitive()
+ is Double ->
+ this.asJsonPrimitive()
+ else ->
+ throw BluePrintException("$this type is not supported")
+ }
+ }
+}
+
+/**
+ * Utility to convert Complex or Primitive object to Json Type.
+ */
fun <T : Any?> T.asJsonType(): JsonNode {
- return if (this == null) {
+ return if (this == null || this is MissingNode || this is NullNode) {
NullNode.instance
} else {
when (this) {
@@ -131,15 +156,11 @@ fun JsonNode.returnNullIfMissing(): JsonNode? {
}
fun <T : JsonNode> T?.isNull(): Boolean {
- return if (this == null || this is NullNode || this is MissingNode) {
- true
- } else false
+ return this == null || this is NullNode || this is MissingNode
}
fun <T : JsonNode> T?.isNotNull(): Boolean {
- return if (this == null || this is NullNode || this is MissingNode) {
- false
- } else true
+ return !(this == null || this is NullNode || this is MissingNode)
}
/**
@@ -232,4 +253,8 @@ fun nullToEmpty(value: String?): String {
return if (isNotEmpty(value)) value!! else ""
}
+inline fun <reified T : JsonNode> T.isComplexType(): Boolean {
+ return this is ObjectNode || this is ArrayNode
+}
+
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
index 15b3e22fb..d3013402b 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,8 @@ data class OperationOutputExpression(
val modelableEntityName: String = "SELF",
val interfaceName: String,
val operationName: String,
- val propertyName: String
+ val propertyName: String,
+ var subPropertyName: String? = null
)
data class DSLExpression(
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
index 9e934c7c7..68e5b0aec 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
@@ -63,26 +63,24 @@ class Credential {
A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities.
*/
class ConstraintClause {
- @get:JsonProperty("equal")
var equal: JsonNode? = null
@get:JsonProperty("greater_than")
- var greaterThan: Any? = null
+ var greaterThan: JsonNode? = null
@get:JsonProperty("greater_or_equal")
- var greaterOrEqual: Any? = null
+ var greaterOrEqual: JsonNode? = null
@get:JsonProperty("less_than")
- var lessThan: Any? = null
+ var lessThan: JsonNode? = null
@get:JsonProperty("less_or_equal")
- var lessOrEqual: Any? = null
+ var lessOrEqual: JsonNode? = null
@get:JsonProperty("in_range")
- var inRange: Any? = null
+ var inRange: MutableList<JsonNode>? = null
@get:JsonProperty("valid_values")
var validValues: MutableList<JsonNode>? = null
- @get:JsonProperty("length")
- var length: Any? = null
+ var length: JsonNode? = null
@get:JsonProperty("min_length")
- var minLength: Any? = null
+ var minLength: JsonNode? = null
@get:JsonProperty("max_length")
- var maxLength: Any? = null
+ var maxLength: JsonNode? = null
var pattern: String? = null
var schema: String? = null
}
@@ -164,6 +162,9 @@ class PropertyDefinition {
var constraints: MutableList<ConstraintClause>? = null
@get:JsonProperty("entry_schema")
var entrySchema: EntrySchema? = null
+ @get:JsonProperty("external-schema")
+ var externalSchema: String? = null
+ var metadata: MutableMap<String, String>? = null
// Mainly used in Workflow Outputs
@get:ApiModelProperty(notes = "Property Value, It may be Expression or Json type values")
var value: JsonNode? = null
@@ -398,7 +399,7 @@ A Relationship Type is a reusable entity that defines the type of one or more re
class RelationshipType : EntityType() {
var interfaces: MutableMap<String, InterfaceDefinition>? = null
@get:JsonProperty("valid_target_types")
- var validTargetTypes: ArrayList<String>? = null
+ var validTargetTypes: MutableList<String>? = null
}
/*
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 f19ae8eb8..eec59d1a7 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
@@ -76,11 +76,18 @@ class NodeTemplateBuilder(private val id: String,
private val type: String,
private val description: String? = "") {
private var nodeTemplate: NodeTemplate = NodeTemplate()
+ private var properties: MutableMap<String, JsonNode>? = null
private var interfaces: MutableMap<String, InterfaceAssignment>? = null
private var artifacts: MutableMap<String, ArtifactDefinition>? = null
private var capabilities: MutableMap<String, CapabilityAssignment>? = null
private var requirements: MutableMap<String, RequirementAssignment>? = null
+ fun properties(block: PropertiesAssignmentBuilder.() -> Unit) {
+ if (properties == null)
+ properties = hashMapOf()
+ properties = PropertiesAssignmentBuilder().apply(block).build()
+ }
+
fun operation(interfaceName: String, description: String? = "",
block: OperationAssignmentBuilder.() -> Unit) {
if (interfaces == null)
@@ -122,6 +129,7 @@ class NodeTemplateBuilder(private val id: String,
nodeTemplate.id = id
nodeTemplate.type = type
nodeTemplate.description = description
+ nodeTemplate.properties = properties
nodeTemplate.interfaces = interfaces
nodeTemplate.artifacts = artifacts
nodeTemplate.capabilities = capabilities
@@ -133,12 +141,27 @@ class NodeTemplateBuilder(private val id: String,
class ArtifactDefinitionBuilder(private val id: String, private val type: String, private val file: String) {
private var artifactDefinition: ArtifactDefinition = ArtifactDefinition()
- // TODO()
+ private var properties: MutableMap<String, JsonNode>? = null
+
+ fun repository(repository: String) {
+ artifactDefinition.repository = repository
+ }
+
+ fun deployPath(deployPath: String) {
+ artifactDefinition.deployPath = deployPath
+ }
+
+ fun properties(block: PropertiesAssignmentBuilder.() -> Unit) {
+ if (properties == null)
+ properties = hashMapOf()
+ properties = PropertiesAssignmentBuilder().apply(block).build()
+ }
fun build(): ArtifactDefinition {
artifactDefinition.id = id
artifactDefinition.type = type
artifactDefinition.file = file
+ artifactDefinition.properties = properties
return artifactDefinition
}
}
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 0f011948d..8afe695ca 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
@@ -17,8 +17,8 @@
package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.data.*
@@ -162,7 +162,16 @@ class ArtifactTypeBuilder(id: String, version: String, derivedFrom: String,
class PolicyTypeBuilder(id: String, version: String, derivedFrom: String,
description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
private var policyType = PolicyType()
- // TODO()
+
+ fun targets(targetsStr: String) {
+ val arrayNode = targetsStr.jsonAsJsonType() as ArrayNode
+ targets(arrayNode.asListOfString())
+ }
+
+ fun targets(target: List<String>) {
+ policyType.targets = target.toMutableList()
+ }
+
fun build(): PolicyType {
buildEntityType(policyType)
return policyType
@@ -174,7 +183,16 @@ class RelationshipTypeBuilder(private val id: String, private val version: Strin
: EntityTypeBuilder(id, version, derivedFrom, description) {
private var relationshipType = RelationshipType()
- // TODO()
+
+ fun validTargetTypes(validTargetTypesStr: String) {
+ val arrayNode = validTargetTypesStr.jsonAsJsonType() as ArrayNode
+ validTargetTypes(arrayNode.asListOfString())
+ }
+
+ fun validTargetTypes(validTargetTypes: List<String>) {
+ relationshipType.validTargetTypes = validTargetTypes.toMutableList()
+ }
+
fun build(): RelationshipType {
buildEntityType(relationshipType)
relationshipType.id = id
@@ -187,7 +205,15 @@ class RelationshipTypeBuilder(private val id: String, private val version: Strin
class DataTypeBuilder(id: String, version: String, derivedFrom: String,
description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
private var dataType = DataType()
- // TODO()
+
+ fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+ if (dataType.constraints == null) {
+ dataType.constraints = mutableListOf()
+ }
+ val constraintClause = ConstraintClauseBuilder().apply(block).build()
+ dataType.constraints!!.add(constraintClause)
+ }
+
fun build(): DataType {
buildEntityType(dataType)
return dataType
@@ -264,29 +290,6 @@ class OperationDefinitionBuilder(private val id: String,
}
}
-class AttributesDefinitionBuilder {
- private val attributes: MutableMap<String, AttributeDefinition> = hashMapOf()
-
- fun attribute(id: String, attribute: AttributeDefinition) {
- attributes[id] = attribute
- }
-
- fun attribute(id: String, type: String?, required: Boolean?, description: String?) {
- val attribute = AttributeDefinitionBuilder(id, type, required, description).build()
- attributes[id] = attribute
- }
-
- fun attribute(id: String, type: String?, required: Boolean?, description: String?,
- block: AttributeDefinitionBuilder.() -> Unit) {
- val attribute = AttributeDefinitionBuilder(id, type, required, description).apply(block).build()
- attributes[id] = attribute
- }
-
- fun build(): MutableMap<String, AttributeDefinition> {
- return attributes
- }
-}
-
class AttributeDefinitionBuilder(private val id: String,
private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
private val required: Boolean? = false,
@@ -302,7 +305,17 @@ class AttributeDefinitionBuilder(private val id: String,
attributeDefinition.entrySchema = EntrySchemaBuilder(entrySchemaType).apply(block).build()
}
- // TODO("Constrains")
+ fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+ if (attributeDefinition.constraints == null) {
+ attributeDefinition.constraints = mutableListOf()
+ }
+ val constraintClause = ConstraintClauseBuilder().apply(block).build()
+ attributeDefinition.constraints!!.add(constraintClause)
+ }
+
+ fun defaultValue(defaultValue: Any) {
+ defaultValue(defaultValue.asJsonType())
+ }
fun defaultValue(defaultValue: JsonNode) {
attributeDefinition.defaultValue = defaultValue
@@ -355,8 +368,12 @@ class PropertyDefinitionBuilder(private val id: String,
propertyDefinition.entrySchema = EntrySchemaBuilder(entrySchemaType).apply(block).build()
}
- fun constrains(block: ConstraintClauseBuilder.() -> Unit) {
- propertyDefinition.constraints = ConstraintClauseBuilder().apply(block).build()
+ fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+ if (propertyDefinition.constraints == null) {
+ propertyDefinition.constraints = mutableListOf()
+ }
+ val constraintClause = ConstraintClauseBuilder().apply(block).build()
+ propertyDefinition.constraints!!.add(constraintClause)
}
fun defaultValue(defaultValue: Any) {
@@ -380,13 +397,11 @@ class PropertyDefinitionBuilder(private val id: String,
}
}
-class ConstraintClauseBuilder {
- private val constraints: MutableList<ConstraintClause> = mutableListOf()
- //TODO("Implementation")
+class ConstraintsClauseBuilder {
+ val constraints: MutableList<ConstraintClause> = mutableListOf()
- fun validValues(values: List<JsonNode>) {
- val constraintClause = ConstraintClause()
- constraintClause.validValues = values.toMutableList()
+ fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+ val constraintClause = ConstraintClauseBuilder().apply(block).build()
constraints.add(constraintClause)
}
@@ -395,10 +410,82 @@ class ConstraintClauseBuilder {
}
}
+class ConstraintClauseBuilder {
+ private val constraintClause = ConstraintClause()
+
+ fun equal(equal: Any) = equal(equal.asJsonType())
+
+ fun equal(equal: JsonNode) {
+ constraintClause.equal = equal
+ }
+
+ fun greaterOrEqual(greaterOrEqual: Any) {
+ constraintClause.greaterOrEqual = greaterOrEqual.asJsonPrimitive()
+ }
+
+ fun greaterThan(greaterThan: Any) {
+ constraintClause.greaterThan = greaterThan.asJsonPrimitive()
+ }
+
+ fun lessOrEqual(lessOrEqual: Any) {
+ constraintClause.lessOrEqual = lessOrEqual.asJsonPrimitive()
+ }
+
+ fun lessThan(lessThan: Any) {
+ constraintClause.lessThan = lessThan.asJsonPrimitive()
+ }
+
+ fun inRange(inRangeStr: String) = inRange(inRangeStr.jsonAsJsonType() as ArrayNode)
+
+ fun inRange(inRangeNode: ArrayNode) {
+ constraintClause.inRange = inRangeNode.toMutableList()
+ }
+
+ fun validValues(validValuesStr: String) = validValues(validValuesStr.jsonAsJsonType() as ArrayNode)
+
+ fun validValues(validValuesNode: ArrayNode) = validValues(validValuesNode.toMutableList())
+
+ fun validValues(validValues: List<JsonNode>) {
+ constraintClause.validValues = validValues.toMutableList()
+ }
+
+ fun length(length: Any) {
+ constraintClause.length = length.asJsonPrimitive()
+ }
+
+ fun minLength(minLength: Any) {
+ constraintClause.minLength = minLength.asJsonPrimitive()
+ }
+
+ fun maxLength(maxLength: Any) {
+ constraintClause.maxLength = maxLength.asJsonPrimitive()
+ }
+
+ fun pattern(pattern: String) {
+ constraintClause.pattern = pattern
+ }
+
+ fun schema(schema: String) {
+ constraintClause.schema = schema
+ }
+
+ fun build(): ConstraintClause {
+ return constraintClause
+ }
+}
+
class EntrySchemaBuilder(private val type: String) {
private var entrySchema: EntrySchema = EntrySchema()
+ fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+ if (entrySchema.constraints == null) {
+ entrySchema.constraints = mutableListOf()
+ }
+ val constraintClause = ConstraintClauseBuilder().apply(block).build()
+ entrySchema.constraints!!.add(constraintClause)
+ }
+
fun build(): EntrySchema {
entrySchema.type = type
return entrySchema
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
index 32cb6ac77..fbf911664 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -170,10 +170,16 @@ object BluePrintExpressionService {
throw BluePrintException(String.format("missing operation output expression, " +
"it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))
}
+
+ var subPropertyName: String? = null
+ if (arrayNode.size() == 5)
+ subPropertyName = arrayNode[4].asText()
+
return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),
interfaceName = arrayNode[1].asText(),
operationName = arrayNode[2].asText(),
- propertyName = arrayNode[3].asText()
+ propertyName = arrayNode[3].asText(),
+ subPropertyName = subPropertyName
)
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
index e6f3f71ca..ba210df10 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018-2019 IBM.
+ * Modifications Copyright © 2018-2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -213,8 +213,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
override fun loadEnvironments(type: String, fileName: String) {
BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
- setNodeTemplateAttributeValue(type, key.toString(), value.toString()
- .asJsonPrimitive())
+ setNodeTemplateAttributeValue(type, key.toString(), value.asJsonType())
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
index 931d31e9d..30bd75f7d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.data.*
-import org.onap.ccsdk.cds.controllerblueprints.core.format
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
@@ -143,8 +140,8 @@ If Property Assignment is Expression.
}
if (subAttributeName != null) {
- if (valueNode.isObject || valueNode.isArray)
- valueNode = JsonParserUtils.parse(valueNode, subAttributeName)
+ if (valueNode.isComplexType())
+ valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subAttributeName)
}
return valueNode
}
@@ -176,8 +173,8 @@ If Property Assignment is Expression.
valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
if (subPropertyName != null) {
- if (valueNode.isObject || valueNode.isArray)
- valueNode = JsonParserUtils.parse(valueNode, subPropertyName)
+ if (valueNode.isComplexType())
+ valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
}
return valueNode
}
@@ -190,9 +187,17 @@ If Property Assignment is Expression.
if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) {
outputNodeTemplateName = operationOutputExpression.modelableEntityName
}
- return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
+
+ var valueNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
operationOutputExpression.interfaceName, operationOutputExpression.operationName,
operationOutputExpression.propertyName)
+
+ val subPropertyName: String? = operationOutputExpression.subPropertyName
+ if (subPropertyName != null) {
+ if (valueNode.isComplexType())
+ valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
+ }
+ return valueNode
}
/*
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
index 5e9fd6207..9b1b66b5b 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
@@ -296,6 +296,5 @@ class JacksonUtils {
else -> getJsonNode(value)
}
}
-
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
index 342ff7636..e5eef5a41 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +39,7 @@ class JsonParserUtils {
}
fun paths(jsonNode: JsonNode, expression: String): List<String> {
- return paths(jsonNode.toString(), expression)
+ return paths(jsonNode, expression)
}
fun parse(jsonContent: String, expression: String): JsonNode {
@@ -54,7 +55,8 @@ class JsonParserUtils {
}
fun parseNSet(jsonNode: JsonNode, expression: String, valueNode: JsonNode): JsonNode {
- return parseNSet(jsonNode.toString(), expression, valueNode)
+
+ return parseNSet(jsonNode, expression, valueNode)
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
index 020edc78e..c0641be69 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
@@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import kotlin.test.assertNotNull
@@ -153,6 +154,41 @@ class BluePrintDSLTest {
}
@Test
+ fun testNodeTypePropertyConstrains() {
+ val nodeType = nodeType("data-node", "1.0.0", "tosca.Nodes.root", "") {
+ property("ip-address", "string", true, "") {
+ defaultValue("127.0.0.1")
+ constrain {
+ validValues(arrayListOf("""127.0.0.1""".asJsonPrimitive()))
+ length(10)
+ maxLength(20)
+ minLength(10)
+ }
+
+ }
+ property("disk-space", "string", true, "") {
+ defaultValue(10)
+ constrain {
+ validValues("""["200KB", "400KB"]""")
+ equal("200KB")
+ inRange("""["100KB", "500KB" ]""")
+ maxLength("10MB")
+ minLength("10KB")
+ }
+ constrain {
+ validValues("""[ 200, 400]""")
+ greaterOrEqual("10KB")
+ greaterThan("20KB")
+ lessOrEqual("200KB")
+ lessThan("190KB")
+ }
+ }
+ }
+ assertNotNull(nodeType, "failed to get nodeType")
+ // println(nodeType.asJsonString(true))
+ }
+
+ @Test
fun testServiceTemplateWorkflow() {
val serviceTemplate = serviceTemplate("sample-bp", "1.0.0",
"brindasanth@onap.com", "sample, blueprints") {