diff options
15 files changed, 516 insertions, 253 deletions
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 bcb81ba87c..83827b425e 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 @@ -434,12 +434,23 @@ public class ToscaResourceInstaller { Service service = toscaResourceStruct.getCatalogService(); List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList(); - for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { - Metadata metadata = nodeTemplate.getMetaData(); - String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper() - .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY); - processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata, - vfCustomizationCategory); + List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct, + EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); + + List<IEntityDetails> arEntityDetails = new ArrayList<IEntityDetails>(); + + for (IEntityDetails vfEntityDetails : vfEntityList) { + + Metadata metadata = vfEntityDetails.getMetadata(); + String category = metadata.getValue("category"); + + if ("Allotted Resource".equalsIgnoreCase(category)) { + arEntityDetails.add(vfEntityDetails); + } + + processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure, + service, metadata); + } processResourceSequence(toscaResourceStruct, service); @@ -631,7 +642,8 @@ public class ToscaResourceInstaller { protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException { - List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, SdcTypes.VL, SdcTypes.SERVICE, false); + List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VL), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); if (vlEntityList != null) { for (IEntityDetails vlEntity : vlEntityList) { @@ -954,17 +966,21 @@ public class ToscaResourceInstaller { return String.valueOf(value); } - protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, - Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) - throws Exception { + protected void processVfModules(IEntityDetails vfEntityDetails, NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service, + Metadata metadata) throws Exception { + + String vfCustomizationCategory = + vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); logger.debug("VF Category is : " + vfCustomizationCategory); if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) { - String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata, - SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + String vfCustomizationUUID = + vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); @@ -980,7 +996,7 @@ public class ToscaResourceInstaller { logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID"); - VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); + VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service); Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>(); Set<VnfcCustomization> existingVnfcSet = new HashSet<>(); @@ -989,14 +1005,19 @@ public class ToscaResourceInstaller { for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); - List<org.onap.sdc.toscaparser.api.Group> vfGroups = - toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); + + List<IEntityDetails> vfModuleEntityList = + getEntityDetails(toscaResourceStruct, + EntityQuery.newBuilder("org.openecomp.groups.VfModule"), TopologyTemplateQuery + .newBuilder(SdcTypes.SERVICE).customizationUUID(vfCustomizationUUID), + false); + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); - Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream() + Optional<IEntityDetails> matchingObject = vfModuleEntityList.stream() .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID") @@ -1004,7 +1025,7 @@ public class ToscaResourceInstaller { .findFirst(); if (matchingObject.isPresent()) { VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), - nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, + toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom); vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); } else @@ -1017,7 +1038,7 @@ public class ToscaResourceInstaller { // Check for VNFC Instance Group info and add it if there is List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, - "org.openecomp.groups.VfcInstanceGroup", + EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false); @@ -1891,9 +1912,10 @@ public class ToscaResourceInstaller { } - List<IEntityDetails> serviceEntityList = - getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VF).customizationUUID( - vnfResourceCustomization.getModelCustomizationUUID()), SdcTypes.SERVICE, false); + List<IEntityDetails> serviceEntityList = getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VF) + .customizationUUID(vnfResourceCustomization.getModelCustomizationUUID()), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); if (serviceEntityList != null && !serviceEntityList.isEmpty()) { vfcInstanceGroupCustom.setFunction(getLeafPropertyValue(serviceEntityList.get(0), getInputName)); @@ -1966,22 +1988,26 @@ public class ToscaResourceInstaller { return jsonStr; } - protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate, + protected VfModuleCustomization createVFModuleResource(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, - IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Set<CvnfcCustomization> existingCvnfcSet, - Set<VnfcCustomization> existingVnfcSet, + IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, + Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet, List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) { VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID()); + if (vfModuleCustomization == null) { + VfModule vfModule = findExistingVfModule(vnfResource, - vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); - Metadata vfMetadata = group.getMetadata(); + vfModuleEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + + Metadata vfMetadata = vfModuleEntityDetails.getMetadata(); if (vfModule == null) - vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata); + vfModule = createVfModule(vfModuleEntityDetails, toscaResourceStructure, vfModuleData, vfMetadata); - vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData); + vfModuleCustomization = + createVfModuleCustomization(vfModuleEntityDetails, toscaResourceStructure, vfModule, vfModuleData); vfModuleCustomization.setVnfCustomization(vnfResource); setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, vfMetadata); @@ -2001,38 +2027,48 @@ public class ToscaResourceInstaller { Set<VnfcCustomization> vnfcCustomizations = new HashSet<>(); // Only set the CVNFC if this vfModule group is a member of it. - List<NodeTemplate> groupMembers = - toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group); - String vfModuleMemberName = null; - for (NodeTemplate node : groupMembers) { - vfModuleMemberName = node.getName(); - } + List<IEntityDetails> groupMembers = getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder("org.openecomp.groups.VfModule") + .uUID(vfModuleCustomization.getVfModule().getModelUUID()), + TopologyTemplateQuery.newBuilder(SdcTypes.VF), false); + + String vfModuleMemberName = null; // Extract CVFC lists - List<IEntityDetails> cvnfcEntityList = - getEntityDetails(toscaResourceStructure, SdcTypes.CVFC, SdcTypes.VF, false); + List<IEntityDetails> cvnfcEntityList = getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false); + for (IEntityDetails cvfcEntity : cvnfcEntityList) { boolean cvnfcVfModuleNameMatch = false; - for (NodeTemplate node : groupMembers) { - vfModuleMemberName = node.getName(); + for (IEntityDetails entity : groupMembers) { + + List<IEntityDetails> groupMembersNodes = entity.getMemberNodes(); + for (IEntityDetails groupMember : groupMembersNodes) { + + vfModuleMemberName = groupMember.getName(); + + if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) { + cvnfcVfModuleNameMatch = true; + break; + } - if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) { - cvnfcVfModuleNameMatch = true; - break; } } + if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) { // Extract associated VFC - Should always be just one - List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, SdcTypes.VFC, + List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VFC), TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID( cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false); + for (IEntityDetails vfcEntity : vfcEntityList) { VnfcCustomization vnfcCustomization = new VnfcCustomization(); @@ -2107,7 +2143,9 @@ public class ToscaResourceInstaller { // ***************************************************************************************************************************************** List<IEntityDetails> fabricEntityList = - getEntityDetails(toscaResourceStructure, SdcTypes.CONFIGURATION, SdcTypes.VF, false); + getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), + TopologyTemplateQuery.newBuilder(SdcTypes.VF), false); + for (IEntityDetails fabricEntity : fabricEntityList) { @@ -2128,7 +2166,7 @@ public class ToscaResourceInstaller { CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, - vfTemplate, vfModuleMemberName); + vfModuleMemberName); cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization); @@ -2153,7 +2191,7 @@ public class ToscaResourceInstaller { protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(IEntityDetails fabricEntity, ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization, - ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) { + ConfigurationResource configResource, String vfModuleMemberName) { Metadata fabricMetadata = fabricEntity.getMetadata(); @@ -2168,7 +2206,9 @@ public class ToscaResourceInstaller { cvnfcConfigurationCustomization.setModelInstanceName(fabricEntity.getName()); List<IEntityDetails> policyList = - getEntityDetails(toscaResourceStruct, "org.openecomp.policies.External", SdcTypes.VF, true); + getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.policies.External"), + TopologyTemplateQuery.newBuilder(SdcTypes.VF), true); + if (policyList != null) { for (IEntityDetails policyEntity : policyList) { @@ -2245,7 +2285,7 @@ public class ToscaResourceInstaller { return vfModule; } - protected VfModuleCustomization createVfModuleCustomization(Group group, + protected VfModuleCustomization createVfModuleCustomization(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) { VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); @@ -2253,62 +2293,64 @@ public class ToscaResourceInstaller { vfModuleCustomization.setVfModule(vfModule); - String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); + String initialCount = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); + + if (initialCount != null && initialCount.length() > 0) { vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount)); } - vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper() - .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT))); + String availabilityZoneCount = + getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT); - String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT); if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) { vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount)); } - vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL)); + vfModuleCustomization + .setLabel(getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL)); + + String maxInstances = + getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES); - String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES); if (maxInstances != null && maxInstances.length() > 0) { vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances)); } - String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES); + String minInstances = + getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES); + if (minInstances != null && minInstances.length() > 0) { vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); } return vfModuleCustomization; } - protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure, + protected VfModule createVfModule(IEntityDetails groupEntityDetails, ToscaResourceStructure toscaResourceStructure, IVfModuleData vfModuleData, Metadata vfMetadata) { VfModule vfModule = new VfModule(); String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID(); if (vfModuleModelUUID == null) { - vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + + vfModuleModelUUID = testNull( + groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + } else if (vfModuleModelUUID.indexOf('.') > -1) { vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.')); } - vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper() - .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); - vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); + vfModule.setModelInvariantUUID( + groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)); + vfModule.setModelName( + groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)); vfModule.setModelUUID(vfModuleModelUUID); - vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); - vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + vfModule.setModelVersion( + groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)); + vfModule.setDescription(groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + + String vfModuleType = getLeafPropertyValue(groupEntityDetails, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE); - String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE); if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) { vfModule.setIsBase(true); } else { @@ -2413,19 +2455,20 @@ public class ToscaResourceInstaller { } } - protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate, + protected VnfResourceCustomization createVnfResource(IEntityDetails entityDetails, ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException { VnfResourceCustomization vnfResourceCustomization = null; if (vnfResourceCustomization == null) { + VnfResource vnfResource = findExistingVnfResource(service, - vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); if (vnfResource == null) { - vnfResource = createVnfResource(vfNodeTemplate); + vnfResource = createVnfResource(entityDetails); } vnfResourceCustomization = - createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource); + createVnfResourceCustomization(entityDetails, toscaResourceStructure, vnfResource); vnfResourceCustomization.setVnfResources(vnfResource); vnfResourceCustomization.setService(service); @@ -2452,61 +2495,56 @@ public class ToscaResourceInstaller { return vnfResource; } - protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate, + protected VnfResourceCustomization createVnfResourceCustomization(IEntityDetails entityDetails, ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) { VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); vnfResourceCustomization.setModelCustomizationUUID( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName()); - - vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); - vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code"))); - vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE))); - vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE))); + entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN)); + vnfResourceCustomization.setModelInstanceName(entityDetails.getName()); + vnfResourceCustomization + .setNfFunction(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + vnfResourceCustomization.setNfNamingCode(getLeafPropertyValue(entityDetails, "nf_naming_code")); + vnfResourceCustomization.setNfRole(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE)); + vnfResourceCustomization.setNfType(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); - vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME))); + vnfResourceCustomization.setMultiStageDesign(getLeafPropertyValue(entityDetails, MULTI_STAGE_DESIGN)); + vnfResourceCustomization.setBlueprintName(getLeafPropertyValue(entityDetails, SDNC_MODEL_NAME)); + vnfResourceCustomization.setBlueprintVersion(getLeafPropertyValue(entityDetails, SDNC_MODEL_VERSION)); - vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION))); + String skipPostInstConfText = getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF); - String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF); if (skipPostInstConfText != null) { - vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText)); + vnfResourceCustomization.setSkipPostInstConf( + Boolean.parseBoolean(getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF))); } + vnfResourceCustomization.setVnfResources(vnfResource); vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger( - vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); + entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); + + entityDetails.getCapabilities().get(SCALABLE); + - CapabilityAssignments vnfCustomizationCapability = - toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(vfNodeTemplate); + if (entityDetails.getCapabilities() != null) { - if (vnfCustomizationCapability != null) { - CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE); + CapabilityAssignment capAssign = entityDetails.getCapabilities().get(SCALABLE); if (capAssign != null) { - vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + vnfResourceCustomization.setMinInstances(Integer + .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResourceCustomization.setMaxInstances(Integer + .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); } } if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) { - vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + vnfResourceCustomization.setMinInstances(Integer + .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResourceCustomization.setMaxInstances(Integer + .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); } toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization); @@ -2514,25 +2552,25 @@ public class ToscaResourceInstaller { return vnfResourceCustomization; } - protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) { + protected VnfResource createVnfResource(IEntityDetails entityDetails) { VnfResource vnfResource = new VnfResource(); vnfResource.setModelInvariantUUID( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); - vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + vnfResource.setModelName(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + vnfResource.setModelUUID(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); vnfResource.setModelVersion( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); vnfResource.setDescription( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); vnfResource.setOrchestrationMode(HEAT); - vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType())); + vnfResource.setToscaNodeType(testNull(entityDetails.getToscaType())); vnfResource.setAicVersionMax( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); vnfResource.setAicVersionMin( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); - vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); + testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResource.setCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + vnfResource.setSubCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); return vnfResource; } @@ -2707,59 +2745,11 @@ public class ToscaResourceInstaller { + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); } - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, SdcTypes entityType, - SdcTypes topologyTemplate, boolean nestedSearch) { - - EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build(); - List<IEntityDetails> entityDetails = - toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch); - - return entityDetails; - - } - - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, String entityType, - SdcTypes topologyTemplate, boolean nestedSearch) { - - EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build(); - List<IEntityDetails> entityDetails = - toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch); - - return entityDetails; - - } - - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, String entityType, - TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) { - - EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build(); - TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build(); - List<IEntityDetails> entityDetails = - toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch); - - return entityDetails; - - } - - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, SdcTypes entityType, - TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) { - - EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build(); - TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build(); - List<IEntityDetails> entityDetails = - toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch); - - return entityDetails; - - } - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, - EntityQueryBuilder entityType, SdcTypes topologyTemplate, boolean nestedSearch) { + EntityQueryBuilder entityType, TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) { EntityQuery entityQuery = entityType.build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build(); + TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build(); List<IEntityDetails> entityDetails = toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 100887dbbc..729f5c95c4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -244,9 +244,9 @@ public class ExceptionBuilder { public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { logger.debug("Processing Audit Results"); String auditListString = (String) execution.getVariable("auditInventoryResult"); + String processKey = getProcessKey(execution.getDelegateExecution()); if (auditListString != null) { StringBuilder errorMessage = new StringBuilder(); - String processKey = getProcessKey(execution.getDelegateExecution()); try { ExtractPojosForBB extractPojosForBB = getExtractPojosForBB(); VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); @@ -302,7 +302,13 @@ public class ExceptionBuilder { } } else { - logger.debug("Unable to process audit results due to auditInventoryResult being null"); + String errorMessage = "Unable to process audit results due to auditInventoryResult being null"; + WorkflowException exception = new WorkflowException(processKey, 400, errorMessage, TargetEntity.SO); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("AAIInventoryFailure"); } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index de44caa120..525307a5df 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -1,22 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.bpmn.common.scripts @@ -32,6 +32,7 @@ import org.junit.runner.RunWith import org.mockito.junit.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient @@ -47,54 +48,56 @@ abstract class MsoGroovyTest { @Rule public ExpectedException thrown = ExpectedException.none() - protected ExecutionEntity mockExecution - protected AAIResourcesClient client + protected ExecutionEntity mockExecution + protected AAIResourcesClient client protected AllottedResourceUtils allottedResourceUtils_MOCK - protected final String SEARCH_RESULT_AAI_WITH_RESULTDATA = - FileUtil.readResourceFile("__files/aai/searchResults.json") - protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString(); - - protected void init(String procName){ - mockExecution = setupMock(procName) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - client = mock(AAIResourcesClient.class) - } - - protected ExecutionEntity setupMock(String procName) { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn(procName) - - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName) - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - - return mockExecution - } - - protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) { - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - - ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class) - RepositoryService repositoryService = mock(RepositoryService.class) - ProcessDefinition processDefinition = mock(ProcessDefinition.class) - - when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices) - when(processEngineServices.getRepositoryService()).thenReturn(repositoryService) - when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition) - when(processDefinition.getKey()).thenReturn(procName) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - return mockExecution - } - + protected final String SEARCH_RESULT_AAI_WITH_RESULTDATA = + FileUtil.readResourceFile("__files/aai/searchResults.json") + protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString(); + + protected void init(String procName){ + mockExecution = setupMock(procName) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + client = mock(AAIResourcesClient.class) + } + + protected ExecutionEntity setupMock(String procName) { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(procName) + + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + + HttpClient httpClient = mock(HttpClient.class) + + return mockExecution + } + + protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + + ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class) + RepositoryService repositoryService = mock(RepositoryService.class) + ProcessDefinition processDefinition = mock(ProcessDefinition.class) + + when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices) + when(processEngineServices.getRepositoryService()).thenReturn(repositoryService) + when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition) + when(processDefinition.getKey()).thenReturn(procName) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + return mockExecution + } + protected <T> Optional<T> getAAIObjectFromJson(Class<T> clazz , String file){ String json = FileUtil.readResourceFile(file) AAIResultWrapper resultWrapper = new AAIResultWrapper(json) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index 18ba91263b..15f8c5e4ef 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -80,6 +80,16 @@ public class AAIDeleteTasks { @Autowired private AAIInstanceGroupResources aaiInstanceGroupResources; + /** + * BPMN access method to delete the VfModule from A&AI. + * + * It will extract the genericVnf & VfModule from the BBObject. + * + * Before deleting it set the aaiVfModuleRollback as false & then it will delete the VfModule. + * + * @param execution + * @throws Exception + */ public void deleteVfModule(BuildingBlockExecution execution) throws Exception { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); @@ -89,10 +99,21 @@ public class AAIDeleteTasks { aaiVfModuleResources.deleteVfModule(vfModule, genericVnf); execution.setVariable("aaiVfModuleRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteVfModule process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the Vnf from A&AI. + * + * It will extract the genericVnf from the BBObject. + * + * Before deleting it set the aaiVnfRollback as false & then it will delete the Vnf. + * + * @param execution + * @throws Exception + */ public void deleteVnf(BuildingBlockExecution execution) throws Exception { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); @@ -101,79 +122,154 @@ public class AAIDeleteTasks { aaiVnfResources.deleteVnf(genericVnf); execution.setVariable("aaiVnfRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteVnf process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the ServiceInstance from A&AI. + * + * It will extract the serviceInstance from the BBObject. + * + * @param execution + * @throws Exception + */ public void deleteServiceInstance(BuildingBlockExecution execution) throws Exception { try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); aaiSIResources.deleteServiceInstance(serviceInstance); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteServiceInstance process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the l3network from A&AI. + * + * It will extract the l3network from the BBObject. + * + * After deleting the l3network it set the isRollbackNeeded as true. + * + * @param execution + * @throws Exception + */ public void deleteNetwork(BuildingBlockExecution execution) throws Exception { try { L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); aaiNetworkResources.deleteNetwork(l3network); execution.setVariable("isRollbackNeeded", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteNetwork process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the Collection from A&AI. + * + * It will extract the serviceInstance from the BBObject. + * + * Then it will get the collection from serviceinstance. + * + * @param execution + * @throws Exception + */ public void deleteCollection(BuildingBlockExecution execution) throws Exception { try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); aaiNetworkResources.deleteCollection(serviceInstance.getCollection()); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteCollection process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the InstanceGroup from A&AI. + * + * It will extract the serviceInstance from the BBObject. + * + * Then it will get the Instance group from serviceInstance. + * + * @param execution + * @throws Exception + */ public void deleteInstanceGroup(BuildingBlockExecution execution) throws Exception { try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); aaiNetworkResources.deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup()); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteInstanceGroup process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the VolumeGroup from A&AI. + * + * It will extract the volumeGroup from the BBObject and cloudRegion from execution object . + * + * Then it will delete from A&AI. + * + * @param execution + * @throws Exception + */ public void deleteVolumeGroup(BuildingBlockExecution execution) { try { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion(); aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteVolumeGroup process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the Configuration from A&AI. + * + * It will extract the configuration from the BBObject. + * + * Then it will delete from A&AI. + * + * @param execution + */ public void deleteConfiguration(BuildingBlockExecution execution) { try { Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); aaiConfigurationResources.deleteConfiguration(configuration); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteConfiguration process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * BPMN access method to delete the InstanceGroupVnf from A&AI. + * + * It will extract the instanceGroup from the BBObject. + * + * Then it will delete from A&AI. + * + * @param execution + */ public void deleteInstanceGroupVnf(BuildingBlockExecution execution) { try { InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup); } catch (Exception ex) { + logger.error("Exception occurred in AAIDeleteTasks deleteInstanceGroupVnf process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + public void deleteNetworkPolicies(BuildingBlockExecution execution) { try { String fqdns = execution.getVariable(contrailNetworkPolicyFqdnList); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 20f4443291..86645391b4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -92,6 +92,7 @@ public class AAIUpdateTasks { OrchestrationStatus.ASSIGNED); execution.setVariable("aaiServiceInstanceRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedService", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -108,6 +109,7 @@ public class AAIUpdateTasks { aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActiveService", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -122,6 +124,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -136,6 +139,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ACTIVE); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActiveVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -155,6 +159,7 @@ public class AAIUpdateTasks { aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedVolumeGroup", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -174,6 +179,7 @@ public class AAIUpdateTasks { aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActiveVolumeGroup", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -193,6 +199,7 @@ public class AAIUpdateTasks { aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusCreatedVolumeGroup", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -215,6 +222,7 @@ public class AAIUpdateTasks { aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateHeatStackIdVolumeGroup", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -231,6 +239,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -247,6 +256,7 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.PENDING_ACTIVATION); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusPendingActivationVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -273,6 +283,9 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED); } } catch (Exception ex) { + logger.error( + "Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedOrPendingActivationVfModule", + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -281,7 +294,7 @@ public class AAIUpdateTasks { * BPMN access method to update status of VfModule to Created in AAI * * @param execution - * + * */ public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) { try { @@ -289,6 +302,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusCreatedVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -307,6 +321,7 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED); execution.setVariable("aaiDeactivateVfModuleRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusDeactivateVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -346,6 +361,7 @@ public class AAIUpdateTasks { L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); updateNetworkAAI(l3Network, status); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateNetwork", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -386,6 +402,7 @@ public class AAIUpdateTasks { aaiCollectionResources.updateCollection(copiedNetworkCollection); execution.setVariable("aaiNetworkCollectionActivateRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActiveNetworkCollection", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -403,6 +420,7 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE); execution.setVariable("aaiActivateVfModuleRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActivateVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -423,6 +441,7 @@ public class AAIUpdateTasks { vfModule.setHeatStackId(heatStackId); aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateHeatStackIdVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -466,6 +485,7 @@ public class AAIUpdateTasks { execution.setVariable("aaiNetworkActivateRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateNetworkCreated", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -495,6 +515,7 @@ public class AAIUpdateTasks { } } } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateNetworkUpdated", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -509,6 +530,7 @@ public class AAIUpdateTasks { L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); aaiNetworkResources.updateNetwork(l3network); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateObjectNetwork", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -524,6 +546,7 @@ public class AAIUpdateTasks { extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); aaiServiceInstanceResources.updateServiceInstance(serviceInstance); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateServiceInstance", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -538,6 +561,7 @@ public class AAIUpdateTasks { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateObjectVnf(genericVnf); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateObjectVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -559,6 +583,7 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED); execution.setVariable("aaiDeleteVfModuleRollback", true); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusDeleteVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -574,6 +599,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVfModuleResources.changeAssignVfModule(vfModule, vnf); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateModelVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -589,6 +615,7 @@ public class AAIUpdateTasks { aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignFabricConfiguration", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -603,6 +630,8 @@ public class AAIUpdateTasks { Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActivateFabricConfiguration", + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -618,6 +647,8 @@ public class AAIUpdateTasks { aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusDeactivateFabricConfiguration", + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -640,6 +671,7 @@ public class AAIUpdateTasks { aaiVnfResources.updateObjectVnf(copiedGenericVnf); } } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateIpv4OamAddressVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -662,6 +694,7 @@ public class AAIUpdateTasks { aaiVnfResources.updateObjectVnf(copiedGenericVnf); } } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateManagementV6AddressVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -681,6 +714,7 @@ public class AAIUpdateTasks { aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf); } } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateContrailServiceInstanceFqdnVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -695,6 +729,7 @@ public class AAIUpdateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGASSIGNED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigAssignedVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -704,12 +739,13 @@ public class AAIUpdateTasks { * * @param execution */ - public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution) { + public void updateOrchestrationStatusConfigDeployConfigureVnf(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfigureVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -720,12 +756,13 @@ public class AAIUpdateTasks { * * @param execution */ - public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution) { + public void updateOrchestrationStatusConfigDeployConfiguredVnf(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED); } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfiguredVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java index cdbe0db57c..6a8058938f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -62,7 +62,7 @@ public class ConfigDeployVnf { * @param execution */ public void updateAAIConfigure(BuildingBlockExecution execution) { - aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution); + aaiUpdateTask.updateOrchestrationStatusConfigDeployConfigureVnf(execution); } @@ -129,7 +129,7 @@ public class ConfigDeployVnf { * @param execution */ public void updateAAIConfigured(BuildingBlockExecution execution) { - aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + aaiUpdateTask.updateOrchestrationStatusConfigDeployConfiguredVnf(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java index e51774c12c..0afca71b99 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java @@ -30,12 +30,15 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIInstanceGroupResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component() public class UnassignVnf { + private static final Logger logger = LoggerFactory.getLogger(UnassignVnf.class); @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -45,6 +48,17 @@ public class UnassignVnf { @Autowired private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator; + /** + * BPMN access method to deleting instanceGroup in AAI. + * + * It will extract the vnf from BBobject ,It will get the instance group from the vnf and add it into a list. + * + * Then iterate that list and check the ModelInfoInstanceGroup type. + * + * Then it will delete that. + * + * @param execution + */ public void deleteInstanceGroups(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); @@ -56,6 +70,7 @@ public class UnassignVnf { } } } catch (Exception ex) { + logger.error("Exception occurred in UnassignVnf deleteInstanceGroups", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java index b85e33144f..f61b40ad23 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java @@ -52,6 +52,7 @@ import org.springframework.stereotype.Component; @Component public class SDNCActivateTasks extends AbstractSDNCTask { + private static final Logger logger = LoggerFactory.getLogger(SDNCActivateTasks.class); public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCVnfResources sdncVnfResources; @@ -66,6 +67,13 @@ public class SDNCActivateTasks extends AbstractSDNCTask { @Autowired private Environment env; + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for activate the vnf. + * + * @param execution + */ public void activateVnf(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -82,13 +90,14 @@ public class SDNCActivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCActivateTasks activateVnf process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } /** * BPMN access method to perform Assign action on SDNC for L3Network - * + * * @param execution * @throws BBObjectNotFoundException */ @@ -112,6 +121,13 @@ public class SDNCActivateTasks extends AbstractSDNCTask { } } + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for activate the activateVfModule. + * + * @param execution + */ public void activateVfModule(BuildingBlockExecution execution) { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); RequestContext requestContext = gBBInput.getRequestContext(); @@ -131,6 +147,7 @@ public class SDNCActivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCActivateTasks activateVfModule process", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java index 3c42f76d73..96b656ff95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java @@ -53,6 +53,7 @@ import org.springframework.stereotype.Component; @Component public class SDNCDeactivateTasks extends AbstractSDNCTask { + private static final Logger logger = LoggerFactory.getLogger(SDNCDeactivateTasks.class); public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCNetworkResources sdncNetworkResources; @@ -69,6 +70,12 @@ public class SDNCDeactivateTasks extends AbstractSDNCTask { @Autowired private Environment env; + /** + * This method is used to prepare a SDNC request and set it to the execution Object. Which is used for deactivate + * VfModule. + * + * @param execution + */ public void deactivateVfModule(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -86,13 +93,14 @@ public class SDNCDeactivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCDeactivateTasks deactivateVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } /** * BPMN access method to perform Service Topology Deactivate action on SDNC for Vnf - * + * * @param execution * @throws Exception */ @@ -113,15 +121,16 @@ public class SDNCDeactivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCDeactivateTasks deactivateVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } /* * BPMN access method to perform Service Topology Deactivate action on SDNC for Service Instance - * + * * @param execution - * + * * @throws Exception */ public void deactivateServiceInstance(BuildingBlockExecution execution) throws Exception { @@ -138,13 +147,14 @@ public class SDNCDeactivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.SERVICE); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCDeactivateTasks deactivateServiceInstance", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } /** * BPMN access method to invoke deactivate on a L3Network object - * + * * @param execution */ public void deactivateNetwork(BuildingBlockExecution execution) { @@ -163,6 +173,7 @@ public class SDNCDeactivateTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.NETWORK); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCDeactivateTasks deactivateNetwork", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java index e3c9785ab2..4817ba8b61 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java @@ -53,6 +53,7 @@ import org.springframework.stereotype.Component; @Component public class SDNCUnassignTasks extends AbstractSDNCTask { + private static final Logger logger = LoggerFactory.getLogger(SDNCUnassignTasks.class); public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCServiceInstanceResources sdncSIResources; @@ -69,6 +70,13 @@ public class SDNCUnassignTasks extends AbstractSDNCTask { @Autowired private Environment env; + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for unassign the ServiceInstance. + * + * @param execution + */ public void unassignServiceInstance(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -83,10 +91,18 @@ public class SDNCUnassignTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.SERVICE); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCUnassignTasks unassignServiceInstance", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for unassign the VfModule. + * + * @param execution + */ public void unassignVfModule(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -102,10 +118,18 @@ public class SDNCUnassignTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCUnassignTasks unassignVfModule", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for unassign the Vnf. + * + * @param execution + */ public void unassignVnf(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -122,10 +146,18 @@ public class SDNCUnassignTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCUnassignTasks unassignVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + /** + * This method is used to prepare a SDNC request and set it to the execution Object. + * + * Which is used for unassign the Network. + * + * @param execution + */ public void unassignNetwork(BuildingBlockExecution execution) throws Exception { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -144,6 +176,7 @@ public class SDNCUnassignTasks extends AbstractSDNCTask { sdncRequest.setTopology(SDNCTopology.NETWORK); execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { + logger.error("Exception occurred in SDNCUnassignTasks unassignNetwork", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 905f244278..c337f7f1b5 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -733,7 +733,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE); - aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution); + aaiUpdateTasks.updateOrchestrationStatusConfigDeployConfigureVnf(execution); } @Test @@ -741,6 +741,6 @@ public class AAIUpdateTasksTest extends BaseTaskTest { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED); - aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + aaiUpdateTasks.updateOrchestrationStatusConfigDeployConfiguredVnf(execution); } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java index f2f99050db..1fe9da984f 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java @@ -21,6 +21,7 @@ package org.onap.so.client.aai.entities.uri; import java.net.URI; +import java.util.regex.Pattern; import javax.ws.rs.core.UriBuilder; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; @@ -138,4 +139,9 @@ public class AAISimpleUri extends SimpleUri implements AAIResourceUri { public AAISimpleUri format(Format format) { return (AAISimpleUri) super.format(format); } + + @Override + protected Pattern getPrefixPattern() { + return Pattern.compile("/aai/v\\d+"); + } } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java index ffbb86f023..ad3bb6c311 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java @@ -20,6 +20,7 @@ package org.onap.so.client.graphinventory.entities; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -49,8 +50,24 @@ public class DSLQueryBuilder<S, E> implements QueryStep { } public DSLQueryBuilder<S, E> output() { - if (steps.get(steps.size() - 1) instanceof DSLNode) { + Object obj = steps.get(steps.size() - 1); + if (obj instanceof DSLNode) { ((DSLNode) steps.get(steps.size() - 1)).output(); + } else if (obj.getClass().getName().contains("$$Lambda$")) { + // process lambda expressions + for (Field f : obj.getClass().getDeclaredFields()) { + f.setAccessible(true); + Object o; + try { + o = f.get(obj); + if (o instanceof DSLQueryBuilder && ((DSLQueryBuilder) o).steps.get(0) instanceof DSLNode) { + ((DSLNode) ((DSLQueryBuilder) o).steps.get(0)).output(); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + f.setAccessible(false); + break; + } } return this; } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java index 41ba07ad6c..ffe47c5c51 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.onap.so.client.graphinventory.Format; @@ -61,7 +62,7 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable { protected SimpleUri(GraphInventoryObjectType type, URI uri) { this.type = type; this.pluralType = null; - this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", "")); + this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll(getPrefixPattern().toString(), "")); this.values = new Object[0]; } @@ -174,6 +175,10 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable { return build(this.values); } + protected Pattern getPrefixPattern() { + return Pattern.compile("/.*?/v\\d+"); + } + protected URI build(Object... values) { // This is a workaround because resteasy does not encode URIs correctly final String[] encoded = new String[values.length]; diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java index 590e83827b..fb45652d53 100644 --- a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java +++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.onap.so.client.graphinventory.entities.DSLNode; +import org.onap.so.client.graphinventory.entities.DSLNodeKey; import org.onap.so.client.graphinventory.entities.DSLQueryBuilder; import org.onap.so.client.graphinventory.entities.__; @@ -118,4 +119,30 @@ public class DSLQueryBuilderTest { assertTrue(builder.equals( "cloud-region('cloud-owner', 'owner')('cloud-region-id', 'id') > vlan-tag*('vlan-id-outer', 167)('my-boolean', true)")); } + + @Test + public void outputOnNodeLambdasTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = + new DSLQueryBuilder<>(new DSLNode(AAIObjectType.L_INTERFACE, new DSLNodeKey("interface-id", "myId"))); + + builder.to(AAIObjectType.VSERVER, __.key("vserver-name", "myName")).output().to(AAIObjectType.P_INTERFACE) + .output(); + assertEquals("l-interface('interface-id', 'myId') > vserver*('vserver-name', 'myName') > p-interface*", + builder.build()); + } + + @Test + public void skipOutputOnUnionTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = + new DSLQueryBuilder<>(new DSLNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); + + builder.union(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()), + __.node(AAIObjectType.VSERVER) + .to(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()))) + .output(); + + assertEquals( + "generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, " + "vserver > pserver* > complex* ]", + builder.build()); + } } |