Display image store disk size used and total disk size in (#4046)

list imagestore api response
This commit is contained in:
Rakesh 2020-06-08 03:35:58 +02:00 committed by GitHub
parent b8ceb88ed9
commit 6bf3769c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -60,6 +60,14 @@ public class ImageStoreResponse extends BaseResponse {
@Param(description = "the scope of the image store")
private ScopeType scope;
@SerializedName("disksizetotal")
@Param(description = "the total disk size of the host")
private Long diskSizeTotal;
@SerializedName("disksizeused")
@Param(description = "the host's currently used disk size")
private Long diskSizeUsed;
public ImageStoreResponse() {
}
@ -132,4 +140,12 @@ public class ImageStoreResponse extends BaseResponse {
this.protocol = protocol;
}
public void setDiskSizeTotal(Long diskSizeTotal) {
this.diskSizeTotal = diskSizeTotal;
}
public void setDiskSizeUsed(Long diskSizeUsed) {
this.diskSizeUsed = diskSizeUsed;
}
}

View File

@ -21,6 +21,8 @@ import java.util.List;
import javax.inject.Inject;
import com.cloud.api.ApiDBUtils;
import com.cloud.storage.StorageStats;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -75,6 +77,12 @@ public class ImageStoreJoinDaoImpl extends GenericDaoBase<ImageStoreJoinVO, Long
osResponse.setZoneId(ids.getZoneUuid());
osResponse.setZoneName(ids.getZoneName());
StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(ids.getId());
if (secStorageStats != null) {
osResponse.setDiskSizeTotal(secStorageStats.getCapacityBytes());
osResponse.setDiskSizeUsed(secStorageStats.getByteUsed());
}
osResponse.setObjectName("imagestore");
return osResponse;
}