From d035fe08249fe8b1e5988b79c7355620727e5da0 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 11 Jan 2019 13:58:38 -0500 Subject: Resource Resolution Service : 2 Changes for Primary-DB Resource Resolution Processor Service Change-Id: Iaf6ad6277d36787d87881819ae530de1d7038a2e Issue-ID: CCSDK-942 Signed-off-by: Singal, Kapil (ks220y) --- .../CapabilityResourceAssignmentProcessor.kt | 4 +- .../DataBaseResourceAssignmentProcessor.kt | 40 ------ .../processor/InputResourceAssignmentProcessor.kt | 8 +- .../PrimaryDataResourceAssignmentProcessor.kt | 40 ++++++ .../resolution/utils/ResourceResolutionUtils.kt | 157 --------------------- .../resolution/ResourceResolutionComponentTest.kt | 2 +- .../resolution/ResourceResolutionServiceTest.kt | 4 +- .../src/test/resources/mapping/db/db-array.json | 35 ----- .../src/test/resources/mapping/db/db-complex.json | 27 ---- .../src/test/resources/mapping/db/db-simple.json | 26 ---- .../src/test/resources/mapping/db/dt-location.json | 15 -- .../mapping/db/resource-assignments-simple.json | 22 --- .../resources/mapping/primary-db/dt-location.json | 15 ++ .../mapping/primary-db/primary-db-array.json | 35 +++++ .../mapping/primary-db/primary-db-complex.json | 27 ++++ .../mapping/primary-db/primary-db-simple.json | 26 ++++ .../primary-db/resource-assignments-simple.json | 22 +++ .../distribution/src/main/dc/docker-compose.yaml | 72 +++++----- .../ResourceDictionaryReactRepositoryTest.java | 2 +- .../src/test/resources/application.properties | 2 +- .../enhance/enhance-resource-assignment.json | 2 +- .../test/resources/enhance/enhance-template.json | 2 +- .../test/resources/enhance/enhanced-template.json | 2 +- 23 files changed, 215 insertions(+), 372 deletions(-) delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/dt-location.json create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-array.json create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-complex.json create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-simple.json create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/resource-assignments-simple.json (limited to 'ms') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt index f1de8f7d..a6c8a3f9 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt @@ -17,9 +17,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext import org.springframework.stereotype.Service @@ -49,7 +49,7 @@ open class CapabilityResourceAssignmentProcessor : ResourceAssignmentProcessor() checkNotNull(resourceSource.properties) { "failed to get ${executionRequest.dictionarySource} properties" } - val capabilityResourceSourceProperty = ResourceResolutionUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java) + val capabilityResourceSourceProperty = ResourceAssignmentUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java) val instanceType = capabilityResourceSourceProperty.type val instanceName = capabilityResourceSourceProperty.instanceName diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt deleted file mode 100644 index da77c273..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt +++ /dev/null @@ -1,40 +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.blueprintsprocessor.functions.resource.resolution.processor - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.springframework.stereotype.Service - -/** - * DataBaseResourceAssignmentProcessor - * - * @author Brinda Santh - */ -@Service("resource-assignment-processor-db") -open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){ - - override fun getName(): String { - return "resource-assignment-processor-db" - } - - override fun process(executionRequest: ResourceAssignment) { - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - } -} \ No newline at end of file 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 ccf3aee1..bd9c188a 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,11 +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 +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils /** * InputResourceAssignmentProcessor @@ -41,13 +41,13 @@ open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() { 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) + ResourceAssignmentUtils.setResourceDataValue(executionRequest, value) } } // Check the value has populated for mandatory case - ResourceResolutionUtils.assertTemplateKeyValueNotNull(executionRequest) + ResourceAssignmentUtils.assertTemplateKeyValueNotNull(executionRequest) } catch (e: Exception) { - ResourceResolutionUtils.setFailedResourceDataValue(executionRequest, e.message) + ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message) throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt new file mode 100644 index 00000000..ec98d09e --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt @@ -0,0 +1,40 @@ +/* + * 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.blueprintsprocessor.functions.resource.resolution.processor + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.springframework.stereotype.Service + +/** + * PrimaryDataResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-primary-db") +open class PrimaryDataResourceAssignmentProcessor : ResourceAssignmentProcessor(){ + + override fun getName(): String { + return "resource-assignment-processor-primary-db" + } + + override fun process(executionRequest: ResourceAssignment) { + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + } +} \ No newline at end of file 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 deleted file mode 100644 index 7c590883..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.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 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): 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 transformResourceSource(properties: MutableMap, classType: Class): 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/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt index ef849605..8adde863 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt @@ -34,7 +34,7 @@ import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) @ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class, InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class, - DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, + PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, CapabilityResourceAssignmentProcessor::class]) class ResourceResolutionComponentTest { 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 46ccb974..6c686753 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 @@ -39,7 +39,7 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @ContextConfiguration(classes = [ResourceResolutionService::class, InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class, - DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, + PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, CapabilityResourceAssignmentProcessor::class]) class ResourceResolutionServiceTest { @@ -53,7 +53,7 @@ class ResourceResolutionServiceTest { 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") + assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "mdsal")), "failed to get registered sources") } @Test diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json deleted file mode 100644 index 679b92db..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "locations": { - "name": "locations", - "data-type": "list", - "entry-schema": "dt-location", - "source": { - "db": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - }, - "candidate-dependency": { - "db": { - "names": [ - "profile_name" - ] - } - } - }, - "profile_name": { - "name": "profile_name", - "data-type": "string", - "source": { - "input": { - - } - } - } -} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json deleted file mode 100644 index 32d04b69..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "location": { - "name": "location", - "data-type": "dt-location", - "source": { - "db": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - } - }, - "profile_name": { - "name": "profile_name", - "data-type": "string", - "source": { - "input": { - - } - } - } -} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json deleted file mode 100644 index 841404f2..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "country": { - "name": "country", - "data-type": "string", - "source": { - "db": { - "query": "SELECT country FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "country": "country" - } - } - } - }, - "profile_name": { - "name": "profile_name", - "data-type": "string", - "source": { - "input": { - - } - } - } -} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json deleted file mode 100644 index 52e0a796..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "test Data Type", - "properties": { - "country": { - "required": true, - "type": "string" - }, - "state": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json deleted file mode 100644 index ddcf32ee..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "name": "country", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "country", - "dictionary-source": "db", - "dependencies": ["state"] - }, - { - "name": "state", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "state", - "dictionary-source": "input", - "dependencies": [] - } -] diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/dt-location.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/dt-location.json new file mode 100644 index 00000000..52e0a796 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/dt-location.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0", + "description": "test Data Type", + "properties": { + "country": { + "required": true, + "type": "string" + }, + "state": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-array.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-array.json new file mode 100644 index 00000000..7082a434 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-array.json @@ -0,0 +1,35 @@ +{ + "locations": { + "name": "locations", + "data-type": "list", + "entry-schema": "dt-location", + "source": { + "primary-db": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + }, + "candidate-dependency": { + "primary-db": { + "names": [ + "profile_name" + ] + } + } + }, + "profile_name": { + "name": "profile_name", + "data-type": "string", + "source": { + "input": { + + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-complex.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-complex.json new file mode 100644 index 00000000..53e2a11c --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-complex.json @@ -0,0 +1,27 @@ +{ + "location": { + "name": "location", + "data-type": "dt-location", + "source": { + "primary-db": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + }, + "profile_name": { + "name": "profile_name", + "data-type": "string", + "source": { + "input": { + + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-simple.json new file mode 100644 index 00000000..fad08887 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/primary-db-simple.json @@ -0,0 +1,26 @@ +{ + "country": { + "name": "country", + "data-type": "string", + "source": { + "primary-db": { + "query": "SELECT country FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "country": "country" + } + } + } + }, + "profile_name": { + "name": "profile_name", + "data-type": "string", + "source": { + "input": { + + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/resource-assignments-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/resource-assignments-simple.json new file mode 100644 index 00000000..bb392d7b --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/primary-db/resource-assignments-simple.json @@ -0,0 +1,22 @@ +[ + { + "name": "country", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "country", + "dictionary-source": "primary-db", + "dependencies": ["state"] + }, + { + "name": "state", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "state", + "dictionary-source": "input", + "dependencies": [] + } +] diff --git a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml index dd219084..eae24703 100644 --- a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml +++ b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml @@ -1,37 +1,37 @@ -version: '3.3' - -services: - db: - image: mariadb:latest - container_name: cb-mariadb - ports: - - "3306:3306" - volumes: - - ~/vm_mysql:/var/lib/mysql - restart: always - environment: - MYSQL_ROOT_PASSWORD: sdnctl - MYSQL_DATABASE: sdnctl - MYSQL_USER: sdnctl - MYSQL_PASSWORD: sdnctl - controller-blueprints: - depends_on: - - db - image: onap/ccsdk-controllerblueprints:latest - container_name: cb-rest - ports: - - "8080:8080" - restart: always - volumes: - - ~/share/vm_ms/controllerblueprints/config:/opt/app/onap/config - - ~/share/vm_ms/controllerblueprints/logs:/logs - environment: - APPLICATIONNAME : ControllerBluePrints - BUNDLEVERSION: 1.0.0 - APP_CONFIG_HOME: /opt/app/onap/config - DB_URL: jdbc:mysql://db:3306/sdnctl - DB_USER: sdnctl - DB_PASSWORD: sdnctl - INIT_DATA_LOAD: "true" - STICKYSELECTORKEY: +version: '3.3' + +services: + db: + image: mariadb:latest + container_name: cb-mariadb + ports: + - "3306:3306" + volumes: + - ~/vm_mysql:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: sdnctl + MYSQL_DATABASE: sdnctl + MYSQL_USER: sdnctl + MYSQL_PASSWORD: sdnctl + controller-blueprints: + depends_on: + - db + image: onap/ccsdk-controllerblueprints:latest + container_name: cb-rest + ports: + - "8080:8080" + restart: always + volumes: + - ~/share/vm_ms/controllerblueprints/config:/opt/app/onap/config + - ~/share/vm_ms/controllerblueprints/logs:/logs + environment: + APPLICATIONNAME : ControllerBluePrints + BUNDLEVERSION: 1.0.0 + APP_CONFIG_HOME: /opt/app/onap/config + DB_URL: jdbc:mysql://db:3306/sdnctl + DB_USER: sdnctl + DB_PASSWORD: sdnctl + INIT_DATA_LOAD: "true" + STICKYSELECTORKEY: ENVCONTEXT: DEV \ No newline at end of file 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 fb11c39f..330eaa84 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.Companion.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-primary-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/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 29bb2b90..24cb23a1 100755 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -20,7 +20,7 @@ logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug # Load Resource Source Mappings -resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability +resourceSourceMappings=primary-db=source-primary-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=./target/blueprints/deploy controllerblueprints.blueprintArchivePath=./target/blueprints/archive diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json index 3715beca..1c81b74d 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json @@ -7,7 +7,7 @@ "required": true }, "dictionary-name": "sample-db-source", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "input-source" ] diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json index b066dad6..42978f84 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json @@ -225,7 +225,7 @@ }, "input-param": false, "dictionary-name": "sample-db-source", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "hostname" ], diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json index b13932b7..66f18f89 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json @@ -227,7 +227,7 @@ }, "input-param" : false, "dictionary-name" : "sample-db-source", - "dictionary-source" : "db", + "dictionary-source" : "primary-db", "dependencies" : [ "hostname" ], "version" : 0 }, { -- cgit 1.2.3-korg