Scale out fix for vfmodule count 63/49463/1
authorSonsino, Ofir (os0695) <os0695@intl.att.com>
Wed, 30 May 2018 09:22:29 +0000 (12:22 +0300)
committerSonsino, Ofir (os0695) <os0695@intl.att.com>
Wed, 30 May 2018 09:22:29 +0000 (12:22 +0300)
Change-Id: I9bd6fe9439f5779afd9711489a1c3b850f6c864e
Issue-ID: VID-188
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js

index 086ae0f..e4ff1a0 100644 (file)
                                                 newVNFName.vfModules = vnf.vfModules;
                                                 newVNFName.category = response.data.service.category;
                                                 newVNFName.groupModules = _.groupBy(newVNFName.vfModules, "customizationUuid");
+
+                                                //list vfmodules ids in AAI that belong to that vnf instance
+                                                var modulesAaiIds = _.filter(newVNFName.relatedTo, function(item){
+                                                                        return item["node-type"] === "vf-module";
+                                                                    }).map(function(item){
+                                                                        return item.id;
+                                                                    });
+
                                                 _.forEach(newVNFName.vfModules, function (mdl, key) {
                                                     mdl.scale = false; //defaults to not scale unless user changes it
                                                     if(mdl.properties && mdl.properties.max_vf_module_instances) {
-                                                        mdl.scalable = mdl.properties.max_vf_module_instances.value - newVNFName.groupModules[mdl.customizationUuid].length > 0;
+
+                                                        //how many vf modules of the same customizationId belong to that vnf instance
+                                                        mdl.currentCount = _.filter(vm.vfModules, function(item){
+                                                            return modulesAaiIds.indexOf(item.id) > -1 && item.properties["model-customization-id"] === mdl.customizationUuid;
+                                                        }).length;
+
+                                                        mdl.scalable = mdl.properties.max_vf_module_instances.value - mdl.currentCount > 0;
                                                     }else{
                                                         mdl.scalable = false;
                                                     }
                         relatedInstanceList: [],
                         requestParameters:requestParametersData
                     };
-                    requestInfoData.instanceName = vnf.name + "_" + (vnf.groupModules[moduleToScale.customizationUuid].length + 1);
+                    requestInfoData.instanceName = vnf.name + "_" + (moduleToScale.currentCount + 1);
                 }else{
                     data = {
                         vnfName: vnf.name,
             // var promiseArrOfGetVnfs = preparePromiseArrOfGetVnfs(instances);
 
             vm.vnfs = [];
+            vm.vfModules = [];
 
             AaiService.getVnfsByCustomerIdAndServiceType(
                 vm.changeManagement.subscriberId,
                                     }
                                 } else if (nodeType === "service-instance") {
                                     vm.serviceInstances.push(vnfsData[i]);
+                                } else if (nodeType === "vf-module") {
+                                    vm.vfModules.push(vnfsData[i]);
                                 }
                             }
                         }