2023-06-26 20:59:30 +00:00
|
|
|
//go:build !(nautilus || octopus || pacific)
|
|
|
|
// +build !nautilus,!octopus,!pacific
|
2022-06-15 05:34:25 +00:00
|
|
|
|
|
|
|
package admin
|
|
|
|
|
|
|
|
// GetMetadata gets custom metadata on the subvolume in a volume belonging to
|
|
|
|
// an optional subvolume group based on provided key name.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-04-26 07:05:57 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume metadata get <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>]
|
2022-06-15 05:34:25 +00:00
|
|
|
func (fsa *FSAdmin) GetMetadata(volume, group, subvolume, key string) (string, error) {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume metadata get",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"key_name": key,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return parsePathResponse(fsa.marshalMgrCommand(m))
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMetadata sets custom metadata on the subvolume in a volume belonging to
|
|
|
|
// an optional subvolume group as a key-value pair.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-04-26 07:05:57 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume metadata set <vol_name> <sub_name> <key_name> <value> [--group_name <subvol_group_name>]
|
2022-06-15 05:34:25 +00:00
|
|
|
func (fsa *FSAdmin) SetMetadata(volume, group, subvolume, key, value string) error {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume metadata set",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"key_name": key,
|
|
|
|
"value": value,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return fsa.marshalMgrCommand(m).NoData().End()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveMetadata removes custom metadata set on the subvolume in a volume
|
|
|
|
// belonging to an optional subvolume group using the metadata key.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-04-26 07:05:57 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>]
|
2022-06-15 05:34:25 +00:00
|
|
|
func (fsa *FSAdmin) RemoveMetadata(volume, group, subvolume, key string) error {
|
|
|
|
return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ForceRemoveMetadata attempt to forcefully remove custom metadata set on
|
|
|
|
// the subvolume in a volume belonging to an optional subvolume group using
|
|
|
|
// the metadata key.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-04-26 07:05:57 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>] --force
|
2022-06-15 05:34:25 +00:00
|
|
|
func (fsa *FSAdmin) ForceRemoveMetadata(volume, group, subvolume, key string) error {
|
|
|
|
return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{force: true})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fsa *FSAdmin) rmSubVolumeMetadata(volume, group, subvolume, key string, o commonRmFlags) error {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume metadata rm",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
"key_name": key,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return fsa.marshalMgrCommand(mergeFlags(m, o)).NoData().End()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListMetadata lists custom metadata (key-value pairs) set on the subvolume
|
|
|
|
// in a volume belonging to an optional subvolume group.
|
|
|
|
//
|
|
|
|
// Similar To:
|
2023-04-26 07:05:57 +00:00
|
|
|
//
|
|
|
|
// ceph fs subvolume metadata ls <vol_name> <sub_name> [--group_name <subvol_group_name>]
|
2022-06-15 05:34:25 +00:00
|
|
|
func (fsa *FSAdmin) ListMetadata(volume, group, subvolume string) (map[string]string, error) {
|
|
|
|
m := map[string]string{
|
|
|
|
"prefix": "fs subvolume metadata ls",
|
|
|
|
"format": "json",
|
|
|
|
"vol_name": volume,
|
|
|
|
"sub_name": subvolume,
|
|
|
|
}
|
|
|
|
|
|
|
|
if group != NoGroup {
|
|
|
|
m["group_name"] = group
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseListKeyValues(fsa.marshalMgrCommand(m))
|
|
|
|
}
|