Expose total and available disk space (#7453)

This commit is contained in:
Harshavardhana
2019-04-04 21:21:50 -07:00
committed by Nitish Tiwari
parent 979309148e
commit 0188009c7e
7 changed files with 94 additions and 56 deletions

View File

@@ -120,18 +120,23 @@ func getStorageInfo(disks []StorageAPI) StorageInfo {
return StorageInfo{}
}
// Combine all disks to get total usage.
var used uint64
// Combine all disks to get total usage
var used, total, available uint64
for _, di := range validDisksInfo {
used = used + di.Used
total = total + di.Total
available = available + di.Free
}
_, sscParity := getRedundancyCount(standardStorageClass, len(disks))
_, rrscparity := getRedundancyCount(reducedRedundancyStorageClass, len(disks))
storageInfo := StorageInfo{
Used: used,
Used: used,
Total: total,
Available: available,
}
storageInfo.Backend.Type = BackendErasure
storageInfo.Backend.OnlineDisks = onlineDisks
storageInfo.Backend.OfflineDisks = offlineDisks