Skip to content

Commit

Permalink
Add total and used field to device response
Browse files Browse the repository at this point in the history
it will be user friendly if we have total,
free,used field in device response.

total size= total size of device.
free size= available size of device for
volume creation.
used size= space used for volume creation.

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 authored and aravindavk committed Dec 17, 2018
1 parent 9bfa471 commit e432ed3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/device/api/resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
type Info struct {
Device string `json:"device"`
State string `json:"state"`
AvailableSize uint64 `json:"available-size"`
AvailableSize uint64 `json:"free-size"`
TotalSize uint64 `json:"total-size"`
UsedSize uint64 `json:"used-size"`
ExtentSize uint64 `json:"extent-size"`
Used bool `json:"device-used"`
PeerID uuid.UUID `json:"peer-id"`
Expand Down
2 changes: 2 additions & 0 deletions plugins/device/deviceutils/store-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func UpdateDeviceFreeSize(peerID, device string) error {
return err
}
dev.AvailableSize = availableSize
dev.UsedSize = dev.TotalSize - availableSize
dev.ExtentSize = extentSize
return AddOrUpdateDevice(*dev)
}
Expand All @@ -127,6 +128,7 @@ func UpdateDeviceFreeSizeByVg(peerID, vgname string) error {
return err
}
dev.AvailableSize = availableSize
dev.UsedSize = dev.TotalSize - availableSize
dev.ExtentSize = extentSize
return AddOrUpdateDevice(dev)
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/device/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func txnPrepareDevice(c transaction.TxnCtx) error {
Device: device,
State: deviceapi.DeviceEnabled,
AvailableSize: availableSize,
TotalSize: availableSize,
UsedSize: 0,
ExtentSize: extentSize,
PeerID: peerID,
}
Expand Down

0 comments on commit e432ed3

Please sign in to comment.