diff options
Diffstat (limited to 'asdc-controller/src/main/java/org')
4 files changed, 75 insertions, 63 deletions
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 7423a7a197..55a437f2c0 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 @@ -25,6 +25,7 @@ package org.onap.so.asdc.client; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.ArrayList; import java.util.List; import org.onap.sdc.api.IDistributionClient; @@ -44,6 +45,7 @@ import org.onap.so.asdc.client.exceptions.ASDCParametersException; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.IVfResourceInstaller; import org.onap.so.asdc.installer.ToscaResourceStructure; +import org.onap.so.asdc.installer.VfModuleStructure; import org.onap.so.asdc.installer.VfResourceStructure; import org.onap.so.asdc.installer.heat.ToscaResourceInstaller; import org.onap.so.asdc.tenantIsolation.DistributionStatus; @@ -671,7 +673,23 @@ public class ASDCController { try { - this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); + this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); + + // Install a service with no resources, only the service itself + if (iNotif.getResources() == null || iNotif.getResources().size() < 1) { + + LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID()); + + try{ + resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); + + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + + } catch(ArtifactInstallerException e){ + deploySuccessful = false; + errorMessage = e.getMessage(); + } + } else { // Services with resources for (IResourceInstance resource : iNotif.getResources()){ @@ -695,23 +713,21 @@ public class ASDCController { resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); } } - } - } - try{ - + } + //Deploy All resources and artifacts LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID()); - if(resourceStructure == null){ - resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); - } - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - - - } catch(ArtifactInstallerException e){ - deploySuccessful = false; - errorMessage = e.getMessage(); - } - + try{ + + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + + } catch(ArtifactInstallerException e){ + deploySuccessful = false; + errorMessage = e.getMessage(); + } + + } + } this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage); } catch (ASDCDownloadException | UnsupportedEncodingException e) { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index 565ddf42b5..8353f708a9 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -65,7 +65,6 @@ public class ToscaResourceStructure { String envHeatTemplateUUID; String heatFilesUUID; String workloadPerformance; - boolean isVnfAlreadyInstalled = false; String serviceVersion; private boolean isDeployedSuccessfully=false; @@ -314,14 +313,6 @@ public class ToscaResourceStructure { this.toscaCsar = toscaCsar; } - public boolean isVnfAlreadyInstalled() { - return isVnfAlreadyInstalled; - } - - public void setVnfAlreadyInstalled(boolean isVnfAlreadyInstalled) { - this.isVnfAlreadyInstalled = isVnfAlreadyInstalled; - } - public String getVolHeatTemplateUUID() { return volHeatTemplateUUID; } 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 ea952f6daf..7dfb1bae3e 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 @@ -33,6 +33,7 @@ import java.util.Set; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.api.notification.IStatusData; import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; import org.onap.sdc.tosca.parser.impl.SdcTypes; @@ -424,46 +425,35 @@ public class ToscaResourceInstaller { String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper() .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); - logger.debug("vfCustomizationUUID=" + vfCustomizationUUID); + logger.debug("vfCustomizationUUID=" + vfCustomizationUUID); - VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); + IResourceInstance vfMetaDataResource = vfResourceStructure.getResourceInstance(); - for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); - List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct - .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream(). - filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())). - findFirst(); - if(matchingObject.isPresent()){ - VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure,vfMetadata, vnfResource); - vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); - }else - throw (new Exception("Cannot find matching VFModule Customization")); + // Make sure the vfMetadata and tosca customizations match before comparing their VF Modules UUID's + if(vfCustomizationUUID.equals(vfMetaDataResource.getResourceCustomizationUUID())){ - } - service.getVnfCustomizations().add(vnfResource); - } - } - - protected void processFlexware(ToscaResourceStructure toscaResourceStruct, Service service, NodeTemplate nodeTemplate, - String serviceType) { - if (serviceType != null && serviceType.equalsIgnoreCase("Flexware")) { - - createVnfResource(nodeTemplate, toscaResourceStruct, service); - String modelName = toscaResourceStruct.getVnfResourceCustomization().getVnfResources().getModelName(); + logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfMetaData CustomizationUUID"); + + VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); - String modelVersion = BigDecimalVersion.castAndCheckNotificationVersionToString( - toscaResourceStruct.getCatalogVnfResourceCustomization().getVnfResources().getModelVersion()); - // check for duplicate record already in the database - VnfResource vnfResource = vnfRepo.findByModelNameAndModelVersion(modelName, modelVersion); - - if (vnfResource != null) { - toscaResourceStruct.setVnfAlreadyInstalled(true); - } - - vnfCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogVnfResourceCustomization()); + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { + logger.debug("vfModuleStructure ModelUUID: " + vfModuleStructure.toString()); + List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct + .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); + + Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream(). + filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())). + findFirst(); + if(matchingObject.isPresent()){ + VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure,vfMetadata, vnfResource); + vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); + }else + throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID()); + + } + service.getVnfCustomizations().add(vnfResource); + } } } @@ -1263,12 +1253,20 @@ public class ToscaResourceInstaller { // Set all Child Templates related to HEAT_VOLUME if(!volumeHeatChildTemplates.isEmpty()){ - vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates); + if(vfModule.getVolumeHeatTemplate() != null){ + vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates); + }else{ + logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()"); + } } // Set all Child Templates related to HEAT if(!heatChildTemplates.isEmpty()){ - vfModule.getVolumeHeatTemplate().setChildTemplates(heatChildTemplates); + if(vfModule.getModuleHeatTemplate() != null){ + vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates); + }else{ + logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()"); + } } } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index ef5b889d09..54977104ff 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -209,9 +209,16 @@ public class ASDCNotificationLogging { List<NodeTemplate> vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList(); for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) { + buffer.append(System.lineSeparator()); + buffer.append("VNF Properties:"); + buffer.append(System.lineSeparator()); + buffer.append("Model Name:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(System.lineSeparator()); buffer.append("Description:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); |