From c01e02538c7e2ccfcbc9f9b22e33875176c0dbf5 Mon Sep 17 00:00:00 2001 From: talio Date: Thu, 2 Nov 2017 14:45:02 +0200 Subject: dynamic ports ignore "depends_on" from / to nested entities Issue - Id : SDC-576 Change-Id: Id96e57a7826638b0c5b582d35417d6369fb9f607 Signed-off-by: talio --- .../ConsolidationTypesConnectivity.java | 64 ++++++++++++++++++++++ .../services/heattotosca/HeatToToscaUtil.java | 41 +------------- 2 files changed, 65 insertions(+), 40 deletions(-) create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationTypesConnectivity.java (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib') diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationTypesConnectivity.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationTypesConnectivity.java new file mode 100644 index 0000000000..4e219dae4d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationTypesConnectivity.java @@ -0,0 +1,64 @@ +package org.openecomp.sdc.translator.services.heattotosca; + +import org.apache.commons.collections.CollectionUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ConsolidationTypesConnectivity { + + private static Map> + entityToEntitiesWithoutRelationship; + + static { + entityToEntitiesWithoutRelationship = new HashMap<>(); + entityToEntitiesWithoutRelationship + .put(ConsolidationEntityType.COMPUTE, getIgnoredComputeRelationships()); + entityToEntitiesWithoutRelationship + .put(ConsolidationEntityType.PORT,getIgnoredPortRelationships()); + entityToEntitiesWithoutRelationship + .put(ConsolidationEntityType.VOLUME, getIgnoredVolumeRelationships()); + entityToEntitiesWithoutRelationship + .put(ConsolidationEntityType.VFC_NESTED, getIgnoredVfcNestedRelationships()); + } + + private static Set getIgnoredComputeRelationships(){ + return Stream.of(ConsolidationEntityType.COMPUTE, + ConsolidationEntityType.VOLUME, + ConsolidationEntityType.PORT, + ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet()); + } + + private static Set getIgnoredPortRelationships(){ + return Stream.of(ConsolidationEntityType.COMPUTE, + ConsolidationEntityType.VOLUME, + ConsolidationEntityType.PORT, + ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet()); + } + + private static Set getIgnoredVolumeRelationships(){ + return Stream.of(ConsolidationEntityType.COMPUTE, + ConsolidationEntityType.VOLUME, + ConsolidationEntityType.PORT, + ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet()); + } + + private static Set getIgnoredVfcNestedRelationships(){ + return Stream.of(ConsolidationEntityType.COMPUTE, + ConsolidationEntityType.VOLUME, + ConsolidationEntityType.PORT, + ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet()); + } + + public static boolean isDependsOnRelationshipValid(ConsolidationEntityType source, + ConsolidationEntityType target) { + Set consolidationEntityTypes = + entityToEntitiesWithoutRelationship.get(source); + return CollectionUtils.isEmpty(consolidationEntityTypes) || + !consolidationEntityTypes.contains(target); + + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java index 4e1a60fff8..d401e4930b 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java @@ -1164,46 +1164,7 @@ public class HeatToToscaUtil { ConsolidationEntityType sourceEntityType = dependencyEntity.getSourceEntityType(); ConsolidationEntityType targetEntityType = dependencyEntity.getTargetEntityType(); - //Ignore Compute->Port, Compute->volume, Compute->Compute and Compute->VFC Nested relationships - if (sourceEntityType == ConsolidationEntityType.COMPUTE) { - if (targetEntityType == ConsolidationEntityType.COMPUTE - || targetEntityType == ConsolidationEntityType.VOLUME - || targetEntityType == ConsolidationEntityType.PORT - || targetEntityType == ConsolidationEntityType.VFC_NESTED) { - return false; - } - } - //Ignore Port->Compute, Port->volume, Port->Port and Port->VFC Nested relationships - if (sourceEntityType == ConsolidationEntityType.PORT) { - if (targetEntityType == ConsolidationEntityType.COMPUTE - || targetEntityType == ConsolidationEntityType.VOLUME - || targetEntityType == ConsolidationEntityType.PORT - || targetEntityType == ConsolidationEntityType.VFC_NESTED) { - return false; - } - } - - //Ignore Volume->Compute, Volume->Volume, Volume->Port and Volume->VFC Nested relationships - if (sourceEntityType == ConsolidationEntityType.VOLUME) { - if (targetEntityType == ConsolidationEntityType.COMPUTE - || targetEntityType == ConsolidationEntityType.VOLUME - || targetEntityType == ConsolidationEntityType.PORT - || targetEntityType == ConsolidationEntityType.VFC_NESTED) { - return false; - } - } - - //Ignore VFC Nested->Compute, VFC Nested->Volume, VFC Nested->Port and - // VFC Nested->VFC Nested relationships - if (sourceEntityType == ConsolidationEntityType.VFC_NESTED) { - if (targetEntityType == ConsolidationEntityType.COMPUTE - || targetEntityType == ConsolidationEntityType.VOLUME - || targetEntityType == ConsolidationEntityType.PORT - || targetEntityType == ConsolidationEntityType.VFC_NESTED) { - return false; - } - } - return true; + return ConsolidationTypesConnectivity.isDependsOnRelationshipValid(sourceEntityType, targetEntityType); } private static Map managerSubstitutionNodeTemplateProperties( -- cgit 1.2.3-korg