aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorshrek2000 <orenkle@amdocs.com>2017-09-12 14:28:40 +0300
committershrek2000 <orenkle@amdocs.com>2017-09-12 14:59:18 +0300
commitcf1033dd4f9e0863f408314ba411fa0dc3150aae (patch)
treeb1431fe7030a00bf611af665dcbf184851d7823b /openecomp-be
parente6fc26ab18d1409c490c859398fc5fca71d0518b (diff)
Create new VSP, onboard from TOSCA file - UI
Issue-ID: SDC-230 Change-Id: I99db84eeef6e795f81d25fac31d17594d0071e69 Signed-off-by: shrek2000 <orenkle@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java32
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java8
8 files changed, 49 insertions, 21 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index 4c6cdaa54d..07cef57251 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -3,7 +3,6 @@ package org.openecomp.sdcrests.vsp.rest.services;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.logging.api.Logger;
@@ -34,7 +33,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Optional;
-import static org.openecomp.core.utilities.file.FileUtils.*;
+
+import static org.openecomp.core.utilities.file.FileUtils.getFileExtension;
+import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName;
@Named
@Service("orchestrationTemplateCandidate")
@@ -55,7 +56,7 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
UploadFileResponse uploadFileResponse = candidateManager
.upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction
.Write), fileToUpload.getObject(InputStream.class), user, getFileExtension(filename),
- FileUtils.getNetworkPackageName(filename));
+ getNetworkPackageName(filename));
UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto()
.applyMapping(uploadFileResponse, UploadFileResponseDto.class);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
index 104da69ed8..85f92662ea 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_Impl_Key;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
public class OrchestrationUploadFactory {
private static Map<String, ImplementationConfiguration> fileHanlders;
@@ -17,7 +17,7 @@ public class OrchestrationUploadFactory {
static {
Configuration config = ConfigurationManager.lookup();
fileHanlders = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
- ORCHESTRATION_Impl_Key, ImplementationConfiguration.class));
+ ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index 5d14477339..9d7421f336 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -59,7 +59,7 @@ import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConst
public class OrchestrationUtil {
public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
- public static final String ORCHESTRATION_Impl_Key = "orchestration_impl";
+ public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
private static VendorSoftwareProductDao vendorSoftwareProductDao =
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
index 5295e6a6d6..db43e0084e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
@@ -23,7 +23,7 @@ public class OrchestrationProcessFactory {
static {
Configuration config = ConfigurationManager.lookup();
processImplMap = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
- ConfigConstants.processImplKey, ImplementationConfiguration.class));
+ ConfigConstants.PROCESS_IMPL_KEY, ImplementationConfiguration.class));
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
index 5e217d4d60..85c6fcb7b5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
@@ -1,6 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
public class ConfigConstants {
- public static final String namespace = "Orchestration";
- public static final String processImplKey = "process_impl";
+ public static final String NAMESPACE = "Orchestration";
+ public static final String PROCESS_IMPL_KEY = "process_impl";
}
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
index 2d33748e26..778445c513 100644
--- 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
@@ -1,23 +1,30 @@
package org.openecomp.core.impl;
+import org.apache.commons.collections4.MapUtils;
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 org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
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 GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME =
+ "GlobalSubstitutionTypesServiceTemplate.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";
+ private static final Map<String, ServiceTemplate> globalServiceTemplates =
+ GlobalTypesGenerator.getGlobalTypesServiceTemplate();
public GlobalSubstitutionServiceTemplate() {
super();
@@ -26,7 +33,10 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
public void appendNodes(Map<String, NodeType> nodes) {
- getNode_types().putAll(nodes);
+ Optional<Map<String, NodeType>> nodeTypesToAdd =
+ removeExistingGlobalTypes(nodes);
+
+ nodeTypesToAdd.ifPresent(nodeTypes -> getNode_types().putAll(nodeTypes));
}
public void init() {
@@ -56,4 +66,22 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
private void writeDefinitionSection() {
setTosca_definitions_version(DEFININTION_VERSION);
}
+
+ public Optional<Map<String, NodeType>> removeExistingGlobalTypes(Map<String, NodeType> nodes){
+ Map<String, NodeType> nodeTypesToAdd = new HashMap<>();
+ ServiceTemplate serviceTemplate = globalServiceTemplates.get("openecomp/nodes.yml");
+
+ if(Objects.isNull(serviceTemplate) || MapUtils.isEmpty(serviceTemplate.getNode_types())){
+ return Optional.of(nodes);
+ }
+
+ Map<String, NodeType> globalNodeTypes = serviceTemplate.getNode_types();
+ for(Map.Entry<String, NodeType> nodeTypeEntry : nodes.entrySet()){
+ if(!globalNodeTypes.containsKey(nodeTypeEntry.getKey())){
+ nodeTypesToAdd.put(nodeTypeEntry.getKey(), nodeTypeEntry.getValue());
+ }
+ }
+
+ return Optional.of(nodeTypesToAdd);
+ }
}
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
index c4ed6f9c5f..69fa33aae7 100644
--- 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
@@ -70,7 +70,7 @@ public class ToscaConverterImpl implements ToscaConverter {
private void handleMetadataFile(Map<String, byte[]> csarFiles) {
byte[] bytes = csarFiles.remove(metadataFile);
if (bytes != null) {
- csarFiles.put(metadataFile + ".old", bytes);
+ csarFiles.put(metadataFile + ".original", bytes);
}
}
@@ -102,11 +102,16 @@ public class ToscaConverterImpl implements ToscaConverter {
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"));
+ externalFilesHandler.addFile(metadataFile + ".original",
+ csarFiles.get(metadataFile + ".original"));
toscaServiceModel.setArtifactFiles(externalFilesHandler);
+
+ if(MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())) {
+ serviceTemplates
+ .put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
+ }
}
private void addGlobalServiceTemplates(Collection<ServiceTemplate> globalServiceTemplates,
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
index 9f7071e9e7..1ee8f6c05f 100644
--- 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
@@ -47,15 +47,9 @@ public class ToscaConvertorDefinitionsTest {
assertNotNull(serviceTemplate.getNode_types());
- assertEquals(7, serviceTemplate.getNode_types().size());
+ assertEquals(1, 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"));
}