mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
util: move getMonsAndClusterID to util
as we had duplicate functions in both cephfs and rbd this commit moves the function to util. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
18f4e9d519
commit
bfde065f92
@ -19,7 +19,6 @@ package cephfs
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -135,8 +134,9 @@ func genSnapFromOptions(ctx context.Context, req *csi.CreateSnapshotRequest) (sn
|
||||
cephfsSnap.RequestName = req.GetName()
|
||||
snapOptions := req.GetParameters()
|
||||
|
||||
cephfsSnap.Monitors, cephfsSnap.ClusterID, err = getMonsAndClusterID(ctx, snapOptions)
|
||||
cephfsSnap.Monitors, cephfsSnap.ClusterID, err = util.GetMonsAndClusterID(snapOptions)
|
||||
if err != nil {
|
||||
klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err)
|
||||
return nil, err
|
||||
}
|
||||
if namePrefix, ok := snapOptions["snapshotNamePrefix"]; ok {
|
||||
@ -145,23 +145,6 @@ func genSnapFromOptions(ctx context.Context, req *csi.CreateSnapshotRequest) (sn
|
||||
return cephfsSnap, nil
|
||||
}
|
||||
|
||||
func getMonsAndClusterID(ctx context.Context, options map[string]string) (monitors, clusterID string, err error) {
|
||||
var ok bool
|
||||
|
||||
if clusterID, ok = options["clusterID"]; !ok {
|
||||
err = errors.New("clusterID must be set")
|
||||
return
|
||||
}
|
||||
|
||||
if monitors, err = util.Mons(util.CsiConfigFile, clusterID); err != nil {
|
||||
klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err)
|
||||
err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func parseTime(ctx context.Context, createTime string) (*timestamp.Timestamp, error) {
|
||||
tm := ×tamp.Timestamp{}
|
||||
layout := "2006-01-02 15:04:05.000000"
|
||||
|
Reference in New Issue
Block a user