aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java/org
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2018-12-12 12:53:54 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-12 12:53:54 +0000
commit22a46fe26228f00d334cf8fca80e907b8cce0cc9 (patch)
treebfb7e85996fe398cbe93834b0ad05ebf277cbc24 /asdc-controller/src/main/java/org
parentd86091c0a9c1aaeb46bf15475a5f9324e3a84ba8 (diff)
parent065ac26be8bacd9a3bab5e58d54d0186849cf132 (diff)
Merge "asdc process vf resource into db bug fix"
Diffstat (limited to 'asdc-controller/src/main/java/org')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java148
1 files changed, 80 insertions, 68 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 ac15fb974c..bde43b0845 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
@@ -59,12 +59,10 @@ import org.onap.so.db.catalog.beans.AllottedResource;
import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
-import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
-import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
import org.onap.so.db.catalog.beans.HeatTemplate;
@@ -141,7 +139,6 @@ public class ToscaResourceInstaller {
protected static final String MSO = "SO";
-
@Autowired
protected ServiceRepository serviceRepo;
@@ -275,9 +272,9 @@ public class ToscaResourceInstaller {
@Transactional(rollbackFor = { ArtifactInstallerException.class })
public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
- throws ArtifactInstallerException {
+ throws ArtifactInstallerException {
VfResourceStructure vfResourceStructure = vfResourceStruct;
- extractHeatInformation(toscaResourceStruct, vfResourceStructure);
+ extractHeatInformation(toscaResourceStruct, vfResourceStructure);
// PCLO: in case of deployment failure, use a string that will represent
// the type of artifact that failed...
@@ -286,21 +283,9 @@ public class ToscaResourceInstaller {
createToscaCsar(toscaResourceStruct);
createService(toscaResourceStruct, vfResourceStruct);
Service service = toscaResourceStruct.getCatalogService();
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
-
- Metadata metadata = nodeTemplate.getMetaData();
- String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
- String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
- }
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
- processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+ processVFResources(toscaResourceStruct, service, vfResourceStructure);
+ processAllottedResources(toscaResourceStruct, service);
processNetworks(toscaResourceStruct, service);
// process Network Collections
processNetworkCollections(toscaResourceStruct, service);
@@ -390,8 +375,9 @@ public class ToscaResourceInstaller {
}
}
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) {
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+
if (allottedResourceList != null) {
for (NodeTemplate allottedNode : allottedResourceList) {
service.getAllottedCustomizations()
@@ -463,60 +449,86 @@ public class ToscaResourceInstaller {
service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
}
- protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
+
+ protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
+ throws Exception{
+ logger.debug("processVFResources");
- logger.debug("VF Category is : " + vfCustomizationCategory);
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+// String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
+// String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
- if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
- {
-
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
- " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
-
- if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
-
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ logger.debug("VF Category is : " + vfCustomizationCategory);
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+ // Do not treat Allotted Resources as VNF resources
+ if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
+ continue;
+ }
+
+ String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca
+ // customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
- Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-
- 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();
-
- logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
-
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
- .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
- if(matchingObject.isPresent()){
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
- vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
- vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
- }else
- throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
-
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, vfCustomizationUUID);
+ }
+ else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+
+ protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
+ Service service, NodeTemplate nodeTemplate, String vfCustomizationUUID)
+ throws Exception {
+ logger.debug("processVfModules for vfCustomizationUUID: " + vfCustomizationUUID);
+
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
+ Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+ 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();
+
+ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
+ if (matchingObject.isPresent()) {
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
+ vfResourceStructure, vfMetadata, vnfResource,service, existingCvnfcSet, existingVnfcSet);
+ vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+ } else {
+ throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
}
- service.getVnfCustomizations().add(vnfResource);
- } else{
- logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
- "Tosca VF Customization UUID: " + vfCustomizationUUID);
}
}
+
+ service.getVnfCustomizations().add(vnfResource);
}
public void processWatchdog(String distributionId, String servideUUID) {