-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package stop | ||
|
||
import ( | ||
basecmd "github.com/opencurve/curve/tools-v2/pkg/cli/command" | ||
snapshot "github.com/opencurve/curve/tools-v2/pkg/cli/command/curvebs/stop/volume" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type StopCommand struct { | ||
basecmd.MidCurveCmd | ||
} | ||
|
||
var _ basecmd.MidCurveCmdFunc = (*StopCommand)(nil) | ||
|
||
func (dCmd *StopCommand) AddSubCommands() { | ||
dCmd.Cmd.AddCommand( | ||
snapshot.NewSnapShotCommand(), | ||
) | ||
} | ||
|
||
func NewDeleteCommand() *cobra.Command { | ||
dCmd := &StopCommand{ | ||
basecmd.MidCurveCmd{ | ||
Use: "stop", | ||
Short: "stop resources in the curvebs", | ||
}, | ||
} | ||
return basecmd.NewMidCurveCli(&dCmd.MidCurveCmd, dCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package snapshot | ||
|
||
import ( | ||
"context" | ||
|
||
basecmd "github.com/opencurve/curve/tools-v2/pkg/cli/command" | ||
"github.com/opencurve/curve/tools-v2/pkg/config" | ||
"github.com/opencurve/curve/tools-v2/pkg/output" | ||
"github.com/opencurve/curve/tools-v2/proto/proto/nameserver2" | ||
"github.com/spf13/cobra" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
const ( | ||
stopCliExample = `` | ||
) | ||
|
||
type StopSnapshotRpc struct { | ||
Info *basecmd.Rpc | ||
Request *nameserver2.StopSnapShotRequest | ||
mdsClient nameserver2.CurveFSServiceClient | ||
} | ||
|
||
type StopCommand struct { | ||
basecmd.FinalCurveCmd | ||
Rpc *StopSnapshotRpc | ||
Response *nameserver2.StopSnapshotResponse | ||
} | ||
|
||
var _ basecmd.FinalCurveCmdFunc = (*StopCommand)(nil) | ||
|
||
func (gRpc *StopSnapshotRpc) NewRpcClient(cc grpc.ClientConnInterface) { | ||
gRpc.mdsClient = nameserver2.NewCurveFSServiceClient(cc) | ||
} | ||
|
||
func (gRpc *StopSnapshotRpc) Stub_Func(ctx context.Context) (interface{}, error) { | ||
return gRpc.mdsClient.StopSnapshot(ctx, gRpc.Request) | ||
} | ||
|
||
func (deleteCommand *StopCommand) Init(cmd *cobra.Command, args []string) error { | ||
return nil | ||
} | ||
|
||
func (deleteCommand *StopCommand) RunCommand(cmd *cobra.Command, args []string) error { | ||
return nil | ||
} | ||
|
||
func (stopCommand *StopCommand) Print(cmd *cobra.Command, args []string) error { | ||
return output.FinalCmdOutput(&stopCommand.FinalCurveCmd, stopCommand) | ||
} | ||
|
||
func (stopCommand *StopCommand) ResultPlainOutput() error { | ||
return output.FinalCmdOutputPlain(&stopCommand.FinalCurveCmd) | ||
} | ||
|
||
func (stopCommand *StopCommand) AddFlags() { | ||
config.AddBsMdsFlagOption(stopCommand.Cmd) | ||
config.AddRpcTimeoutFlag(stopCommand.Cmd) | ||
config.AddRpcRetryTimesFlag(stopCommand.Cmd) | ||
|
||
config.AddBsPathRequiredFlag(stopCommand.Cmd) | ||
config.AddBsSnapshotSeqRequiredFlag(stopCommand.Cmd) | ||
config.AddBsUserOptionFlag(stopCommand.Cmd) | ||
config.AddBsPasswordOptionFlag(stopCommand.Cmd) | ||
} | ||
|
||
func NewStopSnapShotCommand() *StopCommand { | ||
stopCommand := &StopCommand{ | ||
FinalCurveCmd: basecmd.FinalCurveCmd{ | ||
Use: "volume snapshot", | ||
Short: "delete volume snapshot in curvebs", | ||
Example: stopCliExample, | ||
}, | ||
} | ||
basecmd.NewFinalCurveCli(&stopCommand.FinalCurveCmd, stopCommand) | ||
return stopCommand | ||
} | ||
|
||
func NewSnapShotCommand() *cobra.Command { | ||
return NewStopSnapShotCommand().Cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters