cephfs: make createSnapshot() a method of volumeOptions

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-11-04 13:46:31 +01:00 committed by Madhu Rajanna
parent 50d884bad3
commit 57f8ee0aa7
3 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ const (
func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volOpt, parentvolOpt *volumeOptions, cr *util.Credentials) error { func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volOpt, parentvolOpt *volumeOptions, cr *util.Credentials) error {
snapshotID := cloneID snapshotID := cloneID
err := createSnapshot(ctx, parentvolOpt, cr, snapshotID, volID) err := parentvolOpt.createSnapshot(ctx, cr, snapshotID, volID)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to create snapshot %s %v", snapshotID, err) util.ErrorLog(ctx, "failed to create snapshot %s %v", snapshotID, err)
return err return err

View File

@ -587,7 +587,7 @@ func doSnapshot(ctx context.Context, volOpt *volumeOptions, subvolumeName, snaps
volID := volumeID(subvolumeName) volID := volumeID(subvolumeName)
snapID := volumeID(snapshotName) snapID := volumeID(snapshotName)
snap := snapshotInfo{} snap := snapshotInfo{}
err := createSnapshot(ctx, volOpt, cr, snapID, volID) err := volOpt.createSnapshot(ctx, cr, snapID, volID)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to create snapshot %s %v", snapID, err) util.ErrorLog(ctx, "failed to create snapshot %s %v", snapID, err)
return snap, err return snap, err

View File

@ -45,18 +45,18 @@ type cephfsSnapshot struct {
ReservedID string ReservedID string
} }
func createSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, snapID, volID volumeID) error { func (vo *volumeOptions) createSnapshot(ctx context.Context, cr *util.Credentials, snapID, volID volumeID) error {
args := []string{ args := []string{
"fs", "fs",
"subvolume", "subvolume",
"snapshot", "snapshot",
"create", "create",
volOptions.FsName, vo.FsName,
string(volID), string(volID),
string(snapID), string(snapID),
"--group_name", "--group_name",
volOptions.SubvolumeGroup, vo.SubvolumeGroup,
"-m", volOptions.Monitors, "-m", vo.Monitors,
"-c", util.CephConfigPath, "-c", util.CephConfigPath,
"-n", cephEntityClientPrefix + cr.ID, "-n", cephEntityClientPrefix + cr.ID,
"--keyfile=" + cr.KeyFile, "--keyfile=" + cr.KeyFile,
@ -67,7 +67,7 @@ func createSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Cre
"ceph", "ceph",
args[:]...) args[:]...)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to create subvolume snapshot %s %s(%s) in fs %s", string(snapID), string(volID), err, volOptions.FsName) util.ErrorLog(ctx, "failed to create subvolume snapshot %s %s(%s) in fs %s", string(snapID), string(volID), err, vo.FsName)
return err return err
} }
return nil return nil