summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt16
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt25
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt13
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts44
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts46
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json10
6 files changed, 145 insertions, 9 deletions
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 4ef0e82b2..b1a7daad2 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
@@ -27,13 +27,13 @@ object BluePrintConstants {
const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
- const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
-
- const val STATUS_SUCCESS: String = "success"
- const val STATUS_PROCESSING: String = "processing"
- const val STATUS_FAILURE: String = "failure"
-
- const val TYPE_DEFAULT: String = "default"
+ const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
+
+ const val STATUS_SUCCESS: String = "success"
+ const val STATUS_PROCESSING: String = "processing"
+ const val STATUS_FAILURE: String = "failure"
+
+ const val TYPE_DEFAULT: String = "default"
const val DATA_TYPE_STRING: String = "string"
const val DATA_TYPE_INTEGER: String = "integer"
@@ -102,6 +102,7 @@ object BluePrintConstants {
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_KOTLIN: String = "tosca.nodes.component.Kotlin"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
@@ -148,6 +149,7 @@ object BluePrintConstants {
const val TOSCA_SCRIPTS_DIR: String = "Scripts"
const val TOSCA_MAPPINGS_DIR: String = "Mappings"
const val TOSCA_TEMPLATES_DIR: String = "Templates"
+ const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin"
const val METADATA_USER_GROUPS = "user-groups"
const val METADATA_TEMPLATE_NAME = "template_name"
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
new file mode 100644
index 000000000..124c167a8
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
@@ -0,0 +1,25 @@
+/*
+ * 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.interfaces
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+interface BluePrintScriptsService{
+
+ fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
+ reCompile: Boolean): T
+} \ No newline at end of file
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 1a6d096d8..793604514 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
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.service
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.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -55,6 +57,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
return JacksonUtils.getJson(serviceTemplate, pretty)
}
+ fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME)
+ ?: throw BluePrintException("could't get template name from meta data")
+
+ fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION)
+ ?: throw BluePrintException("could't get template version from meta data")
+
+ fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR)
+ ?: throw BluePrintException("could't get template author from meta data")
+
// Workflow
val workflows: MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows
@@ -148,7 +159,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates
fun nodeTemplateByName(name: String): NodeTemplate =
- nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
+ nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {
return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts
new file mode 100644
index 000000000..f1da61407
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+
+open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ lateinit var resourceAssignment: ResourceAssignment
+
+ override fun getName(): String {
+ return "resource-assignment-processor-custom-capability"
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment) {
+ this.resourceAssignment = resourceAssignment
+ }
+
+ override fun prepareResponse(): ResourceAssignment {
+ return resourceAssignment
+ }
+
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
+ TODO("To Implement")
+ }
+
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts
new file mode 100644
index 000000000..184c49335
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+
+open class SampleKotlinComponent : BlueprintFunctionNode<String, String> {
+
+ override fun getName(): String {
+ return "my Name"
+ }
+
+ override fun prepareRequest(executionRequest: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun prepareResponse(): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun apply(t: String): String {
+ return "Successfully Executed Scripts"
+ }
+}
diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
index e4eb90e7b..2bdd7d574 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
@@ -17,10 +17,18 @@
]
},
"instance-name": {
- "description": "Capability component instance reference name.",
+ "description": "Capability component instance reference name for JAVA-COMPONENT, Script Class name for KOTLIN-COMPONENT.",
"required": true,
"type": "string"
},
+ "instance-dependencies": {
+ "required": false,
+ "description": "Instance dependency Names to Inject to Kotlin / Jython Script.",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"input-key-mapping": {
"description": "Context name to input parameters name mapping.",
"required": false,