diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-01-10 12:50:06 -0500 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-01-11 10:08:58 -0500 |
commit | 5916e79bab772cc79765b0d8fedbc2de38e4ff4b (patch) | |
tree | facf49d89b2be30f2800c59404e9da2d8e00de00 | |
parent | 6213aad62019a361126ee218b6b550e539e3582f (diff) |
Resource Resoulution Service
Implement Input Resource Resolution Processor Service along with Resource Resolution Utilities
Change-Id: Ibb4899e415f4b79cd6cd1b190b0f4969b09c3fe4
Issue-ID: CCSDK-936
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
23 files changed, 457 insertions, 232 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 01874455..58a82079 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.apps.controllerblueprints.core.utils
import com.att.eelf.configuration.EELFLogger
@@ -22,6 +21,9 @@ import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
@@ -40,241 +42,209 @@ import java.nio.charset.Charset *
* @author Brinda Santh
*/
-object JacksonUtils {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- inline fun <reified T : Any> readValue(content: String): T =
- jacksonObjectMapper().readValue(content, T::class.java)
+class JacksonUtils {
+ companion object {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ inline fun <reified T : Any> readValue(content: String): T =
+ jacksonObjectMapper().readValue(content, T::class.java)
+
+ fun <T> readValue(content: String, valueType: Class<T>): T? {
+ return jacksonObjectMapper().readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValue(content: String, valueType: Class<T>): T? {
- return jacksonObjectMapper().readValue(content, valueType)
- }
+ fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
+ return jacksonObjectMapper().treeToValue(node, valueType)
+ }
- @JvmStatic
- fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
- return jacksonObjectMapper().treeToValue(node, valueType)
- }
+ fun getContent(fileName: String): String = runBlocking {
+ async {
+ try {
+ File(fileName).readText(Charsets.UTF_8)
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ }
+ }.await()
+ }
- @JvmStatic
- fun getContent(fileName: String): String = runBlocking {
- async {
- try {
- File(fileName).readText(Charsets.UTF_8)
- } catch (e: Exception) {
- throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ fun getClassPathFileContent(fileName: String): String {
+ return runBlocking {
+ withContext(Dispatchers.Default) {
+ IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
}
- }.await()
- }
+ }
- @JvmStatic
- fun getClassPathFileContent(fileName: String): String {
- return runBlocking {
- withContext(Dispatchers.Default) {
- IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
- }
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getContent(fileName)
+ return readValue(content, valueType)
}
- }
- @JvmStatic
- fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getContent(fileName)
- return readValue(content, valueType)
- }
+ fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getClassPathFileContent(fileName)
+ return readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getClassPathFileContent(fileName)
- return readValue(content, valueType)
- }
+ fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
+ return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ }
- @JvmStatic
- fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
+ val content: String = getClassPathFileContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
- val content: String = getClassPathFileContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNodeFromFile(fileName: String): JsonNode {
+ val content: String = getContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNodeFromFile(fileName: String): JsonNode {
- val content: String = getContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNode(content: String): JsonNode {
+ return jacksonObjectMapper().readTree(content)
+ }
- @JvmStatic
- fun jsonNode(content: String): JsonNode {
- return jacksonObjectMapper().readTree(content)
- }
+ fun getJson(any: kotlin.Any): String {
+ return getJson(any, false)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any): String {
- return getJson(any, false)
- }
+ fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
+ val wrapperMap = hashMapOf<String, Any>()
+ wrapperMap[wrapper] = any
+ return getJson(wrapperMap, pretty)
+ }
- @JvmStatic
- fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
- val wrapperMap = hashMapOf<String, Any>()
- wrapperMap[wrapper] = any
- return getJson(wrapperMap, pretty)
- }
+ fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.writeValueAsString(any)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
- val objectMapper = jacksonObjectMapper()
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
- if (pretty) {
- objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.valueToTree(any)
}
- return objectMapper.writeValueAsString(any)
- }
- @JvmStatic
- fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
- return getListFromJson(node.toString(), valueType)
- }
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
- @JvmStatic
- fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
- val objectMapper = jacksonObjectMapper()
- val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
- return objectMapper.readValue<List<T>>(content, javaType)
- }
+ fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
+ val objectMapper = jacksonObjectMapper()
+ val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
+ return objectMapper.readValue<List<T>>(content, javaType)
+ }
- @JvmStatic
- fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getClassPathFileContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getClassPathFileContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
- val objectMapper = jacksonObjectMapper()
- val typeRef = object : TypeReference<MutableMap<String, T>>() {}
- return objectMapper.readValue(content, typeRef)
- }
+ fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
+ val objectMapper = jacksonObjectMapper()
+ val typeRef = object : TypeReference<MutableMap<String, T>>() {}
+ return objectMapper.readValue(content, typeRef)
+ }
- @JvmStatic
- fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
- val content: String = getContent(fileName)
- return getMapFromJson(content, valueType)
- }
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = getContent(fileName)
+ return getMapFromJson(content, valueType)
+ }
- @JvmStatic
- fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
- } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
- return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
+ } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
+ return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ }
+ return false
}
- return false
- }
- @JvmStatic
- fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
- when (primitiveType) {
- BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
- BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
- BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
- else -> return false
+ fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
+ BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
+ BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
+ else -> return false
+ }
}
- }
- @JvmStatic
- fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
- when (type) {
- BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
- BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
- else -> return false
+ fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
+ BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
+ else -> return false
+ }
}
- }
-/*
- @JvmStatic
- fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.put(key, value as String)
- } else {
- objectNode.put(key, value as String)
+ fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)
+ else -> objectNode.put(key, value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.add(value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.add(value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.add(value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.add(value as String)
- } else {
- objectNode.add(value as String)
+ fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)
+ else -> arrayNode.add(value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, 0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, 0.0)
- } else {
- objectNode.put(key, "")
+ fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)
+ else -> objectNode.put(key, "")
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- arrayNode.add(false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- arrayNode.add(0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- arrayNode.add(0.0)
- } else {
- arrayNode.add("")
+ fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)
+ else -> arrayNode.add("")
+ }
}
- }
- @JvmStatic
- fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {
- if (nodeValue == null || nodeValue is NullNode) {
- objectNode.set(key, nodeValue)
- } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {
- objectNode.put(key, nodeValue.asBoolean())
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {
- objectNode.put(key, nodeValue.asInt())
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {
- objectNode.put(key, nodeValue.floatValue())
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {
- objectNode.put(key, nodeValue.asText())
+ fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {
+ if (nodeValue == null || nodeValue is NullNode) {
+ objectNode.set(key, nodeValue)
+ } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ populatePrimitiveValues(key, nodeValue, type, objectNode)
} else {
- objectNode.put(key, nodeValue.asText())
+ objectNode.set(key, nodeValue)
+ }
+ }
+
+ fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)
+ else -> return JacksonUtils.getJsonNode(value)
}
- } else {
- objectNode.set(key, nodeValue)
}
}
- */
}
\ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 1dfb89a5..c01b14b3 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest { val inputDataPath = "src/test/resources/data/default-context.json"
- val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)
+ val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)
bluePrintRuntimeService.assignInputs(inputNode)
val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")
@@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest { "ResourceAssignmentComponent", "process")
assertNotNull(inContext, "Failed to populate interface input property values")
- assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
- assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
- }
+ assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
+ assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ }
@Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
@@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest { val bluePrintRuntimeService = getBluePrintRuntimeService()
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
- jsonNodeFromObject("context1-value"))
+ JacksonUtils.jsonNodeFromObject("context1-value"))
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
- jsonNodeFromObject("context2-value"))
+ JacksonUtils.jsonNodeFromObject("context2-value"))
val keys = listOf("context1", "context2")
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 7d850f20..6d771cd6 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -28,6 +28,14 @@ "required": true, "type": "string" }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, "action-name": { "required": true, "type": "string" @@ -39,6 +47,10 @@ "hostname": { "required": true, "type": "string" + }, + "vnf_name": { + "required": true, + "type": "string" } }, "derived_from": "tosca.datatypes.Dynamic" diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index fde80005..cb39200f 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -31,7 +31,7 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionInputSource(){
String fileName = basePath + "/input-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);
}
@@ -39,7 +39,7 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDefaultSource(){
String fileName = basePath + "/default-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);
}
@@ -47,14 +47,14 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDBSource(){
String fileName = basePath + "/db-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionMDSALSource(){
String fileName = basePath + "/mdsal-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);
}
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java index 2b68585f..f5c3567f 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -45,7 +45,7 @@ public class ResourceDefinitionValidationServiceTest { private void testValidate(String fileName) throws Exception { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); ResourceDefinitionValidationService resourceDictionaryValidationService = diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java index c7444dba..a2c2310b 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java @@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest { @Test
public void testProcess(){
- List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
+ List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);
BulkResourceSequencingUtils.process(assignments);
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index 13bf8195..fa241380 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest { @Test
public void testAssignInputs() {
- JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
+ JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
Map<String, Object> context = new HashMap<>();
ResourceDictionaryUtils.assignInputs(data, context);
String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt index 66c919d4..341ede58 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt @@ -20,6 +20,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon import org.python.core.PyObject import org.python.util.PythonInterpreter import org.slf4j.LoggerFactory +import java.io.File import java.util.* class PythonExecutorUtils { @@ -61,9 +62,9 @@ class PythonExecutorUtils { sb.append(System.getProperty("java.class.path")) for (p in pythonPath) { - sb.append(":").append(p) + sb.append(File.pathSeparator).append(p) } - log.debug("Paths : $sb") + log.debug("Python Paths : $sb") props["python.import.site"] = "true" props.setProperty("python.path", sb.toString()) diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt index 431c6b82..c4fd5467 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt @@ -30,7 +30,7 @@ class PythonExecutorUtilsTest { @Test fun testGetPythonComponent() { - val pythonPath: MutableList<String> = arrayListOf() + val pythonPath: MutableList<String> = mutableListOf() pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints") val properties: MutableMap<String, Any> = hashMapOf() diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json new file mode 100644 index 00000000..7142f045 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json @@ -0,0 +1,31 @@ +{
+ "actionIdentifiers": {
+ "actionName": "activate",
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "mode": "sync"
+ },
+ "commonHeader": {
+ "flags": {
+ "force": true,
+ "ttl": 3600
+ },
+ "originatorId": "sdnc",
+ "requestId": "123456-1000",
+ "subRequestId": "sub-123456-1000",
+ "timestamp": "2012-04-23T18:25:43.511Z"
+ },
+ "payload": {
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "service-instance-id": "siid_1234",
+ "vnf-id": "vnf_1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost",
+ "vnf_name": "temp_vnf"
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt new file mode 100644 index 00000000..9d6f4a6b --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt @@ -0,0 +1,58 @@ +package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
+ : DefaultBluePrintRuntimeService(id, bluePrintContext){
+
+ private var resourceResolutionStore: MutableMap<String, JsonNode> = hashMapOf()
+
+ override fun getExecutionContext(): MutableMap<String, JsonNode> {
+ return resourceResolutionStore
+ }
+
+ @Suppress("UNCHECKED_CAST")
+ override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {
+ this.resourceResolutionStore = executionContext
+ }
+
+ override fun put(key: String, value: JsonNode) {
+ resourceResolutionStore[key] = value
+ }
+
+ override fun get(key: String): JsonNode {
+ return resourceResolutionStore[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")
+ }
+
+ override fun check(key: String): Boolean {
+ return resourceResolutionStore.containsKey(key)
+ }
+
+ override fun cleanRuntime() {
+ resourceResolutionStore.clear()
+ }
+
+ private fun getJsonNode(key: String): JsonNode {
+ return get(key)
+ }
+
+ override fun getAsString(key: String): String? {
+ return get(key).asText()
+ }
+
+ override fun getAsBoolean(key: String): Boolean? {
+ return get(key).asBoolean()
+ }
+
+ override fun getAsInt(key: String): Int? {
+ return get(key).asInt()
+ }
+
+ override fun getAsDouble(key: String): Double? {
+ return get(key).asDouble()
+ }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt index 9d476008..ccf3aee1 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt @@ -17,8 +17,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils +import org.onap.ccsdk.apps.controllerblueprints.core.* import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.springframework.stereotype.Service +import com.fasterxml.jackson.databind.node.NullNode /** * InputResourceAssignmentProcessor @@ -33,6 +36,20 @@ open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() { } override fun process(executionRequest: ResourceAssignment) { + try { + if (checkNotEmpty(executionRequest.name)) { + val value = bluePrintRuntimeService!!.getInputValue(executionRequest.name) + // if value is null don't call setResourceDataValue to populate the value + if (value != null && value !is NullNode) { + ResourceResolutionUtils.setResourceDataValue(executionRequest, value) + } + } + // Check the value has populated for mandatory case + ResourceResolutionUtils.assertTemplateKeyValueNotNull(executionRequest) + } catch (e: Exception) { + ResourceResolutionUtils.setFailedResourceDataValue(executionRequest, e.message) + throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e) + } } override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt index 6bcd21ba..7c590883 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt @@ -16,17 +16,142 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils +import java.util.Date +import org.apache.commons.lang3.StringUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.* import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment class ResourceResolutionUtils { companion object { + private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceResolutionUtils::class.toString()) + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) { + + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" } + checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment") + + if (checkNotEmpty(resourceAssignment.dictionaryName)) { + resourceAssignment.dictionaryName = resourceAssignment.name + logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})") + } + + try { + if (checkNotEmpty(resourceProp.type)) { + val convertedValue = convertResourceValue(resourceProp.type, value) + logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})") + resourceProp.value = convertedValue + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS + } + } catch (e: Exception) { + throw BluePrintProcessorException("Failed in setting value for template key (%s) and " + + "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e) + } + } + + private fun convertResourceValue(type: String, value: Any?): JsonNode? { + var convertedValue: JsonNode? + + if (value == null || value is NullNode) { + logger.info("Returning {} value from convertResourceValue", value) + return null + } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) { + convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value) + } else { + // Case where Resource is non-primitive type + if (value is String) { + convertedValue = JacksonUtils.jsonNode(value) + } else { + convertedValue = JacksonUtils.getJsonNode(value) + } + } + return convertedValue + } + + @Synchronized + fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { + if (checkNotEmpty(resourceAssignment.name)) { + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_FAILURE + resourceAssignment.message = message + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) { + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" } + if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) { + logger.error("failed to populate mandatory resource mapping ($resourceAssignment)") + throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)") + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String { + var result = "{}" + try { + val mapper = ObjectMapper() + val root = mapper.readTree(result) + + assignments.forEach { + if (checkNotEmpty(it.name) && it.property != null) { + + val type = it.property?.type + val value = it.property?.value + logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type, + value) + if (value == null) { + (root as ObjectNode).set(it.name, null) + } else if (value is JsonNode) { + (root as ObjectNode).put(it.name, value as JsonNode) + } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as String) + } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Boolean) + } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Int) + } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Float) + } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as String) + } else { + val jsonNode = JacksonUtils.getJsonNode(value) + if (jsonNode != null) { + (root as ObjectNode).put(it.name, jsonNode) + } else { + (root as ObjectNode).set(it.name, null) + } + } + } + } + result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root) + logger.info("Generated Resource Param Data ({})", result) + } catch (e: Exception) { + throw BluePrintProcessorException("kapil is failing with $e.message", e) + } + + return result + } + fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T { val content = JacksonUtils.getJson(properties) return JacksonUtils.readValue(content, classType) ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)") } + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 7f41ba12..46ccb974 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -19,8 +19,11 @@ 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.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* 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.test.context.ContextConfiguration @@ -62,6 +65,12 @@ class ResourceResolutionServiceTest { 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") + resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig") } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json index 7889a7e4..c4fe4eab 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json @@ -19,9 +19,12 @@ "resource-assignment-request": {
"resource-assignment-properties": {
"request-id": "1234",
+ "service-instance-id": "siid_1234",
+ "vnf-id": "vnf_1234",
"action-name": "assign-activate",
"scope-type": "vnf-type",
- "hostname": "localhost"
+ "hostname": "localhost",
+ "vnf_name": "temp_vnf"
}
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java index 89af9e9a..3a1535ac 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java @@ -59,7 +59,7 @@ public class SchemaGeneratorService { */
public String generateSchema(String serviceTemplateContent) throws BluePrintException {
if (StringUtils.isNotBlank(serviceTemplateContent)) {
- ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent,
+ ServiceTemplate serviceTemplate = JacksonUtils.Companion.readValue(serviceTemplateContent,
ServiceTemplate.class);
return generateSchema(serviceTemplate);
} else {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java index 23d3a977..074483a7 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java @@ -30,11 +30,11 @@ public class JpaJsonNodeConverter implements @Override
public String convertToDatabaseColumn(JsonNode node) {
- return JacksonUtils.getJson(node, true);
+ return JacksonUtils.Companion.getJson(node, true);
}
@Override
public JsonNode convertToEntityAttribute(String dbData) {
- return JacksonUtils.jsonNode(dbData);
+ return JacksonUtils.Companion.jsonNode(dbData);
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java index 18672f1c..e28cdcd5 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java @@ -29,11 +29,11 @@ public class JpaResourceDefinitionConverter implements AttributeConverter<ResourceDefinition, String> {
@Override
public String convertToDatabaseColumn(ResourceDefinition resourceDefinition) {
- return JacksonUtils.getJson(resourceDefinition);
+ return JacksonUtils.Companion.getJson(resourceDefinition);
}
@Override
public ResourceDefinition convertToEntityAttribute(String content) {
- return JacksonUtils.readValue(content, ResourceDefinition.class);
+ return JacksonUtils.Companion.readValue(content, ResourceDefinition.class);
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java index 6d02544e..5d15e087 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java @@ -58,7 +58,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
if (StringUtils.isNotBlank(serviceTemplateContent)) {
ServiceTemplate serviceTemplate =
- JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ JacksonUtils.Companion.readValue(serviceTemplateContent, ServiceTemplate.class);
return validateServiceTemplate(serviceTemplate);
} else {
throw new BluePrintException(
@@ -131,11 +131,11 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService { Object mappingObject =
capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
if (mappingObject != null) {
- String mappingContent = JacksonUtils.getJson(mappingObject);
+ String mappingContent = JacksonUtils.Companion.getJson(mappingObject);
Preconditions.checkArgument(StringUtils.isNotBlank(mappingContent),
String.format("Failed to get capability mapping property (%s) ", ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));
- resourceAssignment = JacksonUtils.getListFromJson(mappingContent, ResourceAssignment.class);
+ resourceAssignment = JacksonUtils.Companion.getListFromJson(mappingContent, ResourceAssignment.class);
Preconditions.checkNotNull(resourceAssignment,
String.format("Failed to get resource assignment info from the content (%s) ", mappingContent));
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java index 412e9606..42c6365a 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java @@ -56,12 +56,12 @@ public class ModelTypeServiceTest { public void test01SaveModelType() throws Exception { log.info("**************** test01SaveModelType ********************"); - String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json"); + String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json"); ModelType modelType = new ModelType(); modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); modelType.setDescription("Definition for Sample Datatype "); - modelType.setDefinition(JacksonUtils.jsonNode(content)); + modelType.setDefinition(JacksonUtils.Companion.jsonNode(content)); modelType.setModelName(modelName); modelType.setVersion("1.0.0"); modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java index 7549b780..739ce51b 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java @@ -54,12 +54,12 @@ public class ModelTypeReactRepositoryTest { @Test @Commit public void test01Save() { - String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json"); + String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json"); ModelType modelType = new ModelType(); modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); modelType.setDescription("Definition for Sample Datatype "); - modelType.setDefinition(JacksonUtils.jsonNode(content)); + modelType.setDefinition(JacksonUtils.Companion.jsonNode(content)); modelType.setModelName(modelName); modelType.setVersion("1.0.0"); modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java index 2a636831..fb11c39f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java @@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest { @Test @Commit public void test01Save() { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class); Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition); resourceDefinition.setName(sourceName); diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index bf5db340..64c87e06 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -53,12 +53,12 @@ public class ModelTypeRestTest { public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
- String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+ String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.jsonNode(content));
+ modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
modelType.setModelName(modelName);
modelType.setVersion("1.0.0");
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
|