diff options
author | Muthuramalingam, Brinda Santh <bs2796@att.com> | 2019-01-30 15:52:30 -0500 |
---|---|---|
committer | Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com> | 2019-02-04 09:45:59 -0500 |
commit | 73528fe9ce4471be5e76c042ea02b40199d36532 (patch) | |
tree | 7c332a906d1df80ab6051db5f9668baed13241ea /components | |
parent | 7727f3dd84ce4ca2af5c3e589651ef57e3813fa9 (diff) |
blueprint scripting services
Change-Id: I834b83e0c2716eceadeec8a5f17a7604e938166a
Issue-ID: CCSDK-941
Signed-off-by: Muthuramalingam, Brinda Santh <bs2796@att.com>
Diffstat (limited to 'components')
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 4ef0e82b..b1a7daad 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 00000000..124c167a --- /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 1a6d096d..79360451 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 00000000..f1da6140 --- /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 00000000..184c4933 --- /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 e4eb90e7..2bdd7d57 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, |