Create definitions for multiple vf-modules 12/97412/1
authorLukasz Rajewski <lukasz.rajewski@orange.com>
Tue, 22 Oct 2019 08:20:27 +0000 (10:20 +0200)
committerLukasz Rajewski <lukasz.rajewski@orange.com>
Tue, 22 Oct 2019 08:32:34 +0000 (10:32 +0200)
This fix does not change distribution when there is one
dummy heat and one cloud technology artifact.

When there is more than one dummy heat or more than one
cloud technology artifact forwarder will try to match them
base on the name of the heat file that should match the prefix
of the name of cloud artifact. There is no need to change use
cases of vFW and EdgeX showcased for Dublin and ElAlto neither
their descriptions should be changed.

Issue-ID: MULTICLOUD-869
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I4d44ea22b412546806ee7dbcdb7e3c9ed644349a

artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java

index e5cf487..894f0c1 100644 (file)
@@ -138,24 +138,50 @@ public class K8sArtifactForwarder implements ArtifactForwarder {
         List<String> artifacts = vfModule.getArtifacts();
         System.out.println("artifacts = " + artifacts);
 
-        String cloudUuid = null;
+        String vfNamePrefix = vfModule.getVfModuleModelName().toLowerCase();
+        if ( vfNamePrefix.indexOf("..") > 0 ) {
+            vfNamePrefix = vfNamePrefix.substring(vfNamePrefix.indexOf("..") + 2);
+            if ( vfNamePrefix.indexOf("..") > 0 )
+                vfNamePrefix = vfNamePrefix.substring(0, vfNamePrefix.indexOf("..")) + "_";
+            else
+                vfNamePrefix = "";
+        } else
+            vfNamePrefix = "";
+
         IArtifactInfo cloudArtifact = null;
+        IArtifactInfo firstCloudArtifact = null;
+        int cloudArtifactCount = 0;
         boolean found = false;
 
         for (String artifact: artifacts) {
             if ( artifactMap.get(artifact) != null
                 && artifactMap.get(artifact).getArtifactType().equals("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT")) {
-                cloudArtifact = artifactMap.get(artifact);
-                cloudUuid = cloudArtifact.getArtifactUUID();
-                found = true;
-                break;
+                if ( cloudArtifactCount == 0 )
+                    firstCloudArtifact = artifactMap.get(artifact);
+                cloudArtifactCount++;
+                IArtifactInfo tmpArtifact = artifactMap.get(artifact);
+                if ( tmpArtifact.getArtifactName().toLowerCase().startsWith(vfNamePrefix) ) {
+                    cloudArtifact = tmpArtifact;
+                    found = true;
+                    break;
+                }
             }
         }
 
-        if ( found == false ) {
-            System.out.println(" meets error , no CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT type found ");
-            return false;
+        if ( found == false  ) {
+            if ( firstCloudArtifact == null ) {
+                System.out.println(" meets error , no CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT type found ");
+                return false;
+            } else {
+                if ( cloudArtifactCount == 1 || vfNamePrefix == "" ) {
+                    cloudArtifact = firstCloudArtifact;
+                } else {
+                    System.out.println(" meets error , CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT artifacts mismatch ");
+                    return false;
+                }
+            }
         }
+
         String cloudArtifactPath = "/data/" + vfModule.getVfModuleModelCustomizationUUID()
             + "/" + cloudArtifact.getArtifactName();
         File file = new File(cloudArtifactPath);