aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang.Ding <liang.ding@intel.com>2019-03-15 08:16:42 +0000
committerLiang Ding <liang.ding@intel.com>2019-04-08 09:22:25 -0700
commitef6ec63b05fb93adef0edb392b0a33de97203876 (patch)
tree0d5b69950f8fd5e8a023b557c07a862b581da539
parent06e8b70cb9cdbcc131a183f3a85a95b513d2b2f1 (diff)
show cloud specific artifacts IDs in vf module meta
Change-Id: I42c54b2b94513c1dd69c3ec662a05a71a89fd3d0 Issue-ID: SDC-2041 Signed-off-by: Liang.Ding <liang.ding@intel.com>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java15
2 files changed, 38 insertions, 1 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index d9a0c46fa9..1eb50e846a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -95,6 +95,7 @@ import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -118,6 +119,9 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class.getName());
private static final String VF_MODULE = "org.openecomp.groups.VfModule";
public static final String TRY_TO_CREATE_ENTRY_ON_GRAPH = "Try to create entry on graph";
+ private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech";
+ private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = {{"k8s", "azure", "aws"}, /* cloud specific technology */
+ {"charts", "day0", "configtemplate"} /*cloud specific sub type*/};
public static final String FAILED_TO_CREATE_ENTRY_ON_GRAPH_FOR_COMPONENT_INSTANCE = "Failed to create entry on graph for component instance {}";
public static final String ENTITY_ON_GRAPH_IS_CREATED = "Entity on graph is created.";
public static final String INVALID_COMPONENT_TYPE = "invalid component type";
@@ -489,6 +493,20 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return resultOp;
}
+ public boolean isCloudSpecificArtifact(String artifact) {
+ if (artifact.contains(CLOUD_SPECIFIC_FIXED_KEY_WORD)) {
+ for (int i = 0; i < CLOUD_SPECIFIC_KEY_WORDS.length; i++) {
+ if (Arrays.stream(CLOUD_SPECIFIC_KEY_WORDS[i]).noneMatch(str -> artifact.contains(str))) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
/**
* addResourceInstanceArtifacts - add artifacts (HEAT_ENV) to resource instance The instance artifacts are generated from the resource's artifacts
* @param containerComponent
@@ -520,7 +538,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (!type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType())) {
finalDeploymentArtifacts.put(artifact.getArtifactLabel(), artifact);
}
- if (!(type.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType()))) {
+ if (!(type.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT.getType()))) {
continue;
}
if (artifact.checkEsIdExist()) {
@@ -550,6 +568,10 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
groupInstancesArtifacts.put(groupInstance.getUniqueId(), artifactsUid);
break;
}
+
+ if (isCloudSpecificArtifact(artifactDefinition.getArtifactName())) {
+ groupInstance.getArtifacts().add(artifactDefinition.getGeneratedFromId());
+ }
}
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index b5d937e0e8..360f12579a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -62,6 +62,7 @@ import org.openecomp.sdc.exception.ResponseFormat;
import java.util.function.BiPredicate;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
@@ -90,6 +91,11 @@ public class ComponentInstanceBusinessLogicTest {
private final static String REQUIREMENT_UID = "requirementUid";
private final static String REQUIREMENT_NAME = "requirementName";
private final static String RELATIONSHIP_TYPE = "relationshipType";
+ private final static String ARTIFACT_1 = "cloudtech_k8s_charts.zip";
+ private final static String ARTIFACT_2 = "cloudtech_azure_day0.zip";
+ private final static String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
+ private final static String ARTIFACT_4 = "k8s_charts.zip";
+ private final static String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
@InjectMocks
private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
@@ -154,6 +160,15 @@ public class ComponentInstanceBusinessLogicTest {
getforwardingPathOnVersionChange();
}
+ @Test
+ public void testIsCloudSpecificArtifact() {
+ assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_1));
+ assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_2));
+ assertTrue(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_3));
+ assertFalse(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_4));
+ assertFalse(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_5));
+ }
+
private void getforwardingPathOnVersionChange(){
String containerComponentParam="services";
String containerComponentID="121-cont";