}\r
},\r
"interfaces": {\r
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {\r
+ "ResourceAssignmentComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"\r
const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"\r
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"\r
+ const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"\r
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"\r
\r
const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"\r
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,\r
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT,\r
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON,\r
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON,\r
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT\r
)\r
\r
"data/default-context.json", executionContext)\r
\r
val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment",\r
- "DefaultComponentNode", "process")\r
+ "ResourceAssignmentComponent", "process")\r
\r
assertNotNull(inContext, "Failed to populate interface input property values")\r
assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance())\r
\r
bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment",\r
- "DefaultComponentNode", "process")\r
+ "ResourceAssignmentComponent", "process")\r
\r
val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",\r
- "DefaultComponentNode", "process", "status")\r
+ "ResourceAssignmentComponent", "process", "status")\r
assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status")\r
\r
val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",\r
- "DefaultComponentNode", "process", "resource-assignment-params")\r
+ "ResourceAssignmentComponent", "process", "resource-assignment-params")\r
assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params")\r
\r
}\r
"resource-assignment-ra-component": {
"type": "component-resource-assignment",
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
},
"imports": [
{
- "file": "Definitions/types.json"
+ "file": "Definitions/data-types.json"
+ },
+ {
+ "file": "Definitions/node-types.json"
+ },
+ {
+ "file": "Definitions/artifact-types.json"
}
],
"topology_template": {
"request-id": "1234"
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
"request-id": "1234"
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"implementation": {
},
"artifacts": {
"component-script": {
- "type": "artifact-script-python",
+ "type": "artifact-script-jython",
+ "file": "Scripts/SamplePythonComponentNode.py"
+ }
+ }
+ },
+ "activate-jython": {
+ "type": "component-jython-executor",
+ "interfaces": {
+ "JythonExecutorComponent": {
+ "operations": {
+ "process": {
+ "implementation": {
+ "primary": "component-script"
+ },
+ "outputs": {
+ "response-data": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "artifacts": {
+ "component-script": {
+ "type": "artifact-script-jython",
"file": "Scripts/SamplePythonComponentNode.py"
}
}
"target": "resource-assignment",
"activities": [
{
- "call_operation": "ResourceAssignmentNode.process"
+ "call_operation": "ResourceAssignmentComponent.process"
}
]
}
"target": "resource-assignment",
"activities": [
{
- "call_operation": "ResourceAssignmentNode.process"
+ "call_operation": "ResourceAssignmentComponent.process"
}
]
}
--- /dev/null
+{
+ "artifact_types": {
+ "artifact-template-velocity": {
+ "description": "Velocity Template used for Configuration",
+ "version": "1.0.0",
+ "file_ext": [
+ "vtl"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-mapping-resource": {
+ "description": "Velocity Template Resource Mapping File used along with Configuration template",
+ "version": "1.0.0",
+ "file_ext": [
+ "json"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-script-jython": {
+ "description": "Jython Script File",
+ "version": "1.0.0",
+ "file_ext": [
+ "py"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-directed-graph": {
+ "description": "Directed Graph File",
+ "version": "1.0.0",
+ "file_ext": [
+ "json",
+ "xml"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ },
+ "artifact-component-jar": {
+ "description": "Component Jar",
+ "version": "1.0.0",
+ "file_ext": [
+ "jar"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "data_types": {
+ "sample-property": {
+ "description": "This is sample data type",
+ "version": "1.0.0",
+ "properties": {
+ "content": {
+ "required": false,
+ "type": "string"
+ },
+ "process-name": {
+ "required": false,
+ "type": "string"
+ },
+ "version": {
+ "required": false,
+ "type": "string",
+ "default": "LATEST"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+ }
+ }
+}
\ No newline at end of file
{
- "artifact_types": {
- "artifact-template-velocity": {
- "description": " Velocity Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "vtl"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-mapping-resource": {
- "description": " Velocity Template Resource Mapping File used along with Configuration template",
- "version": "1.0.0",
- "file_ext": [
- "json"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-script-kotlin": {
- "description": " Kotlin Script Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "kt"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-script-python": {
- "description": " Kotlin Script Template used for Configuration",
- "version": "1.0.0",
- "file_ext": [
- "py"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-directed-graph": {
- "description": "Directed Graph File",
- "version": "1.0.0",
- "file_ext": [
- "json",
- "xml"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- },
- "artifact-component-jar": {
- "description": "Component Jar",
- "version": "1.0.0",
- "file_ext": [
- "jar"
- ],
- "derived_from": "tosca.artifacts.Implementation"
- }
- },
"node_types": {
"dg-activate": {
"description": "This is BPMN Activate node type",
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
- "tosca.nodes.component.Python": {
- "description": "This is Resource Assignment Python Component API",
+ "tosca.nodes.component.Jython": {
+ "description": "This is Resource Assignment Jython Component API",
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
}
},
"interfaces": {
- "DefaultComponentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
},
"derived_from": "tosca.nodes.Component"
},
- "component-resource-assignment-python": {
- "description": "This is Resource Assignment Component API",
+ "component-jython-executor": {
+ "description": "This is Jython Execution Component.",
"version": "1.0.0",
- "properties": {
- "request-id": {
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",
- "required": true,
- "type": "string"
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
}
},
"interfaces": {
- "DefaultComponentNode": {
+ "JythonExecutorComponent": {
"operations": {
"process": {
- "inputs": {
- "action-name": {
- "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- }
- },
"outputs": {
- "resource-assignment-params": {
- "required": true,
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
"type": "string"
},
"status": {
+ "description": "Status of the Component Execution ( success or failure )",
"required": true,
"type": "string"
}
}
}
},
- "derived_from": "tosca.nodes.component.Python"
- }
- },
- "data_types": {
- "sample-property": {
- "description": "This is sample data type",
- "version": "1.0.0",
- "properties": {
- "content": {
- "required": false,
- "type": "string"
- },
- "process-name": {
- "required": false,
- "type": "string"
- },
- "version": {
- "required": false,
- "type": "string",
- "default": "LATEST"
- }
- },
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.nodes.component.Jython"
}
}
}
\ No newline at end of file
--- /dev/null
+{\r
+ "description": "Jython Script File",\r
+ "version": "1.0.0",\r
+ "file_ext": [\r
+ "py"\r
+ ],\r
+ "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
{\r
- "description": " Kotlin Script Template used for Configuration",\r
+ "description": "Python Script file",\r
"version": "1.0.0",\r
"file_ext": [\r
"py"\r
}\r
},\r
"interfaces": {\r
- "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": {\r
+ "ConfigGeneratorComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
--- /dev/null
+{
+ "description": "This is Jython Execution Component.",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "JythonExecutorComponent": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "instance-dependencies": {
+ "required": true,
+ "description": "Instance Names to Inject to Jython Script.",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "outputs": {
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.component.Jython"
+}
\ No newline at end of file
}\r
},\r
"interfaces": {\r
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {\r
+ "NetconfExecutorComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
}\r
}\r
},\r
- "derived_from": "tosca.nodes.Component"\r
+ "derived_from": "tosca.nodes.component.Jython"\r
}
\ No newline at end of file
}\r
},\r
"interfaces": {\r
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {\r
+ "ResourceAssignmentComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
--- /dev/null
+{\r
+ "description": "This is Jython Component",\r
+ "version": "1.0.0",\r
+ "derived_from": "tosca.nodes.Root"\r
+}
\ No newline at end of file
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
-@Component("component-python-executor")
-class ComponentPythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+@Component("component-jython-executor")
+class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
- private val log = LoggerFactory.getLogger(ComponentPythonExecutor::class.java)
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
private var componentFunction: AbstractComponentFunction? = null
val properties: MutableMap<String, Any> = hashMapOf()
properties["log"] = log
- componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath, pythonPath, content, pythonClassName, properties)
+ componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
+ pythonPath, content, pythonClassName, properties)
componentFunction!!.process(executionServiceInput)
--- /dev/null
+/*
+ * 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.blueprintsprocessor.functions.python.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorProperty) {
+
+
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
+
+
+ fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
+ jythonContextInstance: MutableMap<String, Any>,
+ dependencyInstanceNames: List<String>): AbstractComponentFunction {
+
+
+ dependencyInstanceNames.forEach { instanceName ->
+ jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
+
+ }
+
+ return PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
+ pythonPath, content, pythonClassName, jythonContextInstance)
+
+ }
+
+}
\ No newline at end of file
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
-class ComponentPythonExecutorTest {
+class ComponentJythonExecutorTest {
@Autowired
- lateinit var componentPythonExecutor: ComponentPythonExecutor
+ lateinit var componentJythonExecutor: ComponentJythonExecutor
@Test
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
"./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
- componentPythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
val metaData: MutableMap<String, JsonNode> = hashMapOf()
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "resource-assignment-py")
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py")
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "DefaultComponentNode")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
executionServiceInput.metadata = metaData
- componentPythonExecutor.apply(executionServiceInput)
+ componentJythonExecutor.apply(executionServiceInput)
}
}
\ No newline at end of file
resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader\r
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments\r
\r
- val context = hashMapOf<String, Any>()\r
-\r
process(resourceResolutionOutput.resourceAssignments)\r
\r
val status = Status()\r
val metaData: MutableMap<String, JsonNode> = hashMapOf()
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP,"resource-assignment-py")
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py")
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "DefaultComponentNode")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
executionServiceInput.metadata = metaData
}\r
},\r
"interfaces": {\r
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {\r
+ "NetconfExecutorComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
"component-node": {}\r
},\r
"interfaces": {\r
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {\r
+ "ResourceAssignmentComponent": {\r
"operations": {\r
"process": {\r
"inputs": {\r
}
},
"interfaces" : {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : {
+ "ResourceAssignmentComponent" : {
"operations" : {
"process" : {
"inputs" : {
},
"derived_from" : "tosca.nodes.Component"
},
+ "tosca.nodes.component.Jython" : {
+ "description" : "This is Jython Component",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"tosca.nodes.DG" : {
"description" : "This is Directed Graph Node Type",
"version" : "1.0.0",
}
},
"interfaces" : {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "NetconfExecutorComponent" : {
"operations" : {
"process" : {
"inputs" : {
}
}
},
- "derived_from" : "tosca.nodes.Component"
+ "derived_from" : "tosca.nodes.component.Jython"
}
},
"topology_template" : {
}
},
"interfaces" : {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "NetconfExecutorComponent" : {
"operations" : {
"process" : {
"implementation" : {
"component-node" : { }
},
"interfaces" : {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : {
+ "ResourceAssignmentComponent" : {
"operations" : {
"process" : {
"inputs" : {