diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java')
9 files changed, 113 insertions, 51 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java index 1c272770b3..814011d846 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java @@ -31,7 +31,6 @@ import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.datatypes.model.RequirementAssignment; -import org.openecomp.sdc.translator.services.heattotosca.ConsolidationDataUtil; /** * The type Entity consolidation data. @@ -106,7 +105,7 @@ public class EntityConsolidationData { * @param requirementAssignment the requirement assignment */ public void addNodesConnectedIn(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedIn == null) { this.nodesConnectedIn = ArrayListMultimap.create(); @@ -152,7 +151,7 @@ public class EntityConsolidationData { * @param requirementAssignment the requirement assignment */ public void addNodesConnectedOut(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedOut == null) { this.nodesConnectedOut = ArrayListMultimap.create(); @@ -280,7 +279,7 @@ public class EntityConsolidationData { * otherwise return false */ public boolean isGetAttrOutFromEntityLegal(Collection<? extends EntityConsolidationData> - entityConsolidationDataList, Map<String, List<String>> portTypeToIds) { + entityConsolidationDataList, Map<String, List<String>> portTypeToIds) { if (CollectionUtils.isEmpty(entityConsolidationDataList) || MapUtils.isEmpty(portTypeToIds)) { return true; @@ -288,11 +287,11 @@ public class EntityConsolidationData { for (String portType : portTypeToIds.keySet()) { Set<GetAttrFuncData> startingGetAttrFunc = - getEntityGetAttrFuncAsSet(portType); + getEntityGetAttrFuncAsSet(portType, portTypeToIds); for (EntityConsolidationData entity : entityConsolidationDataList) { Set<GetAttrFuncData> currentGetAttrFuncData = - entity.getEntityGetAttrFuncAsSet(portType); + entity.getEntityGetAttrFuncAsSet(portType, portTypeToIds); if (!(startingGetAttrFunc.equals(currentGetAttrFuncData))) { return false; } @@ -301,15 +300,25 @@ public class EntityConsolidationData { return true; } - private Set<GetAttrFuncData> getEntityGetAttrFuncAsSet(String portType) { + private Set<GetAttrFuncData> getEntityGetAttrFuncAsSet(String portType, Map<String, List<String>> portTypeToIds) { if (MapUtils.isEmpty(nodesGetAttrOut)) { return new HashSet<>(); } return nodesGetAttrOut.entrySet().stream() - .filter(entry -> portType.equals(ConsolidationDataUtil.getPortType(entry.getKey()))) - .flatMap(entry -> entry.getValue().stream()) - .collect(Collectors.toSet()); + .filter(entry -> portType.equals(getPortTypeFromNodeTemplateId(entry.getKey(), + portTypeToIds))) + .flatMap(entry -> entry.getValue().stream()) + .collect(Collectors.toSet()); + } + + private String getPortTypeFromNodeTemplateId(String portNodeTemplateId, Map<String, List<String>> portTypeToIds) { + for (Map.Entry<String, List<String>> portTypeToIdEntry : portTypeToIds.entrySet()) { + if (portTypeToIdEntry.getValue().contains(portNodeTemplateId)) { + return portTypeToIdEntry.getKey(); + } + } + return ""; } /** diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java index 229e680bda..0300f9fcd9 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java @@ -77,7 +77,7 @@ public class FilePortConsolidationData { PortTemplateConsolidationData consolidationData = addPortTemplateConsolidationData(parentPortNodeTemplateId, parentPortResourceId, - parentPortResourceType); + parentPortResourceType, null); return consolidationData.addSubInterfaceTemplateConsolidationData(resource, subInterfaceNodeTemplateId, parentPortNodeTemplateId); @@ -90,13 +90,16 @@ public class FilePortConsolidationData { * @return port template consolidation data entity by given keys */ PortTemplateConsolidationData addPortTemplateConsolidationData( - String portNodeTemplateId, String portResourceId, String portResourceType) { + String portNodeTemplateId, String portResourceId, String portResourceType, String portType) { PortTemplateConsolidationData consolidationData = getPortTemplateConsolidationData(portNodeTemplateId); if (consolidationData == null) { consolidationData = createPortTemplateConsolidationData(portNodeTemplateId, - portResourceId, portResourceType); + portResourceId, portResourceType, portType); setPortTemplateConsolidationData(portNodeTemplateId, consolidationData); } + if (consolidationData.getPortType() == null) { + consolidationData.setPortType(portType); + } return consolidationData; } @@ -116,9 +119,10 @@ public class FilePortConsolidationData { } private PortTemplateConsolidationData createPortTemplateConsolidationData(String portNodeTemplateId, - String portResourceId, String portResourceType) { + String portResourceId, String portResourceType, String portType) { PortTemplateConsolidationData consolidationData = new PortTemplateConsolidationData(); consolidationData.setNodeTemplateId(portNodeTemplateId); + consolidationData.setPortType(portType); Optional<String> portNetworkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(portResourceId, portResourceType); portNetworkRole.ifPresent(consolidationData::setNetworkRole); diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java index 1c830646d6..132a507298 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java @@ -50,10 +50,10 @@ public class PortConsolidationData { * @return port template consolidation data */ PortTemplateConsolidationData addPortTemplateConsolidationData(String serviceTemplateFileName, - String portNodeTemplateId, String portResourceId, String portResourceType) { + String portNodeTemplateId, String portResourceId, String portResourceType, String portType) { FilePortConsolidationData consolidationData = addFilePortConsolidationData(serviceTemplateFileName); return consolidationData - .addPortTemplateConsolidationData(portNodeTemplateId, portResourceId, portResourceType); + .addPortTemplateConsolidationData(portNodeTemplateId, portResourceId, portResourceType, portType); } /** diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java index c28c54c861..5114e5d25d 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java @@ -66,7 +66,7 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { Resource resource = heatOrchestrationTemplate.getResources().get(contrailSharedResourceId); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); EntityConsolidationData entityConsolidationData = getPortTemplateConsolidationData(serviceTemplateFileName, - contrailSharedResourceId, resource.getType(), sharedTranslatedResourceId); + contrailSharedResourceId, resource.getType(), sharedTranslatedResourceId, null); entityConsolidationData.removeParamNameFromAttrFuncList(paramName); } @@ -76,9 +76,9 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { * */ public void addConsolidationData(String serviceTemplateFileName, - String portResourceId, String portResourceType, String portNodeTemplateId) { + String portResourceId, String portResourceType, String portNodeTemplateId, String portType) { getPortTemplateConsolidationData( - serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId); + serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId, portType); } @Override @@ -133,7 +133,7 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { Resource resource = heatOrchestrationTemplate.getResources().get(targetResourceId); ServiceTemplate serviceTemplate = functionTranslator.getServiceTemplate(); return getPortTemplateConsolidationData(ToscaUtil.getServiceTemplateFileName(serviceTemplate), - targetResourceId, resource.getType(), targetResourceTranslatedId); + targetResourceId, resource.getType(), targetResourceTranslatedId, null); } private PortTemplateConsolidationData getPortTemplateConsolidationData(TranslateTo translateTo, @@ -141,14 +141,14 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); return getPortTemplateConsolidationData(serviceTemplateFileName, - portResourceId, portResourceType, portNodeTemplateId); + portResourceId, portResourceType, portNodeTemplateId, null); } private PortTemplateConsolidationData getPortTemplateConsolidationData(String serviceTemplateFileName, - String portResourceId, String portResourceType, String portNodeTemplateId) { + String portResourceId, String portResourceType, String portNodeTemplateId, String portType) { return portConsolidationData.addPortTemplateConsolidationData(serviceTemplateFileName, - portNodeTemplateId, portResourceId, portResourceType); + portNodeTemplateId, portResourceId, portResourceType, portType); } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java index f612c35abe..b529c7a55e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java @@ -36,6 +36,8 @@ public class PortTemplateConsolidationData extends EntityConsolidationData { private final ListMultimap<String, SubInterfaceTemplateConsolidationData> subInterfaceConsolidationData = Multimaps.synchronizedListMultimap(ArrayListMultimap.create()); + private String portType; + private String networkRole; public String getNetworkRole() { @@ -46,6 +48,14 @@ public class PortTemplateConsolidationData extends EntityConsolidationData { this.networkRole = networkRole; } + public String getPortType() { + return portType; + } + + public void setPortType(String portType) { + this.portType = portType; + } + public boolean isPortBoundToSubInterface() { return !subInterfaceConsolidationData.isEmpty(); } 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 e7c32e195b..0fb2eb8606 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 @@ -29,6 +29,7 @@ import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; +import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo; @@ -92,7 +93,7 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants. String portNodeTemplateId) { TranslationContext translationContext = translateTo.getContext(); String computeNodeTemplateId = translateTo.getTranslatedId(); - String portType = getPortType(portNodeTemplateId); + String portType = getPortType(portNodeTemplateId, DataModelUtil.getNamespaceSuffix(computeNodeType)); translationContext.getComputeConsolidationDataHandler().addPortToConsolidationData( translateTo, computeNodeType, computeNodeTemplateId, portType, portNodeTemplateId); @@ -100,7 +101,7 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants. ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); translationContext.getPortConsolidationDataHandler().addConsolidationData( - serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId); + serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId, portType); } /** @@ -243,24 +244,30 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants. * @param portNodeTemplateId the port node template id * @return the port type */ - public static String getPortType(String portNodeTemplateId) { + public static String getPortType(String portNodeTemplateId, String vmType) { - if (StringUtils.isBlank(portNodeTemplateId)) { + if (StringUtils.isBlank(portNodeTemplateId) || !portNodeTemplateId.startsWith(vmType + UNDERSCORE)) { return portNodeTemplateId; } + String temp = portNodeTemplateId.substring(portNodeTemplateId.indexOf(vmType) + vmType.length()); - String formattedName = portNodeTemplateId.replaceAll(UNDERSCORE + DIGIT_REGEX + "$", ""); + StringBuilder sb = new StringBuilder(vmType + UNDERSCORE); + String[] tokens = temp.split(UNDERSCORE); - StringBuilder sb = new StringBuilder(); - int count = 0; - for (String token : formattedName.split(UNDERSCORE)) { + if (tokens.length == 0) { + return portNodeTemplateId; + } - if (StringUtils.isNotBlank(token)) { - count++; + for (int i=0; i<tokens.length; i++) { + String token = tokens[i]; + if (token.matches(DIGIT_REGEX) && i != 1) { + sb.append(token); + sb.append(UNDERSCORE); } - if (count != 2 || (!StringUtils.isBlank(token) && !token.matches(DIGIT_REGEX))) { - sb.append(token).append(UNDERSCORE); + if (StringUtils.isNotBlank(token) && !token.matches(DIGIT_REGEX)) { + sb.append(token); + sb.append(UNDERSCORE); } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java index 45f12cea85..df628a06e5 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java @@ -147,7 +147,8 @@ public class ConsolidationService { Set<String> portNodeTemplateIds = filePortConsolidationData.getAllPortNodeTemplateIds(); for (String portNodeTemplateId : portNodeTemplateIds) { consolidationEntityIdToType - .put(portNodeTemplateId, ConsolidationDataUtil.getPortType(portNodeTemplateId)); + .put(portNodeTemplateId, + filePortConsolidationData.getPortTemplateConsolidationData(portNodeTemplateId).getPortType()); } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java index 7eec4e0c72..81a5a199c2 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java @@ -31,6 +31,7 @@ import static org.openecomp.sdc.translator.services.heattotosca.Constants.PORT_I import static org.openecomp.sdc.translator.services.heattotosca.Constants.SUB_INTERFACE_PROPERTY_VALUE_PREFIX; import static org.openecomp.sdc.translator.services.heattotosca.Constants.SUB_INTERFACE_ROLE; import static org.openecomp.sdc.translator.services.heattotosca.Constants.VFC_PARENT_PORT_ROLE; +import static org.openecomp.sdc.translator.services.heattotosca.UnifiedCompositionUtil.getPortTemplateConsolidationDataForPort; import static org.openecomp.sdc.translator.services.heattotosca.UnifiedCompositionUtil.getComputeTypeSuffix; import static org.openecomp.sdc.translator.services.heattotosca.UnifiedCompositionUtil.getConnectedComputeConsolidationData; import static org.openecomp.sdc.translator.services.heattotosca.UnifiedCompositionUtil.getNewComputeNodeTemplateId; @@ -2197,7 +2198,8 @@ public class UnifiedCompositionService { } else { Optional<String> parameterId = updateProperty(unifiedCompositionTo.getServiceTemplate(), nodeTemplateId, unifiedCompositionTo.getNodeTemplate(), propertyEntry, - unifiedCompositionEntity, computeTemplateConsolidationData, null, + unifiedCompositionEntity, computeTemplateConsolidationData, + getPortTemplateConsolidationDataForPort(unifiedCompositionTo.getUnifiedCompositionDataList(), nodeTemplateId), unifiedCompositionTo.getUnifiedCompositionDataList(), unifiedCompositionTo.getContext()); parameterId.ifPresent( @@ -2298,7 +2300,8 @@ public class UnifiedCompositionService { String inputParamId = getParameterId(nodeTemplateId, nodeTemplate, enrichPropertyName, - compositionEntity, computeTemplateConsolidationData, null); + compositionEntity, computeTemplateConsolidationData, + (PortTemplateConsolidationData) entityConsolidationData); Map<String, String> propertyValMap = new HashMap<>(); context @@ -2477,7 +2480,13 @@ public class UnifiedCompositionService { nodeTemplate.getProperties().put(propertyId, propertyVal); break; case PORT: - String portType = ConsolidationDataUtil.getPortType(nodeTemplateId); + PortTemplateConsolidationData portTemplateConsolidationData = + getPortTemplateConsolidationDataForPort(unifiedCompositionDataList, + nodeTemplateId); + String portType = null; + if (Objects.nonNull(portTemplateConsolidationData)) { + portType = portTemplateConsolidationData.getPortType(); + } ComputeTemplateConsolidationData computeTemplateConsolidationData = getConnectedComputeConsolidationData(unifiedCompositionDataList, nodeTemplateId); inputParamId = getInputParamIdForPort(nodeTemplateId, propertyId, portType, computeTemplateConsolidationData); @@ -2690,9 +2699,10 @@ public class UnifiedCompositionService { + getComputeTypeSuffix(nodeTemplate.getType()) + "_" + propertyId; break; case PORT: - String portType = ConsolidationDataUtil.getPortType(nodeTemplateId); + String portType = portTemplateConsolidationData.getPortType(); if (Objects.isNull(computeTemplateConsolidationData) - || computeTemplateConsolidationData.getPorts().get(portType).size() > 1) { + || (computeTemplateConsolidationData.getPorts().get(portType) != null + && computeTemplateConsolidationData.getPorts().get(portType).size() > 1)) { paramterId = UnifiedCompositionEntity.PORT.getDisplayName().toLowerCase() + "_" + nodeTemplateId + "_" + propertyId; } else { @@ -2882,7 +2892,7 @@ public class UnifiedCompositionService { String portNodeTemplateId = portTemplateConsolidationData.getNodeTemplateId(); Object propertyValue = getPortPropertyValue(substitutionTemplateInputName, computeType, portInputType, serviceTemplate, - portNodeTemplateId); + portNodeTemplateId, portTemplateConsolidationData); //If the value object is Optional.empty it implies that the property name was not // found in the input name if (!(propertyValue instanceof Optional)) { @@ -2995,7 +3005,7 @@ public class UnifiedCompositionService { .stream() .filter(s -> substitutionTemplateInputName. contains(getPropertyInputPrefix(s.getNodeTemplateId(), - ConsolidationDataUtil.getPortType(s.getNodeTemplateId()), + s.getPortType(), portInputType, UnifiedCompositionEntity.PORT))) .findFirst(); @@ -3487,9 +3497,10 @@ public class UnifiedCompositionService { String computeType, PropertyInputType portInputType, ServiceTemplate serviceTemplate, - String portNodeTemplateId) { + String portNodeTemplateId, + PortTemplateConsolidationData portTemplateConsolidationData) { //Get the input prefix to extract the property name from the input name - String portType = ConsolidationDataUtil.getPortType(portNodeTemplateId); + String portType = portTemplateConsolidationData.getPortType(); String portInputPrefix = getPropertyInputPrefix( portNodeTemplateId, portType, portInputType, UnifiedCompositionEntity.PORT); //Get the property name from the input diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionUtil.java index bc9fc5a331..82fb4b0c8e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionUtil.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionUtil.java @@ -16,6 +16,9 @@ package org.openecomp.sdc.translator.services.heattotosca; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -25,10 +28,10 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.datatypes.model.NodeTemplate; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; -//import org.openecomp.core.model.types.ServiceTemplate; import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionData; @@ -36,9 +39,6 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.SubInterfaceTemplateConsolidationData; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; - /** * Utility class for consolidation data collection helper methods. */ @@ -123,6 +123,24 @@ public class UnifiedCompositionUtil { return null; } + public static PortTemplateConsolidationData getPortTemplateConsolidationDataForPort(List<UnifiedCompositionData> + unifiedCompositionDataList, + String portNodeTemplateId) { + for (UnifiedCompositionData unifiedCompositionData : unifiedCompositionDataList) { + if (CollectionUtils.isEmpty(unifiedCompositionData.getPortTemplateConsolidationDataList())) { + continue; + } + List<PortTemplateConsolidationData> portTemplateConsolidationDataList = + unifiedCompositionData.getPortTemplateConsolidationDataList(); + for (PortTemplateConsolidationData portTemplateConsolidationData : portTemplateConsolidationDataList) { + if (portTemplateConsolidationData.getNodeTemplateId().equals(portNodeTemplateId)) { + return portTemplateConsolidationData; + } + } + } + return null; + } + //The ID should be <vm_type>_<port_type> or <vm_type>_<portNodeTemplateId> public static String getNewPortNodeTemplateId( String portNodeTemplateId, @@ -130,9 +148,11 @@ public class UnifiedCompositionUtil { ComputeTemplateConsolidationData computeTemplateConsolidationData) { StringBuilder newPortNodeTemplateId = new StringBuilder(); - String portType = ConsolidationDataUtil.getPortType(portNodeTemplateId); + String portType = ConsolidationDataUtil.getPortType(portNodeTemplateId, + DataModelUtil.getNamespaceSuffix(connectedComputeNodeType)); newPortNodeTemplateId.append(DataModelUtil.getNamespaceSuffix(connectedComputeNodeType)); - if (computeTemplateConsolidationData.getPorts().get(portType).size() > 1) { + if (computeTemplateConsolidationData.getPorts().get(portType) != null + && computeTemplateConsolidationData.getPorts().get(portType).size() > 1) { //single port newPortNodeTemplateId.append("_").append(portNodeTemplateId); } else { |