2023-06-08 05:41:52 +00:00
|
|
|
//go:build !(nautilus || octopus || pacific)
|
|
|
|
// +build !nautilus,!octopus,!pacific
|
2022-05-30 12:28:31 +00:00
|
|
|
|
|
|
|
package admin
|
|
|
|
|
|
|
|
// GetSnapshotMetadata gets custom metadata on the subvolume snapshot in a
|
|
|
|
// volume belonging to an optional subvolume group based on provided key name.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume snapshot metadata get <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>]
|
2022-05-30 12:28:31 +00:00
|
|
|
func (fsa *FSAdmin) GetSnapshotMetadata(volume, group, subvolume, snapname, key string) (string, error) {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume snapshot metadata get",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"snap_name": snapname,
|
|
|
|
"key_name": key,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return parsePathResponse(fsa.marshalMgrCommand(m))
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSnapshotMetadata sets custom metadata on the subvolume snapshot in a
|
|
|
|
// volume belonging to an optional subvolume group as a key-value pair.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume snapshot metadata set <vol_name> <sub_name> <snap_name> <key_name> <value> [--group_name <subvol_group_name>]
|
2022-05-30 12:28:31 +00:00
|
|
|
func (fsa *FSAdmin) SetSnapshotMetadata(volume, group, subvolume, snapname, key, value string) error {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume snapshot metadata set",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"snap_name": snapname,
|
|
|
|
"key_name": key,
|
|
|
|
"value": value,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return fsa.marshalMgrCommand(m).NoData().End()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveSnapshotMetadata removes custom metadata set on the subvolume
|
|
|
|
// snapshot in a volume belonging to an optional subvolume group using the
|
|
|
|
// metadata key.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>]
|
2022-05-30 12:28:31 +00:00
|
|
|
func (fsa *FSAdmin) RemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error {
|
|
|
|
return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ForceRemoveSnapshotMetadata attempt to forcefully remove custom metadata
|
|
|
|
// set on the subvolume snapshot in a volume belonging to an optional
|
|
|
|
// subvolume group using the metadata key.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>] --force
|
2022-05-30 12:28:31 +00:00
|
|
|
func (fsa *FSAdmin) ForceRemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error {
|
|
|
|
return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{force: true})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fsa *FSAdmin) rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key string, o commonRmFlags) error {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume snapshot metadata rm",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"snap_name": snapname,
|
|
|
|
"key_name": key,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return fsa.marshalMgrCommand(mergeFlags(m, o)).NoData().End()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListSnapshotMetadata lists custom metadata (key-value pairs) set on the subvolume
|
|
|
|
// snapshot in a volume belonging to an optional subvolume group.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume snapshot metadata ls <vol_name> <sub_name> <snap_name> [--group_name <subvol_group_name>]
|
2022-05-30 12:28:31 +00:00
|
|
|
func (fsa *FSAdmin) ListSnapshotMetadata(volume, group, subvolume, snapname string) (map[string]string, error) {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume snapshot metadata ls",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"snap_name": snapname,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseListKeyValues(fsa.marshalMgrCommand(m))
|
|
|
|
}
|