1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-05 12:45:38 +01:00
Files
glusterd2/glustercli/cmd/snapshot-restore.go
Madhu Rajanna 3c9ca8411b log errors with log.WithError()
during error logging we should log
with WithError()

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
2018-08-09 14:29:28 +05:30

43 lines
1.0 KiB
Go

package cmd
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
const (
snapshotRestoreHelpShort = "Restore a Gluster Snapshot to it's parent volume"
snapshotRestoreHelpLong = "Parent volume will be restored from the snap, which include data as well as the configuration"
)
var (
snapshotRestoreCmd = &cobra.Command{
Use: "restore <snapname>",
Short: snapshotRestoreHelpShort,
Long: snapshotRestoreHelpLong,
Args: cobra.ExactArgs(1),
Run: snapshotRestoreCmdRun,
}
)
func init() {
snapshotCmd.AddCommand(snapshotRestoreCmd)
}
func snapshotRestoreCmdRun(cmd *cobra.Command, args []string) {
snapname := cmd.Flags().Args()[0]
vol, err := client.SnapshotRestore(snapname)
if err != nil {
if GlobalFlag.Verbose {
log.WithError(err).WithFields(log.Fields{
"snapshot": snapname,
"volume": vol.Name,
}).Error("snapshot restore failed")
}
failure("snapshot activation failed", err, 1)
}
fmt.Printf("Snapshot %s restored successfully to volume %s\n", snapname, vol.Name)
}