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 {
snapshotID := cloneID
err := createSnapshot(ctx, parentvolOpt, cr, snapshotID, volID)
err := parentvolOpt.createSnapshot(ctx, cr, snapshotID, volID)
if err != nil {
util.ErrorLog(ctx, "failed to create snapshot %s %v", snapshotID, err)
return err

View File

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

View File

@ -45,18 +45,18 @@ type cephfsSnapshot struct {
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{
"fs",
"subvolume",
"snapshot",
"create",
volOptions.FsName,
vo.FsName,
string(volID),
string(snapID),
"--group_name",
volOptions.SubvolumeGroup,
"-m", volOptions.Monitors,
vo.SubvolumeGroup,
"-m", vo.Monitors,
"-c", util.CephConfigPath,
"-n", cephEntityClientPrefix + cr.ID,
"--keyfile=" + cr.KeyFile,
@ -67,7 +67,7 @@ func createSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Cre
"ceph",
args[:]...)
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 nil