mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-05 12:45:38 +01:00
This also address review comments in PR 846. Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gluster/glusterd2/pkg/api"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const (
|
|
snapshotActivateHelpShort = "Activate a Gluster Snapshot"
|
|
snapshotActivateHelpLong = "Activate a Gluster snapshot. Force flag can be used to activate a snapshot forcefully. It will override some checks."
|
|
)
|
|
|
|
var (
|
|
flagSnapshotActivateCmdForce bool
|
|
|
|
snapshotActivateCmd = &cobra.Command{
|
|
Use: "activate <snapname>",
|
|
Short: snapshotActivateHelpShort,
|
|
Long: snapshotActivateHelpLong,
|
|
Args: cobra.ExactArgs(1),
|
|
Run: snapshotActivateCmdRun,
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
snapshotActivateCmd.Flags().BoolVarP(&flagSnapshotActivateCmdForce, "force", "f", false, "Force")
|
|
snapshotCmd.AddCommand(snapshotActivateCmd)
|
|
}
|
|
|
|
func snapshotActivateCmdRun(cmd *cobra.Command, args []string) {
|
|
snapname := cmd.Flags().Args()[0]
|
|
req := api.SnapActivateReq{
|
|
Force: flagSnapshotActivateCmdForce,
|
|
}
|
|
if err := client.SnapshotActivate(req, snapname); err != nil {
|
|
if GlobalFlag.Verbose {
|
|
log.WithError(err).WithField("snapshot", snapname).Error("snapshot activation failed")
|
|
}
|
|
failure("snapshot activation failed", err, 1)
|
|
}
|
|
fmt.Printf("Snapshot %s activated successfully\n", snapname)
|
|
}
|