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
return DoubleNode.valueOf(this)\r
}\r
\r
+fun MutableMap<String, *>.asJsonNode(): JsonNode {\r
+ return JacksonUtils.jsonNodeFromObject(this)\r
+}\r
+\r
fun format(message: String, vararg args: Any?): String {\r
if (args != null && args.isNotEmpty()) {\r
return MessageFormatter.arrayFormat(message, args).message\r
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
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
interface BlueprintFunctionNode<T, R> : Function<T, R> {
+ fun getName(): String
+
@Throws(BluePrintProcessorException::class)
fun prepareRequest(executionRequest: T): T
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
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
\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
\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
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
}\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
--- /dev/null
+/*
+ * 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
return objectMapper.writeValueAsString(any)\r
}\r
\r
+ @JvmStatic\r
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
+ return getListFromJson(node.toString(), valueType)\r
+ }\r
+\r
@JvmStatic\r
fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
val objectMapper = jacksonObjectMapper()\r
return objectMapper.readValue(content, typeRef)\r
}\r
\r
+ @JvmStatic\r
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ return getMapFromJson(content, valueType)\r
+ }\r
+\r
@JvmStatic\r
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
--- /dev/null
+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);
+}
--- /dev/null
+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);
+}
}
},
"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": {
"resource-id": {
"get_input": "hostname"
},
+ "artifact-prefix-names": [
+ "baseconfig"
+ ],
"template-content": {
"get_artifact": [
"SELF",
"implementation": {
"primary": "component-script"
},
+ "inputs": {
+ "instance-dependencies": [
+ "json-parser-service",
+ "netconf-rpc-service"
+ ]
+ },
"outputs": {
"response-data": "",
"status": ""
"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"
}
]
}
},
"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"
}
]
}
-{
- "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"
+ ]
+ }
+]
}
},
"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
{
"node_types": {
"dg-activate": {
- "description": "This is BPMN Activate node type",
+ "description": "This is Generic Directed Graph Type",
"version": "1.0.0",
"properties": {
"content": {
"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,
"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.",
--- /dev/null
+{
+ "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
+++ /dev/null
-{
-
-}
\ No newline at end of file
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>
</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>
<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'>
"operations": {\r
"process": {\r
"inputs": {\r
- "template-name": {\r
+ "template-name": {\r
"description": "Service Template Name.",\r
"required": true,\r
"type": "string"\r
},\r
- "template-version": {\r
+ "template-version": {\r
"description": "Service Template Version.",\r
"required": true,\r
"type": "string"\r
"type": "string"\r
}\r
},\r
+ "artifact-prefix-names": {\r
+ "required": false,\r
+ "description": "Template , Resource Assignment Artifact Prefix names",\r
+ "type": "list",\r
+ "entry_schema": {\r
+ "type": "string"\r
+ }\r
+ },\r
"request-id": {\r
"description": "Request Id, Unique Id for the request.",\r
"required": true,\r
<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>
<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>
<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 -->
<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>
<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>
**/.springBeans
**/.directory
+**/transaction.log
**/*versionsBackup
**/blackDuckHub*
**/*.jsonld
\ No newline at end of file
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>selfservice-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
--- /dev/null
+/*
+ * 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;
+
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Component;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshedEvent> {
+
+ private static Logger log = LoggerFactory.getLogger(BlueprintGRPCServer.class);
+
+ @Autowired
+ private BluePrintProcessingGRPCHandler bluePrintProcessingGRPCHandler;
+
+ @Autowired
+ private BluePrintManagementGRPCHandler bluePrintManagementGRPCHandler;
+
+ @Value("${blueprintsprocessor.grpcPort}")
+ private Integer grpcPort;
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent event) {
+ try {
+ log.info("Starting Blueprint Processor GRPC Starting..");
+ Server server = ServerBuilder
+ .forPort(grpcPort)
+ .addService(bluePrintProcessingGRPCHandler)
+ .addService(bluePrintManagementGRPCHandler)
+ .build();
+
+ server.start();
+ log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
+ server.awaitTermination();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
+import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
+import org.springframework.boot.web.server.WebServer;
+import org.springframework.http.server.reactive.HttpHandler;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintHttpServer {
+ private static Logger log = LoggerFactory.getLogger(BlueprintHttpServer.class);
+
+ @Value("${blueprintsprocessor.httpPort}")
+ private Integer httpPort;
+
+ @Autowired
+ HttpHandler httpHandler;
+
+ WebServer http;
+
+ @PostConstruct
+ public void start() {
+ ReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(httpPort);
+ this.http = factory.getWebServer(this.httpHandler);
+ this.http.start();
+ }
+
+ @PreDestroy
+ public void stop() {
+ this.http.stop();
+ }
+}
\r
package org.onap.ccsdk.apps.blueprintsprocessor;\r
\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
+\r
import org.springframework.context.annotation.Bean;\r
import springfox.documentation.builders.PathSelectors;\r
import springfox.documentation.builders.RequestHandlerSelectors;\r
import springfox.documentation.spi.DocumentationType;\r
import springfox.documentation.spring.web.plugins.Docket;\r
\r
-import java.util.Arrays;\r
import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
\r
/**\r
* SwaggerConfig\r
#\r
-# Copyright © 2017-2018 AT&T Intellectual Property.\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
# 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
-#
\ No newline at end of file
+#\r
+#logging.level.web=DEBUG\r
+blueprintsprocessor.grpcEnable=false\r
+blueprintsprocessor.httpPort=8080\r
+blueprintsprocessor.grpcPort=9111\r
+# Blueprint Processor File Execution and Handling Properties\r
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy\r
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive\r
+# Primary Database Configuration\r
+blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl\r
+blueprintsprocessor.db.primary.username=sdnctl\r
+blueprintsprocessor.db.primary.password=sdnctl\r
+blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver\r
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=validate\r
+blueprintsprocessor.db.primary.hibernateDDLAuto=none\r
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy\r
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect
\ No newline at end of file
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
\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
}\r
\r
@Test\r
- public void testSample(){\r
+ public void testSample() {\r
Assert.assertNotNull("Failed to create Application Context ", context);\r
}\r
\r
--- /dev/null
+#
+# 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.
+#
+# Blueprint Processor File Execution and Handling Properties
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
+# Primary Database Configuration
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>functions</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>netconf-executor</artifactId>
+ <name>Blueprints Processor Function - Netconf Executor</name>
+ <description>Blueprints Processor Function - Netconf Executor</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>python-executor</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.netconf.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.ComponentJythonExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-netconf-executor")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentNetconfExecutor(private val netconfExecutorConfiguration: NetconfExecutorConfiguration,
+ private val pythonExecutorProperty: PythonExecutorProperty)
+ : ComponentJythonExecutor(pythonExecutorProperty) {
+
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+ override fun process(executionServiceInput: ExecutionServiceInput) {
+ super.process(executionServiceInput)
+ }
+}
\ No newline at end of file
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
-class ResourceResolutionConstants {
- companion object {
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+import org.springframework.stereotype.Service
- }
+@Service("json-parser-service")
+class JsonParserService {
}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.netconf.executor
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class NetconfExecutorConfiguration
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.netconf.executor
+
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service("netconf-rpc-service")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class NetconfRpcService {
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.netconf.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+class ComponentNetconfExecutorTest {
+
+ @Autowired
+ lateinit var componentNetconfExecutor: ComponentNetconfExecutor
+
+ @Test
+ fun testComponentNetconfExecutor() {
+
+ val executionServiceInput = ExecutionServiceInput()
+ val commonHeader = CommonHeader()
+ commonHeader.requestId = "1234"
+ executionServiceInput.commonHeader = commonHeader
+
+ val actionIdentifiers = ActionIdentifiers()
+ actionIdentifiers.blueprintName = "baseconfiguration"
+ actionIdentifiers.blueprintVersion = "1.0.0"
+ actionIdentifiers.actionName = "activate"
+ executionServiceInput.actionIdentifiers = actionIdentifiers
+
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+
+
+ 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")
+ // Set Step Inputs in Blueprint Runtime Service
+ bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
+
+ componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentNetconfExecutor.stepName = "activate-jython"
+
+ componentNetconfExecutor.apply(executionServiceInput)
+
+ }
+}
+
--- /dev/null
+<!--\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
+ <logger name="org.springframework.test" level="warn"/>\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
<modules>
<module>resource-resolution</module>
<module>python-executor</module>
+ <module>netconf-executor</module>
</modules>
<dependencies>
package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
@Component("component-jython-executor")
-class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
private var componentFunction: AbstractComponentFunction? = null
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
- override fun process(executionServiceInput: ExecutionServiceInput) {
-
- log.info("Processing : ${executionServiceInput.metadata}")
- checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
-
+ fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
.nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
- val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
- ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)")
+ val blueprintBasePath: String = bluePrintContext.rootPath
val artifactName: String = operationAssignment.implementation?.primary
?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
pythonPath.add(blueprintBasePath)
pythonPath.addAll(pythonExecutorProperty.modulePaths)
- val properties: MutableMap<String, Any> = hashMapOf()
- properties["log"] = log
+ val jythonInstances: MutableMap<String, Any> = hashMapOf()
+ jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
+
+ val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
+ ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+
+ instanceDependenciesNode.forEach { instanceName ->
+ jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
+ }
componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
- pythonPath, content, pythonClassName, properties)
+ pythonPath, content, pythonClassName, jythonInstances)
+ }
+
+
+ override fun process(executionServiceInput: ExecutionServiceInput) {
+
+ log.info("Processing : ${operationInputs}")
+ checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
+
+ // Populate Component Instance
+ populateJythonComponentInstance(executionServiceInput)
+ // Invoke Jython Component Script
componentFunction!!.process(executionServiceInput)
}
lateinit var applicationContext: ApplicationContext
- fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
- jythonContextInstance: MutableMap<String, Any>,
- dependencyInstanceNames: List<String>): AbstractComponentFunction {
+ fun getJythonComponentFunction(pythonClassName: String, content: String, pythonPath: MutableList<String>,
+ jythonContextInstance: MutableMap<String, Any>,
+ dependencyInstanceNames: List<String>): AbstractComponentFunction {
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
dependencyInstanceNames.forEach { instanceName ->
jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
@Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
lateinit var modulePaths: List<String>
+}
+
+class PythonExecutorConstants {
+ companion object {
+ const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
+ }
}
\ No newline at end of file
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.springframework.beans.factory.annotation.Autowired
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
-
class ComponentJythonExecutorTest {
@Autowired
lateinit var componentJythonExecutor: ComponentJythonExecutor
-
@Test
fun testPythonComponentInjection() {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
"./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
- componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ 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")
+ bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
-
- 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")
- executionServiceInput.metadata = metaData
+ componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentJythonExecutor.stepName = "activate-jython"
componentJythonExecutor.apply(executionServiceInput)
--- /dev/null
+/*
+ * 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.functions.python.executor.mock
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+open class MockInstanceConfiguration {
+ @Bean(name = ["json-parser-service", "netconf-rpc-service"])
+ open fun createComponentFunction(): MockJythonService {
+ return MockJythonService()
+ }
+}
+
+class MockJythonService {
+
+}
\ No newline at end of file
--- /dev/null
+/*\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
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
+\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.springframework.beans.factory.annotation.Autowired\r
+import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
+import org.springframework.context.ApplicationContext\r
+import org.springframework.context.annotation.Scope\r
+import org.springframework.stereotype.Component\r
+\r
+@Component("component-resource-resolution")\r
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {\r
+\r
+ @Autowired\r
+ private lateinit var applicationContext: ApplicationContext\r
+\r
+ override fun process(executionRequest: ExecutionServiceInput) {\r
+\r
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)\r
+\r
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)\r
+ ?: throw BluePrintProcessorException("coundn't transform ${artifactPrefixNamesNode.asText()} to string array")\r
+\r
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService!!, nodeTemplateName, artifactPrefixNames)\r
+\r
+ // Set Output Attributes\r
+ bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,\r
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())\r
+ }\r
+\r
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.resource.resolution
+
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+open class ResourceResolutionConfiguration
+
+
--- /dev/null
+/*
+ * 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.functions.resource.resolution
+
+class ResourceResolutionConstants {
+ companion object {
+ const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
+ const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val FILE_NAME_RESOURCE_DICTIONARY_TYPES = "resources_dictionary_types.json"
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*\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.functions.resource.resolution\r
+\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
+import org.slf4j.LoggerFactory\r
+import org.springframework.beans.factory.annotation.Autowired\r
+import org.springframework.context.ApplicationContext\r
+import org.springframework.stereotype.Service\r
+import java.io.File\r
+\r
+/**\r
+ * ResourceResolutionService\r
+ * @author Brinda Santh\r
+ * 8/14/2018\r
+ */\r
+\r
+@Service\r
+class ResourceResolutionService {\r
+\r
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)\r
+\r
+ @Autowired\r
+ private lateinit var applicationContext: ApplicationContext\r
+\r
+ fun registeredResourceSources(): List<String> {\r
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+ }\r
+\r
+\r
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
+ artifactNames: List<String>): MutableMap<String, String> {\r
+\r
+ val resolvedParams: MutableMap<String, String> = hashMapOf()\r
+ artifactNames.forEach { artifactName ->\r
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)\r
+ resolvedParams[artifactName] = resolvedContent\r
+ }\r
+ return resolvedParams\r
+ }\r
+\r
+\r
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String): String {\r
+\r
+ var resolvedContent = ""\r
+ // Velocity Artifact Definition Name\r
+ val templateArtifactName = "$artifactName-template"\r
+ // Resource Assignment Artifact Definition Name\r
+ val mappingArtifactName = "$artifactName-mapping"\r
+\r
+ log.info("Resolving resource for template artifact($templateArtifactName) with resource assignment artifact($mappingArtifactName)")\r
+\r
+ val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)\r
+\r
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)\r
+ as? MutableList<ResourceAssignment>\r
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
+\r
+ // Get the Resource Dictionary Name\r
+ val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)\r
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)\r
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DICTIONARY_TYPES)\r
+\r
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)\r
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
+\r
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)\r
+\r
+ // Check Template is there\r
+ val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)\r
+\r
+ // TODO ("Generate Param JSON from Resource Assignment")\r
+ val resolvedParamJsonContent = "{}"\r
+\r
+ if (templateContent.isNotEmpty()) {\r
+ // TODO ( "Mash Data and Content")\r
+ resolvedContent = "Mashed Content"\r
+\r
+ } else {\r
+ resolvedContent = resolvedParamJsonContent\r
+ }\r
+ return resolvedContent\r
+ }\r
+\r
+\r
+ fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
+ resourceAssignments: MutableList<ResourceAssignment>) {\r
+\r
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
+\r
+ bulkSequenced.map { batchResourceAssignments ->\r
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
+ .map { resourceAssignment ->\r
+ val dictionarySource = resourceAssignment.dictionarySource\r
+ val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)\r
+\r
+ val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor\r
+ ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +\r
+ "for resource assignment(${resourceAssignment.name})")\r
+ try {\r
+ // Set BluePrint Runtime Service\r
+ resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService\r
+ // Set Resource Dictionaries\r
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries\r
+ // Invoke Apply Method\r
+ resourceAssignmentProcessor.apply(resourceAssignment)\r
+ } catch (e: RuntimeException) {\r
+ resourceAssignmentProcessor.recover(e, resourceAssignment)\r
+ throw BluePrintProcessorException(e)\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@Service("resource-assignment-processor-db")
open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){
+ override fun getName(): String {
+ return "resource-assignment-processor-db"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
* limitations under the License.\r
*/\r
\r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
import org.springframework.stereotype.Service\r
\r
/**\r
@Service("resource-assignment-processor-default")\r
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
\r
+ override fun getName(): String {\r
+ return "resource-assignment-processor-default"\r
+ }\r
+\r
override fun process(executionRequest: ResourceAssignment) {\r
}\r
\r
* limitations under the License.\r
*/\r
\r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
import org.springframework.stereotype.Service\r
\r
/**\r
@Service("resource-assignment-processor-input")\r
open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
\r
+ override fun getName(): String {\r
+ return "resource-assignment-processor-input"\r
+ }\r
+\r
override fun process(executionRequest: ResourceAssignment) {\r
}\r
\r
* limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
- private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+
+ var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
- open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
- this.bluePrintRuntimeService = bluePrintRuntimeService
- }
- open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> {
- return this.bluePrintRuntimeService!!
+ open fun resourceDefinition(name: String): ResourceDefinition {
+ return resourceDictionaries.get(name)
+ ?: throw BluePrintProcessorException("couldn't get resource definition($name)")
}
override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
- log.info("prepareRequest...")
+ log.info("prepareRequest for ${resourceAssignment.name}, dictionary(${resourceAssignment.dictionaryName})," +
+ "source(${resourceAssignment.dictionarySource})")
return resourceAssignment
}
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@Service("resource-assignment-processor-mdsal")
open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ override fun getName(): String {
+ return "resource-assignment-processor-mdsal"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
+++ /dev/null
-/*\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
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
-\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
-import org.springframework.stereotype.Component\r
-\r
-@Component("component-resource-resolution")\r
-open class ResourceResolutionComponent : AbstractComponentFunction() {\r
- override fun process(executionRequest: ExecutionServiceInput) {\r
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
- }\r
-\r
- override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-/*\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.services.resolution\r
-\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
-import org.springframework.beans.factory.annotation.Autowired\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.stereotype.Service\r
-\r
-/**\r
- * ResourceResolutionService\r
- * @author Brinda Santh\r
- * 8/14/2018\r
- */\r
-\r
-@Service\r
-class ResourceResolutionService {\r
-\r
-\r
- @Autowired\r
- private lateinit var applicationContext: ApplicationContext\r
-\r
- fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {\r
- val resourceResolutionOutput = ResourceResolutionOutput()\r
- resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers\r
- resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader\r
- resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments\r
-\r
- process(resourceResolutionOutput.resourceAssignments)\r
-\r
- val status = Status()\r
- status.code = 200\r
- status.message = "Success"\r
- resourceResolutionOutput.status = status\r
-\r
- return resourceResolutionOutput\r
- }\r
-\r
- fun registeredResourceSources(): List<String> {\r
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
- }\r
-\r
- fun process(resourceAssignments: MutableList<ResourceAssignment>) {\r
-\r
- val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
-\r
- bulkSequenced.map { batchResourceAssignments ->\r
- batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
- .map { resourceAssignment ->\r
- val dictionarySource = resourceAssignment.dictionarySource\r
- val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)\r
-\r
- val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor\r
- ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +\r
- "for resource assignment(${resourceAssignment.name})")\r
- try {\r
- // Invoke Apply Method\r
- resourceAssignmentProcessor.apply(resourceAssignment)\r
- } catch (e: RuntimeException) {\r
- resourceAssignmentProcessor.recover(e, resourceAssignment)\r
- throw BluePrintProcessorException(e)\r
- }\r
- }\r
- }\r
- }\r
-}\r
--- /dev/null
+/*
+ * 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.functions.resource.resolution
+
+import com.fasterxml.jackson.databind.JsonNode
+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.core.utils.PayloadUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+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 = [ResourceResolutionComponent::class, ResourceResolutionService::class,
+ InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionComponentTest {
+
+ @Autowired
+ lateinit var resourceResolutionComponent: ResourceResolutionComponent
+
+ @Test
+ fun testProcess() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
+
+ resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
+ resourceResolutionComponent.stepName = "resource-assignment"
+ resourceResolutionComponent.apply(executionServiceInput)
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.resource.resolution
+
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * ResourceResolutionServiceTest
+ *
+ * @author Brinda Santh DATE : 8/15/2018
+ */
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionService::class,
+ InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionServiceTest {
+
+ private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
+
+ @Autowired
+ lateinit var resourceResolutionService: ResourceResolutionService
+
+
+ @Test
+ fun testRegisteredSource() {
+ val sources = resourceResolutionService.registeredResourceSources()
+ assertNotNull(sources, "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResource() {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
+
+ }
+
+}
+++ /dev/null
-/*
- * 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.services.resolution
-
-import com.fasterxml.jackson.databind.node.ObjectNode
-import org.apache.commons.collections.CollectionUtils
-import org.apache.commons.io.FileUtils
-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
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SimpleRestResourceAssignmentProcessor
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringRunner
-import java.io.File
-import java.nio.charset.Charset
-import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
-
-/**
- * ResourceResolutionServiceTest
- *
- * @author Brinda Santh DATE : 8/15/2018
- */
-@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
-class ResourceResolutionServiceTest {
-
- private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
-
- @Autowired
- lateinit var resourceResolutionService: ResourceResolutionService
-
-
- @Test
- fun testRegisteredSource() {
- val sources = resourceResolutionService.registeredResourceSources()
- assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
- }
-
- @Test
- @Throws(Exception::class)
- fun testResolveResource() {
-
- Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
-
- val resourceResolutionInputContent = FileUtils.readFileToString(
- File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset())
-
- val resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput::class.java)
- Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput)
-
- val resourceAssignmentContent = FileUtils.readFileToString(
- File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset())
- val batchResourceAssignment = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
-
- Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment))
- resourceResolutionInput!!.resourceAssignments = batchResourceAssignment as MutableList<ResourceAssignment>
-
- val inputContent = JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json") as ObjectNode
- Assert.assertNotNull("failed to populate input payload ", inputContent)
- resourceResolutionInput.payload = inputContent
- log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true))
-
- val resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput)
- Assert.assertNotNull("failed to populate output", resourceResolutionOutput)
-
- }
-
-}
"timestamp": "2012-04-23T18:25:43.511Z"\r
},\r
"payload": {\r
- },\r
- "resourceAssignments": [\r
- ]\r
+ "resource-assignment-request": {\r
+ "resource-assignment-properties": {\r
+ "request-id": "1234",\r
+ "action-name": "assign-activate",\r
+ "scope-type": "vnf-type",\r
+ "hostname": "localhost"\r
+ }\r
+ }\r
+ }\r
}\r
<packaging>jar</packaging>
<name>Blueprints Processor Core</name>
<description>Blueprints Processor Core</description>
-
<dependencies>
<dependency>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>db-lib</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>rest-lib</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
</dependencies>
</project>
--- /dev/null
+/*
+ * 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.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.core.env.Environment
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+ @Value("\${blueprintsprocessor.blueprintDeployPath}")
+ lateinit var deployPath: String
+
+ @Value("\${blueprintsprocessor.blueprintArchivePath}")
+ lateinit var archivePath: String
+
+}
+
+@Configuration
+open class BlueprintPropertyConfiguration {
+ @Autowired
+ lateinit var environment: Environment
+
+ @Bean
+ open fun bluePrintPropertyBinder(): Binder {
+ val configurationPropertySource = ConfigurationPropertySources.get(environment)
+ return Binder(configurationPropertySource)
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.boot.context.properties.bind.Bindable
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+
+ fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+ return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+ }
+}
\ No newline at end of file
package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data\r
\r
import com.fasterxml.jackson.annotation.JsonFormat\r
-import com.fasterxml.jackson.databind.JsonNode\r
import com.fasterxml.jackson.databind.node.ObjectNode\r
import io.swagger.annotations.ApiModelProperty\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
import java.util.*\r
\r
/**\r
* DATE : 8/15/2018\r
*/\r
\r
-open class ResourceResolutionInput {\r
- @get:ApiModelProperty(required = true)\r
- lateinit var commonHeader: CommonHeader\r
- @get:ApiModelProperty(required = true)\r
- lateinit var actionIdentifiers: ActionIdentifiers\r
- @get:ApiModelProperty(required = true)\r
- lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
- @get:ApiModelProperty(required = true)\r
- lateinit var payload: ObjectNode\r
-}\r
-\r
-open class ResourceResolutionOutput {\r
- @get:ApiModelProperty(required = true)\r
- lateinit var commonHeader: CommonHeader\r
- @get:ApiModelProperty(required = true)\r
- lateinit var actionIdentifiers: ActionIdentifiers\r
- @get:ApiModelProperty(required = true)\r
- lateinit var status: Status\r
- @get:ApiModelProperty(required = true)\r
- lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
-}\r
-\r
open class ExecutionServiceInput {\r
@get:ApiModelProperty(required = true)\r
lateinit var commonHeader: CommonHeader\r
lateinit var actionIdentifiers: ActionIdentifiers\r
@get:ApiModelProperty(required = true)\r
lateinit var payload: ObjectNode\r
- var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
}\r
\r
open class ExecutionServiceOutput {\r
var status: Status = Status()\r
@get:ApiModelProperty(required = true)\r
lateinit var payload: ObjectNode\r
- var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
}\r
\r
open class ActionIdentifiers {\r
+++ /dev/null
-/*\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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+
+class PayloadUtils {
+
+ companion object {
+
+ fun prepareInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+ }
+
+ fun prepareDynamicInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ val propertyFields = input.get("$workflowName-properties")
+ prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService, propertyFields)
+ }
+
+ fun prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode) {
+ payload.fields().forEach { property ->
+ val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
+ .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
+ bluePrintRuntimeService.put(path, property.value)
+ }
+ }
+ }
+}
\ No newline at end of file
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>commons</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>commons</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
- <artifactId>db-lib</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor DB Lib</name>
- <description>Blueprints Processor DB Lib</description>
+ <artifactId>db-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor DB Lib</name>
+ <description>Blueprints Processor DB Lib</description>
- <dependencies>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<scope>test</scope>
</dependency>
-
- </dependencies>
+ </dependencies>
</project>
--- /dev/null
+/*
+ * 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.db
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrintProperties) {
+
+ @Bean("primary-database-properties")
+ open fun getPrimaryProperties(): PrimaryDataSourceProperties {
+ return bluePrintProperties.propertyBeanType(DBLibConstants.PREFIX_DB_PRIMARY,
+ PrimaryDataSourceProperties::class.java)
+ }
+}
+
+class DBLibConstants {
+ companion object {
+ const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.db
+
+
+open class PrimaryDataSourceProperties {
+ lateinit var url: String
+ lateinit var username: String
+ lateinit var password: String
+ lateinit var driverClassName: String
+ lateinit var hibernateHbm2ddlAuto: String
+ lateinit var hibernateDDLAuto: String
+ lateinit var hibernateNamingStrategy: String
+ lateinit var hibernateDialect: String
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.db
+
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+
+interface BluePrintDBLibGenericService {
+
+ fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate
+
+ fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>>
+
+ fun update(sql: String, params: Map<String, Any>): Int
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.db.primary
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.PrimaryDataSourceProperties
+import org.slf4j.LoggerFactory
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Primary
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.jdbc.datasource.DriverManagerDataSource
+import org.springframework.orm.jpa.JpaTransactionManager
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
+import org.springframework.transaction.PlatformTransactionManager
+import java.util.*
+import javax.sql.DataSource
+
+@Configuration
+@EnableJpaRepositories(
+ basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.db.primary"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
+)
+open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
+ val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
+
+ @Primary
+ @Bean("primaryEntityManager")
+ open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
+ val em = LocalContainerEntityManagerFactoryBean()
+ em.dataSource = primaryDataSource()
+ em.setPackagesToScan(
+ "org.onap.ccsdk.apps.blueprintsprocessor.db.primary")
+
+ val vendorAdapter = HibernateJpaVendorAdapter()
+ em.jpaVendorAdapter = vendorAdapter
+ val properties = HashMap<String, Any>()
+ properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
+ properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect
+ em.jpaPropertyMap = properties
+ return em
+ }
+
+ @Primary
+ @Bean("primaryDataSource")
+ open fun primaryDataSource(): DataSource {
+ val dataSource = DriverManagerDataSource()
+ dataSource.setDriverClassName(primaryDataSourceProperties.driverClassName)
+ dataSource.url = primaryDataSourceProperties.url
+ dataSource.username = primaryDataSourceProperties.username
+ dataSource.password = primaryDataSourceProperties.password
+ return dataSource
+ }
+
+ @Primary
+ @Bean("primaryTransactionManager")
+ open fun primaryTransactionManager(): PlatformTransactionManager {
+ val transactionManager = JpaTransactionManager()
+ transactionManager.entityManagerFactory = primaryEntityManager().getObject()
+ log.info("Initialised Primary Transaction Manager for url ${primaryDataSourceProperties.url}")
+ return transactionManager
+ }
+
+ @Bean("primaryNamedParameterJdbcTemplate")
+ open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
+ return NamedParameterJdbcTemplate(primaryDataSource)
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.db.primary.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.stereotype.Service
+
+@Service
+class PrimaryDBLibGenericService(private val primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
+ : BluePrintDBLibGenericService {
+
+ override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
+ return primaryNamedParameterJdbcTemplate
+ }
+
+ override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
+ return primaryNamedParameterJdbcTemplate.queryForList(sql, params)
+ }
+
+ override fun update(sql: String, params: Map<String, Any>): Int {
+ return primaryNamedParameterJdbcTemplate.update(sql, params)
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.db.primary
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import javax.sql.DataSource
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BlueprintPropertyConfiguration::class, BluePrintProperties::class,
+ BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class PrimaryDatabaseConfigurationTest {
+
+ @Autowired
+ lateinit var primaryDataSource: DataSource
+
+ @Test
+ fun testPrimaryDatabaseConfiguration() {
+ assertNotNull(primaryDataSource, " failed to create primary data source")
+ }
+}
\ No newline at end of file
--- /dev/null
+# suppress inspection "UnusedProperty" for whole file
+#
+# 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.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
\ No newline at end of file
--- /dev/null
+<!--\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
+ <logger name="org.springframework.test" level="warn"/>\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
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
</dependency>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </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>
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>commons</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>commons</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
- <artifactId>rest-lib</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor Rest Lib</name>
- <description>Blueprints Processor Rest Lib</description>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-webflux</artifactId>
- </dependency>
- </dependencies>
+ <artifactId>rest-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Rest Lib</name>
+ <description>Blueprints Processor Rest Lib</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ </dependencies>
</project>
--- /dev/null
+/*
+ * 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.rest
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintRestLibConfiguration
+
+
+class RestLibConstants {
+ companion object {
+ const val TYPE_BASIC_AUTH = "basic-auth"
+ const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
+ const val TYPE_DME2_PROXY = "dme2-proxy"
+ const val TYPE_POLICY_MANAGER = "policy-manager"
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.rest
+
+open class RestClientProperties {
+ lateinit var type: String
+ lateinit var url: String
+ lateinit var userId: String
+}
+
+open class BasicAuthRestClientProperties : RestClientProperties() {
+ var passwd: String? = null
+}
+
+open class SSLBasicAuthRestClientProperties : RestClientProperties() {
+ lateinit var sslTrust: String
+ lateinit var sslTrustPasswd: String
+ lateinit var sslKey: String
+ lateinit var sslKeyPasswd: String
+}
+
+open class DME2RestClientProperties : RestClientProperties() {
+ lateinit var service: String
+ lateinit var subContext: String
+ lateinit var version: String
+ lateinit var envContext: String
+ lateinit var routeOffer: String
+ var partner: String? = null
+ lateinit var appId: String
+}
+
+open class PolicyManagerRestClientProperties : RestClientProperties() {
+ lateinit var env: String
+ lateinit var clientAuth: String
+ lateinit var authorisation: String
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+
+class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+
+ @Throws(BluePrintProcessorException::class)
+ fun restClientProperties(prefix: String): RestClientProperties {
+ val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
+ return when (type) {
+ RestLibConstants.TYPE_BASIC_AUTH -> {
+ basicAuthRestClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+ sslBasicAuthRestClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_DME2_PROXY -> {
+ dme2ProxyClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_POLICY_MANAGER -> {
+ policyManagerRestClientProperties(prefix)
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+ @Throws(BluePrintProcessorException::class)
+ fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+ val prefix = "blueprintsprocessor.restclient.$selector"
+ val beanProperties = restClientProperties(prefix)
+ when (beanProperties) {
+ is BasicAuthRestClientProperties -> {
+ return BasicAuthRestClientService(beanProperties)
+ }
+ is SSLBasicAuthRestClientProperties -> {
+ return SSLBasicAuthRestClientService(beanProperties)
+ }
+ is DME2RestClientProperties -> {
+ return DME2ProxyRestClientService(beanProperties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't get rest service for selector($selector)")
+ }
+ }
+
+ }
+
+ fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
+ }
+
+ fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
+ }
+
+ fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
+ }
+
+ fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
+ }
+}
+
+
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.springframework.web.reactive.function.client.WebClient
+
+interface BlueprintWebClientService {
+
+ fun webClient(): WebClient
+
+ fun <T> getResource(path: String, responseType: Class<T>): T
+
+ fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+
+ fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+
+}
+
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
--- /dev/null
+#\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
--- /dev/null
+/*
+ * 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.rest.service
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class])
+@TestPropertySource(properties =
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
+ "blueprintsprocessor.restclient.sample.userId=sampleuser"])
+
+class RestPropertyPlaceHolderConfigurationTest {
+
+ @Autowired
+ lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+
+ @Test
+ fun testRestClientProperties() {
+ val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample")
+ assertNotNull(properties, "failed to create property bean")
+ assertNotNull(properties.url, "failed to get url property in property bean")
+ }
+
+ @Test
+ fun testBlueprintWebClientService() {
+ val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+ assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
+ }
+
+}
+
--- /dev/null
+<!--\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
+ <logger name="org.springframework.test" level="warn"/>\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
<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>
\r
package org.onap.ccsdk.apps.blueprintsprocessor.resource.api;\r
\r
-import io.swagger.annotations.ApiOperation;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.ResourceResolutionService;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService;\r
import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.ResponseBody;\r
+import org.springframework.web.bind.annotation.RestController;\r
import reactor.core.publisher.Mono;\r
\r
/**\r
Mono<String> ping() {\r
return Mono.just("Success");\r
}\r
-\r
- @RequestMapping(path = "/resolve-mapping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)\r
- @ApiOperation(value = "Resolve Resource Mappings",\r
- notes = "Also returns a link to retrieve all students with rel - all-students")\r
- public @ResponseBody\r
- Mono<ResourceResolutionOutput> resolveResource(@RequestBody ResourceResolutionInput resourceResolutionInput) {\r
- return Mono.just(resourceResolutionService.resolveResource(resourceResolutionInput));\r
- }\r
}\r
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>inbounds</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>inbounds</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
- <artifactId>selfservice-api</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor Selfservice API</name>
- <description>Blueprints Processor Selfservice API</description>
+ <artifactId>selfservice-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Selfservice API</name>
+ <description>Blueprints Processor Selfservice API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>
+ com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}
+ </protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>
+ io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier}
+ </pluginArtifact>
+ <protoSourceRoot>./../../../../../components/model-catalog/api-definition</protoSourceRoot>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 io.grpc.stub.StreamObserver
+import org.apache.commons.io.FileUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.*
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+ : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
+
+ private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
+
+ override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver: StreamObserver<BluePrintUploadOutput>) {
+ val response = BluePrintUploadOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+ try {
+ val blueprintName = request.blueprintName
+ val blueprintVersion = request.blueprintVersion
+ val filePath = "${bluePrintCoreConfiguration.archivePath}/$blueprintName/$blueprintVersion"
+ val blueprintDir = File(filePath)
+
+ log.info("Re-creating blueprint directory(${blueprintDir.absolutePath})")
+ FileUtils.deleteDirectory(blueprintDir)
+ FileUtils.forceMkdir(blueprintDir)
+
+ val file = File("${blueprintDir.absolutePath}/$blueprintName.zip")
+ log.info("Writing CBA File under :${file.absolutePath}")
+
+ val fileChunk = request.fileChunk
+
+ file.writeBytes(fileChunk.chunk.toByteArray()).apply {
+ log.info("CBA file(${file.absolutePath} written successfully")
+ }
+ } catch (e: Exception) {
+ log.error("failed to upload file ", e)
+ }
+ responseObserver.onNext(response)
+ responseObserver.onCompleted()
+ }
+
+ override fun removeBlueprint(request: BluePrintRemoveInput?, responseObserver: StreamObserver<BluePrintRemoveOutput>?) {
+ //TODO
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 com.google.protobuf.util.JsonFormat
+import io.grpc.stub.StreamObserver
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+ : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
+
+ override fun process(request: ExecutionServiceInput,
+ responseObserver: StreamObserver<ExecutionServiceOutput>) {
+
+ val json = JsonFormat.printer().print(request)
+
+ //log.info("Received GRPC request ${json}")
+ //TODO( Handle Processing Response")
+ val response = ExecutionServiceOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+ responseObserver.onNext(response)
+ responseObserver.onCompleted()
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 com.google.protobuf.ByteString
+import io.grpc.testing.GrpcServerRule
+import org.apache.commons.io.FileUtils
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.apps.controllerblueprints.management.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.management.api.FileChunk
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import java.io.File
+import java.nio.file.Paths
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintManagementGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintManagementGRPCHandlerTest {
+
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+ @get:Rule
+ val grpcServerRule = GrpcServerRule().directExecutor()
+
+ @Autowired
+ lateinit var bluePrintManagementGRPCHandler: BluePrintManagementGRPCHandler
+
+ @BeforeTest
+ fun init() {
+ // Create a server, add service, start, and register for automatic graceful shutdown.
+ grpcServerRule.serviceRegistry.addService(bluePrintManagementGRPCHandler)
+ }
+
+ @AfterTest
+ fun cleanDir() {
+ FileUtils.deleteDirectory(File("./target/blueprints"))
+ }
+
+ @Test
+ fun testFileUpload() {
+ val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+ val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+ assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+
+ val commonHeader = CommonHeader.newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234")
+ .setSubRequestId("1234-56").build()
+
+ val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes()))
+ .build()
+
+ val input = BluePrintUploadInput.newBuilder()
+ .setCommonHeader(commonHeader)
+ .setBlueprintName("sample")
+ .setBlueprintVersion("1.0.0")
+ .setFileChunk(fileChunk)
+ .build()
+
+ val output = blockingStub.uploadBlueprint(input)
+ assertNotNull(output, "failed to get upload response")
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 com.google.protobuf.util.JsonFormat
+import io.grpc.testing.GrpcServerRule
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintProcessingGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintProcessingGRPCHandlerTest {
+
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+ @get:Rule
+ val grpcServerRule = GrpcServerRule().directExecutor()
+
+ @Autowired
+ lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
+
+ @BeforeTest
+ fun init() {
+ // Create a server, add service, start, and register for automatic graceful shutdown.
+ grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
+ }
+
+ @Test
+ fun testSelfServiceGRPCHandler() {
+
+ val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+ val commonHeader = CommonHeader.newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234")
+ .setSubRequestId("1234-56").build()
+
+ val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
+ val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
+ JsonFormat.parser().merge(jsonContent, payloadBuilder)
+
+ val input = ExecutionServiceInput.newBuilder()
+ .setCommonHeader(commonHeader)
+ .setPayload(payloadBuilder.build())
+ .build()
+
+ val response = blockingStub.process(input)
+ assertNotNull(response, "Response is null")
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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)
+
+ }
+
+}
+
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+#
+# 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.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
--- /dev/null
+{
+ "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"
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "activate-request": {
+ "activate-properties": {
+ "request-id": "1234",
+ "action-name": "activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<!--\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
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>db-lib</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>rest-lib</artifactId>
+ </dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
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 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.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\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.service.BluePrintRuntimeService\r
* @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
var interfaceName: String = ""\r
var operationName: String = ""\r
var nodeTemplateName: String = ""\r
+ var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
\r
+ override fun getName(): String {\r
+ return stepName\r
+ }\r
\r
override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {\r
+ checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
+\r
+ check(stepName.isNotEmpty()) { "failed to assign step name" }\r
\r
- this.executionServiceInput = this.executionServiceInput\r
+ this.executionServiceInput = executionServiceInput\r
\r
processId = executionServiceInput.commonHeader.requestId\r
+ check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }\r
+\r
workflowName = executionServiceInput.actionIdentifiers.actionName\r
+ check(workflowName.isNotEmpty()) { "couldn't get action name for step($stepName)" }\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
- checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
+ val operationInputs = bluePrintRuntimeService!!.get("$stepName-step-inputs")\r
+ ?: 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
+ check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }\r
+\r
+ interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
+ check(interfaceName.isNotEmpty()) { "couldn't get Interface name for step($stepName)" }\r
+\r
+ operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+ check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }\r
+\r
+\r
+ val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+ this.operationInputs.putAll(operationResolvedProperties)\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 stepOutputs = bluePrintRuntimeService!!\r
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+ bluePrintRuntimeService!!.put("$stepName-step-outputs", stepOutputs.asJsonNode())\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
process(executionServiceInput)\r
return prepareResponse()\r
}\r
+\r
+ fun getOperationInput(key: String): JsonNode {\r
+ return operationInputs[key]\r
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")\r
+ }\r
}
\ No newline at end of file
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
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
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.asJsonNode
+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
// 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()
+ plugin.stepName = nodeTemplateName
val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+ // Populate Step Meta Data
+ val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+ plugin.bluePrintRuntimeService!!.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+
// Get the Request from the Context and Set to the Function Input and Invoke the function
val executionOutput = plugin.apply(executionInput)
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)
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.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
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 applicationContext: ApplicationContext
@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)
+
+ }
+
+ @Test
+ fun testSingleton() {
+ val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ singleton1.stepName = "step1"
+ val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
+ }
+
+ @Test
+ fun testProtoTypeFunction() {
+ val stepName1 = "step1"
+ val stepName2 = "step2"
+ val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto1.stepName = stepName1
+
+ val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto2.stepName = stepName2
+
+ assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
+ assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
}
}
\ No newline at end of file
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.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
@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()
}
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) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("singleton-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+class SingletonComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : ${operationInputs}")
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("prototype-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class PrototypeComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : ${operationInputs}")
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
--- /dev/null
+{
+ "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
+++ /dev/null
-{
- "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
--- /dev/null
+{
+ "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
<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>
<sli.version>0.3.1</sli.version>
<guava.version>26.0-jre</guava.version>
<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>
<!-- SLI Version -->
<dependency>
<artifactId>resource-resolution</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>python-executor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>netconf-executor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Application Component 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>
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.ccsdk.apps.controllerblueprints;
-import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.google.common.collect.Lists;
+
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.ResponseMessageBuilder;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* SwaggerConfig
*
import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;\r
import org.springframework.beans.factory.config.ConfigurableBeanFactory;\r
import org.springframework.context.annotation.Scope;\r
-import org.springframework.context.annotation.ScopedProxyMode;\r
import org.springframework.stereotype.Service;\r
\r
import java.util.HashMap;\r
*/\r
\r
@Service\r
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)\r
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {\r
\r
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);\r
String artifactName = configModel.getArtifactName();\r
String artifactVersion = configModel.getArtifactVersion();\r
String author = configModel.getUpdatedBy();\r
- // configModel.setTags(artifactName);\r
+ \r
\r
if (StringUtils.isBlank(author)) {\r
throw new BluePrintException("Artifact Author is missing in the Service Template");\r
private ConfigModelRepository configModelRepository;\r
private ConfigModelContentRepository configModelContentRepository;\r
private ConfigModelCreateService configModelCreateService;\r
+ private static final String CONFIG_MODEL_ID_FAILURE_MSG= "failed to get config model id(%d) from repo";\r
\r
/**\r
* This is a ConfigModelService constructor.\r
if (dbConfigModel.isPresent()) {\r
configModel = dbConfigModel.get();\r
} else {\r
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
}\r
\r
return configModel;\r
}\r
}\r
} else {\r
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
}\r
\r
return cloneConfigModel;\r
configModelContentRepository.deleteByConfigModel(dbConfigModel.get());\r
configModelRepository.delete(dbConfigModel.get());\r
} else {\r
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
}\r
}\r
\r
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
<kotlin.version>1.3.10</kotlin.version>
<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>
<version>${kotlin.version}</version>
</dependency>
+ <!-- GRPC Dependencies -->
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <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 -->
<dependency>
<groupId>com.h2database</groupId>
* ONAP : CCSDK.apps
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
- System.out.println(beanName);
log.info(beanName);
}
log.info("################################");
* ONAP : CCSDK.apps
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* 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.
package org.onap.ccsdk.apps.ms.neng.core.policy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Represents a sequence object in the policy, as a POJO.
*/
public class PolicySequence {
/**
- * The type of the policy sequence.
+ * The type of the policy sequence.
*/
- public enum Type {
- ALPHA, NUMERIC
+ public enum Type {
+ ALPHA, NUMERIC
}
private long startValue;
private String key;
private String value;
private Long lastReleaseSeqNumTried;
+ private Logger logger = LoggerFactory.getLogger(PolicySequence.class);
+
public long getStartValue() {
return startValue;
try {
this.maxValue = Long.valueOf(this.maxValueString, base);
} catch (Exception e) {
+ logger.error("Exception",e);
this.maxValue = null;
}
}
if (mapped == null) {
mapped = camelConverted(recipeItem);
}
- //String value = applyJavaOperation(null, recipeItem, mapped);
return applyJavaOperation(null, recipeItem, mapped);
}
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
private static Logger log = Logger.getLogger(RestServiceImpl.class.getName());
private static final String INTERNAL_ERROR_MSG = "Internal error occured while processing the request.";
private static final String ERROR="error";
-
+ private static final String ERROR_500="err-0500";
@Autowired SpringService service;
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
return buildResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", e.getMessage()));
+ response.put(ERROR, buildErrorResponse(ERROR_500, e.getMessage()));
return buildErrorResponse(response);
}
}
/*******************************************************************************\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
private String property;\r
\r
public PolicyEngineResponse() {\r
- \r
+ // this method does nothing\r
}\r
\r
public String getPolicyConfigMessage() {\r
/*******************************************************************************\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications 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
*/\r
public class AssignVlanTagRequest {\r
\r
- private @Valid List<AssignVlanTagRequestInput> input = new ArrayList<AssignVlanTagRequestInput>();\r
+ private @Valid List<AssignVlanTagRequestInput> input = new ArrayList<>();\r
\r
/**\r
**/\r