mirror of https://github.com/apache/cloudstack.git
bug 11051: Listing Secondary Storage - also show the total and used storage. Listing Storage pools show the realtime storage stats and correctly populate the allocated storage.
This commit is contained in:
parent
10fb507609
commit
d53c3f0798
|
|
@ -66,6 +66,9 @@ public class StoragePoolResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("disksizeallocated") @Param(description="the host's currently allocated disk size")
|
||||
private Long diskSizeAllocated;
|
||||
|
||||
@SerializedName("disksizeused") @Param(description="the host's currently used disk size")
|
||||
private Long diskSizeUsed;
|
||||
|
||||
@SerializedName("tags") @Param(description="the tags for the storage pool")
|
||||
private String tags;
|
||||
|
|
@ -216,7 +219,15 @@ public class StoragePoolResponse extends BaseResponse {
|
|||
this.diskSizeAllocated = diskSizeAllocated;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
public Long getDiskSizeUsed() {
|
||||
return diskSizeUsed;
|
||||
}
|
||||
|
||||
public void setDiskSizeUsed(Long diskSizeUsed) {
|
||||
this.diskSizeUsed = diskSizeUsed;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -578,6 +578,12 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
|
||||
}
|
||||
|
||||
}else if (host.getType() == Host.Type.SecondaryStorage){
|
||||
StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(host.getId());
|
||||
if (secStorageStats != null){
|
||||
hostResponse.setDiskSizeTotal(secStorageStats.getCapacityBytes());
|
||||
hostResponse.setDiskSizeAllocated(secStorageStats.getByteUsed());
|
||||
}
|
||||
}
|
||||
|
||||
if (host.getClusterId() != null) {
|
||||
|
|
@ -938,16 +944,14 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
|
||||
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
|
||||
Long capacity = pool.getCapacityBytes();
|
||||
Long available = pool.getAvailableBytes();
|
||||
Long used = capacity - available;
|
||||
|
||||
if (stats != null) {
|
||||
used = stats.getByteUsed();
|
||||
available = capacity - used;
|
||||
}
|
||||
|
||||
long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(),Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
||||
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
|
||||
poolResponse.setDiskSizeAllocated(used);
|
||||
poolResponse.setDiskSizeAllocated(allocatedSize);
|
||||
|
||||
if (stats != null) {
|
||||
Long used = stats.getByteUsed();
|
||||
poolResponse.setDiskSizeUsed(used);
|
||||
}
|
||||
|
||||
if (pool.getClusterId() != null) {
|
||||
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue