Skip to content

Commit 9aa34c4

Browse files
Merge pull request #2439 from rafaelweingartner/CLOUDSTACK-10259
[CLOUDSTACK-10259] Missing float part of secondary storage data in listAccounts method
2 parents 2ad5202 + 73251bf commit 9aa34c4

7 files changed

Lines changed: 11 additions & 13 deletions

File tree

api/src/main/java/com/cloud/configuration/Resource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public enum ResourceType { // Primary and Secondary storage are allocated_storag
3838
private ResourceOwnerType[] supportedOwners;
3939
private int ordinal;
4040
public static final long bytesToKiB = 1024;
41-
public static final long bytesToMiB = 1024 * 1024;
42-
public static final long bytesToGiB = 1024 * 1024 * 1024;
41+
public static final long bytesToMiB = bytesToKiB * 1024;
42+
public static final long bytesToGiB = bytesToMiB * 1024;
4343

4444
ResourceType(String name, int ordinal, ResourceOwnerType... supportedOwners) {
4545
this.name = name;

api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.serializer.Param;
3030
import com.cloud.user.Account;
3131

32-
@SuppressWarnings("unused")
3332
@EntityReference(value = Account.class)
3433
public class AccountResponse extends BaseResponse implements ResourceLimitAndCountResponse {
3534
@SerializedName(ApiConstants.ID)
@@ -222,7 +221,7 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
222221

223222
@SerializedName("secondarystoragetotal")
224223
@Param(description = "the total secondary storage space (in GiB) owned by account", since = "4.2.0")
225-
private Long secondaryStorageTotal;
224+
private float secondaryStorageTotal;
226225

227226
@SerializedName("secondarystorageavailable")
228227
@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) {
501500
}
502501

503502
@Override
504-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
503+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
505504
this.secondaryStorageTotal = secondaryStorageTotal;
506505
}
507506

api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class DomainResponse extends BaseResponse implements ResourceLimitAndCoun
165165
private String secondaryStorageLimit;
166166

167167
@SerializedName("secondarystoragetotal") @Param(description="the total secondary storage space (in GiB) owned by domain", since="4.2.0")
168-
private Long secondaryStorageTotal;
168+
private float secondaryStorageTotal;
169169

170170
@SerializedName("secondarystorageavailable") @Param(description="the total secondary storage space (in GiB) available to be used for this domain", since="4.2.0")
171171
private String secondaryStorageAvailable;
@@ -399,7 +399,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) {
399399
}
400400

401401
@Override
402-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
402+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
403403
this.secondaryStorageTotal = secondaryStorageTotal;
404404
}
405405

api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.serializer.Param;
3030

3131
@EntityReference(value = Project.class)
32-
@SuppressWarnings("unused")
3332
public class ProjectResponse extends BaseResponse implements ResourceLimitAndCountResponse {
3433

3534
@SerializedName(ApiConstants.ID)
@@ -134,7 +133,7 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
134133

135134
@SerializedName("secondarystoragetotal")
136135
@Param(description = "the total secondary storage space (in GiB) owned by project", since = "4.2.0")
137-
private Long secondaryStorageTotal;
136+
private float secondaryStorageTotal;
138137

139138
@SerializedName("secondarystorageavailable")
140139
@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) {
414413
}
415414

416415
@Override
417-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
416+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
418417
this.secondaryStorageTotal = secondaryStorageTotal;
419418
}
420419

api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public interface ResourceLimitAndCountResponse {
5454

5555
public void setSecondaryStorageLimit(String secondaryStorageLimit);
5656

57-
public void setSecondaryStorageTotal(Long secondaryStorageTotal);
57+
public void setSecondaryStorageTotal(float secondaryStorageTotal);
5858

5959
public void setSecondaryStorageAvailable(String secondaryStorageAvailable);
6060

server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void setResourceLimits(AccountJoinVO account, boolean fullView, ResourceL
214214
//get resource limits for secondary storage space and convert it from Bytes to GiB
215215
long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(), account.getId(), ResourceType.secondary_storage);
216216
String secondaryStorageLimitDisplay = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
217-
long secondaryStorageTotal = (account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
217+
float secondaryStorageTotal = (account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / (ResourceType.bytesToGiB * 1f));
218218
String secondaryStorageAvail = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB)
219219
- secondaryStorageTotal);
220220

server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void setResourceLimits(DomainJoinVO domain, boolean fullView, ResourceLim
183183
//get resource limits for secondary storage space and convert it from Bytes to GiB
184184
long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimitForDomain(domain.getSecondaryStorageLimit(), ResourceType.secondary_storage, domain.getId());
185185
String secondaryStorageLimitDisplay = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
186-
long secondaryStorageTotal = (domain.getSecondaryStorageTotal() == null) ? 0 : (domain.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
186+
float secondaryStorageTotal = (domain.getSecondaryStorageTotal() == null) ? 0 : (domain.getSecondaryStorageTotal() / (ResourceType.bytesToGiB * 1f));
187187
String secondaryStorageAvail = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal);
188188
response.setSecondaryStorageLimit(secondaryStorageLimitDisplay);
189189
response.setSecondaryStorageTotal(secondaryStorageTotal);

0 commit comments

Comments
 (0)