mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +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"`
|
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
|
// ./tbox ceph fs dump --format=json
|
||||||
// JSON: {...,"filesystems":[{"mdsmap":{},"id":<n>},...],...}
|
// JSON: {...,"filesystems":[{"mdsmap":{},"id":<n>},...],...}
|
||||||
var fsDump CephFilesystemDump
|
var fsDump CephFilesystemDump
|
||||||
err := execCommandJSON(ctx, &fsDump,
|
err := execCommandJSON(ctx, &fsDump,
|
||||||
"ceph",
|
"ceph",
|
||||||
"-m", monitors,
|
"-m", vo.Monitors,
|
||||||
"--id", cr.ID,
|
"--id", cr.ID,
|
||||||
"--keyfile="+cr.KeyFile,
|
"--keyfile="+cr.KeyFile,
|
||||||
"-c", util.CephConfigPath,
|
"-c", util.CephConfigPath,
|
||||||
@ -113,10 +113,10 @@ func getFsName(ctx context.Context, monitors string, cr *util.Credentials, fscID
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, fs := range fsDump.Filesystems {
|
for _, fs := range fsDump.Filesystems {
|
||||||
if fs.ID == fscID {
|
if fs.ID == vo.FscID {
|
||||||
return fs.MDSMap.FilesystemName, nil
|
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
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
volOptions.FsName, err = getFsName(ctx, volOptions.Monitors, cr, volOptions.FscID)
|
volOptions.FsName, err = volOptions.getFsName(ctx, cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
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)
|
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 {
|
if err != nil {
|
||||||
return &volOptions, nil, &sid, err
|
return &volOptions, nil, &sid, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user