[ https://issues.apache.org/jira/browse/CLOUDSTACK-10259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16382267#comment-16382267 ]
ASF GitHub Bot commented on CLOUDSTACK-10259: --------------------------------------------- rafaelweingartner closed pull request #2439: [CLOUDSTACK-10259] Missing float part of secondary storage data in listAccounts method URL: https://github.com/apache/cloudstack/pull/2439 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/api/src/main/java/com/cloud/configuration/Resource.java b/api/src/main/java/com/cloud/configuration/Resource.java index 0fd51dc2f17..76f2930e615 100644 --- a/api/src/main/java/com/cloud/configuration/Resource.java +++ b/api/src/main/java/com/cloud/configuration/Resource.java @@ -38,8 +38,8 @@ private ResourceOwnerType[] supportedOwners; private int ordinal; public static final long bytesToKiB = 1024; - public static final long bytesToMiB = 1024 * 1024; - public static final long bytesToGiB = 1024 * 1024 * 1024; + public static final long bytesToMiB = bytesToKiB * 1024; + public static final long bytesToGiB = bytesToMiB * 1024; ResourceType(String name, int ordinal, ResourceOwnerType... supportedOwners) { this.name = name; diff --git a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java index 7b48a1ea8a1..18b11f10bd1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java @@ -29,7 +29,6 @@ import com.cloud.serializer.Param; import com.cloud.user.Account; -@SuppressWarnings("unused") @EntityReference(value = Account.class) public class AccountResponse extends BaseResponse implements ResourceLimitAndCountResponse { @SerializedName(ApiConstants.ID) @@ -222,7 +221,7 @@ @SerializedName("secondarystoragetotal") @Param(description = "the total secondary storage space (in GiB) owned by account", since = "4.2.0") - private Long secondaryStorageTotal; + private float secondaryStorageTotal; @SerializedName("secondarystorageavailable") @Param(description = "the total secondary storage space (in GiB) available to be used for this account", since = "4.2.0") @@ -501,7 +500,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) { } @Override - public void setSecondaryStorageTotal(Long secondaryStorageTotal) { + public void setSecondaryStorageTotal(float secondaryStorageTotal) { this.secondaryStorageTotal = secondaryStorageTotal; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java index e848759c9e4..7e5bd970d29 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java @@ -165,7 +165,7 @@ private String secondaryStorageLimit; @SerializedName("secondarystoragetotal") @Param(description="the total secondary storage space (in GiB) owned by domain", since="4.2.0") - private Long secondaryStorageTotal; + private float secondaryStorageTotal; @SerializedName("secondarystorageavailable") @Param(description="the total secondary storage space (in GiB) available to be used for this domain", since="4.2.0") private String secondaryStorageAvailable; @@ -399,7 +399,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) { } @Override - public void setSecondaryStorageTotal(Long secondaryStorageTotal) { + public void setSecondaryStorageTotal(float secondaryStorageTotal) { this.secondaryStorageTotal = secondaryStorageTotal; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java index 0ae9e18612e..8bfa6d94b63 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java @@ -29,7 +29,6 @@ import com.cloud.serializer.Param; @EntityReference(value = Project.class) -@SuppressWarnings("unused") public class ProjectResponse extends BaseResponse implements ResourceLimitAndCountResponse { @SerializedName(ApiConstants.ID) @@ -134,7 +133,7 @@ @SerializedName("secondarystoragetotal") @Param(description = "the total secondary storage space (in GiB) owned by project", since = "4.2.0") - private Long secondaryStorageTotal; + private float secondaryStorageTotal; @SerializedName("secondarystorageavailable") @Param(description = "the total secondary storage space (in GiB) available to be used for this project", since = "4.2.0") @@ -414,7 +413,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) { } @Override - public void setSecondaryStorageTotal(Long secondaryStorageTotal) { + public void setSecondaryStorageTotal(float secondaryStorageTotal) { this.secondaryStorageTotal = secondaryStorageTotal; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java index ba97c2c83ce..f247be834cb 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java @@ -54,7 +54,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit); - public void setSecondaryStorageTotal(Long secondaryStorageTotal); + public void setSecondaryStorageTotal(float secondaryStorageTotal); public void setSecondaryStorageAvailable(String secondaryStorageAvailable); diff --git a/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java index a8d3b68833d..fdc3cfa40a5 100644 --- a/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java @@ -214,7 +214,7 @@ public void setResourceLimits(AccountJoinVO account, boolean fullView, ResourceL //get resource limits for secondary storage space and convert it from Bytes to GiB long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(), account.getId(), ResourceType.secondary_storage); String secondaryStorageLimitDisplay = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB); - long secondaryStorageTotal = (account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / ResourceType.bytesToGiB); + float secondaryStorageTotal = (account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / (ResourceType.bytesToGiB * 1f)); String secondaryStorageAvail = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal); diff --git a/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java index 497fc2c13a3..a613fcbfe46 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java @@ -183,7 +183,7 @@ public void setResourceLimits(DomainJoinVO domain, boolean fullView, ResourceLim //get resource limits for secondary storage space and convert it from Bytes to GiB long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSecondaryStorageLimit(), ResourceType.secondary_storage, domain.getId()); String secondaryStorageLimitDisplay = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB); - long secondaryStorageTotal = (domain.getSecondaryStorageTotal() == null) ? 0 : (domain.getSecondaryStorageTotal() / ResourceType.bytesToGiB); + float secondaryStorageTotal = (domain.getSecondaryStorageTotal() == null) ? 0 : (domain.getSecondaryStorageTotal() / (ResourceType.bytesToGiB * 1f)); String secondaryStorageAvail = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal); response.setSecondaryStorageLimit(secondaryStorageLimitDisplay); response.setSecondaryStorageTotal(secondaryStorageTotal); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Missing float part of secondary storage data when calculating secondary > storage usage in listAccounts > ------------------------------------------------------------------------------------------------------ > > Key: CLOUDSTACK-10259 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10259 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the > default.) > Reporter: Rafael Weingärtner > Assignee: Rafael Weingärtner > Priority: Minor > > There is a non-floating points division that is missing the floating part of > the secondary storage usage. This will affect methods that use the following > SET method > org.apache.cloudstack.api.response.AccountResponse.setSecondaryStorageLimit(String). > It affects the listAccounts API method, making it differ from the > updateResource count method, which is presented in bytes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)