Instance dependencies in ComponentScriptExecutor 52/117652/3
authorLukasz Rajewski <lukasz.rajewski@orange.com>
Tue, 9 Feb 2021 18:54:19 +0000 (19:54 +0100)
committerKAPIL SINGAL <ks220y@att.com>
Tue, 9 Feb 2021 19:21:03 +0000 (19:21 +0000)
Issue-ID: CCSDK-3146
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I6502abd0d2a3fa85cefc3bc6a900f27171b51569

components/model-catalog/definition-type/starter-type/node_type/component-script-executor.json
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt

index 2259602..a2cd32e 100644 (file)
               "required": true,
               "type": "string"
             },
+            "instance-dependencies": {
+              "required": true,
+              "description": "Instance names to inject to Jython or Kotlin Script.",
+              "type": "list",
+              "entry_schema": {
+                "type": "string"
+              }
+            },
             "dynamic-properties": {
               "description": "Dynamic Json Content or DSL Json reference.",
               "required": false,
index 597426a..213d21e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2019 IBM.
+ *  Copyright © 2021 Orange.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
 
+import com.fasterxml.jackson.databind.node.ArrayNode
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
 import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -36,6 +38,7 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
         const val INPUT_SCRIPT_TYPE = "script-type"
         const val INPUT_SCRIPT_CLASS_REFERENCE = "script-class-reference"
         const val INPUT_DYNAMIC_PROPERTIES = "dynamic-properties"
+        const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
 
         const val ATTRIBUTE_RESPONSE_DATA = "response-data"
         const val ATTRIBUTE_STATUS = "status"
@@ -69,6 +72,9 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
     }
 
     open fun populateScriptDependencies(scriptDependencies: MutableList<String>) {
-        /** Place holder for Child to add extra dependencies */
+        val instanceDependenciesNode = operationInputs.get(INPUT_INSTANCE_DEPENDENCIES) as? ArrayNode
+        instanceDependenciesNode?.forEach { instanceName ->
+            scriptDependencies.add(instanceName.textValue())
+        }
     }
 }