make sure the NetworkResourceUUID are correct. 46/77746/1
authorBenjamin, Max (mb388a) <mb388a@us.att.com>
Fri, 1 Feb 2019 23:01:32 +0000 (18:01 -0500)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Fri, 1 Feb 2019 23:01:54 +0000 (18:01 -0500)
- Added test asserts to show that the NetworkResourceUUID was updated
correctly.
- Added a NetworkResourceCustomization Audit to make sure the
NetworkResourceUUID are correct.

Change-Id: Id4fbf224aa00d6bd34481bab6a907af12fba56dd
Issue-ID: SO-1455
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java

index 7951e9b..6c92224 100644 (file)
@@ -1055,7 +1055,21 @@ public class ToscaResourceInstaller {
                        ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
                
                NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                               if(networkResourceCustomization==null){
+                               
+               boolean networkUUIDsMatch = true;
+               // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.  
+               // If not we'll update the Customization record with latest from the distribution
+               if(networkResourceCustomization != null){
+                       String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
+                       String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+                       
+                       if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){
+                               networkUUIDsMatch = false;
+                       }
+               
+               }
+
+               if(networkResourceCustomization==null || !networkUUIDsMatch){
                        networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
                                        toscaResourceStructure);
                                        
@@ -1067,7 +1081,8 @@ public class ToscaResourceInstaller {
 
                                        networkResource.addNetworkResourceCustomization(networkResourceCustomization);          
                                        networkResourceCustomization.setNetworkResource(networkResource);
-                               }
+               }
+               
                return networkResourceCustomization;
        }