mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cephfs: make getFsName() a method of volumeOptions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
f646840779
commit
0a3f9d3487
@ -96,13 +96,13 @@ type CephFilesystemDump struct {
|
||||
Filesystems []CephFilesystemDetails `json:"filesystems"`
|
||||
}
|
||||
|
||||
func getFsName(ctx context.Context, monitors string, cr *util.Credentials, fscID int64) (string, error) {
|
||||
func (vo *volumeOptions) getFsName(ctx context.Context, cr *util.Credentials) (string, error) {
|
||||
// ./tbox ceph fs dump --format=json
|
||||
// JSON: {...,"filesystems":[{"mdsmap":{},"id":<n>},...],...}
|
||||
var fsDump CephFilesystemDump
|
||||
err := execCommandJSON(ctx, &fsDump,
|
||||
"ceph",
|
||||
"-m", monitors,
|
||||
"-m", vo.Monitors,
|
||||
"--id", cr.ID,
|
||||
"--keyfile="+cr.KeyFile,
|
||||
"-c", util.CephConfigPath,
|
||||
@ -113,10 +113,10 @@ func getFsName(ctx context.Context, monitors string, cr *util.Credentials, fscID
|
||||
}
|
||||
|
||||
for _, fs := range fsDump.Filesystems {
|
||||
if fs.ID == fscID {
|
||||
if fs.ID == vo.FscID {
|
||||
return fs.MDSMap.FilesystemName, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("%w: fscID (%d) not found in Ceph cluster", util.ErrPoolNotFound, fscID)
|
||||
return "", fmt.Errorf("%w: fscID (%d) not found in Ceph cluster", util.ErrPoolNotFound, vo.FscID)
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
volOptions.FsName, err = getFsName(ctx, volOptions.Monitors, cr, volOptions.FscID)
|
||||
volOptions.FsName, err = volOptions.getFsName(ctx, cr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -478,7 +478,7 @@ func newSnapshotOptionsFromID(ctx context.Context, snapID string, cr *util.Crede
|
||||
return &volOptions, nil, &sid, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err)
|
||||
}
|
||||
|
||||
volOptions.FsName, err = getFsName(ctx, volOptions.Monitors, cr, volOptions.FscID)
|
||||
volOptions.FsName, err = volOptions.getFsName(ctx, cr)
|
||||
if err != nil {
|
||||
return &volOptions, nil, &sid, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user