diff --git a/cli/command/cmd.go b/cli/command/cmd.go index 57363a6a5..59f721701 100644 --- a/cli/command/cmd.go +++ b/cli/command/cmd.go @@ -26,13 +26,13 @@ package command import ( "fmt" + copycmd "github.com/opencurve/curveadm/cli/command/copy" "github.com/opencurve/curveadm/cli/cli" "github.com/opencurve/curveadm/cli/command/client" "github.com/opencurve/curveadm/cli/command/cluster" "github.com/opencurve/curveadm/cli/command/config" "github.com/opencurve/curveadm/cli/command/hosts" - "github.com/opencurve/curveadm/cli/command/install" "github.com/opencurve/curveadm/cli/command/monitor" "github.com/opencurve/curveadm/cli/command/pfs" "github.com/opencurve/curveadm/cli/command/playground" @@ -67,7 +67,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) { target.NewTargetCommand(curveadm), // curveadm target ... pfs.NewPFSCommand(curveadm), // curveadm pfs ... monitor.NewMonitorCommand(curveadm), // curveadm monitor ... - install.NewInstallCommand(curveadm), // curveadm install ... + copycmd.NewCopyCommand(curveadm), // curveadm copy ... NewAuditCommand(curveadm), // curveadm audit NewCleanCommand(curveadm), // curveadm clean diff --git a/cli/command/install/cmd.go b/cli/command/copy/cmd.go similarity index 83% rename from cli/command/install/cmd.go rename to cli/command/copy/cmd.go index f7fe12921..16add53f6 100644 --- a/cli/command/install/cmd.go +++ b/cli/command/copy/cmd.go @@ -16,11 +16,11 @@ /* * Project: CurveAdm - * Created Date: 2023-12-21 + * Created Date: 2023-12-25 * Author: Xinyu Zhuo (0fatal) */ -package install +package copy import ( "github.com/opencurve/curveadm/cli/cli" @@ -28,16 +28,16 @@ import ( "github.com/spf13/cobra" ) -func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCopyCommand(curveadm *cli.CurveAdm) *cobra.Command { cmd := &cobra.Command{ - Use: "install", - Short: "Manage install", + Use: "copy", + Short: "Manage copy", Args: cliutil.NoArgs, RunE: cliutil.ShowHelp(curveadm.Err()), } cmd.AddCommand( - NewInstallToolCommand(curveadm), + NewCopyTool2Command(curveadm), ) return cmd } diff --git a/cli/command/install/tool.go b/cli/command/copy/tool.go similarity index 74% rename from cli/command/install/tool.go rename to cli/command/copy/tool.go index 9e7f90614..a68c1a7a1 100644 --- a/cli/command/install/tool.go +++ b/cli/command/copy/tool.go @@ -16,11 +16,11 @@ /* * Project: CurveAdm - * Created Date: 2023-12-21 + * Created Date: 2023-12-25 * Author: Xinyu Zhuo (0fatal) */ -package install +package copy import ( "github.com/fatih/color" @@ -34,68 +34,68 @@ import ( ) var ( - INSTALL_TOOL_PLAYBOOK_STEPS = []int{ - playbook.INSTALL_TOOL, + COPY_TOOL_PLAYBOOK_STEPS = []int{ + playbook.COPY_TOOL, } ) -type installOptions struct { +type copyOptions struct { host string path string confPath string } -func NewInstallToolCommand(curveadm *cli.CurveAdm) *cobra.Command { - var options installOptions +func NewCopyTool2Command(curveadm *cli.CurveAdm) *cobra.Command { + var options copyOptions cmd := &cobra.Command{ Use: "tool [OPTIONS]", - Short: "Install tool v2 on the specified host", + Short: "Copy tool v2 on the specified host", Args: cliutil.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return runInstallTool(curveadm, options) + return runCopyTool(curveadm, options) }, DisableFlagsInUseLine: true, } flags := cmd.Flags() flags.StringVar(&options.host, "host", "localhost", "Specify target host") - flags.StringVar(&options.path, "path", "/usr/local/bin/curve", "Specify target install path of tool v2") + flags.StringVar(&options.path, "path", "/usr/local/bin/curve", "Specify target copy path of tool v2") flags.StringVar(&options.confPath, "confPath", "/etc/curve/curve.yaml", "Specify target config path of tool v2") return cmd } -func genInstallToolPlaybook(curveadm *cli.CurveAdm, +func genCopyToolPlaybook(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, - options installOptions, + options copyOptions, ) (*playbook.Playbook, error) { configs := curveadm.FilterDeployConfig(dcs, topology.FilterOption{Id: "*", Role: "*", Host: options.host})[:1] if len(configs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED } - steps := INSTALL_TOOL_PLAYBOOK_STEPS + steps := COPY_TOOL_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) for _, step := range steps { pb.AddStep(&playbook.PlaybookStep{ Type: step, Configs: configs, Options: map[string]interface{}{ - comm.KEY_INSTALL_PATH: options.path, - comm.KEY_INSTALL_CONF_PATH: options.confPath, + comm.KEY_COPY_PATH: options.path, + comm.KEY_COPY_CONF_PATH: options.confPath, }, }) } return pb, nil } -func runInstallTool(curveadm *cli.CurveAdm, options installOptions) error { +func runCopyTool(curveadm *cli.CurveAdm, options copyOptions) error { dcs, err := curveadm.ParseTopology() if err != nil { return err } - pb, err := genInstallToolPlaybook(curveadm, dcs, options) + pb, err := genCopyToolPlaybook(curveadm, dcs, options) if err != nil { return err } @@ -105,7 +105,7 @@ func runInstallTool(curveadm *cli.CurveAdm, options installOptions) error { return err } - curveadm.WriteOutln(color.GreenString("Install %s to %s success."), + curveadm.WriteOutln(color.GreenString("Copy %s to %s success."), "curve tool v2", options.host) return nil } diff --git a/internal/common/common.go b/internal/common/common.go index c28696ea1..b41cdd31e 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -118,9 +118,9 @@ const ( KEY_MONITOR_STATUS = "MONITOR_STATUS" CLEANED_MONITOR_CONF = "-" - // install - KEY_INSTALL_PATH = "INSTALL_PATH" - KEY_INSTALL_CONF_PATH = "INSTALL_CONF_PATH" + // copy + KEY_COPY_PATH = "COPY_PATH" + KEY_COPY_CONF_PATH = "COPY_CONF_PATH" ) // others diff --git a/internal/playbook/factory.go b/internal/playbook/factory.go index 52d786a75..55dbb9a22 100644 --- a/internal/playbook/factory.go +++ b/internal/playbook/factory.go @@ -31,7 +31,6 @@ import ( "github.com/opencurve/curveadm/internal/task/task/checker" comm "github.com/opencurve/curveadm/internal/task/task/common" "github.com/opencurve/curveadm/internal/task/task/fs" - "github.com/opencurve/curveadm/internal/task/task/install" "github.com/opencurve/curveadm/internal/task/task/monitor" pg "github.com/opencurve/curveadm/internal/task/task/playground" "github.com/opencurve/curveadm/internal/tasks" @@ -85,7 +84,7 @@ const ( INSTALL_CLIENT UNINSTALL_CLIENT ATTACH_LEADER_OR_RANDOM_CONTAINER - INSTALL_TOOL + COPY_TOOL // bs FORMAT_CHUNKFILE_POOL @@ -252,8 +251,8 @@ func (p *Playbook) createTasks(step *PlaybookStep) (*tasks.Tasks, error) { t, err = comm.NewInstallClientTask(curveadm, config.GetCC(i)) case UNINSTALL_CLIENT: t, err = comm.NewUninstallClientTask(curveadm, nil) - case INSTALL_TOOL: - t, err = install.NewInstallToolTask(curveadm, config.GetDC(i)) + case COPY_TOOL: + t, err = comm.NewCopyToolTask(curveadm, config.GetDC(i)) // bs case FORMAT_CHUNKFILE_POOL: t, err = bs.NewFormatChunkfilePoolTask(curveadm, config.GetFC(i)) diff --git a/internal/task/task/install/install_tool.go b/internal/task/task/common/copy_tool.go similarity index 91% rename from internal/task/task/install/install_tool.go rename to internal/task/task/common/copy_tool.go index cc1d23ed3..8f58b63e2 100644 --- a/internal/task/task/install/install_tool.go +++ b/internal/task/task/common/copy_tool.go @@ -20,7 +20,7 @@ * Author: Xinyu Zhuo (0fatal) */ -package install +package common import ( "fmt" @@ -51,10 +51,10 @@ func checkPathExist(path string, sshConfig *module.SSHConfig, curveadm *cli.Curv return nil } -func NewInstallToolTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCopyToolTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { layout := dc.GetProjectLayout() - path := curveadm.MemStorage().Get(comm.KEY_INSTALL_PATH).(string) - confPath := curveadm.MemStorage().Get(comm.KEY_INSTALL_CONF_PATH).(string) + path := curveadm.MemStorage().Get(comm.KEY_COPY_PATH).(string) + confPath := curveadm.MemStorage().Get(comm.KEY_COPY_CONF_PATH).(string) hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err