cephfs: implement getVolumeRootPathCeph with go-ceph

instead of ceph fs CLI commands using go-ceph library
to get subvolume path.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-11-26 13:55:48 +05:30 committed by mergify[bot]
parent 5565a902ac
commit b6f3ba885e

View File

@ -57,30 +57,20 @@ func getVolumeRootPathCephDeprecated(volID volumeID) string {
} }
func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (string, error) { func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (string, error) {
stdout, stderr, err := util.ExecCommand( fsa, err := volOptions.conn.GetFSAdmin()
ctx,
"ceph",
"fs",
"subvolume",
"getpath",
volOptions.FsName,
string(volID),
"--group_name",
volOptions.SubvolumeGroup,
"-m", volOptions.Monitors,
"-c", util.CephConfigPath,
"-n", cephEntityClientPrefix+cr.ID,
"--keyfile="+cr.KeyFile)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to get the rootpath for the vol %s: %s (stdError: %s)", string(volID), err, stderr) util.ErrorLog(ctx, "could not get FSAdmin err %s", err)
if strings.Contains(stderr, volumeNotFound) {
return "", util.JoinErrors(ErrVolumeNotFound, err)
}
return "", err return "", err
} }
return strings.TrimSuffix(stdout, "\n"), nil svPath, err := fsa.SubVolumePath(volOptions.FsName, volOptions.SubvolumeGroup, string(volID))
if err != nil {
util.ErrorLog(ctx, "failed to get the rootpath for the vol %s: %s", string(volID), err)
if strings.Contains(err.Error(), volumeNotFound) {
return "", util.JoinErrors(ErrVolumeNotFound, err)
}
return "", err
}
return svPath, nil
} }
func (vo *volumeOptions) getSubVolumeInfo(ctx context.Context, volID volumeID) (*Subvolume, error) { func (vo *volumeOptions) getSubVolumeInfo(ctx context.Context, volID volumeID) (*Subvolume, error) {