From 0a3f9d34870f1aa80ed5b3e7864a0d1694ee3681 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 2 Oct 2020 10:37:52 +0200 Subject: [PATCH] cephfs: make getFsName() a method of volumeOptions Signed-off-by: Niels de Vos --- internal/cephfs/cephfs_util.go | 8 ++++---- internal/cephfs/volumeoptions.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/cephfs/cephfs_util.go b/internal/cephfs/cephfs_util.go index 7cb987e80..247e2767e 100644 --- a/internal/cephfs/cephfs_util.go +++ b/internal/cephfs/cephfs_util.go @@ -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":},...],...} 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) } diff --git a/internal/cephfs/volumeoptions.go b/internal/cephfs/volumeoptions.go index c80181a82..37ad20f04 100644 --- a/internal/cephfs/volumeoptions.go +++ b/internal/cephfs/volumeoptions.go @@ -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 }