Add existing vnf customization for service 90/85890/1
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 20 Apr 2019 10:50:08 +0000 (16:20 +0530)
committersubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 20 Apr 2019 10:50:08 +0000 (16:20 +0530)
Add existing vnf customiation for service if they are exit in db.
Otherwise vnf_resource_customization_to_service will hold only
last process VF while parsing.

Change-Id: I52ea9dec58630e61eae88e7c9325aa37d64c00d6
Issue-ID: SO-1805
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java

index 50a5558..aba70f3 100644 (file)
@@ -984,7 +984,8 @@ public class ToscaResourceInstaller {
                 }
 
 
-                service.getVnfCustomizations().add(vnfResource);
+                // add this vnfResource with existing vnfResource for this service
+                addVnfCustomization(service, vnfResource);
             } else {
                 logger.debug("Notification VF ResourceCustomizationUUID: "
                         + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
@@ -2440,6 +2441,19 @@ public class ToscaResourceInstaller {
         return inputName;
     }
 
+    // this method add provided vnfCustomization to service with
+    // existing customization available in db.
+    private void addVnfCustomization(Service service, VnfResourceCustomization vnfResourceCustomization) {
+        List<Service> services = serviceRepo.findByModelUUID(service.getModelUUID());
+        if (services.size() > 0) {
+            // service exist in db
+            Service existingService = services.get(0);
+            List<VnfResourceCustomization> vnfCustomizations = existingService.getVnfCustomizations();
+            vnfCustomizations.forEach(e -> service.getVnfCustomizations().add(e));
+        }
+        service.getVnfCustomizations().add(vnfResourceCustomization);
+    }
+
 
     protected static Timestamp getCurrentTimeStamp() {