Support for dynamic property in command args 27/85827/9
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Fri, 19 Apr 2019 15:42:47 +0000 (11:42 -0400)
committerAlexis de Talhouët <adetalhouet89@gmail.com>
Tue, 23 Apr 2019 12:58:16 +0000 (12:58 +0000)
Change-Id: I47c65557a553c79fefbbc28f8dab54b1c0a4a798
Issue-ID: CCCSDK-125
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/node_types.json
components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json
components/model-catalog/definition-type/starter-type/node_type/component-remote-python-executor.json
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
ms/command-executor/src/main/docker/Dockerfile

index 640a4eb..e5b8b30 100644 (file)
                   "required": false,
                   "type": "json"
                 },
+                "argument-properties": {
+                  "description": "Argument Json Content or DSL Json reference.",
+                  "required": false,
+                  "type": "json"
+                },
                 "command": {
                   "description": "Command to execute.",
                   "required": true,
index d78176f..48992bd 100644 (file)
       "file": "Definitions/policy_types.json"
     }
   ],
+  "dsl_definitions": {
+    "execute-argument-properties": {
+      "input": {
+        "get_input": "input"
+      }
+    }
+  },
   "topology_template": {
     "workflows": {
       "execute-remote-python": {
             ]
           }
         },
-        "inputs": {},
+        "inputs": {
+          "input": {
+            "required": false,
+            "type": "string"
+          }
+        },
         "outputs": {
           "prepare-environment-logs": {
             "type": "string",
                   "primary": "component-script"
                 },
                 "inputs": {
-                  "command": "python SamplePython.py blah",
+                  "command": "python SamplePython.py $input",
                   "packages": [
                     {
                       "type": "pip",
                         "pyaml"
                       ]
                     }
-                  ]
+                  ],
+                  "argument-properties": "*execute-argument-properties"
                 }
               }
             }
index 5c9503f..09b371c 100644 (file)
               "required": false,
               "type": "json"
             },
+            "argument-properties": {
+              "description": "Argument Json Content or DSL Json reference.",
+              "required": false,
+              "type": "json"
+            },
             "command": {
               "description": "Command to execute.",
               "required": true,
index 488e0d0..df92d71 100644 (file)
@@ -28,6 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotBlank
 import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -47,6 +48,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
     companion object {
         const val INPUT_ENDPOINT_SELECTOR = "endpoint-selector"
         const val INPUT_DYNAMIC_PROPERTIES = "dynamic-properties"
+        const val INPUT_ARGUMENT_PROPERTIES = "argument-properties"
         const val INPUT_COMMAND = "command"
         const val INPUT_PACKAGES = "packages"
 
@@ -79,11 +81,12 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
 
         val endPointSelector = getOperationInput(INPUT_ENDPOINT_SELECTOR)
         val dynamicProperties = getOperationInput(INPUT_DYNAMIC_PROPERTIES)
-        val command = getOperationInput(INPUT_COMMAND).asText()
         val packages = getOperationInput(INPUT_PACKAGES)
+        val argumentProperties = getOperationInput(INPUT_ARGUMENT_PROPERTIES)
 
-        // TODO("Python execution command and Resolve some expressions with dynamic properties")
-        val scriptCommand = command.replace(pythonScript.name, pythonScript.absolutePath)
+        var command = getOperationInput(INPUT_COMMAND).asText()
+        command = command.replace(pythonScript.name, pythonScript.absolutePath)
+        val scriptCommand = BluePrintVelocityTemplateService.generateContent(command, json = JacksonUtils.getJson(argumentProperties))
 
         try {
             // Open GRPC Connection
index 50f592d..c0458bd 100644 (file)
@@ -1,6 +1,9 @@
 FROM python:3.6-slim
 
-ENV GRPC_PYTHON_VERSION 1.19.0
+ENV HTTP_PROXY  ${HTTP_PROXY}
+ENV HTTPS_PROXY ${HTTPS_PROXY}
+
+ENV GRPC_PYTHON_VERSION 1.20.0
 RUN python -m pip install --upgrade pip
 RUN pip install grpcio==${GRPC_PYTHON_VERSION} grpcio-tools==${GRPC_PYTHON_VERSION}
 RUN pip install virtualenv