From 1141bf4d7f7c641aecdc12c085a7410bbe713bb8 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 10 Dec 2018 17:01:38 -0500 Subject: Implement Resource Resolution Services Change-Id: Ia1cf57c9fa16cb943836e3a78d4d2c9776f0e32f Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/utils/JacksonUtils.kt | 12 +++++ .../Definitions/activation-blueprint.json | 3 ++ .../Definitions/baseconfig-mapping.json | 39 ++++++++++++-- .../baseconfiguration/Definitions/node_types.json | 8 +++ .../Definitions/resources_dictionary_types.json | 62 ++++++++++++++++++++++ .../Definitions/resources_dictionaty_types.json | 3 -- .../node_type/component-resource-assignment.json | 12 ++++- .../resource/dict/ResourceAssignmentProcessor.kt | 57 -------------------- 8 files changed, 131 insertions(+), 65 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt (limited to 'components') diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index f53f8615..40210142 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -121,6 +121,11 @@ object JacksonUtils { return objectMapper.writeValueAsString(any) } + @JvmStatic + fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + return getListFromJson(node.toString(), valueType) + } + @JvmStatic fun getListFromJson(content: String, valueType: Class): List? { val objectMapper = jacksonObjectMapper() @@ -148,6 +153,13 @@ object JacksonUtils { return objectMapper.readValue(content, typeRef) } + @JvmStatic + fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return getMapFromJson(content, valueType) + } + @JvmStatic fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { if (BluePrintTypes.validPrimitiveTypes().contains(type)) { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index e5f0c9c0..446932d5 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -136,6 +136,9 @@ "resource-id": { "get_input": "hostname" }, + "artifact-prefix-names": [ + "baseconfig" + ], "template-content": { "get_artifact": [ "SELF", diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json index caee773b..c457086c 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -1,3 +1,36 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file +[ + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + ] + }, + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "vnf_name", + "input-param": false, + "property": { + "type": "string" + }, + "dictionary-name": "vnf_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + } +] diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 2723510a..6e8d839e 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -69,6 +69,14 @@ "required": true, "type": "string" }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "template-content": { "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", "required": true, diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json new file mode 100644 index 00000000..557f6efc --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json @@ -0,0 +1,62 @@ +{ + "service-instance-id": { + "name": "service-instance-id", + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by": "Singal, Kapil ", + "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 ", + "property": { + "description": "vnf-id", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf_name": { + "name": "vnf_name", + "tags": "vnf_name", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf_name", + "type": "string" + }, + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json deleted file mode 100644 index 0e0dcd23..00000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json index a29a875c..51d70ede 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -11,12 +11,12 @@ "operations": { "process": { "inputs": { - "template-name": { + "template-name": { "description": "Service Template Name.", "required": true, "type": "string" }, - "template-version": { + "template-version": { "description": "Service Template Version.", "required": true, "type": "string" @@ -34,6 +34,14 @@ "type": "string" } }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "request-id": { "description": "Request Id, Unique Id for the request.", "required": true, diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt deleted file mode 100644 index 327d50ac..00000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.slf4j.LoggerFactory - -abstract class ResourceAssignmentProcessor : BlueprintFunctionNode { - - private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) - - private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null - - open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { - this.bluePrintRuntimeService = bluePrintRuntimeService - } - - open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> { - return this.bluePrintRuntimeService!! - } - - override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment { - log.info("prepareRequest...") - return resourceAssignment - } - - override fun prepareResponse(): ResourceAssignment { - log.info("Preparing Response...") - return ResourceAssignment() - } - - override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment { - prepareRequest(executionServiceInput) - process(executionServiceInput) - return prepareResponse() - } - - override abstract fun process(executionRequest: ResourceAssignment) - - override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) -} \ No newline at end of file -- cgit 1.2.3-korg