From 73cb1f8af7a98daa02d72fbdd6bca45056906245 Mon Sep 17 00:00:00 2001 From: "Merkel, Jeff" Date: Thu, 6 Jun 2019 15:50:15 -0400 Subject: Check if configuration resource already exists. Check if configuration resource already exists. Change-Id: I359aaa96ef66b37880cf369c3f5bd7bfd828aab1 Issue-ID: SO-1978 Signed-off-by: Benjamin, Max (mb388a) --- .../installer/heat/ToscaResourceInstaller.java | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'asdc-controller/src') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index bd5f0d0dbc..9af1cb9935 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -740,8 +740,8 @@ public class ToscaResourceInstaller { toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll(); for (RequirementAssignment requirement : requirementsList) { if (requirement.getNodeTemplateName().equals(spNode.getName())) { - ConfigurationResourceCustomization configurationResource = - createConfiguration(configNode, toscaResourceStruct, serviceProxy, service); + ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, + toscaResourceStruct, serviceProxy, service, configurationResourceList); Optional matchingObject = configurationResourceList.stream() @@ -1400,24 +1400,23 @@ public class ToscaResourceInstaller { protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, - Service service) { + Service service, List configurationResourceList) { ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization( nodeTemplate, toscaResourceStructure, spResourceCustomization, service); - ConfigurationResource configResource = getConfigurationResource(nodeTemplate); - - Set configResourceCustomizationSet = new HashSet<>(); - - configCustomizationResource.setConfigurationResource(configResource); - - configResourceCustomizationSet.add(configCustomizationResource); + ConfigurationResource configResource = null; - configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); + ConfigurationResource existingConfigResource = findExistingConfiguration(service, + nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList); - toscaResourceStructure.setCatalogConfigurationResource(configResource); + if (existingConfigResource == null) { + configResource = getConfigurationResource(nodeTemplate); + } else { + configResource = existingConfigResource; + } - toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource); + configCustomizationResource.setConfigurationResource(configResource); return configCustomizationResource; } @@ -2159,6 +2158,19 @@ public class ToscaResourceInstaller { return configResource; } + protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID, + List configurationResourceList) { + ConfigurationResource configResource = null; + for (ConfigurationResourceCustomization configurationResourceCustom : configurationResourceList) { + if (configurationResourceCustom.getConfigurationResource() != null + && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { + configResource = configurationResourceCustom.getConfigurationResource(); + } + } + + return configResource; + } + protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, String vfModuleModelCustomizationUUID) { VfModuleCustomization vfModuleCustomization = null; -- cgit 1.2.3-korg