summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-09-13 00:20:34 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-09-13 00:47:05 +0000
commit5eebfaa6ac0d4cb4fdf20d19ead7cd0303fc6f29 (patch)
treeb6d19d00518737a74ca27689ac818b33eb1c915e /ms/controllerblueprints
parent04d5531c0e299b8ea99cb22a8058b88cb3385cb2 (diff)
Controller Blueprints Microservice
Add resource assignment enhancement and validation to blueprint validation and enhancement. Change-Id: I547760012e7014cfbb7a1e3a1d8ffb77edc9b6a2 Issue-ID: CCSDK-562 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints')
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/db-source.json)2
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/default-source.json)4
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/input-source.json)6
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json29
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json25
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json)8
-rw-r--r--ms/controllerblueprints/application/src/test/resources/application.properties2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java23
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java)26
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt272
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt50
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java17
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java6
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java10
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/application.properties4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json62
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json10
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json312
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json37
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/logback.xml5
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json9
23 files changed, 738 insertions, 187 deletions
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json
index a0c78af0..90775aee 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json
@@ -1,5 +1,5 @@
{
- "name": "db-source",
+ "name": "sample-db-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json
index 64bfa0cc..395b0ddd 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json
@@ -1,6 +1,6 @@
{
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "default-source",
+ "tags": "sample-default-source",
+ "name": "sample-default-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json
index acfad16b..73c0d408 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json
@@ -1,16 +1,16 @@
{
- "name": "input-source",
+ "name": "sample-input-source",
"property" :{
"description": "name of the ",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "action-name, brindasanth",
+ "tags": "sample-input-source",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "action-name"
+ "key": "input-source"
}
}
}
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json
new file mode 100644
index 00000000..5834dd49
--- /dev/null
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json
@@ -0,0 +1,29 @@
+{
+ "tags": "sample-licenses",
+ "name": "sample-licenses",
+ "property": {
+ "description" : " Sample Data for licences",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-license-key"
+ }
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/",
+ "path": "/licenses",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "licenses": "licenses"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json
new file mode 100644
index 00000000..25464d3f
--- /dev/null
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json
@@ -0,0 +1,25 @@
+{
+ "tags": "sample-mdsal-source",
+ "name": "sample-mdsal-source",
+ "property": {
+ "description": "Sample sample-mdsal-source",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "mdsal-source": "v4-ip-prefix"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json
index 1b4432d5..055279c1 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json
@@ -1,16 +1,16 @@
{
- "name": "v4-ip-type",
+ "name": "sample-v4-ip-type",
"property": {
- "description": "name of the ",
+ "description": "sample-v4-ip-type",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "v4-ip-type, source-input, brindasanth",
+ "tags": "sample-v4-ip-type",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "v4-ip-type"
+ "key": "sample-v4-ip-type"
}
}
}
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties
index e2d040c2..5c6acf93 100644
--- a/ms/controllerblueprints/application/src/test/resources/application.properties
+++ b/ms/controllerblueprints/application/src/test/resources/application.properties
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+spring.main.banner-mode=off
+
appName=ControllerBluePrints
ms_name=org.onap.ccsdk.apps.controllerblueprints
appVersion=1.0.0
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
index 8e98f947..ef3b4a48 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -25,12 +25,13 @@ import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -48,14 +49,18 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
+ private ResourceAssignmentEnhancerService resourceAssignmentEnhancerService;
+
private Map<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
- super(bluePrintEnhancerRepoDBService);
+ public BluePrintEnhancerService(ResourceDefinitionRepoService resourceDefinitionRepoService,
+ ResourceAssignmentEnhancerService resourceAssignmentEnhancerService) {
+ super(resourceDefinitionRepoService);
+ this.resourceAssignmentEnhancerService = resourceAssignmentEnhancerService;
}
@Override
- public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException {
super.enrichTopologyTemplate(serviceTemplate);
// Update the Recipe Inputs and DataTypes
@@ -101,7 +106,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
// Modified for ONAP converted Object to JsonNode
JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES);
- log.info("Processing Receipe Names : {} ", recipeNames);
+ log.info("Processing Recipe Names : {} ", recipeNames);
if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) {
@@ -159,6 +164,9 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent);
+ // Enhance Resource Assignment
+ resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments);
+
dataTypeProperties = new HashMap<>();
for (ResourceAssignment resourceAssignment : resourceAssignments) {
@@ -167,9 +175,6 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
&& resourceAssignment.getProperty() != null
&& StringUtils.isNotBlank(resourceAssignment.getName())) {
- // Enrich the Property Definition
- super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty());
-
dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty());
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java
index 5510e480..16cc8415 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java
@@ -23,28 +23,35 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import java.util.Optional;
/**
- * BluePrintRepoDBService
+ * ResourceDefinitionRepoDBService
*
* @author Brinda Santh
*/
@Service
@SuppressWarnings("unused")
-public class BluePrintRepoDBService implements BluePrintRepoService {
+public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoService {
private ModelTypeRepository modelTypeRepository;
+ private ResourceDictionaryRepository resourceDictionaryRepository;
+
@SuppressWarnings("unused")
- public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
+ public ResourceDefinitionRepoDBService(ModelTypeRepository modelTypeRepository,
+ ResourceDictionaryRepository resourceDictionaryRepository) {
this.modelTypeRepository = modelTypeRepository;
+ this.resourceDictionaryRepository = resourceDictionaryRepository;
}
@Override
@@ -72,6 +79,17 @@ public class BluePrintRepoDBService implements BluePrintRepoService {
return getModelType(capabilityDefinitionName, CapabilityDefinition.class);
}
+ @NotNull
+ @Override
+ public Mono<ResourceDefinition> getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException{
+ Optional<ResourceDictionary> dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName);
+ if(dbResourceDictionary.isPresent()){
+ return Mono.just(dbResourceDictionary.get().getDefinition());
+ }else{
+ throw new BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName));
+ }
+ }
+
private <T> Mono<T> getModelType(String modelName, Class<T> valueClass) throws BluePrintException {
Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
"Failed to get model from repo, model name is missing");
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
new file mode 100644
index 00000000..cf9e96e7
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
@@ -0,0 +1,272 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.service.enhancer
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
+import java.io.Serializable
+
+/**
+ * BluePrintEnhancerService
+ * @author Brinda Santh
+ *
+ */
+interface BluePrintEnhancerService : Serializable {
+
+ @Throws(BluePrintException::class)
+ fun enhance(content: String): ServiceTemplate
+
+ /**
+ * Read Blueprint from CSAR structure Directory
+ */
+ @Throws(BluePrintException::class)
+ fun enhance(fileName: String, basePath: String): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate)
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeType(nodeTypeName: String, nodeType: NodeType)
+
+ @Throws(BluePrintException::class)
+ fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition)
+}
+
+open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString())
+
+ lateinit var serviceTemplate: ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ override fun enhance(content: String): ServiceTemplate {
+ return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->
+ enhance(serviceTemplate!!)
+ }.block()!!
+ }
+
+ @Throws(BluePrintException::class)
+ override fun enhance(fileName: String, basePath: String): ServiceTemplate {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ @Throws(BluePrintException::class)
+ override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {
+ this.serviceTemplate = serviceTemplate
+ initialCleanUp()
+ enrichTopologyTemplate(serviceTemplate)
+
+ // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
+ return this.serviceTemplate
+ }
+
+ open fun initialCleanUp() {
+ serviceTemplate.artifactTypes?.clear()
+ serviceTemplate.nodeTypes?.clear()
+ serviceTemplate.dataTypes?.clear()
+
+ serviceTemplate.artifactTypes = HashMap()
+ serviceTemplate.nodeTypes = HashMap()
+ serviceTemplate.dataTypes = HashMap()
+
+ }
+
+ @Throws(BluePrintException::class)
+ open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {
+ serviceTemplate.topologyTemplate?.let { topologyTemplate ->
+ enrichTopologyTemplateInputs(topologyTemplate)
+ enrichTopologyTemplateNodeTemplates(topologyTemplate)
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.inputs?.let { inputs ->
+ enrichPropertyDefinitions(inputs)
+ }
+ }
+
+ open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
+ enrichNodeTemplate(nodeTemplateName, nodeTemplate)
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ val nodeTypeName = nodeTemplate.type
+ // Get NodeType from Repo and Update Service Template
+ val nodeType = populateNodeType(nodeTypeName)
+
+ // Enrich NodeType
+ enrichNodeType(nodeTypeName, nodeType)
+
+ //Enrich Node Template Artifacts
+ enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)
+ }
+
+ @Throws(BluePrintException::class)
+ override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
+ log.debug("Enriching NodeType({})", nodeTypeName)
+ val derivedFrom = nodeType.derivedFrom
+
+ if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
+ val derivedFromNodeType = populateNodeType(nodeTypeName)
+ // Enrich NodeType
+ enrichNodeType(derivedFrom, derivedFromNodeType)
+ }
+
+ // NodeType Property Definitions
+ enrichNodeTypeProperties(nodeTypeName, nodeType)
+
+ //NodeType Requirement
+ enrichNodeTypeRequirements(nodeTypeName, nodeType)
+
+ //NodeType Capability
+ enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType)
+
+ //NodeType Interface
+ enrichNodeTypeInterfaces(nodeTypeName, nodeType)
+ }
+
+ open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) }
+ }
+
+ open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
+
+ nodeType.requirements?.forEach { _, requirementDefinition ->
+ // Populate Requirement Node
+ requirementDefinition.node?.let { requirementNodeTypeName ->
+ // Get Requirement NodeType from Repo and Update Service Template
+ val requirementNodeType = populateNodeType(requirementNodeTypeName)
+
+ enrichNodeType(requirementNodeTypeName, requirementNodeType)
+ }
+ }
+ }
+
+ open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition ->
+ capabilityDefinition.properties?.let { properties ->
+ enrichPropertyDefinitions(properties)
+ }
+ }
+ }
+
+ open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.interfaces?.forEach { interfaceName, interfaceObj ->
+ // Populate Node type Interface Operation
+ log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName)
+ populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj)
+
+ }
+ }
+
+ open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) {
+
+ interfaceObj.operations?.forEach { operationName, operation ->
+ enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)
+ enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)
+ }
+ }
+
+ open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ operation.inputs?.let { inputs ->
+ enrichPropertyDefinitions(inputs)
+ }
+ }
+
+ open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ operation.outputs?.let { inputs ->
+ enrichPropertyDefinitions(inputs)
+ }
+ }
+
+ open fun enrichPropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) {
+
+ properties.forEach { propertyName, propertyDefinition ->
+ enrichPropertyDefinition(propertyName, propertyDefinition)
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
+ val propertyType = propertyDefinition.type
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+ val entrySchema = propertyDefinition.entrySchema
+ ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName))
+
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
+ populateDataTypes(entrySchema.type)
+ }
+ } else {
+ populateDataTypes(propertyType)
+ }
+
+ }
+
+ open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+
+ nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
+ val artifactTypeName = artifactDefinition.type
+ ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName))
+
+ // Populate Artifact Type
+ populateArtifactType(artifactTypeName)
+ }
+ }
+
+ open fun populateNodeType(nodeTypeName: String): NodeType {
+
+ val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block()
+ ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
+ serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
+ return nodeType
+ }
+
+ open fun populateArtifactType(artifactTypeName: String): ArtifactType {
+ val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block()
+ ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
+ serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
+ return artifactType
+ }
+
+ open fun populateDataTypes(dataTypeName: String): DataType {
+ val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: bluePrintRepoService.getDataType(dataTypeName)?.block()
+ ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
+ serviceTemplate.dataTypes?.put(dataTypeName, dataType)
+ return dataType
+ }
+
+}
+
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
index 0d08985a..de6f82ff 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
@@ -19,13 +19,16 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService
+import org.springframework.stereotype.Service
/**
* ResourceAssignmentEnhancerService.
@@ -47,6 +50,7 @@ interface ResourceAssignmentEnhancerService {
*
* @author Brinda Santh
*/
+@Service
open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
: ResourceAssignmentEnhancerService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
@@ -58,20 +62,41 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti
override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
resourceAssignments: List<ResourceAssignment>) {
+ val uniqueSourceNodeTypeNames = hashSetOf<String>()
+
// Iterate the Resource Assignment and
resourceAssignments.map { resourceAssignment ->
val dictionaryName = resourceAssignment.dictionaryName!!
val dictionarySource = resourceAssignment.dictionarySource!!
- log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
+ log.debug("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
dictionaryName, dictionarySource)
- // Get the Resource Definition from Repo
- val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+ val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)
+
+ // Add Unique Node Types
+ uniqueSourceNodeTypeNames.add(sourceNodeTypeName)
+
+ // TODO("Candidate for Optimisation")
+ if (checkResourceDefinitionNeeded(resourceAssignment)) {
+
+ bluePrintEnhancerService.enrichPropertyDefinition(resourceAssignment.name, resourceAssignment.property!!);
+
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
- val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
- // Enrich as NodeTemplate
- bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate)
+ }
}
+ // Enrich the ResourceSource NodeTypes
+ uniqueSourceNodeTypeNames.map { nodeTypeName ->
+ resourceDefinitionRepoService.getNodeType(nodeTypeName).subscribe { nodeType ->
+ bluePrintEnhancerService.enrichNodeType(nodeTypeName, nodeType)
+ }
+ }
+
}
override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
@@ -82,7 +107,14 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti
return bluePrintEnhancerService.serviceTemplate
}
+ private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
+ return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
+ || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
+ && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!))
+ }
+
private fun getResourceDefinition(name: String): ResourceDefinition {
- return resourceDefinitionRepoService.getResourceDefinition(name).block()!!
+ return resourceDefinitionRepoService.getResourceDefinition(name).block()
+ ?: throw BluePrintException(format("failed to get dictionary definition({})", name))
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
index 7d16f50f..e279ec9c 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
@@ -16,12 +16,17 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionFileRepoService;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
@@ -33,18 +38,28 @@ import java.util.List;
* @author Brinda Santh
*/
public class ResourceAssignmentEnhancerServiceTest {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class);
+
+ @Before
+ public void setUp(){
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
+ }
@Test
public void testEnhanceBluePrint() throws BluePrintException {
List<ResourceAssignment> resourceAssignments = JacksonReactorUtils
- .getListFromClassPathFile("enhance/simple-enrich.json", ResourceAssignment.class).block();
+ .getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class).block();
Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load");
ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =
new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);
ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
+ log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true));
}
}
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 ab939ffa..b2e29018 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
@@ -1,5 +1,6 @@
/*
* 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.
@@ -17,7 +18,6 @@
package org.onap.ccsdk.apps.controllerblueprints.service.repository;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest {
@Test
@Commit
public void test01Save() {
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/db-source" +
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/sample-db-source" +
".json", ResourceDefinition.class);
Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition);
resourceDefinition.setName(sourceName);
@@ -88,7 +88,7 @@ public class ResourceDictionaryReactRepositoryTest {
@Test
@Commit
public void test05Delete() {
- resourceDictionaryReactRepository.deleteByName("db-source").block();
+ resourceDictionaryReactRepository.deleteByName(sourceName).block();
}
private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
index ac786d0e..272cdd08 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
@@ -42,7 +42,7 @@ import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResourceDictionaryRestTest {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
index faa10825..37cc61d1 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
@@ -45,7 +45,7 @@ import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ServiceTemplateRestTest {
@@ -143,7 +143,7 @@ public class ServiceTemplateRestTest {
List<ResourceAssignment> autoMappedResourceAssignment = autoMapResponse.getResourceAssignments();
autoMappedResourceAssignment.forEach(resourceAssignment -> {
- if ("bundle-id".equals(resourceAssignment.getName())) {
+ if ("sample-db-source".equals(resourceAssignment.getName())) {
Assert.assertEquals("Failed to assign default first source", "db",
resourceAssignment.getDictionarySource());
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
index 46b725f8..5f34b551 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
@@ -19,9 +19,11 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -33,6 +35,14 @@ import java.util.List;
public class ServiceTemplateValidationTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);
+ @Before
+ public void setUp(){
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
+ }
+
@Test
public void testBluePrintDirs() {
List<String> dirs = ConfigModelUtils.getBlueprintNames("load/blueprints");
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index 3a913b70..397f3b13 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+spring.main.banner-mode=off
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
@@ -23,7 +23,7 @@ logging.level.org.hibernate.SQL=warn
logging.level.org.hibernate.type.descriptor.sql=debug
-blueprints.load.initial-data=true
+blueprints.load.initial-data=false
load.dataTypePath=./../../application/load/model_type/data_type
load.nodeTypePath=./../../application/load/model_type/node_type
load.artifactTypePath=./../../application/load/model_type/artifact_type
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
new file mode 100644
index 00000000..3715beca
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json
@@ -0,0 +1,62 @@
+[
+ {
+ "name": "rs-db-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-db-source",
+ "dictionary-source": "db",
+ "dependencies": [
+ "input-source"
+ ]
+ },
+ {
+ "name": "ra-default-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-default-source",
+ "dictionary-source": "default",
+ "dependencies": []
+ },
+ {
+ "name": "ra-input-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-list-input-source",
+ "input-param": true,
+ "property": {
+ "type": "list",
+ "required": true,
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "dictionary-name": "ra-list-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-complex-input-source",
+ "input-param": true,
+ "property": {
+ "type": "dt-v4-aggregate",
+ "required": true
+ },
+ "dictionary-name": "sample-mdsal-source",
+ "dictionary-source": "mdsal",
+ "dependencies": []
+ }
+]
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 70d03e0a..782ed505 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
@@ -218,13 +218,13 @@
"properties": {
"mapping": [
{
- "name": "bundle-mac",
+ "name": "rs-db-source",
"property": {
"required": true,
"type": "string"
},
"input-param": false,
- "dictionary-name": "bundle-mac",
+ "dictionary-name": "sample-db-source",
"dictionary-source": "db",
"dependencies": [
"hostname"
@@ -232,7 +232,7 @@
"version": 0
},
{
- "name": "wan-aggregate-ipv4-addresses",
+ "name": "mdsal-source",
"property": {
"description": "",
"required": true,
@@ -242,7 +242,7 @@
}
},
"input-param": false,
- "dictionary-name": "wan-aggregate-ipv4-addresses",
+ "dictionary-name": "sample-mdsal-source",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
@@ -313,7 +313,7 @@
}
},
"input-param": false,
- "dictionary-name": "licenses",
+ "dictionary-name": "sample-licenses",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
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 bf3deffb..531d756b 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
@@ -114,10 +114,6 @@
"description" : "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.",
"version" : "1.0.0",
"properties" : {
- "bundle-mac" : {
- "required" : true,
- "type" : "string"
- },
"hostname" : {
"required" : true,
"type" : "string"
@@ -129,13 +125,9 @@
"type" : "dt-license-key"
}
},
- "wan-aggregate-ipv4-addresses" : {
- "description" : "",
+ "rs-db-source" : {
"required" : true,
- "type" : "list",
- "entry_schema" : {
- "type" : "dt-v4-aggregate"
- }
+ "type" : "string"
},
"service" : {
"required" : true,
@@ -144,6 +136,14 @@
"service-instance-id" : {
"required" : true,
"type" : "string"
+ },
+ "mdsal-source" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
}
},
"derived_from" : "tosca.datatypes.Dynamic"
@@ -206,6 +206,127 @@
"version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
+ "artifact-config-template" : {
+ "description" : "This is Configuration Velocity Template",
+ "version" : "1.0.0",
+ "properties" : {
+ "action-names" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "capabilities" : {
+ "content" : {
+ "type" : "tosca.capabilities.Content",
+ "properties" : {
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ },
+ "mapping" : {
+ "type" : "tosca.capabilities.Mapping",
+ "properties" : {
+ "mapping" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-resource-assignment"
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Artifact"
+ },
+ "tosca.nodes.Vnf" : {
+ "description" : "This is VNF Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Artifact" : {
+ "description" : "This is Deprecated Artifact Node Type.",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "dg-activate-netconf" : {
+ "description" : "This is Download Netconf Directed Graph",
+ "version" : "1.0.0",
+ "properties" : {
+ "mode" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "sync"
+ },
+ "version" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "LATEST"
+ },
+ "is-start-flow" : {
+ "required" : false,
+ "type" : "boolean",
+ "default" : false
+ }
+ },
+ "capabilities" : {
+ "dg-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "component-netconf-executor",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ },
+ "source-input" : {
+ "description" : "This is Input Resource Source Node Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "key" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
+ },
+ "tosca.nodes.ResourceSource" : {
+ "description" : "TOSCA base type for Resource Sources",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"component-resource-assignment" : {
"description" : "This is Resource Assignment Component API",
"version" : "1.0.0",
@@ -279,42 +400,44 @@
"version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
- "artifact-config-template" : {
- "description" : "This is Configuration Velocity Template",
+ "source-db" : {
+ "description" : "This is Database Resource Source Node Type",
"version" : "1.0.0",
"properties" : {
- "action-names" : {
+ "type" : {
"required" : true,
- "type" : "list",
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "SQL", "PLSQL" ]
+ } ]
+ },
+ "query" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
"entry_schema" : {
"type" : "string"
}
- }
- },
- "capabilities" : {
- "content" : {
- "type" : "tosca.capabilities.Content",
- "properties" : {
- "content" : {
- "required" : true,
- "type" : "string"
- }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
}
},
- "mapping" : {
- "type" : "tosca.capabilities.Mapping",
- "properties" : {
- "mapping" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-resource-assignment"
- }
- }
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
}
}
},
- "derived_from" : "tosca.nodes.Artifact"
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"vnf-netconf-device" : {
"description" : "This is VNF Device with Netconf Capability",
@@ -357,10 +480,57 @@
},
"derived_from" : "tosca.nodes.Vnf"
},
- "tosca.nodes.Vnf" : {
- "description" : "This is VNF Node Type",
+ "source-rest" : {
+ "description" : "This is Rest Resource Source Node Type",
"version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
+ "properties" : {
+ "type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON" ]
+ } ],
+ "default" : "JSON"
+ },
+ "url-path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "expression-type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON_PATH", "JSON_POINTER" ]
+ } ],
+ "default" : "JSON_PATH"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"component-netconf-executor" : {
"description" : "This is Netconf Transaction Configuration Component API",
@@ -440,62 +610,6 @@
}
},
"derived_from" : "tosca.nodes.Component"
- },
- "tosca.nodes.Artifact" : {
- "description" : "This is Deprecated Artifact Node Type.",
- "version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
- },
- "dg-activate-netconf" : {
- "description" : "This is Download Netconf Directed Graph",
- "version" : "1.0.0",
- "properties" : {
- "mode" : {
- "required" : false,
- "type" : "string",
- "default" : "sync"
- },
- "version" : {
- "required" : false,
- "type" : "string",
- "default" : "LATEST"
- },
- "is-start-flow" : {
- "required" : false,
- "type" : "boolean",
- "default" : false
- }
- },
- "capabilities" : {
- "dg-node" : {
- "type" : "tosca.capabilities.Node"
- }
- },
- "requirements" : {
- "component-dependency" : {
- "capability" : "component-node",
- "node" : "component-netconf-executor",
- "relationship" : "tosca.relationships.DependsOn"
- }
- },
- "interfaces" : {
- "CONFIG" : {
- "operations" : {
- "ActivateNetconf" : {
- "inputs" : {
- "params" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-property"
- }
- }
- }
- }
- }
- }
- },
- "derived_from" : "tosca.nodes.DG"
}
},
"topology_template" : {
@@ -704,18 +818,18 @@
"mapping" : {
"properties" : {
"mapping" : [ {
- "name" : "bundle-mac",
+ "name" : "rs-db-source",
"property" : {
"required" : true,
"type" : "string"
},
"input-param" : false,
- "dictionary-name" : "bundle-mac",
+ "dictionary-name" : "sample-db-source",
"dictionary-source" : "db",
"dependencies" : [ "hostname" ],
"version" : 0
}, {
- "name" : "wan-aggregate-ipv4-addresses",
+ "name" : "mdsal-source",
"property" : {
"description" : "",
"required" : true,
@@ -725,7 +839,7 @@
}
},
"input-param" : false,
- "dictionary-name" : "wan-aggregate-ipv4-addresses",
+ "dictionary-name" : "sample-mdsal-source",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
@@ -787,7 +901,7 @@
}
},
"input-param" : false,
- "dictionary-name" : "licenses",
+ "dictionary-name" : "sample-licenses",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json
deleted file mode 100644
index 641da80a..00000000
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json
+++ /dev/null
@@ -1,37 +0,0 @@
-[
- {
- "name": "rs-db-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "db-source",
- "dictionary-source": "db",
- "dependencies": [
- "input-source"
- ]
- },
- {
- "name": "ra-default-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "default-source",
- "dictionary-source": "default",
- "dependencies": []
- },
- {
- "name": "ra-input-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "input-source",
- "dictionary-source": "input",
- "dependencies": []
- }
-]
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
index 4a04cfdc..7b7ef756 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
@@ -1,5 +1,6 @@
<!--
~ 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.
@@ -27,8 +28,8 @@
</appender>
- <logger name="org.springframework" level="info"/>
- <logger name="org.springframework.web" level="info"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.springframework.web" level="warn"/>
<logger name="org.hibernate" level="error"/>
<logger name="org.onap.ccsdk.apps" level="info"/>
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
index 5a2a4ec0..c6dd7948 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
@@ -1,11 +1,14 @@
[
{
- "name": "input-source"
+ "name": "sample-input-source"
},
{
- "name": "v4-ip-type"
+ "name": "sample-default-source"
},
{
- "name": "db-source"
+ "name": "sample-db-source"
+ },
+ {
+ "name": "sample-mdsal-source"
}
] \ No newline at end of file