aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-02-12 21:34:58 +0100
committersebdet <sebastien.determe@intl.att.com>2019-02-13 10:27:01 +0100
commit6914f938afd9cec84d6bb2b044cef74f4e997ab1 (patch)
tree6fb0bfd6e1beb0994dae4512d07133b944db672c /src/main/java/org
parent95511cbe373d5cf138689b091a1ef26c199868f8 (diff)
support multiple CL
Support multiple CL CSAR deployment per service/vnf Issue-ID: CLAMP-289 Change-Id: I6e52da07b393bffeff18e16a5afa78ef14162935 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java3
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java32
2 files changed, 17 insertions, 18 deletions
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
index 1b7cb28c2..1a99919ee 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -138,8 +138,7 @@ public class CsarHandler {
blueprintArtifact.setResourceAttached(searchForResourceByInstanceName(entry.getName().substring(
entry.getName().indexOf(RESOURCE_INSTANCE_NAME_PREFIX) + RESOURCE_INSTANCE_NAME_PREFIX.length(),
entry.getName().indexOf(RESOURCE_INSTANCE_NAME_SUFFIX))));
- this.mapOfBlueprints.put(blueprintArtifact.getResourceAttached().getResourceInstanceName(),
- blueprintArtifact);
+ this.mapOfBlueprints.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact);
logger.info("Found a blueprint entry in the CSAR " + blueprintArtifact.getBlueprintArtifactName()
+ " for resource instance Name "
+ blueprintArtifact.getResourceAttached().getResourceInstanceName());
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index 50090920e..bfda6924d 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -25,8 +25,8 @@ package org.onap.clamp.clds.sdc.controller.installer;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import com.google.gson.JsonObject;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -59,8 +59,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.Yaml;
/**
- * This class will be instantiated by spring config, and used by Sdc Controller. There is no state kept by the bean.
- * It's used to deploy the csar/notification received from SDC in DB.
+ * This class will be instantiated by spring config, and used by Sdc Controller.
+ * There is no state kept by the bean. It's used to deploy the csar/notification
+ * received from SDC in DB.
*/
public class CsarInstallerImpl implements CsarInstaller {
@@ -101,15 +102,14 @@ public class CsarInstallerImpl implements CsarInstaller {
boolean alreadyInstalled = true;
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
alreadyInstalled = alreadyInstalled
- && (CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getKey()), true).getId() != null) ? true
- : false;
+ && CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getValue()), true).getId() != null;
}
return alreadyInstalled;
}
- public static String buildModelName(CsarHandler csar, String resourceInstanceName)
+ public static String buildModelName(CsarHandler csar, BlueprintArtifact artifact)
throws SdcArtifactInstallerException {
- String policyScopePrefix = searchForPolicyScopePrefix(csar.getMapOfBlueprints().get(resourceInstanceName));
+ String policyScopePrefix = searchForPolicyScopePrefix(artifact);
if (policyScopePrefix.contains("*")) {
// This is policy_filter type
policyScopePrefix = policyScopePrefix.replaceAll("\\*", "");
@@ -117,9 +117,10 @@ public class CsarInstallerImpl implements CsarInstaller {
// This is normally the get_input case
policyScopePrefix = MODEL_NAME_PREFIX;
}
- return policyScopePrefix + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v"
- + csar.getSdcNotification().getServiceVersion().replace('.', '_') + "_"
- + resourceInstanceName.replaceAll(" ", "");
+ return (policyScopePrefix + "_" + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v"
+ + csar.getSdcNotification().getServiceVersion() + "_"
+ + artifact.getResourceAttached().getResourceInstanceName().replaceAll(" ", "") + "_"
+ + artifact.getBlueprintArtifactName().replace(".yaml", "")).replace('.', '_');
}
@Override
@@ -214,8 +215,8 @@ public class CsarInstallerImpl implements CsarInstaller {
}
/**
- * This call must be done when deploying the SDC notification as this call get the latest version of the artifact
- * (version can be specified to DCAE call)
+ * This call must be done when deploying the SDC notification as this call get
+ * the latest version of the artifact (version can be specified to DCAE call)
*
* @return The DcaeInventoryResponse object containing the dcae values
*/
@@ -236,8 +237,7 @@ public class CsarInstallerImpl implements CsarInstaller {
"{\"global\":[{\"name\":\"service\",\"value\":[\"" + blueprintArtifact.getDcaeBlueprint() + "\"]}]}");
template
.setImageText(IOUtils.toString(appContext.getResource(configFiles.getSvgXmlFilePath()).getInputStream()));
- template.setName(TEMPLATE_NAME_PREFIX
- + buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName()));
+ template.setName(TEMPLATE_NAME_PREFIX + buildModelName(csar, blueprintArtifact));
template.save(cldsDao, null);
logger.info("Fake Clds Template created for blueprint " + blueprintArtifact.getBlueprintArtifactName()
+ " with name " + template.getName());
@@ -246,14 +246,14 @@ public class CsarInstallerImpl implements CsarInstaller {
private CldsModel createFakeCldsModel(CsarHandler csar, BlueprintArtifact blueprintArtifact,
CldsTemplate cldsTemplate, DcaeInventoryResponse dcaeInventoryResponse) throws SdcArtifactInstallerException {
-
+
if (dcaeInventoryResponse == null) {
throw new SdcArtifactInstallerException(
"DCAE inventory response is NULL, query to DCAE fail to be answered properly, this is required to deploy CSAR properly !!!");
}
try {
CldsModel cldsModel = new CldsModel();
- cldsModel.setName(buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName()));
+ cldsModel.setName(buildModelName(csar, blueprintArtifact));
cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint());
cldsModel.setTemplateName(cldsTemplate.getName());
cldsModel.setTemplateId(cldsTemplate.getId());