diff options
author | 2020-09-29 23:10:17 +0530 | |
---|---|---|
committer | 2020-10-03 15:03:26 +0530 | |
commit | c0cd58244635c610c604066e9542058b310a706d (patch) | |
tree | c9a2c2dd6608ce153549aa3b399ab4d952c60fe7 /openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java | |
parent | 0fa53516c409ac136f654475c1e41c77cad9cf09 (diff) |
sdc changes for identifying helm package as a vfm
Issue-ID: REQ-341
Signed-off-by: Sithara Nambiar <sitharav.aredath@huawei.com>
Change-Id: Ide4736655c01dd25dae5afe1207a292a6bcd6951
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java')
3 files changed, 60 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/to/FileDataCollection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/to/FileDataCollection.java index a9147b838f..b156078430 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/to/FileDataCollection.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/to/FileDataCollection.java @@ -32,11 +32,16 @@ public class FileDataCollection { Collection<FileData> addOnFiles; Collection<FileData> nestedFiles; Collection<FileData> artifactFiles; + Collection<FileData> HelmFiles; public Collection<FileData> getBaseFile() { return baseFiles; } + public Collection<FileData> getHelmFile() { + return HelmFiles; + } + public void setBaseFile(Collection<FileData> baseFiles) { this.baseFiles = baseFiles; } @@ -109,6 +114,13 @@ public class FileDataCollection { this.baseFiles.add(baseFile); } + public void addHelmFiles(FileData helmFile) { + if (this.HelmFiles == null) { + this.HelmFiles = new ArrayList<>(); + } + this.HelmFiles.add(helmFile); + } + /** * Add artifact files. * diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java index 6649c90adb..d204281d6b 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java @@ -220,6 +220,19 @@ public class HeatToToscaUtil { return null; } + static FileDataCollection getFileCollectionsByHelmFilter(List<FileData> fileDataList, Set<FileData.Type> typeFilter) { + FileDataCollection fileDataCollection = new FileDataCollection(); + Map<String, FileData> filteredFiles = filterFileDataListByType(fileDataList, typeFilter); + for (FileData fileData : filteredFiles.values()) { + String fileName = fileData.getFile(); + if((fileData.getType().equals(FileData.Type.HELM))) + { + fileDataCollection.addHelmFiles(fileData); + } + } + return fileDataCollection; + } + static FileDataCollection getFileCollectionsByFilter(List<FileData> fileDataList, Set<FileData.Type> typeFilter, TranslationContext translationContext) { FileDataCollection fileDataCollection = new FileDataCollection(); diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java index 339d6ff023..6d22a3602c 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java @@ -70,6 +70,12 @@ public class TranslationService { return types; } + public static Set<FileData.Type> getTypesToProcessByHelmTranslator() { + Set<FileData.Type> types = new HashSet<>(); + types.add(FileData.Type.HELM); + return types; + } + /** * Translate heat files translator output. * @@ -81,6 +87,8 @@ public class TranslationService { List<FileData> fileDataList = translationContext.getManifest().getContent().getData(); FileDataCollection fileDataCollection = HeatToToscaUtil.getFileCollectionsByFilter(fileDataList, TranslationService.getTypesToProcessByTranslator(), translationContext); + FileDataCollection fileDataCollectionHelm = HeatToToscaUtil.getFileCollectionsByHelmFilter(fileDataList, + TranslationService.getTypesToProcessByHelmTranslator()); if (fileDataCollection.getBaseFile() != null) { for (FileData fileData : fileDataCollection.getBaseFile()) { @@ -93,6 +101,13 @@ public class TranslationService { } } + if (fileDataCollectionHelm.getHelmFile() !=null) { + for (FileData fileData : fileDataCollectionHelm.getHelmFile()) { + translateHelmFile(mainServiceTemplate, fileData, translationContext); + + } + } + ToscaServiceModel toscaServiceModel = HeatToToscaUtil.createToscaServiceModel(mainServiceTemplate, translationContext); @@ -145,6 +160,26 @@ public class TranslationService { } } + + public void translateHelmFile(ServiceTemplate serviceTemplate, FileData heatFileData, + TranslationContext context) { + String heatFileName = heatFileData.getFile(); + Map<String, ParameterDefinition> inputs = serviceTemplate.getTopology_template().getInputs(); + if (!Objects.isNull(inputs)) { + + inputs.entrySet().forEach( + stringParameterDefinitionEntry -> { + List inputParamVFModuleList = getVFModulesList( + inputs.get(stringParameterDefinitionEntry.getKey())); + if (!inputParamVFModuleList.contains(FileUtils.getFileWithoutExtention(heatFileName)) ){ + inputParamVFModuleList.add(FileUtils.getFileWithoutExtention(heatFileName)); + } + } + ); + } + inputs.putAll(inputs); + } + private void handleHeatPseudoParam(String heatFileName, ServiceTemplate serviceTemplate, TranslationContext context) { Map<String, String> translatedHeatPseudoParam = |