From 7b815eca4fb6a92d3b36418029d3191e768431f1 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 26 Apr 2018 14:45:49 +0200 Subject: Fix sdc controller Support multiple closed loop deployment in the same service and add test for mutliple closed loops Issue-ID: CLAMP-151 Change-Id: Ied352ecb10fee4b807fa4bbfebc5934fd62cba3e Signed-off-by: Determe, Sebastien (sd378r) --- .../sdc/controller/installer/CsarInstallerImpl.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/onap') 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 e28e8ab70..17312442b 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 @@ -99,12 +99,19 @@ public class CsarInstallerImpl implements CsarInstaller { @Override public boolean isCsarAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException { - return (CldsModel.retrieve(cldsDao, buildModelName(csar), true).getId() != null) ? true : false; + boolean alreadyInstalled = true; + for (Entry blueprint : csar.getMapOfBlueprints().entrySet()) { + alreadyInstalled = alreadyInstalled + && (CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getKey()), true).getId() != null) + ? true + : false; + } + return alreadyInstalled; } - public static String buildModelName(CsarHandler csar) { + public static String buildModelName(CsarHandler csar, String resourceInstanceName) { return MODEL_NAME_PREFIX + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v" - + csar.getSdcNotification().getServiceVersion().replace('.', '_'); + + csar.getSdcNotification().getServiceVersion().replace('.', '_') + "_" + resourceInstanceName; } @Override @@ -196,7 +203,8 @@ 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)); + template.setName(TEMPLATE_NAME_PREFIX + + buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName())); template.save(cldsDao, null); logger.info("Fake Clds Template created for blueprint " + blueprintArtifact.getBlueprintArtifactName() + " with name " + template.getName()); @@ -207,7 +215,7 @@ public class CsarInstallerImpl implements CsarInstaller { CldsTemplate cldsTemplate, String serviceTypeId) throws SdcArtifactInstallerException { try { CldsModel cldsModel = new CldsModel(); - cldsModel.setName(buildModelName(csar)); + cldsModel.setName(buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName())); cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint()); cldsModel.setTemplateName(cldsTemplate.getName()); cldsModel.setTemplateId(cldsTemplate.getId()); -- cgit 1.2.3-korg