Add Blueprint Runtime Input/Output logic 95/74195/1
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Tue, 4 Dec 2018 15:25:44 +0000 (10:25 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Tue, 4 Dec 2018 15:31:15 +0000 (10:31 -0500)
Change-Id: I0355e78862096b7b4074faa882d66ce27d6e1844
Issue-ID: CCSDK-670
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
37 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt [new file with mode: 0644]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml [moved from ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml with 94% similarity]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml [moved from ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml with 95% similarity]
components/parent/pom.xml
ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java
ms/blueprintsprocessor/application/src/test/resources/application.properties [new file with mode: 0644]
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt [deleted file]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/pom.xml
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json [deleted file]
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java

index 0517e90..167496e 100644 (file)
@@ -29,6 +29,9 @@ object BluePrintConstants {
     const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"\r
     const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"\r
 \r
+    const val STATUS_SUCCESS: String = "success"\r
+    const val STATUS_FAILURE: String = "failure"\r
+\r
     const val TYPE_DEFAULT: String = "default"\r
 \r
     const val DATA_TYPE_STRING: String = "string"\r
index c32e15f..2329fc9 100644 (file)
@@ -75,17 +75,17 @@ fun <T : Any> MutableMap<String, *>.castValue(key: String, valueType: KClass<T>)
 fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {\r
     when (value) {\r
         is JsonNode ->\r
-            this.put(key, value)\r
+            this[key] = value\r
         is String ->\r
-            this.put(key, TextNode(value))\r
+            this[key] = TextNode(value)\r
         is Boolean ->\r
-            this.put(key, BooleanNode.valueOf(value))\r
+            this[key] = BooleanNode.valueOf(value)\r
         is Int ->\r
-            this.put(key, IntNode.valueOf(value.toInt()))\r
+            this[key] = IntNode.valueOf(value.toInt())\r
         is Double ->\r
-            this.put(key, DoubleNode.valueOf(value.toDouble()))\r
+            this[key] = DoubleNode.valueOf(value.toDouble())\r
         else ->\r
-            this.put(key, JacksonUtils.jsonNodeFromObject(value))\r
+            this[key] = JacksonUtils.jsonNodeFromObject(value)\r
     }\r
 }\r
 \r
@@ -97,6 +97,14 @@ fun MutableMap<String, JsonNode>.getAsBoolean(key: String): Boolean {
     return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)")\r
 }\r
 \r
+fun MutableMap<String, JsonNode>.getAsInt(key: String): Int {\r
+    return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
+fun MutableMap<String, JsonNode>.getAsDouble(key: String): Double {\r
+    return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
 // Checks\r
 \r
 fun checkNotEmpty(value: String?): Boolean {\r
index cce6d90..84af3f9 100644 (file)
@@ -57,6 +57,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
     fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName)\r
             ?: throw BluePrintException("could't get workflow($workFlowName)")\r
 \r
+    fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs\r
+\r
     fun workflowStepByName(workFlowName: String, stepName: String): Step {\r
         return workflowByName(workFlowName).steps?.get(stepName)\r
                 ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")\r
index 84ba104..448a06a 100644 (file)
@@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.node.NullNode
 import com.fasterxml.jackson.databind.node.ObjectNode\r
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate\r
@@ -211,15 +210,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
 \r
         val nodeTypeInterfaceOperationInputs: MutableMap<String, PropertyDefinition> =\r
                 bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName)\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments)\r
 \r
@@ -258,15 +255,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
-                        ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
 \r
         val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> =\r
                 bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName)\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         // Iterate Node Type Properties\r
         nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
@@ -435,10 +430,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
     override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
         log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())\r
 \r
+        val dynamicInputPropertiesName = "$workflowName-properties"\r
+\r
         bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property ->\r
-            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
-                    ?: NullNode.getInstance()\r
-            setInputValue(propertyName, property, valueNode)\r
+            if (propertyName != dynamicInputPropertiesName) {\r
+                val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                        ?: NullNode.getInstance()\r
+                setInputValue(propertyName, property, valueNode)\r
+            }\r
+        }\r
+\r
+        val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName)\r
+\r
+        workflowDynamicInputs?.let {\r
+            bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property ->\r
+                val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                        ?: NullNode.getInstance()\r
+                setInputValue(propertyName, property, valueNode)\r
+\r
+            }\r
         }\r
     }\r
 \r
index 947eb41..36c141f 100644 (file)
@@ -197,8 +197,7 @@ If Property Assignment is Expression.
     }\r
 \r
     fun artifactContent(artifactDefinition: ArtifactDefinition): String {\r
-        val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()\r
-                ?: throw BluePrintException("failed to get property (${BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH}) from getStore")\r
+        val bluePrintBasePath: String = bluePrintContext.rootPath\r
 \r
         if (artifactDefinition.repository != null) {\r
             TODO()\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
new file mode 100644 (file)
index 0000000..f02524f
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * 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.utils
+
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
+import org.apache.commons.io.IOUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import java.io.*
+import java.nio.charset.Charset
+import java.util.zip.ZipFile
+
+class BluePrintArchiveUtils {
+
+    companion object {
+
+
+        fun compress(source: String, destination: String, absolute: Boolean): Boolean {
+            val rootDir = File(source)
+            val saveFile = File(destination)
+            return compress(rootDir, saveFile, absolute)
+        }
+
+        /**
+         * Create a new Zip from a root directory
+         *
+         * @param directory the base directory
+         * @param filename the output filename
+         * @param absolute store absolute filepath (from directory) or only filename
+         * @return True if OK
+         */
+        fun compress(source: File, destination: File, absolute: Boolean): Boolean {
+            // recursive call
+            val zaos: ZipArchiveOutputStream
+            try {
+                zaos = ZipArchiveOutputStream(FileOutputStream(destination))
+            } catch (e: FileNotFoundException) {
+                return false
+            }
+
+            try {
+                recurseFiles(source, source, zaos, absolute)
+            } catch (e2: IOException) {
+                try {
+                    zaos.close()
+                } catch (e: IOException) {
+                    // ignore
+                }
+
+                return false
+            }
+
+            try {
+                zaos.finish()
+            } catch (e1: IOException) {
+                // ignore
+            }
+
+            try {
+                zaos.flush()
+            } catch (e: IOException) {
+                // ignore
+            }
+
+            try {
+                zaos.close()
+            } catch (e: IOException) {
+                // ignore
+            }
+
+            return true
+        }
+
+        /**
+         * Recursive traversal to add files
+         *
+         * @param root
+         * @param file
+         * @param zaos
+         * @param absolute
+         * @throws IOException
+         */
+        @Throws(IOException::class)
+        private fun recurseFiles(root: File, file: File, zaos: ZipArchiveOutputStream,
+                                 absolute: Boolean) {
+            if (file.isDirectory) {
+                // recursive call
+                val files = file.listFiles()
+                for (file2 in files!!) {
+                    recurseFiles(root, file2, zaos, absolute)
+                }
+            } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) {
+                var filename: String? = null
+                if (absolute) {
+                    filename = file.absolutePath.substring(root.absolutePath.length)
+                } else {
+                    filename = file.name
+                }
+                val zae = ZipArchiveEntry(filename)
+                zae.setSize(file.length())
+                zaos.putArchiveEntry(zae)
+                val fis = FileInputStream(file)
+                IOUtils.copy(fis, zaos)
+                zaos.closeArchiveEntry()
+            }
+        }
+
+
+        fun deCompress(zipFile: File, targetPath: String): File {
+            val zip = ZipFile(zipFile, Charset.defaultCharset())
+            val enumeration = zip.entries()
+            while (enumeration.hasMoreElements()) {
+                val entry = enumeration.nextElement()
+                val destFilePath = File(targetPath, entry.name)
+                destFilePath.parentFile.mkdirs()
+                if (entry.isDirectory)
+                    continue
+                val bufferedIs = BufferedInputStream(zip.getInputStream(entry))
+                bufferedIs.use {
+                    destFilePath.outputStream().buffered(1024).use { bos ->
+                        bufferedIs.copyTo(bos)
+                    }
+                }
+            }
+
+            val destinationDir = File(targetPath)
+            check(destinationDir.isDirectory && destinationDir.exists()) {
+                throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ")
+            }
+            return destinationDir
+        }
+    }
+
+}
\ No newline at end of file
index 04e0efc..b538f50 100644 (file)
       }
     },
     "node_templates": {
+      "resource-assignment-process": {
+        "type": "dg-activate",
+        "properties": {
+          "process-name": {
+            "get_input": "action-name"
+          },
+          "version": {
+            "get_property": [
+              "SELF",
+              "process-name"
+            ]
+          },
+          "content": {
+            "get_artifact": [
+              "SELF",
+              "dg-resource-assignment-process"
+            ]
+          }
+        },
+        "artifacts": {
+          "dg-resource-assignment-process": {
+            "type": "artifact-directed-graph",
+            "file": "Plans/CONFIG_ResourceAssignment_1.0.0.xml"
+          }
+        }
+      },
       "activate-process": {
         "type": "dg-activate",
         "properties": {
           }
         }
       },
+      "assign-activate-process": {
+        "type": "dg-activate",
+        "properties": {
+          "process-name": {
+            "get_input": "action-name"
+          },
+          "version": {
+            "get_property": [
+              "SELF",
+              "process-name"
+            ]
+          },
+          "content": {
+            "get_artifact": [
+              "SELF",
+              "dg-assign-activate-process"
+            ]
+          }
+        },
+        "artifacts": {
+          "dg-assign-activate-process": {
+            "type": "artifact-directed-graph",
+            "file": "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml"
+          }
+        }
+      },
       "resource-assignment": {
         "type": "component-resource-assignment",
         "properties": {
     "workflows": {
       "resource-assignment": {
         "inputs": {
-          "request-id": {
+          "resource-assignment-properties": {
             "required": true,
-            "type": "string"
-          },
-          "action-name": {
-            "required": true,
-            "type": "string"
-          },
-          "scope-type": {
-            "required": true,
-            "type": "string"
-          },
-          "hostname": {
-            "required": true,
-            "type": "string"
+            "type": "resource-assignment-properties"
           }
         },
         "steps": {
           "call-resource-assignment": {
             "description": "Resource Assignment Workflow",
-            "target": "resource-assignment",
+            "target": "resource-assignment-process",
             "activities": [
               {
-                "call_operation": "ResourceAssignmentComponent.process"
+                "call_operation": "CONFIG.ResourceAssignment"
               }
             ]
           }
       },
       "activate": {
         "inputs": {
-          "request-id": {
-            "required": true,
-            "type": "string"
-          },
-          "action-name": {
+          "activate-properties": {
             "required": true,
-            "type": "string"
-          },
-          "scope-type": {
-            "required": true,
-            "type": "string"
-          },
-          "hostname": {
-            "required": true,
-            "type": "string"
+            "type": "activate-properties"
           }
         },
         "steps": {
             "target": "activate-process",
             "activities": [
               {
-                "call_operation": "ResourceAssignmentComponent.process"
+                "call_operation": "CONFIG.ActivateProcess"
+              }
+            ]
+          }
+        }
+      },
+      "assign-activate": {
+        "inputs": {
+          "assign-activate-properties": {
+            "required": true,
+            "type": "assign-activate-properties"
+          }
+        },
+        "steps": {
+          "activate-process": {
+            "description": "Resource Assign and Netconf Activation Workflow",
+            "target": "assign-activate-process",
+            "activities": [
+              {
+                "call_operation": "CONFIG.AssignActivateProcess"
               }
             ]
           }
index 6ca1ffd..569b668 100644 (file)
         }
       },
       "derived_from": "tosca.datatypes.Root"
+    },
+    "activate-properties": {
+      "description": "This is Dynamically generated data type for workflow activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
+    },
+    "resource-assignment-properties": {
+      "description": "This is Dynamically generated data type for workflow activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
+    },
+    "assign-activate-properties": {
+      "description": "This is Dynamically generated data type for workflow assign-activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
     }
   }
 }
\ No newline at end of file
index 139ebb1..b83fd2a 100644 (file)
@@ -1,7 +1,7 @@
 {
   "node_types": {
     "dg-activate": {
-      "description": "This is BPMN Activate node type",
+      "description": "This is Generic Directed Graph Type",
       "version": "1.0.0",
       "properties": {
         "content": {
index d256bbd..2f6d2ed 100644 (file)
@@ -19,7 +19,7 @@
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
     <method rpc='ActivateNetconf' mode='sync'>
         <block atomic="true">
-            <execute plugin="resource-assignment" method="process">
+            <execute plugin="activate-jython" method="process">
                 <outcome value='failure'>
                     <return status="failure">
                     </return>
@@ -25,7 +25,7 @@
                     </return>
                 </outcome>
                 <outcome value='success'>
-                    <execute plugin="resource-assignment-py" method="process">
+                    <execute plugin="activate-jython" method="process">
                         <outcome value='failure'>
                             <return status="failure">
                             </return>
@@ -17,7 +17,7 @@
 <service-logic
         xmlns='http://www.onap.org/sdnc/svclogic'
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
-    <method rpc='ActivateNetconf' mode='sync'>
+    <method rpc='ResourceAssignment' mode='sync'>
         <block atomic="true">
             <execute plugin="resource-assignment" method="process">
                  <outcome value='failure'>
index 8a779c1..5c46208 100644 (file)
                 <artifactId>commons-io</artifactId>
                 <version>2.6</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-compress</artifactId>
+                <version>1.15</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.velocity</groupId>
                 <artifactId>velocity</artifactId>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-compress</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
index 3cba1f9..8a4ebd0 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Before;
 import org.junit.Test;\r
 import org.junit.runner.RunWith;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
 import org.springframework.context.ApplicationContext;\r
 import org.springframework.test.context.ContextConfiguration;\r
 import org.springframework.test.context.junit4.SpringRunner;\r
@@ -35,8 +36,8 @@ import org.springframework.test.context.junit4.SpringRunner;
 \r
 @RunWith(SpringRunner.class)\r
 @ContextConfiguration(classes = BlueprintProcessorApplication.class)\r
-//@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
-//        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
+@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
+        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
 public class BlueprintProcessorApplicationTest {\r
 \r
     @Autowired\r
@@ -48,7 +49,7 @@ public class BlueprintProcessorApplicationTest {
     }\r
 \r
     @Test\r
-    public void testSample(){\r
+    public void testSample() {\r
         Assert.assertNotNull("Failed to create Application Context ", context);\r
     }\r
 \r
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
new file mode 100644 (file)
index 0000000..567c257
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+blueprintsprocessor.blueprint-deploy-path=/opt
+blueprintsprocessor.blueprint-archive-path=/opt
\ No newline at end of file
index 1ce8d05..23da74a 100644 (file)
@@ -64,10 +64,13 @@ class ComponentJythonExecutorTest {
 
 
         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, "ResourceAssignmentComponent")
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "activate-jython")
+
+        val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+        metaData.putJsonElement("activate-jython-step-inputs", stepMetaData)
         executionServiceInput.metadata = metaData
 
         componentJythonExecutor.apply(executionServiceInput)
index a7d573c..62adde7 100644 (file)
@@ -23,7 +23,6 @@ import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
 import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor
 import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor
 import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor
@@ -45,7 +44,7 @@ import kotlin.test.assertTrue
  * @author Brinda Santh DATE : 8/15/2018
  */
 @RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
+@ContextConfiguration(classes = [ResourceResolutionService::class,
     InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
     DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
 class ResourceResolutionServiceTest {
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
new file mode 100644 (file)
index 0000000..3b5722d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.core
+
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.context.annotation.Configuration
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+    @Value("\${blueprintsprocessor.blueprint-deploy-path}")
+    lateinit var deployPath: String
+
+    @Value("\${blueprintsprocessor.blueprint-archive-path}")
+    lateinit var archivePath: String
+
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt
deleted file mode 100644 (file)
index 80ad0e6..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*\r
- *  Copyright Â© 2017-2018 AT&T Intellectual Property.\r
- *  Modifications Copyright Â© 2018 IBM.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.core.factory\r
-\r
-import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.context.ApplicationContextAware\r
-import org.springframework.context.annotation.Configuration\r
-\r
-/**\r
- * ResourceAssignmentProcessorFactory\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Configuration\r
-open class ResourceAssignmentProcessorFactory : ApplicationContextAware {\r
-\r
-    private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)\r
-\r
-    var resourceAssignmentProcessors: MutableMap<String, ResourceAssignmentProcessor> = hashMapOf()\r
-\r
-    fun getInstance(instanceName: String): ResourceAssignmentProcessor? {\r
-        log.trace("looking for Resource Assignment Processor : {}", instanceName)\r
-        return resourceAssignmentProcessors.get(instanceName)\r
-    }\r
-\r
-    fun injectInstance(instanceName: String, resourceAssignmentProcessor: ResourceAssignmentProcessor) {\r
-        this.resourceAssignmentProcessors[instanceName] = resourceAssignmentProcessor\r
-    }\r
-\r
-    override fun setApplicationContext(context: ApplicationContext) {\r
-        resourceAssignmentProcessors = context.getBeansOfType(ResourceAssignmentProcessor::class.java)\r
-        log.info("Injected Resource Assignment Processor : {}", resourceAssignmentProcessors)\r
-    }\r
-}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt
new file mode 100644 (file)
index 0000000..6484796
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.core.interfaces
+
+interface BluePrintCatalogService {
+    /**
+     * Get the Blueprint from Data Base and Download it under working directory and return the path path
+     */
+    fun prepareBluePrint(name: String, version: String): String
+}
\ No newline at end of file
index e26af0f..91912c8 100644 (file)
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-test-junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito2</artifactId>
+        </dependency>
     </dependencies>
 </project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt
new file mode 100644 (file)
index 0000000..8e06787
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintCatalogServiceImpl(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration) : BluePrintCatalogService {
+
+    override fun prepareBluePrint(name: String, version: String): String {
+        //TODO("Get the Blueprint from the DB")
+        return bluePrintCoreConfiguration.deployPath.plus(File.separator).plus(name).plus(File.separator).plus(version)
+
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
new file mode 100644 (file)
index 0000000..aa44a06
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class ExecutionServiceHandler(private val bluePrintCatalogService: BluePrintCatalogService,
+                              private val blueprintDGExecutionService: BlueprintDGExecutionService) {
+
+    private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
+
+    fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+        val requestId = executionServiceInput.commonHeader.requestId
+        log.info("processing request id $requestId")
+
+        val actionIdentifiers = executionServiceInput.actionIdentifiers
+
+        val blueprintName = actionIdentifiers.blueprintName
+        val blueprintVersion = actionIdentifiers.blueprintVersion
+
+        val basePath = bluePrintCatalogService.prepareBluePrint(blueprintName, blueprintVersion)
+        log.info("blueprint base path $basePath")
+
+        val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath)
+
+        return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
+    }
+
+
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
new file mode 100644 (file)
index 0000000..e9e1030
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.selfservice.api
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [MockBluePrintCatalogService::class,
+    MockBlueprintDGExecutionService::class, ExecutionServiceHandler::class])
+class ExecutionServiceHandlerTest {
+
+    @Autowired
+    lateinit var executionServiceHandler: ExecutionServiceHandler
+
+    @Test
+    fun testProcess() {
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+        executionServiceHandler.process(executionServiceInput)
+
+    }
+
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt
new file mode 100644 (file)
index 0000000..bc200f4
--- /dev/null
@@ -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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+import kotlin.test.assertNotNull
+
+@Service
+class MockBlueprintDGExecutionService : BlueprintDGExecutionService {
+    override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+        assertNotNull(executionServiceInput, "failed to get executionServiceInput")
+
+        val executionServiceOutput = ExecutionServiceOutput()
+        executionServiceOutput.commonHeader = executionServiceInput.commonHeader
+        return executionServiceOutput
+    }
+}
+
+@Service
+class MockBluePrintCatalogService : BluePrintCatalogService {
+    override fun prepareBluePrint(name: String, version: String): String {
+        assertNotNull(name, "failed to get blueprint Name")
+        assertNotNull(version, "failed to get blueprint version")
+        return "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json
new file mode 100644 (file)
index 0000000..a6eb7a8
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "activate",
+    "mode": "sync"
+  },
+  "payload": {
+    "activate-request": {
+      "activate-properties": {
+        "request-id": "1234",
+        "action-name": "activate",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  },
+  "metadata": {
+    "current-node-template": "resource-assignment-py",
+    "current-step": "resource-assignment-py",
+    "current-operation": "process",
+    "current-interface": "ResourceAssignmentComponent"
+  }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..a816a06
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright Â© 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index dfdf625..37f1492 100644 (file)
 package org.onap.ccsdk.apps.blueprintsprocessor.services.execution\r
 \r
 \r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.JsonNodeFactory\r
+import com.fasterxml.jackson.databind.node.NullNode\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.getAsString\r
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement\r
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
 import org.slf4j.LoggerFactory\r
 \r
@@ -30,6 +35,7 @@ import org.slf4j.LoggerFactory
  * @author Brinda Santh\r
  */\r
 abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {\r
+    @Transient\r
     private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)\r
 \r
     var executionServiceInput: ExecutionServiceInput? = null\r
@@ -41,29 +47,59 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
     var interfaceName: String = ""\r
     var operationName: String = ""\r
     var nodeTemplateName: String = ""\r
+    var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
 \r
     override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {\r
+        checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
 \r
-        this.executionServiceInput = this.executionServiceInput\r
+        this.executionServiceInput = executionServiceInput\r
 \r
         processId = executionServiceInput.commonHeader.requestId\r
         workflowName = executionServiceInput.actionIdentifiers.actionName\r
 \r
         val metadata = executionServiceInput.metadata\r
         stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)\r
-        nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
-        interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
-        operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+        log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")\r
+\r
+        val operationInputs = metadata.get("$stepName-step-inputs") ?: JsonNodeFactory.instance.objectNode()\r
+\r
+        operationInputs.fields().forEach {\r
+            this.operationInputs[it.key] = it.value\r
+        }\r
+\r
+        nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
+        interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
+        operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+\r
+\r
+        val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+        this.operationInputs.putAll(operationResolvedProperties)\r
+\r
 \r
-        checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
 \r
-        log.info("prepareRequest...")\r
         return executionServiceInput\r
     }\r
 \r
     override fun prepareResponse(): ExecutionServiceOutput {\r
         log.info("Preparing Response...")\r
+        executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader\r
+\r
+        // Resolve the Output Expression\r
+        val operationResolvedProperties = bluePrintRuntimeService!!\r
+                .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+        val metadata = executionServiceOutput.metadata\r
+        metadata.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, stepName)\r
+        metadata.putJsonElement("$stepName-step-outputs", operationResolvedProperties)\r
+\r
+        // Populate Status\r
+        val status = Status()\r
+        status.eventType = "EVENT-COMPONENT-EXECUTED"\r
+        status.code = 200\r
+        status.message = BluePrintConstants.STATUS_SUCCESS\r
+        executionServiceOutput.status = status\r
         return this.executionServiceOutput\r
     }\r
 \r
@@ -72,4 +108,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
         process(executionServiceInput)\r
         return prepareResponse()\r
     }\r
+\r
+    fun getOperationInput(key: String): JsonNode {\r
+        return operationInputs.get(key) ?: NullNode.instance\r
+    }\r
 }
\ No newline at end of file
index 993f10e..9bb562b 100644 (file)
@@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
 import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
@@ -55,14 +54,17 @@ class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: Blueprint
                 WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
 
         // Populate the DG Path
-        val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
-                .plus(File.separator).plus(artifactDefinition.file)
+        val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
 
         log.info("Executing directed graph ($dgFilePath)")
 
         // Create DG instance
         val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
 
+        // Assign Workflow inputs
+        val input = executionServiceInput.payload.get("$workflowName-request")
+        bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
         // Execute the DG
         return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
 
index ace9f27..87c0c53 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
 
+import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext
 import org.onap.ccsdk.sli.core.sli.SvcLogicException
 import org.onap.ccsdk.sli.core.sli.SvcLogicNode
@@ -57,13 +60,27 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
             // Get the Component Name, NodeTemplate type is mapped to Component Name
             val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
 
-            log.info("executing node template($nodeTemplateName) component($componentName)")
+            val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+            val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+            log.info("executing node template($nodeTemplateName) component($componentName) interface($interfaceName) operation($operationName)")
             // Get the Component Instance
             val plugin = this.getComponentFunction(componentName)
             // Set the Blueprint Service
             plugin.bluePrintRuntimeService = ctx.getBluePrintService()
 
             val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+            val metaData = executionInput.metadata
+            metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, nodeTemplateName)
+            // Populate Step Meta Data
+            val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+            metaData.putJsonElement("$nodeTemplateName-step-inputs", stepMetaData)
             // Get the Request from the Context and Set to the Function Input and Invoke the function
             val executionOutput = plugin.apply(executionInput)
 
index 46bb6f0..2d0dff5 100644 (file)
@@ -43,7 +43,7 @@ class BlueprintDGExecutionServiceTest {
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
                 "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
 
-        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
 
         blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
 
index 341b6f8..2c1c40c 100644 (file)
@@ -20,7 +20,6 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
@@ -34,26 +33,31 @@ class BlueprintServiceLogicTest {
 
     private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
 
-    val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
-            "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
-
-    val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
-
     @Autowired
-    lateinit var blueprintSvcLogicService: BlueprintSvcLogicService
+    lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
 
     @Test
     fun testExecuteGraphWithSingleComponent() {
 
-        val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml")
-        blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+
+
+        blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
 
     }
 
     @Test
     fun testExecuteGraphWithMultipleComponents() {
-        val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml")
-        blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+
+        blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
 
     }
 
index 747be76..9f7a9c9 100644 (file)
@@ -17,9 +17,8 @@
 package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock
 
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
 import org.slf4j.LoggerFactory
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
@@ -27,7 +26,7 @@ import org.springframework.context.annotation.Configuration
 @Configuration
 open class MockComponentConfiguration {
 
-    @Bean(name = ["component-resource-assignment", "component-netconf-executor"])
+    @Bean(name = ["component-resource-assignment", "component-netconf-executor", "component-jython-executor"])
     open fun createComponentFunction(): AbstractComponentFunction {
         return MockComponentFunction()
     }
@@ -35,12 +34,13 @@ open class MockComponentConfiguration {
 
 class MockComponentFunction : AbstractComponentFunction() {
 
-    private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
 
     override fun process(executionRequest: ExecutionServiceInput) {
-        log.info("Processing component..")
+        log.info("Processing component : ${operationInputs}")
 
-        this.executionServiceOutput = ExecutionServiceOutput()
+        bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+                "assignment-params", "params".asJsonPrimitive())
     }
 
     override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
new file mode 100644 (file)
index 0000000..d63b1d3
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "assign-activate",
+    "mode": "sync"
+  },
+  "payload": {
+    "assign-activate-request": {
+      "assign-activate-properties": {
+        "request-id": "1234",
+        "action-name": "assign-activate",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
deleted file mode 100644 (file)
index 20401fd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "commonHeader" : {
-    "originatorId" : "System",
-    "requestId" : "1234",
-    "subRequestId" : "1234-12234"
-  },
-  "actionIdentifiers" : {
-    "blueprintName" : "baseconfiguration",
-    "blueprintVersion" : "1.0.0",
-    "actionName" : "activate",
-    "mode" : "sync"
-  },
-  "payload" : { },
-  "metadata" : {
-    "current-node-template" : "resource-assignment-py",
-    "current-step" : "resource-assignment-py",
-    "current-operation" : "process",
-    "current-interface" : "ResourceAssignmentComponent"
-  }
-}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
new file mode 100644 (file)
index 0000000..ce7bc8e
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "resource-assignment",
+    "mode": "sync"
+  },
+  "payload": {
+    "resource-assignment-request": {
+      "resource-assignment-properties": {
+        "request-id": "1234",
+        "action-name": "resource-assignment",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  }
+}
\ No newline at end of file
index 2e58b53..1ba3257 100644 (file)
@@ -20,7 +20,6 @@ import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
-import org.junit.Test;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;\r