Github user pedro-martins commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/865#discussion_r52029971 --- Diff: server/src/com/cloud/server/ManagementServerImpl.java --- @@ -2488,6 +2479,23 @@ public int compare(final SummedCapacity arg0, final SummedCapacity arg1) { final SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), capacity.getClusterId()); list.add(summedCapacity); + } + } else { + List<DataCenterVO> dcList = _dcDao.listEnabledZones(); + for (DataCenterVO dc : dcList) { + List<CapacityVO> capacities=new ArrayList<CapacityVO>(); + capacities.add(_storageMgr.getSecondaryStorageUsedStats(null, dc.getId())); + capacities.add(_storageMgr.getStoragePoolUsedStats(null, null, null, dc.getId())); + for (CapacityVO capacity : capacities) { + if (capacity.getTotalCapacity() != 0) { + capacity.setUsedPercentage((float)capacity.getUsedCapacity() / capacity.getTotalCapacity()); + } else { + capacity.setUsedPercentage(0); + } + SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), + capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), capacity.getClusterId()); + list.add(summedCapacity); + } }// End of for --- End diff -- Hi @bvbharatk. Could you extract lines 2489 - 2498 to a method like "configureUsageCapacities" and a test case to this new method? I believe you can also extract lines 2486 -2488 to a method like "createCapacities" with test cases too. Another suggestion for you, I know that you don't touch in this part of the code, but how about you change the name of the variable declared at line 2464 to listOfSummedCapacity, the actual name "list" is a bit shallow. If you find useful, a Java doc describing each methods task would be a plus. Ty.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---