diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator')
4 files changed, 131 insertions, 121 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/ComputeConsolidationDataHandler.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/ComputeConsolidationDataHandler.java index dc2fc96169..8e319e96a0 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/ComputeConsolidationDataHandler.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/ComputeConsolidationDataHandler.java @@ -94,26 +94,49 @@ public class ComputeConsolidationDataHandler implements ConsolidationDataHandler } /** - * Add port to compute consolidation data entity base on given keys.s + * Add port to compute consolidation data entity base on given keys. * */ public void addPortToConsolidationData(TranslateTo translateTo, String computeNodeType, String computeNodeTemplateId, String portType, String portNodeTemplateId) { - ComputeTemplateConsolidationData entityConsolidationData = + ComputeTemplateConsolidationData consolidationData = getComputeTemplateConsolidationData(translateTo, computeNodeType, computeNodeTemplateId); - entityConsolidationData.addPort(portType, portNodeTemplateId); + consolidationData.addPort(portType, portNodeTemplateId); + } + + /** + * Add volume to consolidation data. + * + */ + public void addVolumeToConsolidationData(TranslateTo translateTo, String computeNodeType, + String computeNodeTemplateId, String requirementId, RequirementAssignment requirementAssignment) { + ComputeTemplateConsolidationData consolidationData = + getComputeTemplateConsolidationData(translateTo, computeNodeType, + computeNodeTemplateId); + consolidationData.addVolume(requirementId, requirementAssignment); + } + + /** + * Add group id information to consolidation data. + * + * @param translatedGroupId Group id of which compute node is a part + */ + + public void addGroupIdToConsolidationData(TranslateTo translateTo, String computeNodeType, + String computeNodeTemplateId, String translatedGroupId) { + ComputeTemplateConsolidationData consolidationData = + getComputeTemplateConsolidationData(translateTo, computeNodeType, + computeNodeTemplateId); + consolidationData.addGroupId(translatedGroupId); } private ComputeTemplateConsolidationData getComputeTemplateConsolidationData( TranslateTo translateTo, String computeNodeType, String computeNodeTemplateId) { - ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); return getComputeTemplateConsolidationData(serviceTemplateFileName, computeNodeType, computeNodeTemplateId); - } - private ComputeTemplateConsolidationData getComputeTemplateConsolidationData( String serviceTemplateFileName, String computeNodeType, String computeNodeTemplateId) { 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 7101037562..3987c54054 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 @@ -67,42 +67,42 @@ public class EntityConsolidationData { } /** - * Gets group ids point to me. - * - * @return the group ids point to me - */ + * Gets group ids point to me. + * + * @return the group ids point to me + */ public List<String> getGroupIds() { return groupIds; } /** - * Sets group ids point to me. - * - * @param groupIds the group ids point to me - */ + * Sets group ids point to me. + * + * @param groupIds the group ids point to me + */ public void setGroupIds(List<String> groupIds) { this.groupIds = groupIds; } /** - * Sets node connected to me. - * - * @param nodesConnectedIn the node connected to me - */ + * Sets node connected to me. + * + * @param nodesConnectedIn the node connected to me + */ public void setNodesConnectedIn(Map<String, List<RequirementAssignmentData>> nodesConnectedIn) { this.nodesConnectedIn = nodesConnectedIn; } /** - * Add nodeConnectedIn. - * - * @param nodeTemplateId the node template id which has connection to me - * @param requirementId the requirement id - * @param requirementAssignment the requirement assignment - */ + * Add node connected to me. + * + * @param nodeTemplateId the node template id which has connection to me + * @param requirementId the requirement id + * @param requirementAssignment the requirement assignment + */ public void addNodesConnectedIn(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedIn == null) { this.nodesConnectedIn = new HashMap<>(); @@ -114,42 +114,42 @@ public class EntityConsolidationData { } /** - * Gets node connected to me. - * - * @return the node connected to me - */ + * Gets node connected to me. + * + * @return the node connected to me + */ public Map<String, List<RequirementAssignmentData>> getNodesConnectedIn() { return nodesConnectedIn; } /** - * Gets node connected from me. - * - * @return the node connected from me - */ + * Gets node connected from me. + * + * @return the node connected from me + */ public Map<String, List<RequirementAssignmentData>> getNodesConnectedOut() { return nodesConnectedOut; } /** - * Sets node connected from me. - * - * @param nodesConnectedOut the node connected from me - */ + * Sets node connected from me. + * + * @param nodesConnectedOut the node connected from me + */ public void setNodesConnectedOut(Map<String, List<RequirementAssignmentData>> nodesConnectedOut) { this.nodesConnectedOut = nodesConnectedOut; } /** - * Add nodeConnectedOut. - * - * @param nodeTemplateId the node template id which is connected from me - * @param requirementId the requirement id - * @param requirementAssignment the requirement assignment - */ + * Add nodeConnectedOut. + * + * @param nodeTemplateId the node template id which is connected from me + * @param requirementId the requirement id + * @param requirementAssignment the requirement assignment + */ public void addNodesConnectedOut(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedOut == null) { this.nodesConnectedOut = new HashMap<>(); @@ -161,29 +161,29 @@ public class EntityConsolidationData { } /** - * Gets nodes get attr in. - * - * @return the get attr in - */ + * Gets nodes get attr in. + * + * @return the get attr in + */ public Map<String, List<GetAttrFuncData>> getNodesGetAttrIn() { return nodesGetAttrIn; } /** - * Sets nodes get attr in. - * - * @param nodesGetAttrIn the get attr in - */ + * Sets nodes get attr in. + * + * @param nodesGetAttrIn the get attr in + */ public void setNodesGetAttrIn(Map<String, List<GetAttrFuncData>> nodesGetAttrIn) { this.nodesGetAttrIn = nodesGetAttrIn; } /** - * Add nodes get attr in data. - * - * @param nodeTemplateId the node template id - * @param getAttrFuncData get attr data - */ + * Add nodes get attr in data. + * + * @param nodeTemplateId the node template id + * @param getAttrFuncData get attr data + */ public void addNodesGetAttrIn(String nodeTemplateId, GetAttrFuncData getAttrFuncData) { if (nodesGetAttrIn == null) { @@ -195,28 +195,28 @@ public class EntityConsolidationData { } /** - * Gets output parameters get attr from me. - * - * @return the get attr from me - */ + * Gets output parameters get attr from me. + * + * @return the get attr from me + */ public List<GetAttrFuncData> getOutputParametersGetAttrIn() { return outputParametersGetAttrIn; } /** - * Sets output parameters get attr from me. - * - * @param outputParametersGetAttrIn the output parameters get attr from me - */ + * Sets output parameters get attr from me. + * + * @param outputParametersGetAttrIn the output parameters get attr from me + */ public void setOutputParametersGetAttrIn(List<GetAttrFuncData> outputParametersGetAttrIn) { this.outputParametersGetAttrIn = outputParametersGetAttrIn; } /** - * Add output parameters get attr data. - * - * @param getAttrFuncData get attr data - */ + * Add output parameters get attr data. + * + * @param getAttrFuncData get attr data + */ public void addOutputParamGetAttrIn(GetAttrFuncData getAttrFuncData) { if (outputParametersGetAttrIn == null) { @@ -227,29 +227,29 @@ public class EntityConsolidationData { } /** - * Gets nodes get attr out. - * - * @return the get attr out - */ + * Gets nodes get attr out. + * + * @return the get attr out + */ public Map<String, List<GetAttrFuncData>> getNodesGetAttrOut() { return nodesGetAttrOut; } /** - * Sets nodes get attr out. - * - * @param nodesGetAttrOut the get attr out - */ + * Sets nodes get attr out. + * + * @param nodesGetAttrOut the get attr out + */ public void setNodesGetAttrOut(Map<String, List<GetAttrFuncData>> nodesGetAttrOut) { this.nodesGetAttrOut = nodesGetAttrOut; } /** - * Add nodes get attr out data. - * - * @param nodeTemplateId the node template id - * @param getAttrFuncData get attr data - */ + * Add nodes get attr out data. + * + * @param nodeTemplateId the node template id + * @param getAttrFuncData get attr data + */ public void addNodesGetAttrOut(String nodeTemplateId, GetAttrFuncData getAttrFuncData) { if (nodesGetAttrOut == null) { @@ -277,10 +277,8 @@ public class EntityConsolidationData { * @return true in case get attr list same for all port types. * otherwise return false */ - public boolean isGetAttrOutFromEntityLegal( - Collection<? extends EntityConsolidationData> entityConsolidationDataList, - Map<String, List<String>> portTypeToIds) { - + public boolean isGetAttrOutFromEntityLegal(Collection<? extends EntityConsolidationData> + entityConsolidationDataList, Map<String, List<String>> portTypeToIds) { for (String portType : portTypeToIds.keySet()) { Set<GetAttrFuncData> startingGetAttrFunc = getEntityGetAttrFuncAsSet(portType); @@ -293,7 +291,6 @@ public class EntityConsolidationData { } } } - return true; } @@ -307,4 +304,17 @@ public class EntityConsolidationData { .flatMap(entry -> entry.getValue().stream()) .collect(Collectors.toSet()); } + + /** + * Add group id information to consolidation data. + * + * @param groupId Group id of which compute node is a part + */ + + void addGroupId(String groupId) { + if (groupIds == null) { + groupIds = new ArrayList<>(); + } + groupIds.add(groupId); + } } 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 0d8a07a41f..b766f30388 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 @@ -16,7 +16,6 @@ package org.openecomp.sdc.translator.services.heattotosca; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -36,6 +35,7 @@ import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeConsolidationDataHandler; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationDataHandler; @@ -283,21 +283,6 @@ public class ConsolidationDataUtil { } /** - * Update group id information in consolidation data. - * - * @param entityConsolidationData Entity consolidation data (Port/Compute) - * @param translatedGroupId Group id of which compute node is a part - */ - public static void updateGroupIdInConsolidationData(EntityConsolidationData - entityConsolidationData, - String translatedGroupId) { - if (entityConsolidationData.getGroupIds() == null) { - entityConsolidationData.setGroupIds(new ArrayList<>()); - } - entityConsolidationData.getGroupIds().add(translatedGroupId); - } - - /** * Update volume information in consolidation data. * * @param translateTo {@link TranslateTo} object @@ -309,17 +294,13 @@ public class ConsolidationDataUtil { String computeType, String computeNodeTemplateId, String requirementId, - RequirementAssignment - requirementAssignment) { - TranslationContext translationContext = translateTo.getContext(); - ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); - ComputeTemplateConsolidationData computeTemplateConsolidationData = - getComputeTemplateConsolidationData(translationContext, serviceTemplate, computeType, - computeNodeTemplateId); - computeTemplateConsolidationData.addVolume(requirementId, requirementAssignment); + RequirementAssignment requirementAssignment) { + ComputeConsolidationDataHandler handler = + translateTo.getContext().getComputeConsolidationDataHandler(); + handler.addVolumeToConsolidationData( + translateTo, computeType, computeNodeTemplateId, requirementId, requirementAssignment); } - /** * Update port in consolidation data. * 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/ResourceTranslationNovaServerImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java index d6f0d7a2b8..e70ca5f2f9 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java @@ -55,7 +55,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.PropertyRegexMatcher; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo; import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource; -import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeConsolidationDataHandler; import org.openecomp.sdc.translator.services.heattotosca.ConsolidationDataUtil; import org.openecomp.sdc.translator.services.heattotosca.Constants; import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil; @@ -167,14 +167,10 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase { } private void updateComputeConsolidationDataGroup(TranslateTo translateTo, - NodeTemplate novaNodeTemplate, - String groupId) { - TranslationContext translationContext = translateTo.getContext(); - ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); - ComputeTemplateConsolidationData computeTemplateConsolidationData = ConsolidationDataUtil - .getComputeTemplateConsolidationData(translationContext, serviceTemplate, - novaNodeTemplate.getType(), translateTo.getTranslatedId()); - ConsolidationDataUtil.updateGroupIdInConsolidationData(computeTemplateConsolidationData, groupId); + NodeTemplate novaNodeTemplate, String groupId) { + ComputeConsolidationDataHandler handler = translateTo.getContext().getComputeConsolidationDataHandler(); + handler.addGroupIdToConsolidationData(translateTo,novaNodeTemplate.getType(), + translateTo.getTranslatedId(), groupId); } private boolean isHintOfTypeNovaServerGroup(HeatOrchestrationTemplate heatOrchestrationTemplate, |