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
@ -18,6 +18,7 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
@ -111,3 +112,19 @@ func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) {
|
||||
}
|
||||
return cluster.CephFS.SubvolumeGroup, nil
|
||||
}
|
||||
|
||||
// GetMonsAndClusterID returns monitors and clusterID information read from
|
||||
// configfile.
|
||||
func GetMonsAndClusterID(options map[string]string) (string, string, error) {
|
||||
clusterID, ok := options["clusterID"]
|
||||
if !ok {
|
||||
return "", "", errors.New("clusterID must be set")
|
||||
}
|
||||
|
||||
monitors, err := Mons(CsiConfigFile, clusterID)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err)
|
||||
}
|
||||
|
||||
return monitors, clusterID, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user