go-ceph/cephfs/admin/volume.go

42 lines
1.2 KiB
Go

package admin
var listVolumesCmd = []byte(`{"prefix":"fs volume ls"}`)
// ListVolumes return a list of volumes in this Ceph cluster.
func (fsa *FSAdmin) ListVolumes() ([]string, error) {
r, s, err := fsa.rawMgrCommand(listVolumesCmd)
return parseListNames(r, s, err)
}
// VolumePool reports on the pool status for a CephFS volume.
type VolumePool struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Available uint64 `json:"avail"`
Used uint64 `json:"used"`
}
// VolumeStatus reports various properties of a CephFS volume.
// TODO: Fill in.
type VolumeStatus struct {
MDSVersion string `json:"mds_version"`
Pools []VolumePool `json:"pools"`
}
func parseVolumeStatus(res []byte, status string, err error) (*VolumeStatus, error) {
var vs VolumeStatus
err = unmarshalResponseJSON(res, status, err, &vs)
return &vs, err
}
// VolumeStatus returns a VolumeStatus object for the given volume name.
func (fsa *FSAdmin) VolumeStatus(name string) (*VolumeStatus, error) {
r, s, err := fsa.marshalMgrCommand(map[string]string{
"fs": name,
"prefix": "fs status",
"format": "json",
})
return parseVolumeStatus(r, s, err)
}