mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: add unset volume/snapshot metadata utility functions
Added GetVolumeMetadataKeys() GetSnaoshotMetadataKeys() unsetVolumeMetadata() and unsetSnapshotMetadata() functions. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
1fd5277b3c
commit
bac33262ae
@ -1923,3 +1923,16 @@ func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// unsetAllMetadata unset all the metadata from arg keys on RBD image.
|
||||
func (rv *rbdVolume) unsetAllMetadata(keys []string) error {
|
||||
for _, key := range keys {
|
||||
err := rv.RemoveMetadata(key)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
return fmt.Errorf("failed to unset metadata key %q on %q: %w", key, rv, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -69,6 +69,15 @@ func GetVolumeMetadata(parameters map[string]string) map[string]string {
|
||||
return newParam
|
||||
}
|
||||
|
||||
// GetVolumeMetadataKeys return volume metadata keys.
|
||||
func GetVolumeMetadataKeys() []string {
|
||||
return []string{
|
||||
pvcNameKey,
|
||||
pvcNamespaceKey,
|
||||
pvNameKey,
|
||||
}
|
||||
}
|
||||
|
||||
// PrepareVolumeMetadata return PV/PVC/PVCNamespace metadata based on inputs.
|
||||
func PrepareVolumeMetadata(pvcName, pvcNamespace, pvName string) map[string]string {
|
||||
newParam := map[string]string{}
|
||||
@ -100,3 +109,12 @@ func GetSnapshotMetadata(parameters map[string]string) map[string]string {
|
||||
|
||||
return newParam
|
||||
}
|
||||
|
||||
// GetSnapshotMetadataKeys return snapshot metadata keys.
|
||||
func GetSnapshotMetadataKeys() []string {
|
||||
return []string{
|
||||
volSnapNameKey,
|
||||
volSnapNamespaceKey,
|
||||
volSnapContentNameKey,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user