From cf90f6988c717eb609f5da7d1aee04c668b21fe9 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 10 Aug 2018 17:19:31 -0400 Subject: Casablana bugfixes updated mock in unassignnetworkbbtest instead of base added mock to extract pojos method in unassignnetwork Return gBuildingBlockExecution from calls to VnfAdapter subprocess Correct JUnit data to expect modelInfoVfModule Enable Spring Security for logging of unauthorized/bad credentials errors Fix handling of a case of no VF Modules in a VNF resource. fix populating lookupKeyMap with resource ids removed unnecessary test resources Issue-ID: SO-848 Change-Id: Id89f075dcac4042bf8fb1e207e66d289d079171f Signed-off-by: Benjamin, Max (mb388a) --- .../org/onap/so/asdc/client/ASDCController.java | 48 ++++++++++++++-------- .../installer/heat/ToscaResourceInstaller.java | 44 ++++++++++++-------- .../onap/so/asdc/util/ASDCNotificationLogging.java | 4 ++ 3 files changed, 63 insertions(+), 33 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 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/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 87df2648d1..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,26 +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 vfGroups = toscaResourceStruct - .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - Optional 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()); + // Make sure the vfMetadata and tosca customizations match before comparing their VF Modules UUID's + if(vfCustomizationUUID.equals(vfMetaDataResource.getResourceCustomizationUUID())){ - } - service.getVnfCustomizations().add(vnfResource); + logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfMetaData CustomizationUUID"); + + VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); + + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { + logger.debug("vfModuleStructure ModelUUID: " + vfModuleStructure.toString()); + List vfGroups = toscaResourceStruct + .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); + + Optional 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); + } } } 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 13af95a8fc..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,6 +209,10 @@ public class ASDCNotificationLogging { List 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()); -- cgit 1.2.3-korg