api: Add diskInfo as part of StatVol and ListVols. (#1349)

It is the bucket and volumes which needs to have this
value rather than the DiskInfo API itself. Eventually
this can be extended to show disk usage per
Buckets/Volumes whenever we have that functionality.

For now since buckets/volumes are thinly provisioned
this is the right approach.
This commit is contained in:
Harshavardhana
2016-04-21 20:07:47 -07:00
committed by Anand Babu (AB) Periasamy
parent 1284ecc6f2
commit 4cf73caf02
6 changed files with 49 additions and 24 deletions

View File

@@ -31,7 +31,6 @@ import (
"github.com/dustin/go-humanize"
"github.com/gorilla/mux"
"github.com/gorilla/rpc/v2/json2"
"github.com/minio/minio/pkg/disk"
"github.com/minio/miniobrowser"
)
@@ -99,27 +98,6 @@ func (web *webAPIHandlers) ServerInfo(r *http.Request, args *WebGenericArgs, rep
return nil
}
// DiskInfoRep - disk info reply.
type DiskInfoRep struct {
DiskInfo disk.Info `json:"diskInfo"`
UIVersion string `json:"uiVersion"`
}
// DiskInfo - get disk statistics.
func (web *webAPIHandlers) DiskInfo(r *http.Request, args *WebGenericArgs, reply *DiskInfoRep) error {
// FIXME: bring in StatFS in StorageAPI interface and uncomment the below lines.
// if !isJWTReqAuthenticated(r) {
// return &json2.Error{Message: "Unauthorized request"}
// }
// info, e := disk.GetInfo(web.ObjectAPI.(*Filesystem).GetRootPath())
// if e != nil {
// return &json2.Error{Message: e.Error()}
// }
// reply.DiskInfo = info
// reply.UIVersion = miniobrowser.UIVersion
return nil
}
// MakeBucketArgs - make bucket args.
type MakeBucketArgs struct {
BucketName string `json:"bucketName"`
@@ -150,6 +128,10 @@ type WebBucketInfo struct {
Name string `json:"name"`
// Date the bucket was created.
CreationDate time.Time `json:"creationDate"`
// Total storage space where the bucket resides.
Total int64 `json:"total"`
// Free storage space where the bucket resides.
Free int64 `json:"free"`
}
// ListBuckets - list buckets api.
@@ -167,6 +149,8 @@ func (web *webAPIHandlers) ListBuckets(r *http.Request, args *WebGenericArgs, re
reply.Buckets = append(reply.Buckets, WebBucketInfo{
Name: bucket.Name,
CreationDate: bucket.Created,
Total: bucket.Total,
Free: bucket.Free,
})
}
}