aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2017-11-01 16:44:32 +0200
committertalio <tali.orenbach@amdocs.com>2017-11-01 18:31:18 +0200
commitc68f91c55e6f2813bbfa4b76a50fd368b3cdfe16 (patch)
treeceb9a5d0d69309863f86ce0c3646d72292a918d8 /openecomp-be
parentf8572ca437bf106b3e61cc7c39580284176d97c3 (diff)
nested node templates
ignore relations to / from node templates that point to substitution service templates without topology template Issue - Id : SDC-574 Change-Id: I03d2b305d6ebfd3d355ec3ab9a6f7ae8cb1c5743 Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java54
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java17
5 files changed, 76 insertions, 41 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
index ddbcaf72b9..7d3ebb9c7c 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
@@ -123,6 +123,8 @@ public class TranslationContext {
private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
+ private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
+
public static Map<String, ImplementationConfiguration>
getSupportedConsolidationComputeResources() {
return supportedConsolidationComputeResources;
@@ -583,22 +585,22 @@ public class TranslationContext {
}
- public Set<String> getServiceTemplatesWithoutNodeTemplateSection() {
- return serviceTemplatesWithoutNodeTemplateSection;
- }
-
- public void setServiceTemplatesWithoutNodeTemplateSection(
- Set<String> serviceTemplatesWithoutNodeTemplateSection) {
- this.serviceTemplatesWithoutNodeTemplateSection = serviceTemplatesWithoutNodeTemplateSection;
+ public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
+ return Objects.nonNull(serviceTemplateName)
+ && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
}
public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
}
- public boolean isServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
- return !Objects.isNull(serviceTemplateName) &&
- this.serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
+ public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
+ this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
+ }
+
+ public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
+ return Objects.nonNull(nodeTemplateId)
+ && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
}
public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
index 5d1bb1c61e..c5a6735ee7 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
@@ -2,6 +2,7 @@ package org.openecomp.sdc.translator.services.heattotosca;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.math.NumberUtils;
+import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
@@ -34,7 +35,6 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -145,17 +145,23 @@ public class ConsolidationDataUtil {
*
* @param context the context
* @param serviceTemplate the service template
- * @param nestedHeatFileName
- *@param nestedNodeTemplateId the nested node template id @return the nested template consolidation data
+ * @param nestedNodeTemplateId the nested node template id @return the nested template
+ * consolidation data
*/
public static NestedTemplateConsolidationData getNestedTemplateConsolidationData(
TranslationContext context,
ServiceTemplate serviceTemplate,
String nestedHeatFileName, String nestedNodeTemplateId) {
- if(isNestedResourceIdOccuresInDifferentNestedFiles(context, nestedHeatFileName,
- nestedNodeTemplateId)){
- throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(nestedNodeTemplateId).build());
+ if (isNestedResourceIdOccuresInDifferentNestedFiles(context, nestedHeatFileName,
+ nestedNodeTemplateId)) {
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(nestedNodeTemplateId).build());
+ }
+
+ if (isNodeTemplatePointsToServiceTemplateWithoutNodeTemplates(
+ nestedNodeTemplateId, nestedHeatFileName, context)) {
+ return null;
}
ConsolidationData consolidationData = context.getConsolidationData();
@@ -185,11 +191,22 @@ public class ConsolidationDataUtil {
return nestedTemplateConsolidationData;
}
+ public static boolean isNodeTemplatePointsToServiceTemplateWithoutNodeTemplates(String
+ nestedNodeTemplateId,
+ String nestedHeatFileName,
+ TranslationContext context) {
+
+ return context.isServiceTemplateWithoutNodeTemplatesSection(
+ FileUtils.getFileWithoutExtention(nestedHeatFileName))
+ || context.isNodeTemplateIdPointsToStWithoutNodeTemplates(nestedNodeTemplateId);
+ }
+
private static boolean isNestedResourceIdOccuresInDifferentNestedFiles(TranslationContext context,
String nestedHeatFileName,
String nestedNodeTemplateId) {
return Objects.nonNull(nestedHeatFileName)
- && context.getAllTranslatedResourceIdsFromDiffNestedFiles(nestedHeatFileName).contains(nestedNodeTemplateId);
+ && context.getAllTranslatedResourceIdsFromDiffNestedFiles(nestedHeatFileName)
+ .contains(nestedNodeTemplateId);
}
/**
@@ -331,22 +348,21 @@ public class ConsolidationDataUtil {
|| consolidationEntityType == ConsolidationEntityType.NESTED) {
entityConsolidationData =
getNestedTemplateConsolidationData(translationContext, serviceTemplate,
- null,
+ translateTo.getHeatFileName(),
translateTo.getTranslatedId());
}
- if(Objects.isNull(entityConsolidationData)){
+ if (Objects.isNull(entityConsolidationData)) {
return;
}
- if (entityConsolidationData != null) {
- if (entityConsolidationData.getNodesConnectedOut() == null) {
- entityConsolidationData.setNodesConnectedOut(new HashMap<>());
- }
- entityConsolidationData.getNodesConnectedOut()
- .computeIfAbsent(nodeTemplateId, k -> new ArrayList<>())
- .add(requirementAssignmentData);
+ if (Objects.isNull(entityConsolidationData.getNodesConnectedOut())) {
+ entityConsolidationData.setNodesConnectedOut(new HashMap<>());
}
+
+ entityConsolidationData.getNodesConnectedOut()
+ .computeIfAbsent(nodeTemplateId, k -> new ArrayList<>())
+ .add(requirementAssignmentData);
}
/**
@@ -433,7 +449,7 @@ public class ConsolidationDataUtil {
/**
* Checks if the current HEAT resource if of type compute.
*
- * @param resource the resource
+ * @param resource the resource
* @return true if the resource is of compute type and false otherwise
*/
public static boolean isComputeResource(Resource resource) {
@@ -473,7 +489,7 @@ public class ConsolidationDataUtil {
/**
* Checks if the current HEAT resource if of type port.
*
- * @param resource the resource
+ * @param resource the resource
* @return true if the resource is of port type and false otherwise
*/
public static boolean isPortResource(Resource resource) {
@@ -507,7 +523,7 @@ public class ConsolidationDataUtil {
/**
* Checks if the current HEAT resource if of type volume.
*
- * @param resource the resource
+ * @param resource the resource
* @return true if the resource is of volume type and false otherwise
*/
public static boolean isVolumeResource(Resource resource) {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
index b2909d15b3..48d564227e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
@@ -276,7 +276,7 @@ public class FunctionTranslationGetAttrImpl implements FunctionTranslation {
return Optional.of(ConsolidationDataUtil
.getPortTemplateConsolidationData(context, serviceTemplate, resourceId));
} else if (HeatToToscaUtil.isNestedResource(resource)) {
- return Optional.of(ConsolidationDataUtil
+ return Optional.ofNullable(ConsolidationDataUtil
.getNestedTemplateConsolidationData(context, serviceTemplate, heatFileName, resourceId));
}
return Optional.empty();
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
index 385a0fb0f5..cebabc0df1 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
@@ -146,16 +146,34 @@ public abstract class ResourceTranslationBase {
throw new CoreException(
new ResourceNotFoundInHeatFileErrorBuilder(resourceId, heatFileName).build());
}
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return getTranslatedResourceId(resourceId, heatFileName, resource, heatOrchestrationTemplate,
+ context
+ );
+ }
+
+ private static Optional<String> getTranslatedResourceId(String resourceId,
+ String heatFileName,
+ Resource resource,
+ HeatOrchestrationTemplate heatOrchestrationTemplate,
+ TranslationContext context) {
TranslateTo translateTo =
generateTranslationTo(heatFileName, null, heatOrchestrationTemplate, resource, resourceId,
null, context);
- translatedId =
+
+ String translatedId =
ResourceTranslationFactory.getInstance(resource).generateTranslatedId(translateTo);
+
+ if (ConsolidationDataUtil.isNodeTemplatePointsToServiceTemplateWithoutNodeTemplates
+ (translatedId, heatFileName, context)) {
+ return Optional.empty();
+ }
+
if (translatedId != null) {
context.getTranslatedIds().get(heatFileName).put(resourceId, translatedId);
}
- mdcDataDebugMessage.debugExitMessage(null, null);
return Optional.ofNullable(translatedId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java
index c29409fe48..7ba33c47e4 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.logging.api.Logger;
@@ -39,8 +38,6 @@ import org.openecomp.sdc.translator.services.heattotosca.Constants;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.TranslationService;
-import java.util.Objects;
-
public class ResourceTranslationNestedImpl extends ResourceTranslationBase {
protected static Logger logger =
@@ -95,7 +92,8 @@ public class ResourceTranslationNestedImpl extends ResourceTranslationBase {
.get(translateTo.getResource().getType());
if(DataModelUtil.isNodeTemplateSectionMissingFromServiceTemplate(substitutionServiceTemplate)){
- handleSubstitutionServiceTemplateWithoutNodeTemplates(translateTo, context, templateName);
+ handleSubstitutionServiceTemplateWithoutNodeTemplates(
+ templateName, translateTo);
mdcDataDebugMessage.debugExitMessage(null, null);
return;
}
@@ -113,11 +111,12 @@ public class ResourceTranslationNestedImpl extends ResourceTranslationBase {
mdcDataDebugMessage.debugExitMessage(null, null);
}
- private void handleSubstitutionServiceTemplateWithoutNodeTemplates(TranslateTo translateTo,
- TranslationContext context,
- String templateName) {
- context.addServiceTemplateWithoutNodeTemplates(templateName);
- context.getTranslatedServiceTemplates().remove(translateTo.getResource().getType());
+ private void handleSubstitutionServiceTemplateWithoutNodeTemplates(String templateName,
+ TranslateTo translateTo) {
+ translateTo.getContext().addServiceTemplateWithoutNodeTemplates(templateName);
+ translateTo.getContext()
+ .addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(translateTo.getTranslatedId());
+ translateTo.getContext().getTranslatedServiceTemplates().remove(translateTo.getResource().getType());
}
private ServiceTemplate createSubstitutionServiceTemplate(TranslateTo translateTo,