aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorAvi Gaffa <avi.gaffa@amdocs.com>2017-09-12 11:00:02 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-12 11:00:02 +0000
commite6fc26ab18d1409c490c859398fc5fca71d0518b (patch)
tree30441a6b43e2507e8cdef3589a5defc74083263f /openecomp-be/lib
parenta0858efdab2f9bdc5d46be5655cdbb76708f4763 (diff)
parentc8a540b3c234449163f6fb1899807bba951113b4 (diff)
Merge "Create new VSP, onboard from TOSCA file - UI"
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java14
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java47
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java1
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java14
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java32
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml7
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java5
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java32
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java70
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/pom.xml27
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java79
-rw-r--r--openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml5
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-api/pom.xml37
-rw-r--r--openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-core/pom.xml42
-rw-r--r--openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-impl/pom.xml30
-rw-r--r--openecomp-be/lib/openecomp-sdc-orchestration-lib/pom.xml23
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml35
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java24
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ToscaConverter.java12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java45
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/factory/ToscaConverterFactory.java12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml51
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java59
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java446
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java49
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java76
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/resources/ToscaConverters.json3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java193
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java62
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/csar/vCSCF.csarbin0 -> 8186 bytes
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/checksum.lst1
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/csar.meta3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Definitions/GlobalSubstitutionTypesServiceTemplate.yaml60
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.mf12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml551
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/TOSCA-Metadata/TOSCA.meta135
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml546
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml23
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java18
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java3
-rw-r--r--openecomp-be/lib/pom.xml2
54 files changed, 2962 insertions, 48 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 9fff4bd749..8bcb0a5ffe 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -28,6 +28,14 @@ public enum Messages {
"functionalities"),
INVALID_ZIP_FILE("Invalid zip file"),
+ INVALID_CSAR_FILE("Invalid csar file"),
+ CSAR_FILE_NOT_FOUND("Each CSAR file must contain %s file."),
+ CSAR_DIRECTORIES_NOT_ALLOWED("Directory : %s , is not allowed."),
+ CSAR_FILES_NOT_ALLOWED("File : %s , are not allowed."),
+ MANIFEST_INVALID_LINE("Manifest contains invalid line : %s"),
+ MANIFEST_NO_METADATA("Manifest must contain metadata"),
+ MANIFEST_NO_SOURCES("Manifest must contain source"),
+ MANIFEST_PARSER_INTERNAL("Invalid manifest file"),
FAILED_TO_TRANSLATE_ZIP_FILE("Failed to translate zip file"),
ZIP_NOT_EXIST("Zip file doesn't exist"),
@@ -45,7 +53,7 @@ public enum Messages {
NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST("no zip file was uploaded or zip file doesn't exist"),
MAPPING_OBJECTS_FAILURE("Failed to map object %s to %s. Exception message: %s"),
MORE_THEN_ONE_VOL_FOR_HEAT("heat contains more then one vol. selecting only first vol"),
- ZIP_CONTENT_MAP("failed to load zip content"),
+ FILE_CONTENT_MAP("failed to load %s content"),
CREATE_MANIFEST_FROM_ZIP("cannot create manifest from the attached zip file"),
CANDIDATE_PROCESS_FAILED("Candidate zip file process failed"),
FOUND_UNASSIGNED_FILES("cannot process zip since it has unassigned files"),
@@ -66,7 +74,9 @@ public enum Messages {
INVALID_MANIFEST_FILE("invalid manifest file"),
INVALID_FILE_TYPE("Missing or Unknown file type in Manifest"),
ENV_NOT_ASSOCIATED_TO_HEAT("ENV file must be associated to a HEAT file"),
-
+ CSAR_MANIFEST_FILE_NOT_EXIST("CSAR manifest file does not exist"),
+ CSAR_FAILED_TO_READ("CSAR file is not readable"),
+ TOSCA_PARSING_FAILURE("Invalid tosca file. Error code : %s, Error message : %s/"),
/* content errors*/
INVALID_YAML_FORMAT("Invalid YAML format - %s"),
INVALID_YAML_FORMAT_REASON("Invalid YAML format Problem - [%s]"),
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index f4d6209eec..1c5293004d 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -22,8 +22,11 @@ package org.openecomp.sdc.common.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -45,38 +48,54 @@ import java.util.zip.ZipInputStream;
public class CommonUtil {
- public static FileContentHandler validateAndUploadFileContent(byte[] uploadedFileData)
+ public static FileContentHandler validateAndUploadFileContent(OnboardingTypesEnum type,
+ byte[] uploadedFileData)
throws IOException {
- return getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(uploadedFileData);
+ return getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(type, uploadedFileData);
}
/**
* Gets files out of the zip AND validates zip is flat (no folders)
*
+ *
+ * @param type
* @param uploadFileData zip file
* @return FileContentHandler if input is valid and has no folders
*/
private static FileContentHandler getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(
- byte[] uploadFileData)
+ OnboardingTypesEnum type, byte[] uploadFileData)
throws IOException {
+ Pair<FileContentHandler,List<String> > pair = getFileContentMapFromOrchestrationCandidateZip(uploadFileData);
- List<String> folderList = new ArrayList<>();
- FileContentHandler mapFileContent = new FileContentHandler();
+ if(type.equals(OnboardingTypesEnum.ZIP)) {
+ validateNoFolders(pair.getRight());
+ }
- try (ZipInputStream inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData))) {
+ return pair.getLeft();
+ }
+ public static Pair<FileContentHandler,List<String> > getFileContentMapFromOrchestrationCandidateZip(
+ byte[] uploadFileData)
+ throws IOException {
+ ZipEntry zipEntry;
+ List<String> folderList = new ArrayList<>();
+ FileContentHandler mapFileContent = new FileContentHandler();
+ try ( ByteArrayInputStream in = new ByteArrayInputStream(uploadFileData);
+ ZipInputStream inputZipStream = new ZipInputStream(in)){
+ byte[] fileByteContent;
String currentEntryName;
- ZipEntry zipEntry;
while ((zipEntry = inputZipStream.getNextEntry()) != null) {
-
currentEntryName = zipEntry.getName();
+ // else, get the file content (as byte array) and save it in a map.
+ fileByteContent = FileUtils.toByteArray(inputZipStream);
+
int index = lastIndexFileSeparatorIndex(currentEntryName);
if (index != -1) { //todo ?
folderList.add(currentEntryName);
- } else {
- // else, get the file content (as byte array) and save it in a map.
- mapFileContent.addFile(currentEntryName, FileUtils.toByteArray(inputZipStream));
+ }
+ if(isFile(currentEntryName)) {
+ mapFileContent.addFile(currentEntryName, fileByteContent);
}
}
@@ -84,9 +103,11 @@ public class CommonUtil {
throw new IOException(exception);
}
- validateNoFolders(folderList);
+ return new ImmutablePair<>(mapFileContent,folderList);
+ }
- return mapFileContent;
+ private static boolean isFile(String currentEntryName) {
+ return !(currentEntryName.endsWith("\\") || currentEntryName.endsWith("/"));
}
private static void validateNoFolders(List<String> folderList) {
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
index 156a86c841..24da8363c1 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.common.utils;
public class SdcCommon {
public static final String MANIFEST_NAME = "MANIFEST.json";
+ public static final String CSAR_MANIFEST_NAME = "MainServiceTemplate.mf";
public static final String UPLOAD_FILE = "uploadFile";
public static final String PROCESS_FILE = "Process File";
public static final String ILLEGAL_MANIFEST = "Illegal manifest";
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
index e04f02cce5..0fb587cc68 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
@@ -20,6 +20,7 @@
package org.openecomp.core.utilities.file;
+import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.tosca.services.YamlUtil;
@@ -195,6 +196,19 @@ public class FileUtils {
return fileName.substring(0, fileName.lastIndexOf("."));
}
+ public static String getFileExtension(String filename) {
+ return FilenameUtils.getExtension(filename);
+ }
+
+ public static String getNetworkPackageName(String filename){
+ String[] split = filename.split("\\.");
+ String name = null;
+ if (split != null && split.length > 1){
+ name = split[0];
+ }
+ return name;
+ }
+
/**
* Gets file content map from zip.
*
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
new file mode 100644
index 0000000000..04e64c33a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
@@ -0,0 +1,32 @@
+package org.openecomp.core.utilities.orchestration;
+
+import java.util.Optional;
+
+import static java.util.Arrays.asList;
+public enum OnboardingTypesEnum {
+ CSAR("csar"), ZIP("zip"), NONE("none");
+ private String type;
+
+ OnboardingTypesEnum(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return type;
+ }
+
+ public static final OnboardingTypesEnum getOnboardingTypesEnum(final String inStr) {
+ if (inStr == null) {
+ return null;
+ }
+ Optional<OnboardingTypesEnum> onboardingTypesOptional = asList(OnboardingTypesEnum.values()).stream()
+ .filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equals(inStr)).findAny();
+ if( onboardingTypesOptional.isPresent()){
+ return onboardingTypesOptional.get();
+ }else {
+ return null;
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
index 618922c2af..03ee98dd4e 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -33,6 +33,13 @@
<artifactId>openecomp-sdc-vendor-license-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index bdb7bc3a93..9800d02ba6 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -27,6 +27,7 @@ import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
@@ -49,7 +50,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
@@ -300,7 +300,8 @@ public class CompositionDataHealer implements Healer {
FileContentHandler fileContentHandler;
try {
fileContentHandler =
- CommonUtil.validateAndUploadFileContent(uploadData.getContentData().array());
+ CommonUtil.validateAndUploadFileContent(
+ OnboardingTypesEnum.ZIP, uploadData.getContentData().array());
return HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
} catch (Exception e) {
return null;
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
index e0b7adb6d3..0d484440cf 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -94,7 +95,7 @@ public class FileDataStructureHealer implements Healer {
byte[] byteContentData = uploadData.getContentData().array();
FileContentHandler fileContentHandler;
try{
- fileContentHandler = CommonUtil.validateAndUploadFileContent(byteContentData);
+ fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
Map<String, List<ErrorMessage>> errors = new HashMap<>();
OrchestrationTemplateCandidateData candidateDataEntity =
new CandidateEntityBuilder(candidateService)
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
index d5ccd36c95..44b6062e89 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
@@ -8,6 +8,7 @@ import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
@@ -53,7 +54,7 @@ public class HeatToToscaTranslationHealer implements Healer {
FileContentHandler fileContentHandler;
TranslatorOutput translatorOutput;
try {
- fileContentHandler = CommonUtil.validateAndUploadFileContent(uploadData
+ fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
.getContentData().array());
translatorOutput =
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
index 5d6050a7f0..0b06fb1c83 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
@@ -1,11 +1,10 @@
package org.openecomp.sdc.healing.healers;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -15,15 +14,18 @@ import java.util.Map;
import java.util.Objects;
public class VspOnboardingMethodHealer implements Healer {
- /*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();*/
- private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
+ private static VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
public VspOnboardingMethodHealer(){
+ }
+ public VspOnboardingMethodHealer( VendorSoftwareProductInfoDao inVendorSoftwareProductInfoDao){
+ vendorSoftwareProductInfoDao = inVendorSoftwareProductInfoDao;
}
+
+
@Override
public Object heal(Map<String, Object> healingParams) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null, null);
@@ -33,14 +35,22 @@ public class VspOnboardingMethodHealer implements Healer {
Version version = (Version) healingParams.get(SdcCommon.VERSION);
VspDetails vendorSoftwareProductInfo =
vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
- vendorSoftwareProductInfo.getOnboardingMethod();
+ String onboardingValue = vendorSoftwareProductInfo.getOnboardingMethod();
- if(Objects.isNull(vendorSoftwareProductInfo.getOnboardingMethod())) {
- onboardingMethod="HEAT";
- vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
- vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
- //vendorSoftwareProductDao.updateVendorSoftwareProductInfo(vendorSoftwareProductInfo);
+ if(Objects.isNull(onboardingValue)) {
+ onboardingMethod="NetworkPackage";
+
+ updateVSPInfo(OnboardingTypesEnum.ZIP.toString(), onboardingMethod, vendorSoftwareProductInfo);
+ } else if (onboardingValue.equals("HEAT")){
+ onboardingMethod="NetworkPackage";
+ updateVSPInfo(OnboardingTypesEnum.ZIP.toString(),onboardingMethod, vendorSoftwareProductInfo);
}
return onboardingMethod;
}
+
+ private void updateVSPInfo(String onboardingOrigin, String onboardingMethod, VspDetails vendorSoftwareProductInfo) {
+ vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
+ vendorSoftwareProductInfo.setOnboardingOrigin(onboardingOrigin);
+ vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
new file mode 100644
index 0000000000..b732cb03b6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
@@ -0,0 +1,70 @@
+package org.openecomp.sdc.healing.healers;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+
+public class VspOnboardingMethodHealerTest{
+
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
+ }
+
+ @Test
+ public void checkHealingWithNullOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod(null);
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
+ assertEquals(vspDetails.getOnboardingOrigin(),"zip");
+ }
+
+ @Test
+ public void checkHealingWithHEATOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod("HEAT");
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
+ assertEquals(vspDetails.getOnboardingOrigin(),"zip");
+ }
+
+ @Test
+ public void checkHealingWithManualOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod("Manual");
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"Manual");
+ assertEquals(vspDetails.getOnboardingOrigin(),null);
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/pom.xml b/openecomp-be/lib/openecomp-heat-lib/pom.xml
index 55ab0623b4..0a4e14f417 100644
--- a/openecomp-be/lib/openecomp-heat-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-heat-lib/pom.xml
@@ -16,6 +16,18 @@
<dependencies>
<dependency>
<groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-core</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
<artifactId>openecomp-tosca-datatype</artifactId>
<version>${openecomp.sdc.common.version}</version>
</dependency>
@@ -52,4 +64,19 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${mvn.surefire.version}</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java
new file mode 100644
index 0000000000..517c690194
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java
@@ -0,0 +1,79 @@
+package org.openecomp.sdc.heat.services.tree;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.heat.datatypes.structure.Artifact;
+import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class ToscaTreeManager {
+
+ private static Logger logger = (Logger) LoggerFactory.getLogger(ToscaTreeManager.class);
+
+ private FileContentHandler csarContentMap = new FileContentHandler();
+ private byte[] manifest;
+ private HeatStructureTree tree = new HeatStructureTree();
+ private Map<String, Artifact> artifactRef = new HashMap<>();
+ private Map<String, HeatStructureTree> fileTreeRef = new HashMap<>();
+
+
+ public void addFile(String fileName, byte[] content) {
+ if (fileName.equals(SdcCommon.CSAR_MANIFEST_NAME)) {
+ manifest = content;
+
+ } else {
+ csarContentMap.addFile(fileName, content);
+ }
+ }
+
+ public void createTree(){
+ if (manifest == null) {
+ logger.error("Missing manifest file in the zip.");
+ return;
+ }
+
+ for(Map.Entry<String, byte[]> fileEntry : csarContentMap.getFiles().entrySet()){
+ String[] splitFilename = getFullFileNameAsArray(fileEntry.getKey());
+ addFileToTree(splitFilename, 0, tree);
+ }
+
+
+ }
+
+ private void addFileToTree(String[] splitFilename, int startIndex, HeatStructureTree parent){
+ fileTreeRef.putIfAbsent(splitFilename[startIndex], new HeatStructureTree());
+ HeatStructureTree heatStructureTree = fileTreeRef.get(splitFilename[startIndex]);
+ heatStructureTree.setFileName(splitFilename[startIndex]);
+ if(startIndex < splitFilename.length - 1){
+ addFileToTree(splitFilename, startIndex + 1, heatStructureTree);
+ }
+ parent.addHeatStructureTreeToNestedHeatList(heatStructureTree);
+ }
+
+ public void addErrors(Map<String, List<ErrorMessage>> validationErrors){
+ validationErrors.entrySet().stream().filter(entry -> {
+ return fileTreeRef.get(entry.getKey()) != null;
+ }).forEach(entry -> entry.getValue().stream().forEach(error ->
+ fileTreeRef.get(entry.getKey()).addErrorToErrorsList(error)));
+ }
+
+ private String[] getFullFileNameAsArray(String filename){
+ if(filename.contains("/")){
+ return filename.split("/");
+ }
+
+ return filename.split(Pattern.quote(File.separator));
+ }
+
+ public HeatStructureTree getTree(){
+ return tree;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java
index de39cff30f..387b2046fd 100644
--- a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java
+++ b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java
@@ -30,6 +30,7 @@ public class AuditMessages {
public static final String HEAT_VALIDATION_STARTED = "HEAT validation started. VSP Id: ";
public static final String HEAT_VALIDATION_COMPLETED = "HEAT validation completed. VSP Id: ";
public static final String HEAT_VALIDATION_ERROR = "HEAT validation error: %s. VSP Id: %s";
+ public static final String CSAR_VALIDATION_STARTED = "CSAR validation started. VSP Id: ";
public static final String HEAT_TRANSLATION_STARTED = "HEAT translation started. VSP Id: ";
public static final String HEAT_TRANSLATION_COMPLETED = "HEAT translation completed. VSP Id: ";
public static final String ENRICHMENT_ERROR = "Enrichment error: %s. VSP Id: %s";
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
index 30c4bde443..b3b7598c11 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
@@ -56,5 +56,10 @@
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
index 575ba856a7..a7fecdd806 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
@@ -22,9 +22,9 @@ import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.core.converter.datatypes.Constants;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
diff --git a/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-api/pom.xml b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-api/pom.xml
new file mode 100644
index 0000000000..87a93ee6dd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-api/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchestration-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchesrtation-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-core/pom.xml b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-core/pom.xml
new file mode 100644
index 0000000000..343ff0213c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-core/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchesrtation-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchestration-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchesrtation-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-impl/pom.xml
new file mode 100644
index 0000000000..8ecfa0de9e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-orchestration-lib/openecomp-sdc-orchesrtation-impl/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchesrtation-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchestration-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-orchesrtation-impl</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-orchestration-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-orchestration-lib/pom.xml
new file mode 100644
index 0000000000..dbcef4da29
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-orchestration-lib/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>openecomp-sdc-orchestration-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <modules>
+ <module>openecomp-sdc-orchesrtation-api</module>
+ <module>openecomp-sdc-orchesrtation-core</module>
+ <module>openecomp-sdc-orchesrtation-impl</module>
+ </modules>
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
index 2758e3dfe9..ccadeced62 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
@@ -61,6 +61,11 @@ public class VspDetails implements VersionableEntity {
private Long writetimeMicroSeconds;
private String onboardingMethod;
+
+ private String onboardingOrigin;
+
+ private String networkPackageName;
+
public VspDetails() {
}
@@ -215,12 +220,29 @@ public class VspDetails implements VersionableEntity {
this.oldVersion = oldVersion;
}
+ public String getOnboardingOrigin() {
+ return onboardingOrigin;
+ }
+
+ public void setOnboardingOrigin(String onboardingOrigin) {
+ this.onboardingOrigin = onboardingOrigin;
+ }
+
public String getOnboardingMethod() {
return onboardingMethod;
}
public void setOnboardingMethod(String onboardingMethod) {
this.onboardingMethod = onboardingMethod;
}
+
+ public String getNetworkPackageName() {
+ return networkPackageName;
+ }
+
+ public void setNetworkPackageName(String networkPackageName) {
+ this.networkPackageName = networkPackageName;
+ }
+
@Override
public String toString() {
return String.format(
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 4ca623e6a3..6cc639fac0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -21,10 +21,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
@@ -61,9 +61,12 @@ public interface CandidateService {
Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
OrchestrationTemplateCandidateData candidateDataEntity,
- String manifest, Map<String, List<ErrorMessage>> uploadErrors);
+ String manifest,
+ OnboardingTypesEnum type,
+ Map<String, List<ErrorMessage>> uploadErrors);
- byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId)
+ byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
+ OnboardingTypesEnum type)
throws IOException;
Optional<ManifestContent> createManifest(VspDetails vspDetails,
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index 9540f3d965..ca5329344b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -75,6 +75,14 @@ public class CandidateEntityBuilder {
return candidateDataEntity;
}
+// public OrchestrationTemplateCandidateData buildOrchestrationTemplateFromCsar(VspDetails vspDetails,
+// byte[] uploadedFileData,
+// FileContentHandler contentMap,
+// Map<String, List<ErrorMessage>> uploadErrors,
+// String user){
+//
+// }
+
private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
FileContentHandler contentMap,
AnalyzedZipHeatFiles analyzedZipHeatFiles) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
index eef90d4742..7ad7929ccb 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
@@ -200,6 +200,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
info.addProperty(InfoPropertyName.featureGroups.name(), vspDetails.getFeatureGroups());
info.addProperty(InfoPropertyName.oldVersion.name(), vspDetails.getOldVersion());
info.addProperty(InfoPropertyName.onboardingMethod.name(), vspDetails.getOnboardingMethod());
+ info.addProperty(InfoPropertyName.obBoardingOrigin.name(), vspDetails.getOnboardingOrigin());
+ info.addProperty(InfoPropertyName.networkPackageName.name(), vspDetails.getNetworkPackageName());
}
private VspDetails mapInfoToVspDetails(String vspId, Version version, Info info,
@@ -215,6 +217,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
Version.valueOf(info.getProperty(InfoPropertyName.vendorVersion.name())));
vspDetails.setLicenseAgreement(info.getProperty(InfoPropertyName.licenseAgreement.name()));
vspDetails.setFeatureGroups(info.getProperty(InfoPropertyName.featureGroups.name()));
+
vspDetails.setWritetimeMicroSeconds(
modificationTime == null ? creationTime.getTime() : modificationTime.getTime());
vspDetails.setVersion(version);
@@ -223,7 +226,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
//Boolean oldVersion = ind == null || "true".equals( ind.toLowerCase());
vspDetails.setOldVersion(oldVersion);
vspDetails.setOnboardingMethod(info.getProperty(InfoPropertyName.onboardingMethod.name()));
-
+ vspDetails.setOnboardingOrigin(info.getProperty(InfoPropertyName.obBoardingOrigin.name()));
+ vspDetails.setNetworkPackageName(info.getProperty(InfoPropertyName.networkPackageName.name()));
return vspDetails;
}
@@ -239,7 +243,9 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
licenseAgreement,
featureGroups,
oldVersion,
- onboardingMethod
+ onboardingMethod,
+ obBoardingOrigin,
+ networkPackageName
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 6ccece1e76..e5f1a4c3ac 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructurem
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -89,17 +90,17 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
- public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload) {
+ public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
mdcDataDebugMessage.debugEntryMessage(null);
- if (Objects.isNull(heatFileToUpload)) {
+ if (Objects.isNull(fileToUpload)) {
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
} else {
try {
- int available = heatFileToUpload.available();
+ int available = fileToUpload.available();
if (available == 0) {
mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
@@ -321,10 +322,7 @@ public class CandidateServiceImpl implements CandidateService {
public void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData,
String itemId) {
mdcDataDebugMessage.debugEntryMessage(null);
-
- //vendorSoftwareProductDao.updateCandidateUploadData(uploadData);
orchestrationTemplateCandidateDataDao.update(itemId, uploadData);
-
mdcDataDebugMessage.debugExitMessage(null);
}
@@ -393,11 +391,12 @@ public class CandidateServiceImpl implements CandidateService {
public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
OrchestrationTemplateCandidateData candidateDataEntity,
String manifest,
+ OnboardingTypesEnum type,
Map<String, List<ErrorMessage>> uploadErrors) {
byte[] file;
ByteArrayInputStream byteArrayInputStream = null;
try {
- file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId);
+ file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type);
byteArrayInputStream = new ByteArrayInputStream(
Objects.isNull(file) ? candidateDataEntity.getContentData().array()
: file);
@@ -413,7 +412,8 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
- public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId)
+ public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
+ OnboardingTypesEnum type)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -433,12 +433,12 @@ public class CandidateServiceImpl implements CandidateService {
}
} else {
manifestWritten = true;
- writeManifest(manifest, zos);
+ writeManifest(manifest, type, zos);
}
zos.closeEntry();
}
if (!manifestWritten) {
- writeManifest(manifest, zos);
+ writeManifest(manifest, type, zos);
zos.closeEntry();
}
}
@@ -451,7 +451,14 @@ public class CandidateServiceImpl implements CandidateService {
return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
}
- private void writeManifest(String manifest, ZipOutputStream zos) throws IOException {
+ private void writeManifest(String manifest,
+ OnboardingTypesEnum type,
+ ZipOutputStream zos) throws IOException {
+
+ if(isManifestNeedsToGetWritten(type)){
+ return;
+ }
+
zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME));
try (InputStream manifestStream = new ByteArrayInputStream(
manifest.getBytes(StandardCharsets.UTF_8))) {
@@ -463,6 +470,10 @@ public class CandidateServiceImpl implements CandidateService {
}
}
+ private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) {
+ return type.equals(OnboardingTypesEnum.CSAR);
+ }
+
private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) {
if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml
new file mode 100644
index 0000000000..faf890f672
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-tosca-datatype</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
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
new file mode 100644
index 0000000000..09c823ce7e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ServiceTemplateReaderService.java
@@ -0,0 +1,24 @@
+package org.openecomp.core.converter;
+
+import java.util.Map;
+
+public interface ServiceTemplateReaderService {
+
+ Map<String, Object> readServiceTemplate(byte[] serivceTemplateContent);
+
+ Object getMetadata();
+
+ Object getToscaVersion();
+
+ Object getNodeTypes();
+
+ Object getTopologyTemplate();
+
+ Map<String, Object> getNodeTemplates();
+
+ Map<String, Object> getInputs();
+
+ Map<String, Object> getOutputs();
+
+ Map<String, Object> getSubstitutionMappings();
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ToscaConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ToscaConverter.java
new file mode 100644
index 0000000000..543d32347f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/ToscaConverter.java
@@ -0,0 +1,12 @@
+package org.openecomp.core.converter;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+
+import java.io.IOException;
+
+public interface ToscaConverter {
+
+ ToscaServiceModel convert(FileContentHandler fileContentHandler)
+ throws IOException;
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java
new file mode 100644
index 0000000000..1cf010c1b5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java
@@ -0,0 +1,9 @@
+package org.openecomp.core.converter.api;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+
+public interface ToscaConverterManager {
+
+ ToscaServiceModel convert(String csarName, FileContentHandler fileContentHandler);
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
new file mode 100644
index 0000000000..6f7e6be8af
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
@@ -0,0 +1,45 @@
+package org.openecomp.core.converter.datatypes;
+
+import java.io.File;
+
+public class Constants {
+ public static final String mainStName = "MainServiceTemplate.yaml";
+ public static final String globalStName = "GlobalSubstitutionTypesServiceTemplate.yaml";
+ public static final String manifestFileName = "MainServiceTemplate.mf";
+ public static final String definitionsDir = "Definitions/";
+ public static final String metadataFile = "TOSCA-Metadata/TOSCA.meta";
+
+
+ public static final String definitionVersion = "tosca_definitions_version";
+ private static final String DEFAULT_NAMESPACE = "tosca_default_namespace";
+ private static final String TEMPLATE_NAME = "template_name";
+ public static final String topologyTemplate = "topology_template";
+ private static final String TEMPLATE_AUTHOR = "template_author";
+ private static final String TEMPLATE_VERSION = "template_version";
+ private static final String DESCRIPTION = "description";
+ private static final String IMPORTS = "imports";
+ private static final String DSL_DEFINITIONS = "dsl_definitions";
+ public static final String nodeType = "node_type";
+ public static final String nodeTypes = "node_types";
+ private static final String RELATIONSHIP_TYPES = "relationship_types";
+ private static final String RELATIONSHIP_TEMPLATES = "relationship_templates";
+ private static final String CAPABILITY_TYPES = "capability_types";
+ private static final String ARTIFACT_TYPES = "artifact_types";
+ private static final String DATA_TYPES = "data_types";
+ private static final String INTERFACE_TYPES = "interface_types";
+ private static final String POLICY_TYPES = "policy_types";
+ private static final String GROUP_TYPES = "group_types";
+ private static final String REPOSITORIES = "repositories";
+ public static final String metadata = "metadata";
+ public static final String nodeTemplates = "node_templates";
+ public static final String inputs = "inputs";
+ public static final String outputs = "outputs";
+ public static final String substitutionMappings = "substitution_mappings";
+ public static final String capabilities = "capabilities";
+ public static final String requirements = "requirements";
+
+ public static final String openecompHeatIndex = "openecomp_heat_index";
+ public static final String globalSubstitution = "GlobalSubstitutionTypes";
+
+ public static final String externalFilesFolder = "External" + File.separator;
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
new file mode 100644
index 0000000000..323bd8a5fb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
@@ -0,0 +1,9 @@
+package org.openecomp.core.converter.datatypes;
+
+public enum CsarFileTypes {
+ mainServiceTemplate,
+ globalServiceTemplate,
+ externalFile,
+ toscaMetadata,
+ definitionsFile,;
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/factory/ToscaConverterFactory.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/factory/ToscaConverterFactory.java
new file mode 100644
index 0000000000..7506759d25
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/factory/ToscaConverterFactory.java
@@ -0,0 +1,12 @@
+package org.openecomp.core.converter.factory;
+
+import org.openecomp.core.converter.ToscaConverter;
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ToscaConverterFactory extends AbstractComponentFactory<ToscaConverter> {
+
+ public static ToscaConverterFactory getInstance(){
+ return AbstractFactory.getInstance(ToscaConverterFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..d9f4ff3cbd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.converter.factory.ToscaConverterFactory" : "org.openecomp.core.impl.factory.ToscaConverterFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
new file mode 100644
index 0000000000..39f02becf8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.jtosca</groupId>
+ <artifactId>jtosca</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-translator-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
new file mode 100644
index 0000000000..2d33748e26
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
@@ -0,0 +1,59 @@
+package org.openecomp.core.impl;
+
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
+ private static final Logger logger = LoggerFactory.getLogger(ServiceTemplate.class);
+
+ public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME = "GlobalSubstitutionServiceTemplate.yaml";
+ public static final String TEMPLATE_NAME_PROPERTY = "template_name";
+ public static final String DEFININTION_VERSION = "tosca_simple_yaml_1_0_0";
+ public static final String HEAT_INDEX = "openecomp_heat_index";
+
+ public GlobalSubstitutionServiceTemplate() {
+ super();
+ init();
+ }
+
+
+ public void appendNodes(Map<String, NodeType> nodes) {
+ getNode_types().putAll(nodes);
+ }
+
+ public void init() {
+ writeDefinitionSection();
+ writeMetadataSection();
+ writeImportsSection();
+ setNode_types(new HashMap<>());
+ }
+
+ private void writeImportsSection() {
+ List<Map<String, Import>> imports = new ArrayList<>();
+ Map<String, Import> stringImportMap = new HashMap<>();
+ imports.add(stringImportMap);
+ setImports(imports);
+ Import imprtObj = new Import();
+ imprtObj.setFile("openecomp-heat/_index.yml");
+ stringImportMap.put("openecomp_heat_index", imprtObj);
+ }
+
+
+ private void writeMetadataSection() {
+ Map<String, String> metadata = new HashMap<>();
+ metadata.put(TEMPLATE_NAME_PROPERTY, "GlobalSubstitutionTypes");
+ setMetadata(metadata);
+ }
+
+ private void writeDefinitionSection() {
+ setTosca_definitions_version(DEFININTION_VERSION);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
new file mode 100644
index 0000000000..c4ed6f9c5f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -0,0 +1,446 @@
+package org.openecomp.core.impl;
+
+import org.apache.commons.collections.MapUtils;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.ToscaConverter;
+import org.openecomp.core.converter.datatypes.Constants;
+import org.openecomp.core.converter.datatypes.CsarFileTypes;
+import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.*;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
+import org.yaml.snakeyaml.error.YAMLException;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.jar.Manifest;
+import java.util.regex.Pattern;
+
+import static org.openecomp.core.converter.datatypes.Constants.*;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
+
+public class ToscaConverterImpl implements ToscaConverter {
+
+ public ToscaConverterImpl() {
+
+ }
+
+ @Override
+ public ToscaServiceModel convert(FileContentHandler fileContentHandler)
+ throws IOException {
+ Map<String, byte[]> csarFiles = new HashMap<>(fileContentHandler.getFiles());
+ ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
+ Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+ FileContentHandler artifacts = new FileContentHandler();
+ GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate();
+ for (Map.Entry<String, byte[]> fileEntry : csarFiles.entrySet()) {
+ CsarFileTypes fileType = getFileType(fileEntry.getKey());
+ switch (fileType) {
+ case mainServiceTemplate:
+ handleServiceTemplate(mainStName, fileEntry.getKey(), csarFiles, serviceTemplates);
+ break;
+
+ case globalServiceTemplate:
+ handleServiceTemplate(globalStName, fileEntry.getKey(), csarFiles, serviceTemplates);
+ break;
+
+ case externalFile:
+ artifacts.addFile(fileEntry.getKey(), fileEntry.getValue());
+ break;
+
+ case definitionsFile:
+ handleDefintionTemplate(fileEntry.getKey(), csarFiles, gsst);
+ break;
+ }
+ }
+ handleMetadataFile(csarFiles);
+ updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles);
+ return toscaServiceModel;
+ }
+
+ private void handleMetadataFile(Map<String, byte[]> csarFiles) {
+ byte[] bytes = csarFiles.remove(metadataFile);
+ if (bytes != null) {
+ csarFiles.put(metadataFile + ".old", bytes);
+ }
+ }
+
+ private void handleDefintionTemplate(String key, Map<String, byte[]> csarFiles,
+ GlobalSubstitutionServiceTemplate gsst) {
+ try {
+ ServiceTemplateReaderService readerService = new ServiceTemplateReaderServiceImpl(csarFiles.get(key));
+ if (readerService == null) {
+ return;
+ }
+ Object nodeTypes = readerService.getNodeTypes();
+ if (nodeTypes instanceof Map) {
+ Map<String, NodeType> nodeTypeMap = (Map<String, NodeType>) nodeTypes;
+ gsst.appendNodes(nodeTypeMap);
+ }
+ } catch (YAMLException ye) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage("Invalid YAML content in file " + key + ". reason - "
+ + ye.getMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
+ }
+
+ private void updateToscaServiceModel(ToscaServiceModel toscaServiceModel,
+ Map<String, ServiceTemplate> serviceTemplates,
+ FileContentHandler externalFilesHandler,
+ GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate,
+ Map<String, byte[]> csarFiles) {
+ Collection<ServiceTemplate> globalServiceTemplates =
+ GlobalTypesGenerator.getGlobalTypesServiceTemplate().values();
+ addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates);
+ serviceTemplates.put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
+ toscaServiceModel.setEntryDefinitionServiceTemplate(mainStName);
+ toscaServiceModel.setServiceTemplates(serviceTemplates);
+ externalFilesHandler.addFile(metadataFile + ".old", csarFiles.get(metadataFile + ".old"));
+ toscaServiceModel.setArtifactFiles(externalFilesHandler);
+ }
+
+ private void addGlobalServiceTemplates(Collection<ServiceTemplate> globalServiceTemplates,
+ Map<String, ServiceTemplate> serviceTemplates) {
+ for (ServiceTemplate serviceTemplate : globalServiceTemplates) {
+ serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate), serviceTemplate);
+ }
+ }
+
+ private void handleServiceTemplate(String serviceTemplateName,
+ String fileName, Map<String, byte[]> csarFiles,
+ Map<String, ServiceTemplate> serviceTemplates) {
+ Optional<ServiceTemplate> serviceTemplate =
+ getServiceTemplateFromCsar(fileName, csarFiles);
+ serviceTemplate.ifPresent(
+ serviceTemplate1 -> addServiceTemplate(serviceTemplateName, serviceTemplate1,
+ serviceTemplates));
+ }
+
+ private void addServiceTemplate(String serviceTemplateName,
+ ServiceTemplate serviceTemplate,
+ Map<String, ServiceTemplate> serviceTemplates) {
+ serviceTemplates.put(serviceTemplateName, serviceTemplate);
+ }
+
+ private Optional<byte[]> getManifestContent(Map<String, byte[]> csarFiles) {
+ for (Map.Entry<String, byte[]> csarFileEntry : csarFiles.entrySet()) {
+ if (csarFileEntry.getKey().contains(manifestFileName)) {
+ return Optional.of(csarFileEntry.getValue());
+ }
+ }
+
+ return Optional.empty();
+ }
+
+ private Optional<ServiceTemplate> getServiceTemplateFromCsar(String fileName,
+ Map<String, byte[]> csarFiles) {
+ byte[] fileContent = csarFiles.get(fileName);
+ ServiceTemplate serviceTemplate = convertServiceTemplate(fileName, fileContent);
+
+ return Optional.of(serviceTemplate);
+ }
+
+ private ServiceTemplate convertServiceTemplate(String serviceTemplateName,
+ byte[] fileContent) {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ try {
+ ServiceTemplateReaderService readerService =
+ new ServiceTemplateReaderServiceImpl(fileContent);
+ convertMetadata(serviceTemplateName, serviceTemplate, readerService);
+ convertToscaVersion(serviceTemplate, readerService);
+ convertImports(serviceTemplate);
+ convertNodeTypes(serviceTemplate, readerService);
+ convertTopologyTemplate(serviceTemplate, readerService);
+
+ } catch (YAMLException ye) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage("Invalid YAML content in file" + serviceTemplateName + ". reason - "
+ + ye.getMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
+
+
+ return serviceTemplate;
+ }
+
+ private void convertToscaVersion(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Object toscaVersion = readerService.getToscaVersion();
+ serviceTemplate.setTosca_definitions_version((String) toscaVersion);
+ }
+
+ private void convertImports(ServiceTemplate serviceTemplate) {
+ serviceTemplate.setImports(new ArrayList<>());
+ serviceTemplate.getImports()
+ .add(createImportMap(openecompHeatIndex, "openecomp-heat/_index.yml"));
+ serviceTemplate.getImports().add(createImportMap(globalSubstitution, globalStName));
+
+ }
+
+ private Map<String, Import> createImportMap(String key, String fileName) {
+ Map<String, Import> importMap = new HashMap<>();
+ Import anImport = new Import();
+ anImport.setFile(fileName);
+ importMap.put(key, anImport);
+
+ return importMap;
+ }
+
+ private void convertMetadata(String serviceTemplateName,
+ ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Map<String, Object> metadataToConvert = (Map<String, Object>) readerService.getMetadata();
+ Map<String, String> finalMetadata = new HashMap<>();
+
+ if (MapUtils.isNotEmpty(metadataToConvert)) {
+ for (Map.Entry<String, Object> metadataEntry : metadataToConvert.entrySet()) {
+ if (Objects.isNull(metadataEntry.getValue()) ||
+ !(metadataEntry.getValue() instanceof String)) {
+ continue;
+ }
+ finalMetadata.put(metadataEntry.getKey(), (String) metadataEntry.getValue());
+ }
+ }
+
+ finalMetadata.put("template_name", getTemplateNameFromStName(serviceTemplateName));
+ serviceTemplate.setMetadata(finalMetadata);
+ }
+
+ private void convertNodeTypes(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
+ Map<String, Object> nodeTypes = (Map<String, Object>) readerService.getNodeTypes();
+ if (MapUtils.isEmpty(nodeTypes)) {
+ return;
+ }
+
+ for (Map.Entry<String, Object> nodeTypeEntry : nodeTypes.entrySet()) {
+ DataModelUtil
+ .addNodeType(serviceTemplate, nodeTypeEntry.getKey(),
+ (NodeType) createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(),
+ NodeType.class));
+ }
+ }
+
+ private void convertTopologyTemplate(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+
+ convertInputs(serviceTemplate, readerService);
+ convertNodeTemplates(serviceTemplate, readerService);
+ convertOutputs(serviceTemplate, readerService);
+ convertSubstitutionMappings(serviceTemplate, readerService);
+ }
+
+ private void convertInputs(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Map<String, Object> inputs = readerService.getInputs();
+ addInputsOrOutputsToServiceTemplate(serviceTemplate, inputs, Constants.inputs);
+ }
+
+ private void convertOutputs(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Map<String, Object> outputs = readerService.getOutputs();
+ addInputsOrOutputsToServiceTemplate(serviceTemplate, outputs, Constants.outputs);
+ }
+
+ private void addInputsOrOutputsToServiceTemplate(ServiceTemplate serviceTemplate,
+ Map<String, Object> mapToConvert,
+ String inputsOrOutputs) {
+ if (MapUtils.isEmpty(mapToConvert)) {
+ return;
+ }
+
+ for (Map.Entry<String, Object> entry : mapToConvert.entrySet()) {
+ ParameterDefinition parameterDefinition =
+ (ParameterDefinition) createObjectFromClass(
+ entry.getKey(), entry.getValue(), ParameterDefinition.class);
+ addToServiceTemplateAccordingToSection(
+ serviceTemplate, inputsOrOutputs, entry.getKey(), parameterDefinition);
+ }
+ }
+
+ private void addToServiceTemplateAccordingToSection(ServiceTemplate serviceTemplate,
+ String inputsOrOutputs,
+ String parameterId,
+ ParameterDefinition parameterDefinition) {
+ switch (inputsOrOutputs) {
+ case inputs:
+ DataModelUtil
+ .addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
+ break;
+ case outputs:
+ DataModelUtil
+ .addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
+ }
+ }
+
+ private void convertNodeTemplates(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Map<String, Object> nodeTemplates = readerService.getNodeTemplates();
+ if (MapUtils.isEmpty(nodeTemplates)) {
+ return;
+ }
+
+ for (Map.Entry<String, Object> nodeTemplateEntry : nodeTemplates.entrySet()) {
+ NodeTemplate nodeTemplate = convertNodeTemplate(nodeTemplateEntry.getValue());
+ DataModelUtil.addNodeTemplate(serviceTemplate, nodeTemplateEntry.getKey(), nodeTemplate);
+ }
+ }
+
+ private void convertSubstitutionMappings(ServiceTemplate serviceTemplate,
+ ServiceTemplateReaderService readerService) {
+ Map<String, Object> substitutionMappings = readerService.getSubstitutionMappings();
+ if (MapUtils.isEmpty(substitutionMappings)) {
+ return;
+ }
+ SubstitutionMapping substitutionMapping = convertSubstitutionMappings(substitutionMappings);
+ DataModelUtil.addSubstitutionMapping(serviceTemplate, substitutionMapping);
+ }
+
+ private SubstitutionMapping convertSubstitutionMappings(Map<String, Object> substitutionMappings) {
+ SubstitutionMapping substitutionMapping = new SubstitutionMapping();
+
+ substitutionMapping.setNode_type((String) substitutionMappings.get(nodeType));
+ substitutionMapping.setCapabilities(
+ convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(capabilities)));
+ substitutionMapping.setRequirements(
+ convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(requirements)));
+
+ return substitutionMapping;
+ }
+
+ private Map<String, List<String>> convertSubstitutionMappingsSections(
+ Map<String, Object> sectionToConvert) {
+ Map<String, List<String>> convertedSection = new HashMap<>();
+ if (MapUtils.isEmpty(sectionToConvert)) {
+ return null;
+ }
+
+ for (Map.Entry<String, Object> entry : sectionToConvert.entrySet()) {
+ if (entry.getValue() instanceof List) {
+ convertedSection.put(entry.getKey(), (List<String>) entry.getValue());
+ }
+ }
+
+ return convertedSection;
+ }
+
+ private CsarFileTypes getFileType(String fileName) {
+ if (isMainServiceTemplate(fileName)) {
+ return CsarFileTypes.mainServiceTemplate;
+ } else if (isGlobalServiceTemplate(fileName)) {
+ return CsarFileTypes.globalServiceTemplate;
+ } else if (isDefinitions(fileName)) {
+ return CsarFileTypes.definitionsFile;
+ } else if (isMetadataFile(metadataFile)) {
+ return CsarFileTypes.toscaMetadata;
+ }
+ return CsarFileTypes.externalFile;
+ }
+
+ private Optional<Manifest> getCsarManifest(Map<String, byte[]> csarFiles) throws IOException {
+ Optional<byte[]> manifestContent = getManifestContent(csarFiles);
+
+ if (manifestContent.isPresent()) {
+ ByteArrayInputStream byteInputStream = new ByteArrayInputStream(manifestContent.get());
+
+ return Optional.of(new Manifest(byteInputStream));
+ }
+
+ return Optional.empty();
+ }
+
+ private NodeTemplate convertNodeTemplate(Object candidateNodeTemplate) {
+ NodeTemplate nodeTemplate = new NodeTemplate();
+
+ Map<String, Object> nodeTemplateAsMap = (Map<String, Object>) candidateNodeTemplate;
+ nodeTemplate.setArtifacts((Map<String, ArtifactDefinition>) nodeTemplateAsMap.get("artifacts"));
+ nodeTemplate.setAttributes((Map<String, Object>) nodeTemplateAsMap.get("attributes"));
+ nodeTemplate.setCopy((String) nodeTemplateAsMap.get("copy"));
+ nodeTemplate.setDescription((String) nodeTemplateAsMap.get("description"));
+ nodeTemplate.setDirectives((List<String>) nodeTemplateAsMap.get("directives"));
+ nodeTemplate.setInterfaces(
+ (Map<String, InterfaceDefinition>) nodeTemplateAsMap.get("interfaces"));
+ nodeTemplate.setNode_filter((NodeFilter) nodeTemplateAsMap.get("node_filter"));
+ nodeTemplate.setProperties((Map<String, Object>) nodeTemplateAsMap.get("properties"));
+ nodeTemplate.setRequirements(
+ (List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
+ nodeTemplate.setType((String) nodeTemplateAsMap.get("type"));
+ nodeTemplate.setCapabilities(
+ convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
+
+ return nodeTemplate;
+ }
+
+ private List<Map<String, CapabilityAssignment>> convertCapabilities(Map<String, Object> capabilities) {
+ List<Map<String, CapabilityAssignment>> convertedCapabilities = new ArrayList<>();
+ if (MapUtils.isEmpty(capabilities)) {
+ return null;
+ }
+ for (Map.Entry<String, Object> capabilityAssignmentEntry : capabilities.entrySet()) {
+ Map<String, CapabilityAssignment> tempMap = new HashMap<>();
+ tempMap.put(capabilityAssignmentEntry.getKey(),
+ (CapabilityAssignment) createObjectFromClass
+ (capabilityAssignmentEntry.getKey(), capabilityAssignmentEntry.getValue(), CapabilityAssignment.class));
+ convertedCapabilities.add(tempMap);
+ }
+ return convertedCapabilities;
+ }
+
+ private Object createObjectFromClass(String nodeTypeId,
+ Object objectCandidate,
+ Class classToCreate) {
+ try {
+ return JsonUtil.json2Object(objectCandidate.toString(), classToCreate);
+ } catch (Exception e) {
+ //todo - return error to user?
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage("Can't create Node Type from " + nodeTypeId).build());
+ }
+ }
+
+ private boolean isMainServiceTemplate(String fileName) {
+ return fileName.endsWith(mainStName);
+ }
+
+ private boolean isMetadataFile(String fileName) {
+ return fileName.equals(metadataFile);
+ }
+
+ private boolean isGlobalServiceTemplate(String fileName) {
+ return fileName.endsWith(globalStName);
+ }
+
+ private boolean isDefinitions(String fileName) {
+ return fileName.startsWith(definitionsDir);
+ }
+
+ private String getTemplateNameFromStName(String serviceTemplateName) {
+ String fileNameWithoutDirectories;
+ fileNameWithoutDirectories = getFileNameWithoutDirectories(serviceTemplateName);
+ return fileNameWithoutDirectories.split("ServiceTemplate")[0];
+ }
+
+ private String getFileNameWithoutDirectories(String serviceTemplateName) {
+ String fileNameWithoutDirectories;
+ if (serviceTemplateName.contains("/")) {
+ String[] split = serviceTemplateName.split("/");
+ fileNameWithoutDirectories = split[split.length - 1];
+ } else if (serviceTemplateName.contains(File.separator)) {
+ String[] split = serviceTemplateName.split(Pattern.quote(File.separator));
+ fileNameWithoutDirectories = split[split.length - 1];
+ } else {
+ fileNameWithoutDirectories = serviceTemplateName;
+ }
+ return fileNameWithoutDirectories;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java
new file mode 100644
index 0000000000..520e41817e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java
@@ -0,0 +1,49 @@
+package org.openecomp.core.impl;
+
+import org.openecomp.core.converter.ToscaConverter;
+import org.openecomp.core.converter.api.ToscaConverterManager;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class ToscaConverterManagerImpl implements ToscaConverterManager {
+
+ private static List<ToscaConverter> toscaConverters;
+ private static final String toscaConverterFileName = "ToscaConverters.json";
+
+ static {
+ toscaConverters = getConvertersList();
+ }
+
+ @Override
+ public ToscaServiceModel convert(String csarName, FileContentHandler fileContentHandler) {
+ return null;
+ }
+
+ private static List<ToscaConverter> getConvertersList(){
+ List<ToscaConverter> toscaConvertersList = new ArrayList<>();
+ Map<String, String> convertersMap = FileUtils.readViaInputStream(toscaConverterFileName,
+ stream -> JsonUtil.json2Object(stream, Map.class));
+ return getToscaConvertersList(toscaConvertersList, convertersMap);
+ }
+
+ private static List<ToscaConverter> getToscaConvertersList(
+ List<ToscaConverter> toscaConvertersList, Map<String, String> convertersMap) {
+ for(String implClassName : convertersMap.values()){
+ try{
+ Class<?> clazz = Class.forName(implClassName);
+ Constructor<?> constructor = clazz.getConstructor();
+ toscaConvertersList.add((ToscaConverter) constructor.newInstance());
+ }catch (Exception e){
+ continue;
+ }
+ }
+ return toscaConvertersList;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java
new file mode 100644
index 0000000000..e04cd239c9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java
@@ -0,0 +1,12 @@
+package org.openecomp.core.impl.factory;
+
+import org.openecomp.core.converter.ToscaConverter;
+import org.openecomp.core.converter.factory.ToscaConverterFactory;
+import org.openecomp.core.impl.ToscaConverterImpl;
+
+public class ToscaConverterFactoryImpl extends ToscaConverterFactory {
+ @Override
+ public ToscaConverter createInterface() {
+ return new ToscaConverterImpl();
+ }
+}
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
new file mode 100644
index 0000000000..fa8532546c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -0,0 +1,76 @@
+package org.openecomp.core.impl.services;
+
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.yaml.snakeyaml.error.YAMLException;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.openecomp.core.converter.datatypes.Constants.*;
+
+public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderService {
+
+ private Map<String, Object> readServiceTemplate = new HashMap<>();
+
+ public ServiceTemplateReaderServiceImpl(byte[] serviceTemplateContent){
+ this.readServiceTemplate = readServiceTemplate(serviceTemplateContent);
+ }
+
+ @Override
+ public Map<String, Object> readServiceTemplate(byte[] serviceTemplateContent) {
+
+ Map<String, Object> readSt =
+ new YamlUtil().yamlToObject(new String(serviceTemplateContent), Map.class);
+
+ return readSt;
+ }
+
+ @Override
+ public Object getMetadata(){
+ return this.readServiceTemplate.get(metadata);
+ }
+
+ @Override
+ public Object getToscaVersion(){
+ return this.readServiceTemplate.get(definitionVersion);
+ }
+
+ @Override
+ public Object getNodeTypes(){
+ return this.readServiceTemplate.get(nodeTypes);
+ }
+
+ @Override
+ public Object getTopologyTemplate(){
+ return this.readServiceTemplate.get(topologyTemplate);
+ }
+
+ @Override
+ public Map<String, Object> getNodeTemplates(){
+ return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
+ : (Map<String, Object>) ((Map<String, Object>)this.getTopologyTemplate()).get(nodeTemplates);
+ }
+
+ @Override
+ public Map<String, Object> getInputs(){
+ return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
+ : (Map<String, Object>) ((Map<String, Object>)this.getTopologyTemplate()).get(inputs);
+ }
+
+ @Override
+ public Map<String, Object> getOutputs(){
+ return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
+ : (Map<String, Object>) ((Map<String, Object>)this.getTopologyTemplate()).get(outputs);
+ }
+
+ @Override
+ public Map<String, Object> getSubstitutionMappings(){
+ return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
+ : (Map<String, Object>) ((Map<String, Object>)this.getTopologyTemplate()).get(substitutionMappings);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/resources/ToscaConverters.json b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/resources/ToscaConverters.json
new file mode 100644
index 0000000000..e1cddeb854
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/resources/ToscaConverters.json
@@ -0,0 +1,3 @@
+{
+ "ToscaConverter" : "org.openecomp.core.converter.impl.ToscaConverterImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
new file mode 100644
index 0000000000..4abed3e316
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
@@ -0,0 +1,193 @@
+package org.openecomp.core.converter.impl;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.junit.Test;
+import org.openecomp.core.converter.ToscaConverter;
+import org.openecomp.core.impl.ToscaConverterImpl;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.NotDirectoryException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.junit.Assert.assertEquals;
+import static org.openecomp.core.converter.datatypes.Constants.globalStName;
+import static org.openecomp.core.converter.datatypes.Constants.mainStName;
+
+public class ToscaConverterImplTest {
+
+ private static ToscaConverter toscaConverter = new ToscaConverterImpl();
+ private static String inputFilesPath;
+ private static String outputFilesPath;
+ private static Map<String, ServiceTemplate> expectedOutserviceTemplates;
+
+
+ @Test
+ public void testConvertMainSt() throws IOException {
+ inputFilesPath = "/mock/toscaConverter/convertMainSt/in";
+ outputFilesPath = "/mock/toscaConverter/convertMainSt/out";
+
+ FileContentHandler fileContentHandler =
+ createFileContentHandlerFromInput(inputFilesPath);
+
+ expectedOutserviceTemplates = new HashMap<>();
+ loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(),
+ expectedOutserviceTemplates);
+
+ ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler);
+ ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName);
+
+ checkSTResults(expectedOutserviceTemplates, null, mainSt);
+ }
+
+
+
+ private FileContentHandler createFileContentHandlerFromInput(String inputFilesPath)
+ throws IOException {
+ URL inputFilesUrl = this.getClass().getResource(inputFilesPath);
+ String path = inputFilesUrl.getPath();
+ File directory = new File(path);
+ File[] listFiles = directory.listFiles();
+
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ insertFilesIntoFileContentHandler(listFiles, fileContentHandler);
+ return fileContentHandler;
+ }
+
+ private void insertFilesIntoFileContentHandler(File[] listFiles,
+ FileContentHandler fileContentHandler)
+ throws IOException {
+ byte[] fileContent;
+ if(CollectionUtils.isEmpty(fileContentHandler.getFileList())) {
+ fileContentHandler.setFiles(new HashMap<>());
+ }
+
+ for (File file : listFiles) {
+ if(!file.isDirectory()) {
+ try (FileInputStream fis = new FileInputStream(file)) {
+ fileContent = FileUtils.toByteArray(fis);
+ fileContentHandler.addFile(file.getPath(), fileContent);
+ }
+ }else{
+ File[] currFileList = file.listFiles();
+ insertFilesIntoFileContentHandler(currFileList, fileContentHandler);
+ }
+
+ }
+ }
+
+ private void checkSTResults(
+ Map<String, ServiceTemplate> expectedOutserviceTemplates,
+ ServiceTemplate gloablSubstitutionServiceTemplate, ServiceTemplate mainServiceTemplate) {
+ YamlUtil yamlUtil = new YamlUtil();
+ if (Objects.nonNull(gloablSubstitutionServiceTemplate)) {
+ assertEquals("difference global substitution service template: ",
+ yamlUtil.objectToYaml(expectedOutserviceTemplates.get(globalStName)),
+ yamlUtil.objectToYaml(gloablSubstitutionServiceTemplate));
+ }
+ if (Objects.nonNull(mainServiceTemplate)) {
+ assertEquals("difference main service template: ",
+ yamlUtil.objectToYaml(expectedOutserviceTemplates.get(mainStName)),
+ yamlUtil.objectToYaml(mainServiceTemplate));
+ }
+ }
+
+ public static void loadServiceTemplates(String serviceTemplatesPath,
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil,
+ Map<String, ServiceTemplate> serviceTemplates)
+ throws IOException {
+ URL urlFile = ToscaConverterImplTest.class.getResource(serviceTemplatesPath);
+ if (urlFile != null) {
+ File pathFile = new File(urlFile.getFile());
+ File[] files = pathFile.listFiles();
+ if (files != null) {
+ addServiceTemplateFiles(serviceTemplates, files, toscaExtensionYamlUtil);
+ } else {
+ throw new NotDirectoryException(serviceTemplatesPath);
+ }
+ } else {
+ throw new NotDirectoryException(serviceTemplatesPath);
+ }
+ }
+
+ private static void addServiceTemplateFiles(Map<String, ServiceTemplate> serviceTemplates,
+ File[] files,
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil)
+ throws IOException {
+ for (File file : files) {
+ try (InputStream yamlFile = new FileInputStream(file)) {
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil);
+ serviceTemplates.put(file.getName(), serviceTemplateFromYaml);
+ try {
+ yamlFile.close();
+ } catch (IOException ignore) {
+ }
+ } catch (FileNotFoundException e) {
+ throw e;
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+ }
+
+ private static void createConcreteRequirementObjectsInServiceTemplate(ServiceTemplate
+ serviceTemplateFromYaml,
+ ToscaExtensionYamlUtil
+ toscaExtensionYamlUtil) {
+
+ if (serviceTemplateFromYaml == null
+ || serviceTemplateFromYaml.getTopology_template() == null
+ || serviceTemplateFromYaml.getTopology_template().getNode_templates() == null) {
+ return;
+ }
+
+ //Creating concrete objects
+ Map<String, NodeTemplate> nodeTemplates =
+ serviceTemplateFromYaml.getTopology_template().getNode_templates();
+ for (Map.Entry<String, NodeTemplate> entry : nodeTemplates.entrySet()) {
+ NodeTemplate nodeTemplate = entry.getValue();
+ List<Map<String, RequirementAssignment>> requirements = nodeTemplate.getRequirements();
+ List<Map<String, RequirementAssignment>> concreteRequirementList = new ArrayList<>();
+ if (requirements != null) {
+ ListIterator<Map<String, RequirementAssignment>> reqListIterator = requirements
+ .listIterator();
+ while (reqListIterator.hasNext()){
+ Map<String, RequirementAssignment> requirement = reqListIterator.next();
+ Map<String, RequirementAssignment> concreteRequirement = new HashMap<>();
+ for (Map.Entry<String, RequirementAssignment> reqEntry : requirement.entrySet()) {
+ RequirementAssignment requirementAssignment = (toscaExtensionYamlUtil
+ .yamlToObject(toscaExtensionYamlUtil.objectToYaml(reqEntry.getValue()),
+ RequirementAssignment.class));
+ concreteRequirement.put(reqEntry.getKey(), requirementAssignment);
+ concreteRequirementList.add(concreteRequirement);
+ reqListIterator.remove();
+ }
+ }
+ requirements.clear();
+ requirements.addAll(concreteRequirementList);
+ nodeTemplate.setRequirements(requirements);
+ }
+ System.out.println();
+ //toscaExtensionYamlUtil.yamlToObject(nodeTemplate, NodeTemplate.class);
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
new file mode 100644
index 0000000000..9f7071e9e7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
@@ -0,0 +1,62 @@
+package org.openecomp.core.converter.impl;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+import org.openecomp.core.impl.GlobalSubstitutionServiceTemplate;
+import org.openecomp.core.impl.ToscaConverterImpl;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+
+import java.net.URL;
+import java.util.Map;
+import java.util.Set;
+
+import static org.openecomp.sdc.common.utils.CommonUtil.*;
+import static org.junit.Assert.*;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.*;
+public class ToscaConvertorDefinitionsTest {
+
+
+ @Test
+ public void loadCsar() throws Exception {
+ URL resource = ToscaConvertorDefinitionsTest.class.getResource("/csar/vCSCF.csar");
+ byte[] bytes = IOUtils.toByteArray(resource);
+ assertNotNull(bytes);
+ FileContentHandler contentMap = validateAndUploadFileContent(OnboardingTypesEnum.CSAR, bytes);
+ ToscaConverterImpl toscaConverter = new ToscaConverterImpl();
+ ToscaServiceModel convert = toscaConverter.convert(contentMap);
+ Map<String, ServiceTemplate> serviceTemplates = convert.getServiceTemplates();
+ assertTrue(serviceTemplates.containsKey(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME));
+ ServiceTemplate serviceTemplate = serviceTemplates.get(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME);
+
+ assertNotNull(serviceTemplate);
+ assertTrue(serviceTemplate instanceof GlobalSubstitutionServiceTemplate);
+
+ assertNotNull(serviceTemplate.getMetadata());
+ assertFalse(serviceTemplate.getMetadata().isEmpty());
+ assertTrue(serviceTemplate.getMetadata().containsKey(TEMPLATE_NAME_PROPERTY));
+
+ assertNotNull(serviceTemplate.getImports());
+ assertFalse(serviceTemplate.getImports().isEmpty());
+ assertEquals(1 ,serviceTemplate.getImports().size());
+ assertTrue(serviceTemplate.getImports().get(0).containsKey(HEAT_INDEX));
+
+ assertEquals(DEFININTION_VERSION, serviceTemplate.getTosca_definitions_version());
+
+
+ assertNotNull(serviceTemplate.getNode_types());
+ assertEquals(7, serviceTemplate.getNode_types().size());
+ Set<String> keys = serviceTemplate.getNode_types().keySet();
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VDU"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.CP"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF.vCSCF"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.ImageFile"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.LocalStorage"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF"));
+ assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VL"));
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/csar/vCSCF.csar b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/csar/vCSCF.csar
new file mode 100644
index 0000000000..f1b77554e4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/csar/vCSCF.csar
Binary files differ
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/checksum.lst b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/checksum.lst
new file mode 100644
index 0000000000..701f14d45d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/checksum.lst
@@ -0,0 +1 @@
+Definitions/openovnf__vPCRF.yaml:75bd8963ecc09bf769d0bb5cb475314d
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/csar.meta b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/csar.meta
new file mode 100644
index 0000000000..aac2fed3c3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Artifacts/csar.meta
@@ -0,0 +1,3 @@
+Type:NFAR
+Version:v1.0
+Provider:Huawei \ 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/in/Definitions/GlobalSubstitutionTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Definitions/GlobalSubstitutionTypesServiceTemplate.yaml
new file mode 100644
index 0000000000..a88171701e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/Definitions/GlobalSubstitutionTypesServiceTemplate.yaml
@@ -0,0 +1,60 @@
+node_types:
+ tosca.nodes.nfv.VDU.Compute:
+ attributes:
+ private_address:
+ type: string
+ public_address:
+ type: string
+ networks:
+ type: string
+ ports:
+ type: string
+ capabilities:
+ scalable:
+ type: tosca.capabilities.Scalable
+ virtual_compute:
+ type: tosca.capabilities.nfv.VirtualCompute
+ endpoint:
+ type: tosca.capabilities.Endpoint.Admin
+ os:
+ type: tosca.capabilities.OperatingSystem
+ virtual_binding:
+ type: tosca.capabilities.nfv.VirtualBindable
+ host:
+ type: tosca.capabilities.Container
+ binding:
+ type: tosca.capabilities.network.Bindable
+ monitoring_parameter:
+ type: tosca.capabilities.nfv.Metric
+ derived_from: tosca.nodes.Root
+ properties:
+ configurable_properties:
+ entry_schema:
+ type: tosca.datatypes.nfv.VnfcConfigurableProperties
+ type: map
+ name:
+ type: string
+ nfvi_constraints:
+ entry_schema:
+ type: string
+ required: false
+ type: list
+ descrption:
+ type: string
+ boot_order:
+ entry_schema:
+ type: string
+ required: false
+ type: list
+ requirements:
+ - local_storage:
+ capability: tosca.capabilities.Attachment
+ occurrences:
+ - 0
+ - UNBOUNDED
+ - virtual_storage:
+ capability: tosca.capabilities.nfv.VirtualStorage
+ occurrences:
+ - 0
+ - UNBOUNDED
+tosca_definitions_version: tosca_simple_yaml_1_0
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.mf b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.mf
new file mode 100644
index 0000000000..e45f002332
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.mf
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+
+Name: Entry-Definitions
+Name: MainServiceTemplate.yaml
+
+Name: Definitions\GlobalSubstitutionTypesServiceTemplate.yaml
+
+Name: Artifacts\install.sh
+
+Name: Artifacts\create_stack.sh
+
+Name: Licenses\license.xml
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
new file mode 100644
index 0000000000..041afbacf8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/MainServiceTemplate.yaml
@@ -0,0 +1,551 @@
+imports:
+- openovnf__tosca.nodes.nfv.VNF.vPCRF.yaml
+- openonfv__tosca.capabilities.Scalable.yaml
+- openonfv__tosca.capabilities.nfv.Metric.yaml
+- openonfv__tosca.nodes.nfv.VnfVirtualLinkDesc.yaml
+- openonfv__tosca.capabilities.network.Bindable.yaml
+- openonfv__tosca.capabilities.Attachment.yaml
+- openonfv__tosca.capabilities.nfv.VirtualBindable.yaml
+- openonfv__tosca.capabilities.nfv.VirtualLinkable.yaml
+- openonfv__tosca.requirements.nfv.VirtualStorage.yaml
+- openonfv__tosca.nodes.nfv.VDU.VirtualStorage.yaml
+- openonfv__tosca.relationships.nfv.VirtualBindsTo.yaml
+- openonfv__tosca.nodes.nfv.VDU.Compute.yaml
+- openonfv__tosca.relationships.nfv.VirtualLinksTo.yaml
+- openonfv__tosca.capabilities.nfv.VirtualCompute.yaml
+- openonfv__tosca.capabilities.Container.yaml
+- openonfv__tosca.capabilities.nfv.VirtualStorage.yaml
+- openonfv__tosca.requirements.nfv.VirtualBinding.yaml
+- openonfv__tosca.capabilities.Endpoint.Admin.yaml
+- openonfv__tosca.capabilities.OperatingSystem.yaml
+- openonfv__tosca.nodes.nfv.VduCpd.yaml
+- openonfv__tosca.relationships.nfv.VDU.AttachedTo.yaml
+
+metadata:
+ vendor: Huawei
+ csarVersion: v1.0
+ csarProvider: Huawei
+ id: vPCRF_NF_HW
+ version: v1.0
+ csarType: NFAR
+ name: vPCRF
+ vnfdVersion: v1.0
+ vnfmType: hwvnfm
+
+node_types:
+ org.openecomp.resource.vfc.nodes.heat.nat_fw:
+ derived_from: org.openecomp.resource.vfc.nodes.heat.nova.Server
+
+topology_template:
+ node_templates:
+ PUPDU_Storage:
+ attributes:
+ tosca_name: PUPDU_Storage
+ properties:
+ id: PUPDU_Storage
+ size_of_storage: 200G
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ USRSU:
+ attributes:
+ tosca_name: USRSU
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {}
+ virtual_cpu:
+ num_virtual_cpu: 4
+ properties:
+ configurable_properties:
+ test: {"additional_vnfc_configurable_properties":{"aaa":"1"}}
+ name: USRSU
+ descrption: the virtual machine of USRSU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: USRSU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VDU.Compute
+ USPID3_VduCpd_Fabric:
+ attributes:
+ tosca_name: USPID3_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+ PUPDU_VduCpd_Base:
+ attributes:
+ tosca_name: PUPDU_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ OMU_VduCpd_Fabric:
+ attributes:
+ tosca_name: OMU_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: OMU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+ USPID3:
+ attributes:
+ tosca_name: USPID3
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {}
+ virtual_cpu:
+ num_virtual_cpu: 4
+ properties:
+ configurable_properties:
+ test: {"additional_vnfc_configurable_properties":{"aaa":"1"}}
+ name: USPID3
+ descrption: the virtual machine of USPID3
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: USPID3_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VDU.Compute
+ UPIRU_VduCpd_Base:
+ attributes:
+ tosca_name: UPIRU_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ OMU2ManageNet:
+ attributes:
+ tosca_name: OMU2ManageNet
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ node: tosca.nodes.Root
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ OMU_Storage:
+ attributes:
+ tosca_name: OMU_Storage
+ properties:
+ id: OMU_Storage
+ size_of_storage: 256G
+ rdma_enabled: false
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ UPSPU:
+ attributes:
+ tosca_name: UPSPU
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {}
+ virtual_cpu:
+ num_virtual_cpu: 4
+ properties:
+ configurable_properties:
+ test: {"additional_vnfc_configurable_properties":{"aaa":"1"}}
+ name: UPSPU
+ descrption: the virtual machine of UPSPU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: UPSPU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VDU.Compute
+ PUPDU_VduCpd_Fabric:
+ attributes:
+ tosca_name: PUPDU_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+ USPID2BossNet:
+ attributes:
+ tosca_name: USPID2BossNet
+ properties:
+ role: root
+ layer_protocol: ethernet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ OMU_VduCpd_Base:
+ attributes:
+ tosca_name: OMU_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: OMU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ USPID3_Storage:
+ attributes:
+ tosca_name: USPID3_Storage
+ properties:
+ id: USPID3_Storage
+ size_of_storage: 300G
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ UPIRU2DataNet2:
+ attributes:
+ tosca_name: UPIRU2DataNet2
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ USPID2ManageNet:
+ attributes:
+ tosca_name: USPID2ManageNet
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ UPIRU2DataNet3:
+ attributes:
+ tosca_name: UPIRU2DataNet3
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ PUPDU2DataNet3:
+ attributes:
+ tosca_name: PUPDU2DataNet3
+ properties:
+ role: root
+ layer_protocol: ethernet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ USRSU2DataNet1:
+ attributes:
+ tosca_name: USRSU2DataNet1
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ USRSU2DataNet2:
+ attributes:
+ tosca_name: USRSU2DataNet2
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ UPIRU_Storage:
+ attributes:
+ tosca_name: UPIRU_Storage
+ properties:
+ id: UPIRU_Storage
+ size_of_storage: 4G
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ PUPDU2SignalNet1:
+ attributes:
+ tosca_name: PUPDU2SignalNet1
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ UPIRU2DataNet1:
+ attributes:
+ tosca_name: UPIRU2DataNet1
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ USPID3_VduCpd_Base:
+ attributes:
+ tosca_name: USPID3_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ Base:
+ attributes:
+ tosca_name: Base
+ properties:
+ vl_flavours:
+ flavours: test2
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern:
+ type: tosca.nodes.nfv.VnfVirtualLinkDesc
+ USRSU_Storage:
+ attributes:
+ tosca_name: USRSU_Storage
+ properties:
+ id: USRSU_Storage
+ size_of_storage: 200G
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ UPSPU_VduCpd_Base:
+ attributes:
+ tosca_name: UPSPU_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPSPU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ PUPDU:
+ attributes:
+ tosca_name: PUPDU
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {}
+ virtual_cpu:
+ num_virtual_cpu: 4
+ properties:
+ configurable_properties:
+ test: {"additional_vnfc_configurable_properties":{"aaa":"1"}}
+ name: PUPDU
+ descrption: the virtual machine of PUPDU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: PUPDU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VDU.Compute
+ USRSU_VduCpd_Base:
+ attributes:
+ tosca_name: USRSU_VduCpd_Base
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ type: tosca.nodes.nfv.VduCpd
+ OMU:
+ attributes:
+ tosca_name: OMU
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 16G
+ requested_additional_capabilities: {}
+ virtual_cpu:
+ num_virtual_cpu: 4
+ properties:
+ configurable_properties:
+ test: {"additional_vnfc_configurable_properties":{"aaa":"1"}}
+ name: OMU
+ descrption: the virtual machine of OMU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: OMU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VDU.Compute
+ UPIRU_VduCpd_Fabric:
+ attributes:
+ tosca_name: UPIRU_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+ UPSPU_Storage:
+ attributes:
+ tosca_name: UPSPU_Storage
+ properties:
+ id: UPSPU_Storage
+ size_of_storage: 4G
+ type_of_storage: volume
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ PUPDU2ManageNet:
+ attributes:
+ tosca_name: PUPDU2ManageNet
+ properties:
+ role: root
+ layer_protocol: ethernet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ USRSU_VduCpd_Fabric:
+ attributes:
+ tosca_name: USRSU_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+ UPIRU2SignalNet1:
+ attributes:
+ tosca_name: UPIRU2SignalNet1
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ type: tosca.nodes.nfv.VduCpd
+ Fabric:
+ attributes:
+ tosca_name: Fabric
+ properties:
+ vl_flavours:
+ flavours: test1
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern:
+ type: tosca.nodes.nfv.VnfVirtualLinkDesc
+ UPSPU_VduCpd_Fabric:
+ attributes:
+ tosca_name: UPSPU_VduCpd_Fabric
+ properties:
+ role: root
+ layer_protocol: ipv4
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPSPU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ type: tosca.nodes.nfv.VduCpd
+
+ substitution_mappings:
+ node_type: tosca.nodes.nfv.VNF.vPCRF
+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/in/TOSCA-Metadata/TOSCA.meta b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/TOSCA-Metadata/TOSCA.meta
new file mode 100644
index 0000000000..69f62ca864
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/in/TOSCA-Metadata/TOSCA.meta
@@ -0,0 +1,135 @@
+TOSCA-Meta-Version: 1.0
+CSAR-Version: 1.0
+Created-By: Winery 0.1.37-SNAPSHOT
+Entry-Definitions: Definitions/openovnf__vPCRF.yaml
+
+Name: Definitions/openovnf__vPCRF.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openovnf__tosca.nodes.nfv.VNF.vPCRF.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.Scalable.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.nfv.Metric.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.nodes.nfv.VnfVirtualLinkDesc.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.network.Bindable.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.Attachment.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.nfv.VirtualBindable.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.nfv.VirtualLinkable.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.requirements.nfv.VirtualStorage.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.nodes.nfv.VDU.VirtualStorage.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.relationships.nfv.VirtualBindsTo.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.nodes.nfv.VDU.Compute.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.relationships.nfv.VirtualLinksTo.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.nfv.VirtualCompute.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.Container.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.nfv.VirtualStorage.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.requirements.nfv.VirtualBinding.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.Endpoint.Admin.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.capabilities.OperatingSystem.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.nodes.nfv.VduCpd.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.relationships.nfv.VDU.AttachedTo.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openonfv__tosca.requirements.nfv.VirtualLink.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: Definitions/openovnf__tosca.nodes.nfv.VNF.yaml
+Content-Type: application/vnd.oasis.tosca.definitions
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.VirtualStorage/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VnfVirtualLinkDesc/appearance/bigIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VnfVirtualLinkDesc/appearance/smallIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.Compute/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VduCpd/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: capabilitytypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.capabilities.nfv.VirtualCompute/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv%2Fvnf/tosca.nodes.nfv.VNF/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.VirtualStorage/appearance/bigIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.VirtualStorage/appearance/smallIcon.png
+Content-Type: image/png
+
+Name: capabilitytypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.capabilities.Container/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.Compute/appearance/bigIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VDU.Compute/appearance/smallIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv%2Fvnf/tosca.nodes.nfv.VNF.vPCRF/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: capabilitytypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.capabilities.OperatingSystem/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VnfVirtualLinkDesc/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VduCpd/appearance/bigIcon.png
+Content-Type: image/png
+
+Name: nodetypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.nodes.nfv.VduCpd/appearance/smallIcon.png
+Content-Type: image/png
+
+Name: capabilitytypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.capabilities.Scalable/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+Name: relationshiptypes/http%3A%2F%2Fwww.open-o.org%2Ftosca%2Fnfv/tosca.relationships.nfv.VDU.AttachedTo/propertiesdefinition/Properties.xsd
+Content-Type: text/xml
+
+
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
new file mode 100644
index 0000000000..77bfcac710
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml
@@ -0,0 +1,546 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ vnfdVersion: v1.0
+ template_name: Main
+ vendor: Huawei
+ csarVersion: v1.0
+ vnfmType: hwvnfm
+ csarProvider: Huawei
+ name: vPCRF
+ id: vPCRF_NF_HW
+ version: v1.0
+ csarType: NFAR
+imports:
+- openecomp_heat_index:
+ file: openecomp-heat/_index.yml
+- GlobalSubstitutionTypes:
+ file: GlobalSubstitutionTypesServiceTemplate.yaml
+node_types:
+ org.openecomp.resource.vfc.nodes.heat.nat_fw:
+ derived_from: org.openecomp.resource.vfc.nodes.heat.nova.Server
+topology_template:
+ node_templates:
+ PUPDU_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: PUPDU_Storage
+ size_of_storage: 200G
+ type_of_storage: volume
+ attributes:
+ tosca_name: PUPDU_Storage
+ USRSU:
+ type: tosca.nodes.nfv.VDU.Compute
+ properties:
+ configurable_properties:
+ test:
+ additional_vnfc_configurable_properties:
+ aaa: '1'
+ name: USRSU
+ descrption: the virtual machine of USRSU
+ attributes:
+ tosca_name: USRSU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: USRSU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ capabilities:
+ - virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {
+ }
+ virtual_cpu:
+ num_virtual_cpu: 4.0
+ USPID3_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USPID3_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ PUPDU_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: PUPDU_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ OMU_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: OMU_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: OMU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ USPID3:
+ type: tosca.nodes.nfv.VDU.Compute
+ properties:
+ configurable_properties:
+ test:
+ additional_vnfc_configurable_properties:
+ aaa: '1'
+ name: USPID3
+ descrption: the virtual machine of USPID3
+ attributes:
+ tosca_name: USPID3
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: USPID3_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ capabilities:
+ - virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {
+ }
+ virtual_cpu:
+ num_virtual_cpu: 4.0
+ UPIRU_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ OMU2ManageNet:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: OMU2ManageNet
+ requirements:
+ - virtual_binding:
+ node: tosca.nodes.Root
+ - virtual_link:
+ node: tosca.nodes.Root
+ OMU_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: OMU_Storage
+ size_of_storage: 256G
+ rdma_enabled: false
+ type_of_storage: volume
+ attributes:
+ tosca_name: OMU_Storage
+ UPSPU:
+ type: tosca.nodes.nfv.VDU.Compute
+ properties:
+ configurable_properties:
+ test:
+ additional_vnfc_configurable_properties:
+ aaa: '1'
+ name: UPSPU
+ descrption: the virtual machine of UPSPU
+ attributes:
+ tosca_name: UPSPU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: UPSPU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ capabilities:
+ - virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {
+ }
+ virtual_cpu:
+ num_virtual_cpu: 4.0
+ PUPDU_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: PUPDU_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ USPID2BossNet:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ethernet
+ attributes:
+ tosca_name: USPID2BossNet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ node: tosca.nodes.Root
+ OMU_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: OMU_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: OMU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ USPID3_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: USPID3_Storage
+ size_of_storage: 300G
+ type_of_storage: volume
+ attributes:
+ tosca_name: USPID3_Storage
+ UPIRU2DataNet2:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU2DataNet2
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ USPID2ManageNet:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USPID2ManageNet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ node: tosca.nodes.Root
+ UPIRU2DataNet3:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU2DataNet3
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ PUPDU2DataNet3:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ethernet
+ attributes:
+ tosca_name: PUPDU2DataNet3
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ USRSU2DataNet1:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USRSU2DataNet1
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ node: tosca.nodes.Root
+ USRSU2DataNet2:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USRSU2DataNet2
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ node: tosca.nodes.Root
+ UPIRU_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: UPIRU_Storage
+ size_of_storage: 4G
+ type_of_storage: volume
+ attributes:
+ tosca_name: UPIRU_Storage
+ PUPDU2SignalNet1:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: PUPDU2SignalNet1
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ UPIRU2DataNet1:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU2DataNet1
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ USPID3_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USPID3_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USPID3
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ Base:
+ type: tosca.nodes.nfv.VnfVirtualLinkDesc
+ properties:
+ vl_flavours:
+ flavours: test2
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern: null
+ attributes:
+ tosca_name: Base
+ USRSU_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: USRSU_Storage
+ size_of_storage: 200G
+ type_of_storage: volume
+ attributes:
+ tosca_name: USRSU_Storage
+ UPSPU_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPSPU_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPSPU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ PUPDU:
+ type: tosca.nodes.nfv.VDU.Compute
+ properties:
+ configurable_properties:
+ test:
+ additional_vnfc_configurable_properties:
+ aaa: '1'
+ name: PUPDU
+ descrption: the virtual machine of PUPDU
+ attributes:
+ tosca_name: PUPDU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: PUPDU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ capabilities:
+ - virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 24G
+ requested_additional_capabilities: {
+ }
+ virtual_cpu:
+ num_virtual_cpu: 4.0
+ USRSU_VduCpd_Base:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USRSU_VduCpd_Base
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Base
+ OMU:
+ type: tosca.nodes.nfv.VDU.Compute
+ properties:
+ configurable_properties:
+ test:
+ additional_vnfc_configurable_properties:
+ aaa: '1'
+ name: OMU
+ descrption: the virtual machine of OMU
+ attributes:
+ tosca_name: OMU
+ requirements:
+ - virtual_storage:
+ capability: virtual_storage
+ node: OMU_Storage
+ - local_storage:
+ node: tosca.nodes.Root
+ capabilities:
+ - virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 16G
+ requested_additional_capabilities: {
+ }
+ virtual_cpu:
+ num_virtual_cpu: 4.0
+ UPIRU_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ UPSPU_Storage:
+ type: tosca.nodes.nfv.VDU.VirtualStorage
+ properties:
+ id: UPSPU_Storage
+ size_of_storage: 4G
+ type_of_storage: volume
+ attributes:
+ tosca_name: UPSPU_Storage
+ PUPDU2ManageNet:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ethernet
+ attributes:
+ tosca_name: PUPDU2ManageNet
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: PUPDU
+ - virtual_link:
+ node: tosca.nodes.Root
+ USRSU_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: USRSU_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: USRSU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ UPIRU2SignalNet1:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPIRU2SignalNet1
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPIRU
+ - virtual_link:
+ node: tosca.nodes.Root
+ Fabric:
+ type: tosca.nodes.nfv.VnfVirtualLinkDesc
+ properties:
+ vl_flavours:
+ flavours: test1
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern: null
+ attributes:
+ tosca_name: Fabric
+ UPSPU_VduCpd_Fabric:
+ type: tosca.nodes.nfv.VduCpd
+ properties:
+ role: root
+ layer_protocol: ipv4
+ attributes:
+ tosca_name: UPSPU_VduCpd_Fabric
+ requirements:
+ - virtual_binding:
+ capability: virtual_binding
+ node: UPSPU
+ - virtual_link:
+ capability: virtual_linkable
+ node: Fabric
+ substitution_mappings:
+ node_type: tosca.nodes.nfv.VNF.vPCRF
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml
new file mode 100644
index 0000000000..e789e09965
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-tosca-converter-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>openecomp-tosca-converter-api</module>
+ <module>openecomp-tosca-converter-core</module>
+ </modules>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
index 0fcaafa1c2..722c286f50 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
@@ -33,6 +33,7 @@ import java.util.Map;
*/
public class ToscaServiceModel implements AsdcModel {
private FileContentHandler artifactFiles;
+ private FileContentHandler externalFiles;
private Map<String, ServiceTemplate> serviceTemplates;
private String entryDefinitionServiceTemplate;
@@ -54,6 +55,15 @@ public class ToscaServiceModel implements AsdcModel {
this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate;
}
+ public ToscaServiceModel(FileContentHandler artifactFiles,
+ FileContentHandler externalFiles,
+ Map<String, ServiceTemplate> serviceTemplates,
+ String entryDefinitionServiceTemplate) {
+ this.artifactFiles = artifactFiles;
+ this.externalFiles = externalFiles;
+ this.serviceTemplates = serviceTemplates;
+ this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate;
+ }
/**
* Gets artifact files.
@@ -113,4 +123,12 @@ public class ToscaServiceModel implements AsdcModel {
public static ToscaServiceModel getClonedServiceModel(ToscaServiceModel toscaServiceModel) {
return ToscaServiceModel.class.cast(DataModelUtil.getClonedObject(toscaServiceModel));
}
+
+ public FileContentHandler getExternalFiles() {
+ return externalFiles;
+ }
+
+ public void setExternalFiles(FileContentHandler externalFiles) {
+ this.externalFiles = externalFiles;
+ }
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index dc2ed6c76b..45e6c3deef 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -492,7 +492,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
toscaServiceModel.getServiceTemplates().get(fetchFileNameForImport(importFile,
serviceTemplate.getMetadata() == null ? null
: serviceTemplate.getMetadata().get("filename")));
- if (filesScanned.contains(ToscaUtil.getServiceTemplateFileName(template))) {
+ if (Objects.isNull(template) ||
+ filesScanned.contains(ToscaUtil.getServiceTemplateFileName(template))) {
continue;
} else {
filesScanned.add(ToscaUtil.getServiceTemplateFileName(template));
diff --git a/openecomp-be/lib/pom.xml b/openecomp-be/lib/pom.xml
index 5095578db4..df1b854a31 100644
--- a/openecomp-be/lib/pom.xml
+++ b/openecomp-be/lib/pom.xml
@@ -31,5 +31,7 @@
<module>openecomp-logging-lib</module>
<module>openecomp-healing-lib</module>
<module>openecomp-sdc-activity-log-lib</module>
+ <module>openecomp-tosca-converter-lib</module>
+ <module>openecomp-sdc-orchestration-lib</module>
</modules>
</project>