diff options
Diffstat (limited to 'components')
22 files changed, 706 insertions, 118 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 0517e90b..167496eb 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -29,6 +29,9 @@ object BluePrintConstants { const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
+ const val STATUS_SUCCESS: String = "success"
+ const val STATUS_FAILURE: String = "failure"
+
const val TYPE_DEFAULT: String = "default"
const val DATA_TYPE_STRING: String = "string"
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index c32e15f8..4d1d9b65 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -49,6 +49,10 @@ fun Double.asJsonPrimitive(): DoubleNode { return DoubleNode.valueOf(this)
}
+fun MutableMap<String, *>.asJsonNode(): JsonNode {
+ return JacksonUtils.jsonNodeFromObject(this)
+}
+
fun format(message: String, vararg args: Any?): String {
if (args != null && args.isNotEmpty()) {
return MessageFormatter.arrayFormat(message, args).message
@@ -75,17 +79,17 @@ fun <T : Any> MutableMap<String, *>.castValue(key: String, valueType: KClass<T>) fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {
when (value) {
is JsonNode ->
- this.put(key, value)
+ this[key] = value
is String ->
- this.put(key, TextNode(value))
+ this[key] = TextNode(value)
is Boolean ->
- this.put(key, BooleanNode.valueOf(value))
+ this[key] = BooleanNode.valueOf(value)
is Int ->
- this.put(key, IntNode.valueOf(value.toInt()))
+ this[key] = IntNode.valueOf(value.toInt())
is Double ->
- this.put(key, DoubleNode.valueOf(value.toDouble()))
+ this[key] = DoubleNode.valueOf(value.toDouble())
else ->
- this.put(key, JacksonUtils.jsonNodeFromObject(value))
+ this[key] = JacksonUtils.jsonNodeFromObject(value)
}
}
@@ -97,6 +101,14 @@ fun MutableMap<String, JsonNode>.getAsBoolean(key: String): Boolean { return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)")
}
+fun MutableMap<String, JsonNode>.getAsInt(key: String): Int {
+ return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)")
+}
+
+fun MutableMap<String, JsonNode>.getAsDouble(key: String): Double {
+ return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)")
+}
+
// Checks
fun checkNotEmpty(value: String?): Boolean {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt index 6add70e6..0b9f1f18 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt @@ -22,6 +22,8 @@ import java.util.function.Function interface BlueprintFunctionNode<T, R> : Function<T, R> { + fun getName(): String + @Throws(BluePrintProcessorException::class) fun prepareRequest(executionRequest: T): T diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index cce6d904..84af3f98 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -57,6 +57,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName)
?: throw BluePrintException("could't get workflow($workFlowName)")
+ fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs
+
fun workflowStepByName(workFlowName: String, stepName: String): Step {
return workflowByName(workFlowName).steps?.get(stepName)
?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 84ba1047..448a06a8 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
@@ -211,15 +210,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignments: MutableMap<String, Any> =
bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>
- ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " +
- "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))
+ ?: hashMapOf()
val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type
val nodeTypeInterfaceOperationInputs: MutableMap<String, PropertyDefinition> =
bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName)
- ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +
- "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))
+ ?: hashMapOf()
log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments)
@@ -258,15 +255,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignments: MutableMap<String, Any> =
bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>
- ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " +
- "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))
+ ?: hashMapOf()
val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type
val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> =
bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName)
- ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +
- "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))
+ ?: hashMapOf()
// Iterate Node Type Properties
nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->
@@ -435,10 +430,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {
log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())
+ val dynamicInputPropertiesName = "$workflowName-properties"
+
bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property ->
- val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)
- ?: NullNode.getInstance()
- setInputValue(propertyName, property, valueNode)
+ if (propertyName != dynamicInputPropertiesName) {
+ val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)
+ ?: NullNode.getInstance()
+ setInputValue(propertyName, property, valueNode)
+ }
+ }
+
+ val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName)
+
+ workflowDynamicInputs?.let {
+ bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property ->
+ val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName)
+ ?: NullNode.getInstance()
+ setInputValue(propertyName, property, valueNode)
+
+ }
}
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 947eb41e..36c141f5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -197,8 +197,7 @@ If Property Assignment is Expression. }
fun artifactContent(artifactDefinition: ArtifactDefinition): String {
- val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
- ?: throw BluePrintException("failed to get property (${BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH}) from getStore")
+ val bluePrintBasePath: String = bluePrintContext.rootPath
if (artifactDefinition.repository != null) {
TODO()
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 index 00000000..f02524ff --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -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 diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index f53f8615..40210142 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -122,6 +122,11 @@ object JacksonUtils { }
@JvmStatic
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
+
+ @JvmStatic
fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
val objectMapper = jacksonObjectMapper()
val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
@@ -149,6 +154,13 @@ object JacksonUtils { }
@JvmStatic
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return getMapFromJson(content, valueType)
+ }
+
+ @JvmStatic
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto new file mode 100644 index 00000000..55f9466e --- /dev/null +++ b/components/model-catalog/api-definition/proto/BluePrintManagement.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.management.api; + +message BluePrintUploadInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; + FileChunk fileChunk = 4; +} + +message FileChunk { + bytes chunk = 1; +} + +message BluePrintUploadOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message BluePrintRemoveInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; +} + +message BluePrintRemoveOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + string timestamp = 1; + int32 code = 2; + string message = 3; + string errorMessage = 4; +} + +service BluePrintManagementService { + rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintUploadOutput); + rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintRemoveOutput); +} diff --git a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto new file mode 100644 index 00000000..8fa4a13f --- /dev/null +++ b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.processing.api; + +message ExecutionServiceInput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + google.protobuf.Struct payload = 3; +} + +message ExecutionServiceOutput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + Status status = 3; + google.protobuf.Struct payload = 4; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; + Flag flag = 5; +} + +message Flag { + bool isForce = 1; + int32 ttl = 2; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + int32 code = 1; + string errorMessage = 2; + string message = 3; + string eventType = 4; + string timestamp = 5; +} + +service BluePrintProcessingService { + rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); +} diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 04e0efce..446932d5 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -38,6 +38,32 @@ } }, "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": { @@ -64,6 +90,32 @@ } } }, + "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": { @@ -84,6 +136,9 @@ "resource-id": { "get_input": "hostname" }, + "artifact-prefix-names": [ + "baseconfig" + ], "template-content": { "get_artifact": [ "SELF", @@ -162,6 +217,12 @@ "implementation": { "primary": "component-script" }, + "inputs": { + "instance-dependencies": [ + "json-parser-service", + "netconf-rpc-service" + ] + }, "outputs": { "response-data": "", "status": "" @@ -181,30 +242,18 @@ "workflows": { "resource-assignment": { "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { + "resource-assignment-properties": { "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" } ] } @@ -212,21 +261,9 @@ }, "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": { @@ -235,7 +272,26 @@ "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" } ] } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json index caee773b..c457086c 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -1,3 +1,36 @@ -{ - "assignments": "Sample Assignments" -}
\ No newline at end of file +[ + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + ] + }, + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "vnf_name", + "input-param": false, + "property": { + "type": "string" + }, + "dictionary-name": "vnf_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + } +] diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 6ca1ffde..569b668a 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -19,6 +19,75 @@ } }, "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 diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 139ebb1a..6e8d839e 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -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": { @@ -69,6 +69,14 @@ "required": true, "type": "string" }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "template-content": { "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", "required": true, @@ -108,6 +116,16 @@ "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.", diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json new file mode 100644 index 00000000..557f6efc --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json @@ -0,0 +1,62 @@ +{ + "service-instance-id": { + "name": "service-instance-id", + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by": "Singal, Kapil <ks220y@att.com>", + "property": { + "description": "To be provided", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf-id": { + "name": "vnf-id", + "tags": "vnf-id", + "updated-by": "Singal, Kapil <ks220y@att.com>", + "property": { + "description": "vnf-id", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf_name": { + "name": "vnf_name", + "tags": "vnf_name", + "updated-by": "Singal, Kapil <ks220y@att.com>", + "property": { + "description": "vnf_name", + "type": "string" + }, + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json deleted file mode 100644 index 0e0dcd23..00000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml index d256bbd2..2f6d2eda 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml @@ -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> diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml new file mode 100644 index 00000000..eb41b7df --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> + +<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='ResourceAssignAndActivate' mode='sync'> + <block atomic="true"> + <execute plugin="resource-assignment" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <execute plugin="activate-jython" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml new file mode 100644 index 00000000..a197877f --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml @@ -0,0 +1,34 @@ +<!-- + ~ 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. + --> + +<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='ResourceAssignment' mode='sync'> + <block atomic="true"> + <execute plugin="resource-assignment" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json index a29a875c..51d70ede 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -11,12 +11,12 @@ "operations": {
"process": {
"inputs": {
- "template-name": {
+ "template-name": {
"description": "Service Template Name.",
"required": true,
"type": "string"
},
- "template-version": {
+ "template-version": {
"description": "Service Template Version.",
"required": true,
"type": "string"
@@ -34,6 +34,14 @@ "type": "string"
}
},
+ "artifact-prefix-names": {
+ "required": false,
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"request-id": {
"description": "Request Id, Unique Id for the request.",
"required": true,
diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 8a779c1d..03656ebd 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -35,6 +35,7 @@ <kotlin.maven.version>1.3.10</kotlin.maven.version> <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version> <grpc.version>1.16.1</grpc.version> + <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version> <eelf.version>1.0.0</eelf.version> <guava.version>26.0-jre</guava.version> <springfox.swagger2.version>2.9.2</springfox.swagger2.version> @@ -92,6 +93,11 @@ <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> <version>1.7</version> @@ -150,6 +156,11 @@ <artifactId>grpc-stub</artifactId> <version>${grpc.version}</version> </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java-util</artifactId> + <version>${protobuff.java.utils.version}</version> + </dependency> <!-- Database --> @@ -216,6 +227,10 @@ <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> </dependency> @@ -247,6 +262,24 @@ <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-kotlin</artifactId> </dependency> + <!-- GRPC Dependencies --> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-netty</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-protobuf</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-stub</artifactId> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java-util</artifactId> + </dependency> + </dependencies> <build> diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt deleted file mode 100644 index 327d50ac..00000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications 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.resource.dict - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.slf4j.LoggerFactory - -abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> { - - private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) - - private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null - - open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { - this.bluePrintRuntimeService = bluePrintRuntimeService - } - - open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> { - return this.bluePrintRuntimeService!! - } - - override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment { - log.info("prepareRequest...") - return resourceAssignment - } - - override fun prepareResponse(): ResourceAssignment { - log.info("Preparing Response...") - return ResourceAssignment() - } - - override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment { - prepareRequest(executionServiceInput) - process(executionServiceInput) - return prepareResponse() - } - - override abstract fun process(executionRequest: ResourceAssignment) - - override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) -}
\ No newline at end of file |