mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: add MakeVolumeGroupID() utility function
The Manager.MakeVolumeGroupID() function can be used to build a CSI VolumeGroupID from the backend (pool and name of the RBD-group). This will be used when checking if an RBD-image belongs to a group already. It is also possible to resolve the VolumeGroup by passing the VolumeGroupID to the existing Manager.GetVolumeGroupByID() function. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
@ -238,6 +238,21 @@ func (mgr *rbdManager) GetVolumeGroupByID(ctx context.Context, id string) (types
|
||||
return vg, nil
|
||||
}
|
||||
|
||||
func (mgr *rbdManager) MakeVolumeGroupID(ctx context.Context, poolID int64, name string) (string, error) {
|
||||
clusterID, err := util.GetClusterID(mgr.parameters)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get cluster-id: %w", err)
|
||||
}
|
||||
|
||||
// convert the clusterid, poolid and name to an id/handle
|
||||
id, err := journal.MakeVolumeGroupID(clusterID, poolID, name, mgr.getVolumeGroupNamePrefix())
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to convert name %q to a CSI-handle: %w", name, err)
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (types.VolumeGroup, error) {
|
||||
creds, err := mgr.getCredentials()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user