You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/07/03 09:23:33 UTC

[GitHub] [cloudstack] olivierlemasle commented on a change in pull request #4193: Fix usage record count

olivierlemasle commented on a change in pull request #4193:
URL: https://github.com/apache/cloudstack/pull/4193#discussion_r449478789



##########
File path: server/src/main/java/com/cloud/usage/UsageServiceImpl.java
##########
@@ -328,9 +333,20 @@ public boolean generateUsageRecords(GenerateUsageRecordsCmd cmd) {
                     break;
                 case UsageTypes.IP_ADDRESS:
                     IPAddressVO ip = _ipDao.findByUuidIncludingRemoved(usageId);
-                    if (ip != null) {
-                        usageDbId = ip.getId();
+                    if (ip == null) {
+                        break;
+                    }
+                    Long networkId = ip.getAssociatedWithNetworkId();
+                    if (networkId == null) {
+                        networkId = ip.getSourceNetworkId();
+                    }
+                    NetworkDetailVO networkDetail = _networkDetailsDao.findDetail(networkId, Network.hideIpAddressUsage);
+                    if (networkDetail != null && networkDetail.getValue() != null && networkDetail.getValue().equals("true")) {

Review comment:
       As this code is in a test `if (usageId != null)`, it will remove IP address usage only if the API command `listUsageRecords` was called with a specific `usageId` parameter.
   For API calls like `command=listUsageRecords&startdate=xxx&enddate=xxx`, it will include all usage records, including for IP addresses on networks with "Hide usage".




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org