summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>2020-08-04 15:40:02 +0200
committerJulien Bertozzi <julien.bertozzi@intl.att.com>2020-08-11 11:02:14 +0000
commit547b491752b577aff4a3c0f520cc87247e2f2c38 (patch)
tree220a76dfe89bf589ad7a73b5c66e616cf258f3b4 /openecomp-be/lib
parent38e9beac2e4e5f7abf6e1d9ee21517a19fb8e45e (diff)
Fix policy element type
CSAR onboarding phase: policy element type fixed from map to list according TOSCA format documentation. Change-Id: I654f4b049a8f5129938a5d5f8307e105e2bed024 Issue-ID: SDC-3152 Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertPolicies/in/MainServiceTemplate.yaml40
6 files changed, 30 insertions, 54 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java
index 3a0b2ce401..afde5052d3 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java
@@ -45,7 +45,7 @@ public interface ServiceTemplateReaderService {
List<Object> getImports();
- Map<String, Object> getPolicies();
+ List<Object> getPolicies();
Map<String, Object> getDataTypes();
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
index fe76ba01fe..dd7e11ab2b 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
@@ -207,11 +207,9 @@ public class VnfTopologyTemplateConverter {
}
private void convertPolicies(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
- Map<String, Object> policiesAsMap = readerService.getPolicies();
- for (Map.Entry<String, Object> policy : policiesAsMap.entrySet()) {
- PolicyDefinition policyDefinition = convertPolicy(policy.getValue());
- DataModelUtil.addPolicyDefinition(serviceTemplate, policy.getKey(), policyDefinition);
- }
+ List<Object> policiesList = readerService.getPolicies();
+ policiesList.forEach(policiesListItem -> ((Map<String, Object>) policiesListItem).forEach((key, value) ->
+ DataModelUtil.addPolicyDefinition(serviceTemplate, key, convertPolicy(value))));
}
private PolicyDefinition convertPolicy(Object policyCandidate) {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
index e39a5a6c2e..9cd2d7ea07 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -61,13 +61,13 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
}
@Override
- public Map<String, Object> getPolicies() {
- Map<String, Object> policiesAsMap = new HashMap<>();
- if (!Objects.isNull(this.getTopologyTemplate()) && !Objects.isNull(
- ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES))) {
- policiesAsMap = (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES);
+ public List<Object> getPolicies() {
+ List<Object> policiesList = new ArrayList<>();
+ if (Objects.nonNull(this.getTopologyTemplate()) && Objects.nonNull(
+ ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES))) {
+ policiesList = (List<Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES);
}
- return policiesAsMap;
+ return policiesList;
}
@Override
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml
index a650f7d29d..041afbacf8 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml
@@ -548,15 +548,4 @@ topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF.vPCRF
- policies:
- scaling_aspects:
- type: tosca.policies.nfv.ScalingAspects
- properties:
- aspects:
- processing:
- name: processing
- description: aspect for processing
- max_scale_level: 5
- step_deltas:
- - delta_1
tosca_definitions_version: tosca_simple_yaml_1_0 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml
index f40f214929..0f41bb0d8b 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml
@@ -544,16 +544,5 @@ topology_template:
- virtual_link:
capability: virtual_linkable
node: Fabric
- policies:
- scaling_aspects:
- type: tosca.policies.nfv.ScalingAspects
- properties:
- aspects:
- processing:
- name: processing
- description: aspect for processing
- max_scale_level: 5
- step_deltas:
- - delta_1
substitution_mappings:
node_type: tosca.nodes.nfv.VNF.vPCRF
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertPolicies/in/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertPolicies/in/MainServiceTemplate.yaml
index 2a3de9d1e9..e2e411ba58 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertPolicies/in/MainServiceTemplate.yaml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertPolicies/in/MainServiceTemplate.yaml
@@ -549,24 +549,24 @@ topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF.vPCRF
policies:
- scaling_aspects:
- type: tosca.policies.nfv.ScalingAspects
- properties:
- aspects:
- processing:
- name: processing
- description: aspect for processing
- max_scale_level: 5
- step_deltas:
- - delta_1
- instantiation_levels:
- type: tosca.policies.nfv.InstantiationLevels
- description: test policy
- properties:
- levels:
- instantiation_level_1:
- scale_info:
- processing:
- scale_level: 0
- default_level: instantiation_level_1
+ - scaling_aspects:
+ type: tosca.policies.nfv.ScalingAspects
+ properties:
+ aspects:
+ processing:
+ name: processing
+ description: aspect for processing
+ max_scale_level: 5
+ step_deltas:
+ - delta_1
+ - instantiation_levels:
+ type: tosca.policies.nfv.InstantiationLevels
+ description: test policy
+ properties:
+ levels:
+ instantiation_level_1:
+ scale_info:
+ processing:
+ scale_level: 0
+ default_level: instantiation_level_1
tosca_definitions_version: tosca_simple_yaml_1_0 \ No newline at end of file