summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Gaffa <avi.gaffa@amdocs.com>2017-11-05 06:58:56 +0000
committerGerrit Code Review <gerrit@onap.org>2017-11-05 06:58:56 +0000
commit972ffba3024f8d4c7aed20e38086fc83f4d756fb (patch)
tree8bf0c9ac9a16217677e672d7e68656bae88eceb7
parent120584659bfa2e96af3b5dd445b5c60b64b96b1b (diff)
parentc01e02538c7e2ccfcbc9f9b22e33875176c0dbf5 (diff)
Merge "dynamic ports"
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationTypesConnectivity.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java41
2 files changed, 65 insertions, 40 deletions
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<ConsolidationEntityType, Set<ConsolidationEntityType>>
+ 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<ConsolidationEntityType> getIgnoredComputeRelationships(){
+ return Stream.of(ConsolidationEntityType.COMPUTE,
+ ConsolidationEntityType.VOLUME,
+ ConsolidationEntityType.PORT,
+ ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet());
+ }
+
+ private static Set<ConsolidationEntityType> getIgnoredPortRelationships(){
+ return Stream.of(ConsolidationEntityType.COMPUTE,
+ ConsolidationEntityType.VOLUME,
+ ConsolidationEntityType.PORT,
+ ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet());
+ }
+
+ private static Set<ConsolidationEntityType> getIgnoredVolumeRelationships(){
+ return Stream.of(ConsolidationEntityType.COMPUTE,
+ ConsolidationEntityType.VOLUME,
+ ConsolidationEntityType.PORT,
+ ConsolidationEntityType.VFC_NESTED).collect(Collectors.toSet());
+ }
+
+ private static Set<ConsolidationEntityType> 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<ConsolidationEntityType> 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<String, Object> managerSubstitutionNodeTemplateProperties(