From 713b2b8be4dd1dd57f5ef9b0927ceb9bd3b009c4 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 2 Aug 2019 21:17:09 +0530 Subject: Fix parsing issue for ccvpn Fix csar parsing issue for ccvpn. Change-Id: Ie99acbec8a52de7a08d1627c210c0e3fda986520 Issue-ID: SO-1393 Signed-off-by: sarada prasad sahoo Signed-off-by: subhash kumar singh --- .../org/onap/so/asdc/client/ASDCController.java | 7 ++-- .../installer/heat/ToscaResourceInstaller.java | 44 +++++++++++++++------- 2 files changed, 34 insertions(+), 17 deletions(-) (limited to 'asdc-controller/src/main/java') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 073412133c..90116ad4f5 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -742,8 +742,7 @@ public class ASDCController { logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID()); - if ("VF".equals(resourceType) && resource.getArtifacts() != null - && !resource.getArtifacts().isEmpty()) { + if ("VF".equals(resourceType)) { resourceStructure = new VfResourceStructure(iNotif, resource); } else if ("PNF".equals(resourceType)) { resourceStructure = new PnfResourceStructure(iNotif, resource); @@ -761,8 +760,8 @@ public class ASDCController { logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID()); - if ("VF".equals(resourceType) && resource.getArtifacts() != null - && !resource.getArtifacts().isEmpty()) { + + if ("VF".equals(resourceType)) { hasVFResource = true; for (IArtifactInfo artifact : resource.getArtifacts()) { IDistributionClientDownloadResult resultArtifact = 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 83827b425e..08aee1ab4e 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 @@ -437,20 +437,17 @@ public class ToscaResourceInstaller { List vfEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - List arEntityDetails = new ArrayList(); - for (IEntityDetails vfEntityDetails : vfEntityList) { Metadata metadata = vfEntityDetails.getMetadata(); - String category = metadata.getValue("category"); + String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); - if ("Allotted Resource".equalsIgnoreCase(category)) { - arEntityDetails.add(vfEntityDetails); + if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) { + continue; } processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure, service, metadata); - } processResourceSequence(toscaResourceStruct, service); @@ -667,6 +664,8 @@ public class ToscaResourceInstaller { } else { NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct, null, null, null, service); + networkCustomization.setResourceInput( + getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID())); service.getNetworkCustomizations().add(networkCustomization); logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + networkResourceModelName); @@ -677,11 +676,14 @@ public class ToscaResourceInstaller { } protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service, - List allottedResourceList) { + List allottedResourceList) throws ArtifactInstallerException { if (allottedResourceList != null) { for (NodeTemplate allottedNode : allottedResourceList) { - service.getAllottedCustomizations() - .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); + AllottedResourceCustomization allottedResource = + createAllottedResource(allottedNode, toscaResourceStruct, service); + allottedResource.setResourceInput( + getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID())); + service.getAllottedCustomizations().add(allottedResource); } } } @@ -1370,7 +1372,14 @@ public class ToscaResourceInstaller { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); - Service service = new Service(); + List services = + serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + Service service; + if (!services.isEmpty() && services.size() > 0) { + service = services.get(0); + } else { + service = new Service(); + } if (serviceMetadata != null) { @@ -1482,7 +1491,14 @@ public class ToscaResourceInstaller { } protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { - ToscaCsar toscaCsar = new ToscaCsar(); + Optional toscaCsarOpt = + toscaCsarRepo.findById(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + ToscaCsar toscaCsar; + if (toscaCsarOpt.isPresent()) { + toscaCsar = toscaCsarOpt.get(); + } else { + toscaCsar = new ToscaCsar(); + } if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) { toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); } else { @@ -2789,8 +2805,10 @@ public class ToscaResourceInstaller { if (!services.isEmpty()) { // service exist in db Service existingService = services.get(0); - List vnfCustomizations = existingService.getVnfCustomizations(); - vnfCustomizations.forEach(e -> service.getVnfCustomizations().add(e)); + List existingVnfCustomizations = existingService.getVnfCustomizations(); + if (existingService != null) { + service.getVnfCustomizations().addAll(existingVnfCustomizations); + } } service.getVnfCustomizations().add(vnfResourceCustomization); } -- cgit 1.2.3-korg