mirror of https://github.com/ceph/go-ceph
cephfs admin: add a SubVolumeGroupPath function
The SubVolumeGroupPath function maps the subvolumegroup to a path from the root of the cephfs, and works like `ceph fs subvolumegroup getpath ...`. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
b66dcaf565
commit
fbb4f957eb
|
@ -77,3 +77,18 @@ func (fsa *FSAdmin) RemoveSubVolumeGroup(volume, name string) error {
|
|||
})
|
||||
return checkEmptyResponseExpected(r, s, err)
|
||||
}
|
||||
|
||||
// SubVolumeGroupPath returns the path to the subvolume from the root of the
|
||||
// file system.
|
||||
//
|
||||
// Similar To:
|
||||
// ceph fs subvolumegroup getpath <volume> <group_name>
|
||||
func (fsa *FSAdmin) SubVolumeGroupPath(volume, name string) (string, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "fs subvolumegroup getpath",
|
||||
"vol_name": volume,
|
||||
"group_name": name,
|
||||
// ceph doesn't respond in json for this cmd (even if you ask)
|
||||
}
|
||||
return extractPathResponse(fsa.marshalMgrCommand(m))
|
||||
}
|
||||
|
|
|
@ -87,3 +87,26 @@ func TestRemoveSubVolumeGroup(t *testing.T) {
|
|||
nowCount := len(lsvg)
|
||||
assert.Equal(t, beforeCount, nowCount)
|
||||
}
|
||||
|
||||
func TestSubVolumeGroupPath(t *testing.T) {
|
||||
fsa := getFSAdmin(t)
|
||||
volume := "cephfs"
|
||||
group := "grewp"
|
||||
|
||||
err := fsa.CreateSubVolumeGroup(volume, group, nil)
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
err := fsa.RemoveSubVolumeGroup(volume, group)
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
|
||||
path, err := fsa.SubVolumeGroupPath(volume, group)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, path, "/volumes/"+group)
|
||||
assert.NotContains(t, path, "\n")
|
||||
|
||||
// invalid group name
|
||||
path, err = fsa.SubVolumeGroupPath(volume, "oops")
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "", path)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue