Implement Base Jython Executor function.
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Mon, 19 Nov 2018 17:48:31 +0000 (12:48 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 29 Nov 2018 00:46:23 +0000 (19:46 -0500)
Change-Id: I3fb066a021de4a7b3aa1fce7f6c191bc3944fb51
Issue-ID: CCSDK-696
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py
components/scripts/python/ccsdk_blueprints/__init__.py [new file with mode: 0644]
components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py [new file with mode: 0644]
components/scripts/python/ccsdk_blueprints/blueprint_constants.py [new file with mode: 0644]
components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py [new file with mode: 0644]
components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py [new file with mode: 0644]

index f84b2c5..9da5b0e 100644 (file)
@@ -59,6 +59,8 @@ interface BluePrintRuntimeService<T> {
 \r
     fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String\r
 \r
+    fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition\r
+\r
     fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)\r
 \r
     fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)\r
@@ -269,15 +271,19 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
         return propertyAssignmentValue\r
     }\r
 \r
-    override fun resolveNodeTemplateArtifact(nodeTemplateName: String,\r
-                                             artifactName: String): String {\r
+    override fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String {\r
+        val artifactDefinition: ArtifactDefinition = resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)\r
+        val propertyAssignmentExpression = PropertyAssignmentService(this)\r
+        return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
+    }\r
+\r
+    override fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition {\r
         val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
 \r
-        val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)\r
+        return nodeTemplate.artifacts?.get(artifactName)\r
                 ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"\r
                         , artifactName))\r
-        val propertyAssignmentExpression = PropertyAssignmentService(this)\r
-        return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
+\r
     }\r
 \r
 \r
index ee02b3a..e067a7d 100644 (file)
         "artifacts": {
           "component-script": {
             "type": "artifact-script-python",
-            "file": "Scripts/baseconfig-template.vtl"
+            "file": "Scripts/SamplePythonComponentNode.py"
           }
         }
       }
         }
       },
       "activate": {
+        "inputs": {
+          "request-id": {
+            "required": true,
+            "type": "string"
+          },
+          "action-name": {
+            "required": true,
+            "type": "string"
+          },
+          "scope-type": {
+            "required": true,
+            "type": "string"
+          },
+          "hostname": {
+            "required": true,
+            "type": "string"
+          }
+        },
         "steps": {
           "call-resource-assignment": {
             "description": "Netconf Activation Workflow",
index fc51513..0a583dc 100644 (file)
@@ -1,8 +1,12 @@
-from com.brvith.orchestrator.core.interfaces import ComponentNode
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
 
-class SamplePythonComponentNode(ComponentNode):
-    def prepare(self, context, componentContext):
+class SamplePythonComponentNode(AbstractPythonComponentFunction):
+
+    def process(self, execution_request):
+        print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
         return None
 
-    def prepare(self, context, componentContext):
-        return None
No newline at end of file
+    def recover(self, runtime_exception, execution_request):
+        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
       return None
diff --git a/components/scripts/python/ccsdk_blueprints/__init__.py b/components/scripts/python/ccsdk_blueprints/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
new file mode 100644 (file)
index 0000000..0ddab16
--- /dev/null
@@ -0,0 +1,11 @@
+from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction
+
+class AbstractPythonComponentFunction(AbstractComponentFunction):
+
+    def process(self, execution_request):
+        print "Processing calling.."
+        return None
+
+    def recover(self, runtime_exception, execution_request):
+        print "Recovering calling.."
+        return None
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py
new file mode 100644 (file)
index 0000000..2ec95f3
--- /dev/null
@@ -0,0 +1,23 @@
+
+PROPERTY_BLUEPRINT_PROCESS_ID= "blueprint-process-id"
+PROPERTY_BLUEPRINT_BASE_PATH= "blueprint-basePath"
+PROPERTY_BLUEPRINT_RUNTIME= "blueprint-runtime"
+PROPERTY_BLUEPRINT_INPUTS_DATA= "blueprint-inputs-data"
+PROPERTY_BLUEPRINT_CONTEXT= "blueprint-context"
+PROPERTY_BLUEPRINT_NAME= "template_name"
+PROPERTY_BLUEPRINT_VERSION= "template_version"
+
+METADATA_USER_GROUPS = "user-groups"
+METADATA_TEMPLATE_NAME = "template_name"
+METADATA_TEMPLATE_VERSION = "template_version"
+METADATA_TEMPLATE_AUTHOR = "template_author"
+METADATA_TEMPLATE_TAGS = "template_tags"
+METADATA_WORKFLOW_NAME = "workflow_name"
+
+PAYLOAD_DATA = "payload-data"
+PROPERTY_CURRENT_STEP = "current-step"
+PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
+PROPERTY_CURRENT_INTERFACE = "current-interface"
+PROPERTY_CURRENT_OPERATION = "current-operation"
+PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
+PROPERTY_EXECUTION_REQUEST = "execution-request"
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py
new file mode 100644 (file)
index 0000000..022b472
--- /dev/null
@@ -0,0 +1,13 @@
+class BluePrintRuntimeService:
+
+    def __init__(self, bps):
+        self.bps = bps
+
+    def resolveNodeTemplateArtifact(self, node_template_name, artifact_name):
+        return self.bps.resolveNodeTemplateArtifact(node_template_name, artifact_name)
+
+    def setNodeTemplateAttributeValue(self, nodeTemplateName, attributeName, value):
+        return self.bps.setNodeTemplateAttributeValue(nodeTemplateName, attributeName, value)
+
+    def setNodeTemplatePropertyValue(self, nodeTemplateName, propertyName, value):
+        return self.bps.setNodeTemplatePropertyValue(nodeTemplateName, propertyName, value)
diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
new file mode 100644 (file)
index 0000000..62665dc
--- /dev/null
@@ -0,0 +1,12 @@
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
+
+class SampleBlueprintComponent(AbstractPythonComponentFunction):
+
+    def process(self, execution_request):
+        print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        return None
+
+    def recover(self, runtime_exception, execution_request):
+        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        return None