From df0f6dd7c22d3981e2f5945d18d71e28f66c01e9 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Tue, 22 Oct 2019 10:20:27 +0200 Subject: Create definitions for multiple vf-modules 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 Change-Id: I4d44ea22b412546806ee7dbcdb7e3c9ed644349a --- .../forwarding/k8s/K8sArtifactForwarder.java | 42 +++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'artifactbroker/plugins/forwarding-plugins') diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java index e5cf487..894f0c1 100644 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java +++ b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/k8s/K8sArtifactForwarder.java @@ -138,24 +138,50 @@ public class K8sArtifactForwarder implements ArtifactForwarder { List 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); -- cgit 1.2.3-korg