cephfs admin: add ForceRemove<XYZ> variants for subv and group snaps

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-09-22 11:29:33 -04:00 committed by John Mulligan
parent 6a020daeb7
commit c9ab11ad12
4 changed files with 41 additions and 2 deletions

View File

@ -248,6 +248,19 @@ func (fsa *FSAdmin) CreateSubVolumeSnapshot(volume, group, source, name string)
// Similar To:
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name>
func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name string) error {
return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, rmFlags{})
}
// ForceRemoveSubVolumeSnapshot removes the specified snapshot from the subvolume.
//
// Similar To:
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name> --force
func (fsa *FSAdmin) ForceRemoveSubVolumeSnapshot(volume, group, subvolume, name string) error {
return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, rmFlags{force: true})
}
func (fsa *FSAdmin) rmSubVolumeSnapshot(volume, group, subvolume, name string, o rmFlags) error {
m := map[string]string{
"prefix": "fs subvolume snapshot rm",
"vol_name": volume,
@ -258,7 +271,7 @@ func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name strin
if group != NoGroup {
m["group_name"] = group
}
return fsa.marshalMgrCommand(m).noData().End()
return fsa.marshalMgrCommand(o.Update(m)).noData().End()
}
// ListSubVolumeSnapshots returns a listing of snapshots for a given subvolume.

View File

@ -391,6 +391,13 @@ func TestSubVolumeSnapshots(t *testing.T) {
assert.NoError(t, err)
})
t.Run("createAndForceRemove", func(t *testing.T) {
err = fsa.CreateSubVolumeSnapshot(volume, group, subname, snapname1)
assert.NoError(t, err)
err := fsa.ForceRemoveSubVolumeSnapshot(volume, group, subname, snapname1)
assert.NoError(t, err)
})
t.Run("listOne", func(t *testing.T) {
err = fsa.CreateSubVolumeSnapshot(volume, group, subname, snapname1)
assert.NoError(t, err)

View File

@ -124,6 +124,18 @@ func (fsa *FSAdmin) CreateSubVolumeGroupSnapshot(volume, group, name string) err
// Similar To:
// ceph fs subvolumegroup snapshot rm <volume> <group> <name>
func (fsa *FSAdmin) RemoveSubVolumeGroupSnapshot(volume, group, name string) error {
return fsa.rmSubVolumeGroupSnapshot(volume, group, name, rmFlags{})
}
// ForceRemoveSubVolumeGroupSnapshot removes the specified snapshot from the subvolume group.
//
// Similar To:
// ceph fs subvolumegroup snapshot rm <volume> <group> <name> --force
func (fsa *FSAdmin) ForceRemoveSubVolumeGroupSnapshot(volume, group, name string) error {
return fsa.rmSubVolumeGroupSnapshot(volume, group, name, rmFlags{force: true})
}
func (fsa *FSAdmin) rmSubVolumeGroupSnapshot(volume, group, name string, o rmFlags) error {
m := map[string]string{
"prefix": "fs subvolumegroup snapshot rm",
"vol_name": volume,
@ -131,7 +143,7 @@ func (fsa *FSAdmin) RemoveSubVolumeGroupSnapshot(volume, group, name string) err
"snap_name": name,
"format": "json",
}
return fsa.marshalMgrCommand(m).noData().End()
return fsa.marshalMgrCommand(o.Update(m)).noData().End()
}
// ListSubVolumeGroupSnapshots returns a listing of snapshots for a given subvolume group.

View File

@ -153,6 +153,13 @@ func TestSubVolumeGroupSnapshots(t *testing.T) {
assert.NoError(t, err)
})
t.Run("createAndForceRemove", func(t *testing.T) {
err = fsa.CreateSubVolumeGroupSnapshot(volume, group, snapname1)
assert.NoError(t, err)
err := fsa.ForceRemoveSubVolumeGroupSnapshot(volume, group, snapname1)
assert.NoError(t, err)
})
t.Run("listOne", func(t *testing.T) {
err = fsa.CreateSubVolumeGroupSnapshot(volume, group, snapname1)
assert.NoError(t, err)