diff --git a/Makefile b/Makefile index b3541c8c5..988a6ed8a 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ OUTPUT := bin/dingoadm # build flags LDFLAGS := -s -w LDFLAGS += -extldflags "-static -fpic" -LDFLAGS += -X github.com/dingodb/curveadm/cli/cli.CommitId=$(shell git rev-parse --short HEAD) +LDFLAGS += -X github.com/dingodb/dingoadm/cli/cli.CommitId=$(shell git rev-parse --short HEAD) BUILD_FLAGS := -a BUILD_FLAGS += -trimpath @@ -51,7 +51,7 @@ TEST_FLAGS += $(DEBUG_FLAGS) TEST_FLAGS += -run $(CASE) # packages -PACKAGES := $(PWD)/cmd/curveadm/main.go +PACKAGES := $(PWD)/cmd/dingoadm/main.go # tar VERSION := "unknown" @@ -63,7 +63,7 @@ debug: $(GOENV) $(GO) build -o $(OUTPUT) $(DEBUG_FLAGS) $(PACKAGES) install: - cp bin/dingoadm ~/.curveadm/bin + cp bin/dingoadm ~/.dingoadm/bin test: $(GO_TEST) $(TEST_FLAGS) ./... diff --git a/cli/cli/cli.go b/cli/cli/cli.go index 2b95e9050..0d3a60eae 100644 --- a/cli/cli/cli.go +++ b/cli/cli/cli.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ import ( "time" comm "github.com/dingodb/dingoadm/internal/common" - configure "github.com/dingodb/dingoadm/internal/configure/curveadm" + configure "github.com/dingodb/dingoadm/internal/configure/dingoadm" "github.com/dingodb/dingoadm/internal/configure/hosts" "github.com/dingodb/dingoadm/internal/configure/topology" "github.com/dingodb/dingoadm/internal/errno" @@ -45,7 +46,7 @@ import ( "github.com/dingodb/dingoadm/pkg/module" ) -type CurveAdm struct { +type DingoAdm struct { // project layout rootDir string dataDir string @@ -81,14 +82,14 @@ type CurveAdm struct { * - /logs/2006-01-02_15-04-05.log * - /temp/ */ -func NewCurveAdm() (*CurveAdm, error) { +func NewDingoAdm() (*DingoAdm, error) { home, err := os.UserHomeDir() if err != nil { return nil, errno.ERR_GET_USER_HOME_DIR_FAILED.E(err) } rootDir := fmt.Sprintf("%s/.dingoadm", home) - curveadm := &CurveAdm{ + dingoadm := &DingoAdm{ rootDir: rootDir, dataDir: path.Join(rootDir, "data"), pluginDir: path.Join(rootDir, "plugins"), @@ -96,23 +97,23 @@ func NewCurveAdm() (*CurveAdm, error) { tempDir: path.Join(rootDir, "temp"), } - err = curveadm.init() + err = dingoadm.init() if err != nil { return nil, err } - go curveadm.detectVersion() - return curveadm, nil + go dingoadm.detectVersion() + return dingoadm, nil } -func (curveadm *CurveAdm) init() error { +func (dingoadm *DingoAdm) init() error { // (1) Create directory dirs := []string{ - curveadm.rootDir, - curveadm.dataDir, - curveadm.pluginDir, - curveadm.logDir, - curveadm.tempDir, + dingoadm.rootDir, + dingoadm.dataDir, + dingoadm.pluginDir, + dingoadm.logDir, + dingoadm.tempDir, } for _, dir := range dirs { if err := os.MkdirAll(dir, os.ModePerm); err != nil { @@ -121,7 +122,7 @@ func (curveadm *CurveAdm) init() error { } // (2) Parse dingoadm.cfg - confpath := fmt.Sprintf("%s/dingoadm.cfg", curveadm.rootDir) + confpath := fmt.Sprintf("%s/dingoadm.cfg", dingoadm.rootDir) config, err := configure.ParseCurveAdmConfig(confpath) if err != nil { return err @@ -130,7 +131,7 @@ func (curveadm *CurveAdm) init() error { // (3) Init logger now := time.Now().Format("2006-01-02_15-04-05") - logpath := fmt.Sprintf("%s/dingoadm-%s.log", curveadm.logDir, now) + logpath := fmt.Sprintf("%s/dingoadm-%s.log", dingoadm.logDir, now) if err := log.Init(config.GetLogLevel(), logpath); err != nil { return errno.ERR_INIT_LOGGER_FAILED.E(err) } else { @@ -181,31 +182,31 @@ func (curveadm *CurveAdm) init() error { return errno.ERR_GET_MONITOR_FAILED.E(err) } - curveadm.logpath = logpath - curveadm.config = config - curveadm.in = os.Stdin - curveadm.out = os.Stdout - curveadm.err = os.Stderr - curveadm.storage = s - curveadm.memStorage = utils.NewSafeMap() - curveadm.hosts = hosts.Data - curveadm.clusterId = cluster.Id - curveadm.clusterUUId = cluster.UUId - curveadm.clusterName = cluster.Name - curveadm.clusterTopologyData = cluster.Topology - curveadm.clusterPoolData = cluster.Pool - curveadm.monitor = monitor + dingoadm.logpath = logpath + dingoadm.config = config + dingoadm.in = os.Stdin + dingoadm.out = os.Stdout + dingoadm.err = os.Stderr + dingoadm.storage = s + dingoadm.memStorage = utils.NewSafeMap() + dingoadm.hosts = hosts.Data + dingoadm.clusterId = cluster.Id + dingoadm.clusterUUId = cluster.UUId + dingoadm.clusterName = cluster.Name + dingoadm.clusterTopologyData = cluster.Topology + dingoadm.clusterPoolData = cluster.Pool + dingoadm.monitor = monitor return nil } -func (curveadm *CurveAdm) detectVersion() { +func (dingoadm *DingoAdm) detectVersion() { latestVersion, err := tools.GetLatestVersion(Version) if err != nil || len(latestVersion) == 0 { return } - versions, err := curveadm.Storage().GetVersions() + versions, err := dingoadm.Storage().GetVersions() if err != nil { return } else if len(versions) > 0 { @@ -215,15 +216,15 @@ func (curveadm *CurveAdm) detectVersion() { } } - curveadm.Storage().SetVersion(latestVersion, "") + dingoadm.Storage().SetVersion(latestVersion, "") } -func (curveadm *CurveAdm) Upgrade() (bool, error) { - if curveadm.config.GetAutoUpgrade() == false { +func (dingoadm *DingoAdm) Upgrade() (bool, error) { + if dingoadm.config.GetAutoUpgrade() == false { return false, nil } - versions, err := curveadm.Storage().GetVersions() + versions, err := dingoadm.Storage().GetVersions() if err != nil || len(versions) == 0 { return false, nil } @@ -242,7 +243,7 @@ func (curveadm *CurveAdm) Upgrade() (bool, error) { return false, nil } - curveadm.Storage().SetVersion(latestVersion, day) + dingoadm.Storage().SetVersion(latestVersion, day) pass := tui.ConfirmYes(tui.PromptAutoUpgrade(latestVersion)) if !pass { return false, errno.ERR_CANCEL_OPERATION @@ -255,35 +256,35 @@ func (curveadm *CurveAdm) Upgrade() (bool, error) { return true, nil } -func (curveadm *CurveAdm) RootDir() string { return curveadm.rootDir } -func (curveadm *CurveAdm) DataDir() string { return curveadm.dataDir } -func (curveadm *CurveAdm) PluginDir() string { return curveadm.pluginDir } -func (curveadm *CurveAdm) LogDir() string { return curveadm.logDir } -func (curveadm *CurveAdm) TempDir() string { return curveadm.tempDir } -func (curveadm *CurveAdm) LogPath() string { return curveadm.logpath } -func (curveadm *CurveAdm) Config() *configure.CurveAdmConfig { return curveadm.config } -func (curveadm *CurveAdm) SudoAlias() string { return curveadm.config.GetSudoAlias() } -func (curveadm *CurveAdm) SSHTimeout() int { return curveadm.config.GetSSHTimeout() } -func (curveadm *CurveAdm) Engine() string { return curveadm.config.GetEngine() } -func (curveadm *CurveAdm) In() io.Reader { return curveadm.in } -func (curveadm *CurveAdm) Out() io.Writer { return curveadm.out } -func (curveadm *CurveAdm) Err() io.Writer { return curveadm.err } -func (curveadm *CurveAdm) Storage() *storage.Storage { return curveadm.storage } -func (curveadm *CurveAdm) MemStorage() *utils.SafeMap { return curveadm.memStorage } -func (curveadm *CurveAdm) Hosts() string { return curveadm.hosts } -func (curveadm *CurveAdm) ClusterId() int { return curveadm.clusterId } -func (curveadm *CurveAdm) ClusterUUId() string { return curveadm.clusterUUId } -func (curveadm *CurveAdm) ClusterName() string { return curveadm.clusterName } -func (curveadm *CurveAdm) ClusterTopologyData() string { return curveadm.clusterTopologyData } -func (curveadm *CurveAdm) ClusterPoolData() string { return curveadm.clusterPoolData } -func (curveadm *CurveAdm) Monitor() storage.Monitor { return curveadm.monitor } - -func (curveadm *CurveAdm) GetHost(host string) (*hosts.HostConfig, error) { - if len(curveadm.Hosts()) == 0 { +func (dingoadm *DingoAdm) RootDir() string { return dingoadm.rootDir } +func (dingoadm *DingoAdm) DataDir() string { return dingoadm.dataDir } +func (dingoadm *DingoAdm) PluginDir() string { return dingoadm.pluginDir } +func (dingoadm *DingoAdm) LogDir() string { return dingoadm.logDir } +func (dingoadm *DingoAdm) TempDir() string { return dingoadm.tempDir } +func (dingoadm *DingoAdm) LogPath() string { return dingoadm.logpath } +func (dingoadm *DingoAdm) Config() *configure.CurveAdmConfig { return dingoadm.config } +func (dingoadm *DingoAdm) SudoAlias() string { return dingoadm.config.GetSudoAlias() } +func (dingoadm *DingoAdm) SSHTimeout() int { return dingoadm.config.GetSSHTimeout() } +func (dingoadm *DingoAdm) Engine() string { return dingoadm.config.GetEngine() } +func (dingoadm *DingoAdm) In() io.Reader { return dingoadm.in } +func (dingoadm *DingoAdm) Out() io.Writer { return dingoadm.out } +func (dingoadm *DingoAdm) Err() io.Writer { return dingoadm.err } +func (dingoadm *DingoAdm) Storage() *storage.Storage { return dingoadm.storage } +func (dingoadm *DingoAdm) MemStorage() *utils.SafeMap { return dingoadm.memStorage } +func (dingoadm *DingoAdm) Hosts() string { return dingoadm.hosts } +func (dingoadm *DingoAdm) ClusterId() int { return dingoadm.clusterId } +func (dingoadm *DingoAdm) ClusterUUId() string { return dingoadm.clusterUUId } +func (dingoadm *DingoAdm) ClusterName() string { return dingoadm.clusterName } +func (dingoadm *DingoAdm) ClusterTopologyData() string { return dingoadm.clusterTopologyData } +func (dingoadm *DingoAdm) ClusterPoolData() string { return dingoadm.clusterPoolData } +func (dingoadm *DingoAdm) Monitor() storage.Monitor { return dingoadm.monitor } + +func (dingoadm *DingoAdm) GetHost(host string) (*hosts.HostConfig, error) { + if len(dingoadm.Hosts()) == 0 { return nil, errno.ERR_HOST_NOT_FOUND. F("host: %s", host) } - hcs, err := hosts.ParseHosts(curveadm.Hosts()) + hcs, err := hosts.ParseHosts(dingoadm.Hosts()) if err != nil { return nil, err } @@ -297,9 +298,9 @@ func (curveadm *CurveAdm) GetHost(host string) (*hosts.HostConfig, error) { F("host: %s", host) } -func (curveadm *CurveAdm) ParseTopologyData(data string) ([]*topology.DeployConfig, error) { +func (dingoadm *DingoAdm) ParseTopologyData(data string) ([]*topology.DeployConfig, error) { ctx := topology.NewContext() - hcs, err := hosts.ParseHosts(curveadm.Hosts()) + hcs, err := hosts.ParseHosts(dingoadm.Hosts()) if err != nil { return nil, err } @@ -316,21 +317,21 @@ func (curveadm *CurveAdm) ParseTopologyData(data string) ([]*topology.DeployConf return dcs, err } -func (curveadm *CurveAdm) ParseTopology() ([]*topology.DeployConfig, error) { - if curveadm.ClusterId() == -1 { +func (dingoadm *DingoAdm) ParseTopology() ([]*topology.DeployConfig, error) { + if dingoadm.ClusterId() == -1 { return nil, errno.ERR_NO_CLUSTER_SPECIFIED } - return curveadm.ParseTopologyData(curveadm.ClusterTopologyData()) + return dingoadm.ParseTopologyData(dingoadm.ClusterTopologyData()) } -func (curveadm *CurveAdm) FilterDeployConfig(deployConfigs []*topology.DeployConfig, +func (dingoadm *DingoAdm) FilterDeployConfig(deployConfigs []*topology.DeployConfig, options topology.FilterOption) []*topology.DeployConfig { dcs := []*topology.DeployConfig{} for _, dc := range deployConfigs { dcId := dc.GetId() role := dc.GetRole() host := dc.GetHost() - serviceId := curveadm.GetServiceId(dcId) + serviceId := dingoadm.GetServiceId(dcId) if (options.Id == "*" || options.Id == serviceId) && (options.Role == "*" || options.Role == role) && (options.Host == "*" || options.Host == host) { @@ -341,7 +342,7 @@ func (curveadm *CurveAdm) FilterDeployConfig(deployConfigs []*topology.DeployCon return dcs } -func (curveadm *CurveAdm) FilterDeployConfigByGateway(deployConfigs []*topology.DeployConfig, +func (dingoadm *DingoAdm) FilterDeployConfigByGateway(deployConfigs []*topology.DeployConfig, options topology.FilterOption) *topology.DeployConfig { for _, dc := range deployConfigs { host := dc.GetHost() @@ -353,19 +354,19 @@ func (curveadm *CurveAdm) FilterDeployConfigByGateway(deployConfigs []*topology. return nil } -func (curveadm *CurveAdm) FilterDeployConfigByRole(dcs []*topology.DeployConfig, +func (dingoadm *DingoAdm) FilterDeployConfigByRole(dcs []*topology.DeployConfig, role string) []*topology.DeployConfig { options := topology.FilterOption{Id: "*", Role: role, Host: "*"} - return curveadm.FilterDeployConfig(dcs, options) + return dingoadm.FilterDeployConfig(dcs, options) } -func (curveadm *CurveAdm) GetServiceId(dcId string) string { - serviceId := fmt.Sprintf("%s_%s", curveadm.ClusterUUId(), dcId) +func (dingoadm *DingoAdm) GetServiceId(dcId string) string { + serviceId := fmt.Sprintf("%s_%s", dingoadm.ClusterUUId(), dcId) return utils.MD5Sum(serviceId)[:12] } -func (curveadm *CurveAdm) GetContainerId(serviceId string) (string, error) { - containerId, err := curveadm.Storage().GetContainerId(serviceId) +func (dingoadm *DingoAdm) GetContainerId(serviceId string) (string, error) { + containerId, err := dingoadm.Storage().GetContainerId(serviceId) if err != nil { return "", errno.ERR_GET_SERVICE_CONTAINER_ID_FAILED } else if len(containerId) == 0 { @@ -375,34 +376,34 @@ func (curveadm *CurveAdm) GetContainerId(serviceId string) (string, error) { } // FIXME -func (curveadm *CurveAdm) IsSkip(dc *topology.DeployConfig) bool { - serviceId := curveadm.GetServiceId(dc.GetId()) - containerId, err := curveadm.Storage().GetContainerId(serviceId) +func (dingoadm *DingoAdm) IsSkip(dc *topology.DeployConfig) bool { + serviceId := dingoadm.GetServiceId(dc.GetId()) + containerId, err := dingoadm.Storage().GetContainerId(serviceId) return err == nil && len(containerId) == 0 && dc.GetRole() == topology.ROLE_SNAPSHOTCLONE } -func (curveadm *CurveAdm) GetVolumeId(host, user, volume string) string { +func (dingoadm *DingoAdm) GetVolumeId(host, user, volume string) string { volumeId := fmt.Sprintf("curvebs_volume_%s_%s_%s", host, user, volume) return utils.MD5Sum(volumeId)[:12] } -func (curveadm *CurveAdm) GetFilesystemId(host, mountPoint string) string { +func (dingoadm *DingoAdm) GetFilesystemId(host, mountPoint string) string { filesystemId := fmt.Sprintf("curvefs_filesystem_%s_%s", host, mountPoint) return utils.MD5Sum(filesystemId)[:12] } -func (curveadm *CurveAdm) ExecOptions() module.ExecOptions { +func (dingoadm *DingoAdm) ExecOptions() module.ExecOptions { return module.ExecOptions{ ExecWithSudo: true, ExecInLocal: false, - ExecSudoAlias: curveadm.config.GetSudoAlias(), - ExecTimeoutSec: curveadm.config.GetTimeout(), - ExecWithEngine: curveadm.config.GetEngine(), + ExecSudoAlias: dingoadm.config.GetSudoAlias(), + ExecTimeoutSec: dingoadm.config.GetTimeout(), + ExecWithEngine: dingoadm.config.GetEngine(), } } -func (curveadm *CurveAdm) CheckId(id string) error { - services, err := curveadm.Storage().GetServices(curveadm.ClusterId()) +func (dingoadm *DingoAdm) CheckId(id string) error { + services, err := dingoadm.Storage().GetServices(dingoadm.ClusterId()) if err != nil { return err } @@ -414,8 +415,8 @@ func (curveadm *CurveAdm) CheckId(id string) error { return errno.ERR_ID_NOT_FOUND.F("id: %s", id) } -func (curveadm *CurveAdm) CheckRole(role string) error { - dcs, err := curveadm.ParseTopology() +func (dingoadm *DingoAdm) CheckRole(role string) error { + dcs, err := dingoadm.ParseTopology() if err != nil { return err } @@ -437,29 +438,29 @@ func (curveadm *CurveAdm) CheckRole(role string) error { return nil } -func (curveadm *CurveAdm) CheckHost(host string) error { - _, err := curveadm.GetHost(host) +func (dingoadm *DingoAdm) CheckHost(host string) error { + _, err := dingoadm.GetHost(host) return err } // writer for cobra command error -func (curveadm *CurveAdm) Write(p []byte) (int, error) { +func (dingoadm *DingoAdm) Write(p []byte) (int, error) { // trim prefix which generate by cobra p = p[len(cliutil.PREFIX_COBRA_COMMAND_ERROR):] - return curveadm.WriteOut(string(p)) + return dingoadm.WriteOut(string(p)) } -func (curveadm *CurveAdm) WriteOut(format string, a ...interface{}) (int, error) { +func (dingoadm *DingoAdm) WriteOut(format string, a ...interface{}) (int, error) { output := fmt.Sprintf(format, a...) - return curveadm.out.Write([]byte(output)) + return dingoadm.out.Write([]byte(output)) } -func (curveadm *CurveAdm) WriteOutln(format string, a ...interface{}) (int, error) { +func (dingoadm *DingoAdm) WriteOutln(format string, a ...interface{}) (int, error) { output := fmt.Sprintf(format, a...) + "\n" - return curveadm.out.Write([]byte(output)) + return dingoadm.out.Write([]byte(output)) } -func (curveadm *CurveAdm) IsSameRole(dcs []*topology.DeployConfig) bool { +func (dingoadm *DingoAdm) IsSameRole(dcs []*topology.DeployConfig) bool { role := dcs[0].GetRole() for _, dc := range dcs { if dc.GetRole() != role { @@ -469,9 +470,9 @@ func (curveadm *CurveAdm) IsSameRole(dcs []*topology.DeployConfig) bool { return true } -func (curveadm *CurveAdm) DiffTopology(data1, data2 string) ([]topology.TopologyDiff, error) { +func (dingoadm *DingoAdm) DiffTopology(data1, data2 string) ([]topology.TopologyDiff, error) { ctx := topology.NewContext() - hcs, err := hosts.ParseHosts(curveadm.Hosts()) + hcs, err := hosts.ParseHosts(dingoadm.Hosts()) if err != nil { return nil, err } @@ -493,7 +494,7 @@ func (curveadm *CurveAdm) DiffTopology(data1, data2 string) ([]topology.Topology return topology.DiffTopology(data1, data2, ctx) } -func (curveadm *CurveAdm) PreAudit(now time.Time, args []string) int64 { +func (dingoadm *DingoAdm) PreAudit(now time.Time, args []string) int64 { if len(args) == 0 { return -1 } else if args[0] == "audit" || args[0] == "__complete" { @@ -501,8 +502,8 @@ func (curveadm *CurveAdm) PreAudit(now time.Time, args []string) int64 { } cwd, _ := os.Getwd() - command := fmt.Sprintf("curveadm %s", strings.Join(args, " ")) - id, err := curveadm.Storage().InsertAuditLog( + command := fmt.Sprintf("dingoadm %s", strings.Join(args, " ")) + id, err := dingoadm.Storage().InsertAuditLog( now, cwd, command, comm.AUDIT_STATUS_ABORT) if err != nil { log.Error("Insert audit log failed", @@ -512,12 +513,12 @@ func (curveadm *CurveAdm) PreAudit(now time.Time, args []string) int64 { return id } -func (curveadm *CurveAdm) PostAudit(id int64, ec error) { +func (dingoadm *DingoAdm) PostAudit(id int64, ec error) { if id < 0 { return } - auditLogs, err := curveadm.Storage().GetAuditLog(id) + auditLogs, err := dingoadm.Storage().GetAuditLog(id) if err != nil { log.Error("Get audit log failed", log.Field("Error", err)) @@ -540,7 +541,7 @@ func (curveadm *CurveAdm) PostAudit(id int64, ec error) { } } - err = curveadm.Storage().SetAuditLogStatus(id, status, errorCode) + err = dingoadm.Storage().SetAuditLogStatus(id, status, errorCode) if err != nil { log.Error("Set audit log status failed", log.Field("Error", err)) diff --git a/cli/cli/version.go b/cli/cli/version.go index 31c61892b..0576a021c 100644 --- a/cli/cli/version.go +++ b/cli/cli/version.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ package cli var ( - Version = "0.3.2" + Version = "1.1" CommitId = "unknown" ) diff --git a/cli/command/audit.go b/cli/command/audit.go index 351a7a725..aee387e6b 100644 --- a/cli/command/audit.go +++ b/cli/command/audit.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ type auditOptions struct { verbose bool } -func NewAuditCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewAuditCommand(curveadm *cli.DingoAdm) *cobra.Command { var options auditOptions cmd := &cobra.Command{ @@ -57,7 +58,7 @@ func NewAuditCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runAudit(curveadm *cli.CurveAdm, options auditOptions) error { +func runAudit(curveadm *cli.DingoAdm, options auditOptions) error { auditLogs, err := curveadm.Storage().GetAuditLogs() if err != nil { return errno.ERR_GET_AUDIT_LOGS_FAILE.E(err) diff --git a/cli/command/clean.go b/cli/command/clean.go index 95142f44d..d9c69abe2 100644 --- a/cli/command/clean.go +++ b/cli/command/clean.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +65,7 @@ type cleanOptions struct { force bool } -func checkCleanOptions(curveadm *cli.CurveAdm, options cleanOptions) error { +func checkCleanOptions(curveadm *cli.DingoAdm, options cleanOptions) error { supported := utils.Slice2Map(CLEAN_ITEMS) for _, item := range options.only { if !supported[item] { @@ -75,7 +76,7 @@ func checkCleanOptions(curveadm *cli.CurveAdm, options cleanOptions) error { return checkCommonOptions(curveadm, options.id, options.role, options.host) } -func NewCleanCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCleanCommand(curveadm *cli.DingoAdm) *cobra.Command { var options cleanOptions cmd := &cobra.Command{ @@ -103,7 +104,7 @@ func NewCleanCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genCleanPlaybook(curveadm *cli.CurveAdm, +func genCleanPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options cleanOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -130,7 +131,7 @@ func genCleanPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runClean(curveadm *cli.CurveAdm, options cleanOptions) error { +func runClean(curveadm *cli.DingoAdm, options cleanOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/client/cmd.go b/cli/command/client/cmd.go index 7f510883a..ea9d12636 100644 --- a/cli/command/client/cmd.go +++ b/cli/command/client/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ import ( "github.com/spf13/cobra" ) -func NewClientCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewClientCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "client", Short: "Manage client", diff --git a/cli/command/client/enter.go b/cli/command/client/enter.go index a730be877..d2f8321fb 100644 --- a/cli/command/client/enter.go +++ b/cli/command/client/enter.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ type enterOptions struct { id string } -func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewEnterCommand(curveadm *cli.DingoAdm) *cobra.Command { var options enterOptions cmd := &cobra.Command{ @@ -52,7 +53,7 @@ func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runEnter(curveadm *cli.CurveAdm, options enterOptions) error { +func runEnter(curveadm *cli.DingoAdm, options enterOptions) error { // 1) get container id clients, err := curveadm.Storage().GetClient(options.id) if err != nil { diff --git a/cli/command/client/install.go b/cli/command/client/install.go index 1f41b8057..77f88514d 100644 --- a/cli/command/client/install.go +++ b/cli/command/client/install.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +49,7 @@ type installOptions struct { filename string } -func checkInstallOptions(curveadm *cli.CurveAdm, options installOptions) error { +func checkInstallOptions(curveadm *cli.DingoAdm, options installOptions) error { kind := options.kind if kind != topology.KIND_CURVEBS && kind != topology.KIND_CURVEFS && kind != topology.KIND_DINGOFS { return errno.ERR_UNSUPPORT_CLIENT_KIND.F("kind: %s", kind) @@ -59,7 +60,7 @@ func checkInstallOptions(curveadm *cli.CurveAdm, options installOptions) error { return nil } -func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewInstallCommand(curveadm *cli.DingoAdm) *cobra.Command { var options installOptions cmd := &cobra.Command{ @@ -83,7 +84,7 @@ func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genInstallPlaybook(curveadm *cli.CurveAdm, +func genInstallPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options installOptions) (*playbook.Playbook, error) { steps := INSTALL_CURVE_CLIENT_PLAYBOOK_STEPS @@ -100,7 +101,7 @@ func genInstallPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runInstall(curveadm *cli.CurveAdm, options installOptions) error { +func runInstall(curveadm *cli.DingoAdm, options installOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/client/map.go b/cli/command/client/map.go index d47c70334..81119b9d3 100644 --- a/cli/command/client/map.go +++ b/cli/command/client/map.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +126,7 @@ func ParseBlockSize(blocksize string) (uint64, error) { } return m, nil } -func checkMapOptions(curveadm *cli.CurveAdm, options mapOptions) error { +func checkMapOptions(curveadm *cli.DingoAdm, options mapOptions) error { if _, _, err := ParseImage(options.image); err != nil { return err } else if _, err = ParseSize(options.size); err != nil { @@ -137,7 +138,7 @@ func checkMapOptions(curveadm *cli.CurveAdm, options mapOptions) error { return nil } -func NewMapCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewMapCommand(curveadm *cli.DingoAdm) *cobra.Command { var options mapOptions cmd := &cobra.Command{ @@ -165,7 +166,7 @@ func NewMapCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genMapPlaybook(curveadm *cli.CurveAdm, +func genMapPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options mapOptions) (*playbook.Playbook, error) { user, name, _ := ParseImage(options.image) @@ -195,7 +196,7 @@ func genMapPlaybook(curveadm *cli.CurveAdm, } // TODO(P1): unmap by id -func runMap(curveadm *cli.CurveAdm, options mapOptions) error { +func runMap(curveadm *cli.DingoAdm, options mapOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/client/mount.go b/cli/command/client/mount.go index fe0f0df15..7a864a02e 100644 --- a/cli/command/client/mount.go +++ b/cli/command/client/mount.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +63,7 @@ type mountOptions struct { useLocalImage bool } -func checkMountOptions(curveadm *cli.CurveAdm, options mountOptions) error { +func checkMountOptions(curveadm *cli.DingoAdm, options mountOptions) error { if !strings.HasPrefix(options.mountPoint, "/") { return errno.ERR_FS_MOUNTPOINT_REQUIRE_ABSOLUTE_PATH. F("mount point: %s", options.mountPoint) @@ -70,7 +71,7 @@ func checkMountOptions(curveadm *cli.CurveAdm, options mountOptions) error { return nil } -func NewMountCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewMountCommand(curveadm *cli.DingoAdm) *cobra.Command { var options mountOptions cmd := &cobra.Command{ @@ -101,7 +102,7 @@ func NewMountCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genMountPlaybook(curveadm *cli.CurveAdm, +func genMountPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options mountOptions) (*playbook.Playbook, error) { steps := MOUNT_PLAYBOOK_STEPS @@ -134,7 +135,7 @@ func genMountPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runMount(curveadm *cli.CurveAdm, options mountOptions) error { +func runMount(curveadm *cli.DingoAdm, options mountOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/client/mount_test.go b/cli/command/client/mount_test.go index 1dc10de36..3d9754785 100644 --- a/cli/command/client/mount_test.go +++ b/cli/command/client/mount_test.go @@ -7,7 +7,7 @@ import ( ) func TestMountConfig(t *testing.T) { - curveadm, err := cli.NewCurveAdm() + curveadm, err := cli.NewDingoAdm() if err != nil { t.Errorf("Error: %v", err) } diff --git a/cli/command/client/status.go b/cli/command/client/status.go index 2fc006236..3f31f9baa 100644 --- a/cli/command/client/status.go +++ b/cli/command/client/status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ type statusOptions struct { verbose bool } -func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStatusCommand(curveadm *cli.DingoAdm) *cobra.Command { var options statusOptions cmd := &cobra.Command{ @@ -64,7 +65,7 @@ func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStatusPlaybook(curveadm *cli.CurveAdm, +func genStatusPlaybook(curveadm *cli.DingoAdm, clients []storage.Client, options statusOptions) (*playbook.Playbook, error) { config := []interface{}{} @@ -91,7 +92,7 @@ func genStatusPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayStatus(curveadm *cli.CurveAdm, clients []storage.Client, options statusOptions) { +func displayStatus(curveadm *cli.DingoAdm, clients []storage.Client, options statusOptions) { statuses := []task.ClientStatus{} v := curveadm.MemStorage().Get(comm.KEY_ALL_CLIENT_STATUS) if v != nil { @@ -108,7 +109,7 @@ func displayStatus(curveadm *cli.CurveAdm, clients []storage.Client, options sta curveadm.WriteOut(output) } -func runStatus(curveadm *cli.CurveAdm, options statusOptions) error { +func runStatus(curveadm *cli.DingoAdm, options statusOptions) error { // 1) get all clients clients, err := curveadm.Storage().GetClients() if err != nil { diff --git a/cli/command/client/umount.go b/cli/command/client/umount.go index 22c768d2e..436f3bdaa 100644 --- a/cli/command/client/umount.go +++ b/cli/command/client/umount.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +48,7 @@ type umountOptions struct { mountPoint string } -func checkUmountOptions(curveadm *cli.CurveAdm, options umountOptions) error { +func checkUmountOptions(curveadm *cli.DingoAdm, options umountOptions) error { if !strings.HasPrefix(options.mountPoint, "/") { return errno.ERR_FS_MOUNTPOINT_REQUIRE_ABSOLUTE_PATH. F("mount point: %s", options.mountPoint) @@ -55,7 +56,7 @@ func checkUmountOptions(curveadm *cli.CurveAdm, options umountOptions) error { return nil } -func NewUmountCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewUmountCommand(curveadm *cli.DingoAdm) *cobra.Command { var options umountOptions cmd := &cobra.Command{ @@ -79,7 +80,7 @@ func NewUmountCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genUnmountPlaybook(curveadm *cli.CurveAdm, +func genUnmountPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options umountOptions) (*playbook.Playbook, error) { steps := UMOUNT_PLAYBOOK_STEPS @@ -99,7 +100,7 @@ func genUnmountPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runUmount(curveadm *cli.CurveAdm, options umountOptions) error { +func runUmount(curveadm *cli.DingoAdm, options umountOptions) error { // 1) generate unmap playbook pb, err := genUnmountPlaybook(curveadm, nil, options) if err != nil { diff --git a/cli/command/client/uninstall.go b/cli/command/client/uninstall.go index d764e55d7..88ff999ca 100644 --- a/cli/command/client/uninstall.go +++ b/cli/command/client/uninstall.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ type uninstallOptions struct { host string } -func checkUninstallOptions(curveadm *cli.CurveAdm, options uninstallOptions) error { +func checkUninstallOptions(curveadm *cli.DingoAdm, options uninstallOptions) error { kind := options.kind if kind != topology.KIND_CURVEBS && kind != topology.KIND_CURVEFS && kind != topology.KIND_DINGOFS { return errno.ERR_UNSUPPORT_CLIENT_KIND. @@ -54,7 +55,7 @@ func checkUninstallOptions(curveadm *cli.CurveAdm, options uninstallOptions) err return nil } -func NewUninstallCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewUninstallCommand(curveadm *cli.DingoAdm) *cobra.Command { var options uninstallOptions cmd := &cobra.Command{ @@ -77,7 +78,7 @@ func NewUninstallCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genUninstallPlaybook(curveadm *cli.CurveAdm, +func genUninstallPlaybook(curveadm *cli.DingoAdm, v interface{}, options uninstallOptions) (*playbook.Playbook, error) { steps := UNINSTALL_CURVE_CLEINT_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) @@ -94,7 +95,7 @@ func genUninstallPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runUninstall(curveadm *cli.CurveAdm, options uninstallOptions) error { +func runUninstall(curveadm *cli.DingoAdm, options uninstallOptions) error { // 1) generate map playbook pb, err := genUninstallPlaybook(curveadm, nil, options) if err != nil { diff --git a/cli/command/client/unmap.go b/cli/command/client/unmap.go index f48ee8a70..c57bb386b 100644 --- a/cli/command/client/unmap.go +++ b/cli/command/client/unmap.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,12 +49,12 @@ type unmapOptions struct { image string } -func checkUnmapOptions(curveadm *cli.CurveAdm, options unmapOptions) error { +func checkUnmapOptions(curveadm *cli.DingoAdm, options unmapOptions) error { _, _, err := ParseImage(options.image) return err } -func NewUnmapCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewUnmapCommand(curveadm *cli.DingoAdm) *cobra.Command { var options unmapOptions cmd := &cobra.Command{ @@ -78,7 +79,7 @@ func NewUnmapCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genUnmapPlaybook(curveadm *cli.CurveAdm, +func genUnmapPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options unmapOptions) (*playbook.Playbook, error) { user, name, _ := ParseImage(options.image) @@ -100,7 +101,7 @@ func genUnmapPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runUnmap(curveadm *cli.CurveAdm, options unmapOptions) error { +func runUnmap(curveadm *cli.DingoAdm, options unmapOptions) error { // 1) generate unmap playbook pb, err := genUnmapPlaybook(curveadm, nil, options) if err != nil { diff --git a/cli/command/cluster/add.go b/cli/command/cluster/add.go index d03abb464..a023c9e60 100644 --- a/cli/command/cluster/add.go +++ b/cli/command/cluster/add.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,7 @@ type addOptions struct { filename string } -func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewAddCommand(curveadm *cli.DingoAdm) *cobra.Command { var options addOptions cmd := &cobra.Command{ @@ -92,7 +93,7 @@ func readTopology(filename string) (string, error) { return data, nil } -func genCheckTopologyPlaybook(curveadm *cli.CurveAdm, +func genCheckTopologyPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options addOptions) (*playbook.Playbook, error) { steps := CHECK_TOPOLOGY_PLAYBOOK_STEPS @@ -117,7 +118,7 @@ func genCheckTopologyPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func checkTopology(curveadm *cli.CurveAdm, data string, options addOptions) error { +func checkTopology(curveadm *cli.DingoAdm, data string, options addOptions) error { if len(options.filename) == 0 { return nil } @@ -134,7 +135,7 @@ func checkTopology(curveadm *cli.CurveAdm, data string, options addOptions) erro return pb.Run() } -func runAdd(curveadm *cli.CurveAdm, options addOptions) error { +func runAdd(curveadm *cli.DingoAdm, options addOptions) error { // 1) check wether cluster already exist name := options.name storage := curveadm.Storage() diff --git a/cli/command/cluster/checkout.go b/cli/command/cluster/checkout.go index 267878636..926022796 100644 --- a/cli/command/cluster/checkout.go +++ b/cli/command/cluster/checkout.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,7 @@ type checkoutOptions struct { clusterName string } -func NewCheckoutCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCheckoutCommand(curveadm *cli.DingoAdm) *cobra.Command { var options checkoutOptions cmd := &cobra.Command{ @@ -53,7 +54,7 @@ func NewCheckoutCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runCheckout(curveadm *cli.CurveAdm, options checkoutOptions) error { +func runCheckout(curveadm *cli.DingoAdm, options checkoutOptions) error { // 1) get cluster by name clusterName := options.clusterName storage := curveadm.Storage() diff --git a/cli/command/cluster/cmd.go b/cli/command/cluster/cmd.go index 3daef3d34..e1489538d 100644 --- a/cli/command/cluster/cmd.go +++ b/cli/command/cluster/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +31,7 @@ import ( "github.com/spf13/cobra" ) -func NewClusterCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewClusterCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "cluster", Short: "Manage clusters", diff --git a/cli/command/cluster/export.go b/cli/command/cluster/export.go index 71f26165c..9b724b7d3 100644 --- a/cli/command/cluster/export.go +++ b/cli/command/cluster/export.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +53,7 @@ type exportOptions struct { outfile string } -func NewExportCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewExportCommand(curveadm *cli.DingoAdm) *cobra.Command { var options exportOptions cmd := &cobra.Command{ @@ -124,7 +125,7 @@ func exportCluster(cluster storage.Cluster, services []storage.Service, filename return nil } -func runExport(curveadm *cli.CurveAdm, options exportOptions) error { +func runExport(curveadm *cli.DingoAdm, options exportOptions) error { name := options.name storage := curveadm.Storage() clusters, err := storage.GetClusters(name) diff --git a/cli/command/cluster/import.go b/cli/command/cluster/import.go index f2f87aeb6..aafc214b0 100644 --- a/cli/command/cluster/import.go +++ b/cli/command/cluster/import.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +48,7 @@ type importOptions struct { dbfile string } -func NewImportCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewImportCommand(curveadm *cli.DingoAdm) *cobra.Command { var options importOptions cmd := &cobra.Command{ @@ -120,7 +121,7 @@ func importCluster(storage *storage.Storage, dbfile, name string) error { return nil } -func runImport(curveadm *cli.CurveAdm, options importOptions) error { +func runImport(curveadm *cli.DingoAdm, options importOptions) error { name := options.name storage := curveadm.Storage() clusters, err := storage.GetClusters(name) diff --git a/cli/command/cluster/list.go b/cli/command/cluster/list.go index 385c8b1cd..73901ccbb 100644 --- a/cli/command/cluster/list.go +++ b/cli/command/cluster/list.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ type listOptions struct { verbose bool } -func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewListCommand(curveadm *cli.DingoAdm) *cobra.Command { var options listOptions cmd := &cobra.Command{ @@ -57,7 +58,7 @@ func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runList(curveadm *cli.CurveAdm, options listOptions) error { +func runList(curveadm *cli.DingoAdm, options listOptions) error { // 1) get all clusters storage := curveadm.Storage() clusters, err := storage.GetClusters("%") diff --git a/cli/command/cluster/remove.go b/cli/command/cluster/remove.go index aace82f8b..7ef8ebdfa 100644 --- a/cli/command/cluster/remove.go +++ b/cli/command/cluster/remove.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +40,7 @@ type removeOptions struct { force bool } -func NewRemoveCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewRemoveCommand(curveadm *cli.DingoAdm) *cobra.Command { var options removeOptions cmd := &cobra.Command{ @@ -60,7 +61,7 @@ func NewRemoveCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func checkAllServicesRemoved(curveadm *cli.CurveAdm, options removeOptions, clusterId int) error { +func checkAllServicesRemoved(curveadm *cli.DingoAdm, options removeOptions, clusterId int) error { if options.force { return nil } @@ -80,7 +81,7 @@ func checkAllServicesRemoved(curveadm *cli.CurveAdm, options removeOptions, clus return nil } -func runRemove(curveadm *cli.CurveAdm, options removeOptions) error { +func runRemove(curveadm *cli.DingoAdm, options removeOptions) error { // 1) get cluster by name storage := curveadm.Storage() clusterName := options.clusterName diff --git a/cli/command/cmd.go b/cli/command/cmd.go index 3d2179fa5..b7c310ab5 100644 --- a/cli/command/cmd.go +++ b/cli/command/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +45,7 @@ import ( "github.com/spf13/cobra" ) -var curveadmExample = `Examples: +var dingoadmExample = `Examples: $ dingoadm playground run --kind dingofs # Run a dingoFS playground quickly $ dingoadm cluster add c1 # Add a cluster named 'c1' $ dingoadm deploy # Deploy current cluster @@ -58,68 +59,68 @@ type rootOptions struct { upgrade bool } -func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) { +func addSubCommands(cmd *cobra.Command, dingoadm *cli.DingoAdm) { cmd.AddCommand( - client.NewClientCommand(curveadm), // curveadm client - cluster.NewClusterCommand(curveadm), // curveadm cluster ... - config.NewConfigCommand(curveadm), // curveadm config ... - hosts.NewHostsCommand(curveadm), // curveadm hosts ... - playground.NewPlaygroundCommand(curveadm), // curveadm playground ... - target.NewTargetCommand(curveadm), // curveadm target ... - pfs.NewPFSCommand(curveadm), // curveadm pfs ... - monitor.NewMonitorCommand(curveadm), // curveadm monitor ... - gateway.NewGatewayCommand(curveadm), // curveadm gateway ... - - NewAuditCommand(curveadm), // curveadm audit - NewCleanCommand(curveadm), // curveadm clean - NewCompletionCommand(curveadm), // curveadm completion - NewDeployCommand(curveadm), // curveadm deploy - NewEnterCommand(curveadm), // curveadm enter - NewExecCommand(curveadm), // curveadm exec - NewFormatCommand(curveadm), // curveadm format - NewMigrateCommand(curveadm), // curveadm migrate - NewPrecheckCommand(curveadm), // curveadm precheck - NewReloadCommand(curveadm), // curveadm reload - NewRestartCommand(curveadm), // curveadm restart - NewScaleOutCommand(curveadm), // curveadm scale-out - NewStartCommand(curveadm), // curveadm start - NewStatusCommand(curveadm), // curveadm status - NewStopCommand(curveadm), // curveadm stop - NewSupportCommand(curveadm), // curveadm support - NewUpgradeCommand(curveadm), // curveadm upgrade + client.NewClientCommand(dingoadm), // dingoadm client + cluster.NewClusterCommand(dingoadm), // dingoadm cluster ... + config.NewConfigCommand(dingoadm), // dingoadm config ... + hosts.NewHostsCommand(dingoadm), // dingoadm hosts ... + playground.NewPlaygroundCommand(dingoadm), // dingoadm playground ... + target.NewTargetCommand(dingoadm), // dingoadm target ... + pfs.NewPFSCommand(dingoadm), // dingoadm pfs ... + monitor.NewMonitorCommand(dingoadm), // dingoadm monitor ... + gateway.NewGatewayCommand(dingoadm), // dingoadm gateway ... + + NewAuditCommand(dingoadm), // dingoadm audit + NewCleanCommand(dingoadm), // dingoadm clean + NewCompletionCommand(dingoadm), // dingoadm completion + NewDeployCommand(dingoadm), // dingoadm deploy + NewEnterCommand(dingoadm), // dingoadm enter + NewExecCommand(dingoadm), // dingoadm exec + NewFormatCommand(dingoadm), // dingoadm format + NewMigrateCommand(dingoadm), // dingoadm migrate + NewPrecheckCommand(dingoadm), // dingoadm precheck + NewReloadCommand(dingoadm), // dingoadm reload + NewRestartCommand(dingoadm), // dingoadm restart + NewScaleOutCommand(dingoadm), // dingoadm scale-out + NewStartCommand(dingoadm), // dingoadm start + NewStatusCommand(dingoadm), // dingoadm status + NewStopCommand(dingoadm), // dingoadm stop + NewSupportCommand(dingoadm), // dingoadm support + NewUpgradeCommand(dingoadm), // dingoadm upgrade // commonly used shorthands - hosts.NewSSHCommand(curveadm), // curveadm ssh - hosts.NewPlaybookCommand(curveadm), // curveadm playbook - client.NewMapCommand(curveadm), // curveadm map - client.NewMountCommand(curveadm), // curveadm mount - client.NewUnmapCommand(curveadm), // curveadm unmap - client.NewUmountCommand(curveadm), // curveadm umount + hosts.NewSSHCommand(dingoadm), // dingoadm ssh + hosts.NewPlaybookCommand(dingoadm), // dingoadm playbook + client.NewMapCommand(dingoadm), // dingoadm map + client.NewMountCommand(dingoadm), // dingoadm mount + client.NewUnmapCommand(dingoadm), // dingoadm unmap + client.NewUmountCommand(dingoadm), // dingoadm umount ) } -func setupRootCommand(cmd *cobra.Command, curveadm *cli.CurveAdm) { +func setupRootCommand(cmd *cobra.Command, dingoadm *cli.DingoAdm) { cmd.SetVersionTemplate("{{.Version}}\n") cliutil.SetFlagErrorFunc(cmd) cliutil.SetHelpTemplate(cmd) cliutil.SetUsageTemplate(cmd) - cliutil.SetErr(cmd, curveadm) + cliutil.SetErr(cmd, dingoadm) } -func NewCurveAdmCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCurveAdmCommand(dingoadm *cli.DingoAdm) *cobra.Command { var options rootOptions cmd := &cobra.Command{ Use: "dingoadm [OPTIONS] COMMAND [ARGS...]", Short: "Deploy and manage dingoFS cluster", Version: fmt.Sprintf("dingoadm v%s, build %s", cli.Version, cli.CommitId), - Example: curveadmExample, + Example: dingoadmExample, RunE: func(cmd *cobra.Command, args []string) error { if options.debug { return errno.List() } else if options.upgrade { return tools.Upgrade2Latest(cli.Version) } else if len(args) == 0 { - return cliutil.ShowHelp(curveadm.Err())(cmd, args) + return cliutil.ShowHelp(dingoadm.Err())(cmd, args) } return fmt.Errorf("dingoadm: '%s' is not a dingoadm command.\n"+ @@ -132,10 +133,10 @@ func NewCurveAdmCommand(curveadm *cli.CurveAdm) *cobra.Command { cmd.Flags().BoolP("version", "v", false, "Print version information and quit") cmd.PersistentFlags().BoolP("help", "h", false, "Print usage") cmd.Flags().BoolVarP(&options.debug, "debug", "d", false, "Print debug information") - cmd.Flags().BoolVarP(&options.upgrade, "upgrade", "u", false, "Upgrade curveadm itself to the latest version") + cmd.Flags().BoolVarP(&options.upgrade, "upgrade", "u", false, "Upgrade dingoadm itself to the latest version") - addSubCommands(cmd, curveadm) - setupRootCommand(cmd, curveadm) + addSubCommands(cmd, dingoadm) + setupRootCommand(cmd, dingoadm) return cmd } diff --git a/cli/command/completion.go b/cli/command/completion.go index 2fab17a50..588c8bd75 100644 --- a/cli/command/completion.go +++ b/cli/command/completion.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ import ( "github.com/spf13/cobra" ) -func NewCompletionCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCompletionCommand(curveadm *cli.DingoAdm) *cobra.Command { var completionCmd = &cobra.Command{ Use: "completion [bash|zsh|fish|powershell]", Short: "Generate completion script", diff --git a/cli/command/config/cmd.go b/cli/command/config/cmd.go index 818ecfb85..23079c475 100644 --- a/cli/command/config/cmd.go +++ b/cli/command/config/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +31,7 @@ import ( "github.com/spf13/cobra" ) -func NewConfigCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewConfigCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "config", Short: "Manage cluster topology", diff --git a/cli/command/config/commit.go b/cli/command/config/commit.go index 99725cc8d..ebc5dd1e9 100644 --- a/cli/command/config/commit.go +++ b/cli/command/config/commit.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +55,7 @@ type commitOptions struct { force bool } -func NewCommitCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCommitCommand(curveadm *cli.DingoAdm) *cobra.Command { var options commitOptions cmd := &cobra.Command{ @@ -84,7 +85,7 @@ func skipError(err error) bool { return false } -func checkDiff(curveadm *cli.CurveAdm, newData string) error { +func checkDiff(curveadm *cli.DingoAdm, newData string) error { diffs, err := curveadm.DiffTopology(curveadm.ClusterTopologyData(), newData) if err != nil && !skipError(err) { return err @@ -104,7 +105,7 @@ func checkDiff(curveadm *cli.CurveAdm, newData string) error { return nil } -func genCheckTopologyPlaybook(curveadm *cli.CurveAdm, +func genCheckTopologyPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options commitOptions) (*playbook.Playbook, error) { steps := CHECK_TOPOLOGY_PLAYBOOK_STEPS @@ -128,7 +129,7 @@ func genCheckTopologyPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func readTopology(curveadm *cli.CurveAdm, options commitOptions) (string, error) { +func readTopology(curveadm *cli.DingoAdm, options commitOptions) (string, error) { filename := options.filename if len(filename) == 0 { return "", nil @@ -150,7 +151,7 @@ func readTopology(curveadm *cli.CurveAdm, options commitOptions) (string, error) return data, nil } -func checkTopology(curveadm *cli.CurveAdm, data string, options commitOptions) error { +func checkTopology(curveadm *cli.DingoAdm, data string, options commitOptions) error { if options.force { return nil } @@ -182,7 +183,7 @@ func checkTopology(curveadm *cli.CurveAdm, data string, options commitOptions) e return nil } -func runCommit(curveadm *cli.CurveAdm, options commitOptions) error { +func runCommit(curveadm *cli.DingoAdm, options commitOptions) error { // 1) parse cluster topology _, err := curveadm.ParseTopology() if err != nil && !skipError(err) { diff --git a/cli/command/config/diff.go b/cli/command/config/diff.go index 884c0bbba..17e094de4 100644 --- a/cli/command/config/diff.go +++ b/cli/command/config/diff.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +41,7 @@ type diffOptions struct { filename string } -func NewDiffCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewDiffCommand(curveadm *cli.DingoAdm) *cobra.Command { var options diffOptions cmd := &cobra.Command{ @@ -58,7 +59,7 @@ func NewDiffCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runDiff(curveadm *cli.CurveAdm, options diffOptions) error { +func runDiff(curveadm *cli.DingoAdm, options diffOptions) error { // 1) data1: current cluster topology data data1 := curveadm.ClusterTopologyData() diff --git a/cli/command/config/show.go b/cli/command/config/show.go index 650e874f0..643415452 100644 --- a/cli/command/config/show.go +++ b/cli/command/config/show.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +39,7 @@ type showOptions struct { showPool bool } -func NewShowCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewShowCommand(curveadm *cli.DingoAdm) *cobra.Command { var options showOptions cmd := &cobra.Command{ @@ -70,7 +71,7 @@ func decodePoolJSON(data string) (string, error) { return string(bytes), nil } -func runShow(curveadm *cli.CurveAdm, options showOptions) error { +func runShow(curveadm *cli.DingoAdm, options showOptions) error { // 1) check whether cluster exist if curveadm.ClusterId() == -1 { return errno.ERR_NO_CLUSTER_SPECIFIED diff --git a/cli/command/deploy.go b/cli/command/deploy.go index f7db388b7..6a6355b07 100644 --- a/cli/command/deploy.go +++ b/cli/command/deploy.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +132,7 @@ func checkDeployOptions(options deployOptions) error { return nil } -func NewDeployCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewDeployCommand(curveadm *cli.DingoAdm) *cobra.Command { var options deployOptions cmd := &cobra.Command{ @@ -182,7 +183,7 @@ func skipDeploySteps(dcs []*topology.DeployConfig, deploySteps []int, options de return steps } -func precheckBeforeDeploy(curveadm *cli.CurveAdm, +func precheckBeforeDeploy(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options deployOptions) error { // 1) skip precheck @@ -213,12 +214,12 @@ func precheckBeforeDeploy(curveadm *cli.CurveAdm, return nil } -func calcNumOfChunkserver(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig) int { +func calcNumOfChunkserver(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig) int { services := curveadm.FilterDeployConfigByRole(dcs, topology.ROLE_CHUNKSERVER) return len(services) } -func genDeployPlaybook(curveadm *cli.CurveAdm, +func genDeployPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options deployOptions) (*playbook.Playbook, error) { var steps []int @@ -309,7 +310,7 @@ func serviceStats(dcs []*topology.DeployConfig) string { return serviceStats } -func displayDeployTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig) { +func displayDeployTitle(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig) { curveadm.WriteOutln("Cluster Name : %s", curveadm.ClusterName()) curveadm.WriteOutln("Cluster Kind : %s", dcs[0].GetKind()) curveadm.WriteOutln("Cluster Services: %s", serviceStats(dcs)) @@ -330,7 +331,7 @@ func displayDeployTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig) { * 5) create logical pool * 6) balance leader rapidly */ -func runDeploy(curveadm *cli.CurveAdm, options deployOptions) error { +func runDeploy(curveadm *cli.DingoAdm, options deployOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/enter.go b/cli/command/enter.go index 78e872e4a..2155fa8da 100644 --- a/cli/command/enter.go +++ b/cli/command/enter.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ type enterOptions struct { id string } -func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewEnterCommand(curveadm *cli.DingoAdm) *cobra.Command { var options enterOptions cmd := &cobra.Command{ @@ -57,7 +58,7 @@ func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runEnter(curveadm *cli.CurveAdm, options enterOptions) error { +func runEnter(curveadm *cli.DingoAdm, options enterOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/exec.go b/cli/command/exec.go index 6a63e5388..3e6e6229c 100644 --- a/cli/command/exec.go +++ b/cli/command/exec.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ type execOptions struct { cmd string } -func NewExecCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewExecCommand(curveadm *cli.DingoAdm) *cobra.Command { var options execOptions cmd := &cobra.Command{ @@ -63,7 +64,7 @@ func NewExecCommand(curveadm *cli.CurveAdm) *cobra.Command { // 2. filter service // 3. get container id // 4. exec cmd in remote container -func runExec(curveadm *cli.CurveAdm, options execOptions) error { +func runExec(curveadm *cli.DingoAdm, options execOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/format.go b/cli/command/format.go index 67ec1b4a4..eafc952a5 100644 --- a/cli/command/format.go +++ b/cli/command/format.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +64,7 @@ type formatOptions struct { concurrent uint } -func NewFormatCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewFormatCommand(curveadm *cli.DingoAdm) *cobra.Command { var options formatOptions cmd := &cobra.Command{ @@ -86,7 +87,7 @@ func NewFormatCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genFormatPlaybook(curveadm *cli.CurveAdm, +func genFormatPlaybook(curveadm *cli.DingoAdm, fcs []*configure.FormatConfig, options formatOptions) (*playbook.Playbook, error) { if len(fcs) == 0 { @@ -118,7 +119,7 @@ func genFormatPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayFormatStatus(curveadm *cli.CurveAdm, fcs []*configure.FormatConfig, options formatOptions) { +func displayFormatStatus(curveadm *cli.DingoAdm, fcs []*configure.FormatConfig, options formatOptions) { statuses := []bs.FormatStatus{} v := curveadm.MemStorage().Get(comm.KEY_ALL_FORMAT_STATUS) if v != nil { @@ -134,7 +135,7 @@ func displayFormatStatus(curveadm *cli.CurveAdm, fcs []*configure.FormatConfig, return } -func runFormat(curveadm *cli.CurveAdm, options formatOptions) error { +func runFormat(curveadm *cli.DingoAdm, options formatOptions) error { // 1) parse format config fcs, err := configure.ParseFormat(options.filename) if err != nil { diff --git a/cli/command/gateway/cmd.go b/cli/command/gateway/cmd.go index 130912114..43661c2ee 100644 --- a/cli/command/gateway/cmd.go +++ b/cli/command/gateway/cmd.go @@ -28,7 +28,7 @@ import ( "github.com/spf13/cobra" ) -func NewGatewayCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewGatewayCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "gateway", Short: "Manage gateway", diff --git a/cli/command/gateway/start.go b/cli/command/gateway/start.go index 82e7d5235..d039118fe 100644 --- a/cli/command/gateway/start.go +++ b/cli/command/gateway/start.go @@ -50,7 +50,7 @@ var ( } ) -func NewStartGatewayCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStartGatewayCommand(curveadm *cli.DingoAdm) *cobra.Command { var options startOptions cmd := &cobra.Command{ @@ -74,7 +74,7 @@ func NewStartGatewayCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runStart(curveadm *cli.CurveAdm, options startOptions) error { +func runStart(curveadm *cli.DingoAdm, options startOptions) error { // 1) generate mount playbook pb, err := genStartPlaybook(curveadm, options) @@ -95,7 +95,7 @@ func runStart(curveadm *cli.CurveAdm, options startOptions) error { return nil } -func genStartPlaybook(curveadm *cli.CurveAdm, options startOptions) (*playbook.Playbook, error) { +func genStartPlaybook(curveadm *cli.DingoAdm, options startOptions) (*playbook.Playbook, error) { steps := START_GATEWAY_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) diff --git a/cli/command/hosts/cmd.go b/cli/command/hosts/cmd.go index 165d506b7..89af7c906 100644 --- a/cli/command/hosts/cmd.go +++ b/cli/command/hosts/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +31,7 @@ import ( "github.com/spf13/cobra" ) -func NewHostsCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewHostsCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "hosts", Short: "Manage hosts", diff --git a/cli/command/hosts/commit.go b/cli/command/hosts/commit.go index 26399fd53..7837fb897 100644 --- a/cli/command/hosts/commit.go +++ b/cli/command/hosts/commit.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ type commitOptions struct { force bool } -func NewCommitCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCommitCommand(curveadm *cli.DingoAdm) *cobra.Command { var options commitOptions cmd := &cobra.Command{ @@ -67,7 +68,7 @@ func NewCommitCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func readAndCheckHosts(curveadm *cli.CurveAdm, options commitOptions) (string, error) { +func readAndCheckHosts(curveadm *cli.DingoAdm, options commitOptions) (string, error) { // 1) read hosts from file if !utils.PathExist(options.filename) { return "", errno.ERR_HOSTS_FILE_NOT_FOUND. @@ -90,7 +91,7 @@ func readAndCheckHosts(curveadm *cli.CurveAdm, options commitOptions) (string, e return data, err } -func runCommit(curveadm *cli.CurveAdm, options commitOptions) error { +func runCommit(curveadm *cli.DingoAdm, options commitOptions) error { // 1) read and check hosts data, err := readAndCheckHosts(curveadm, options) if err != nil { diff --git a/cli/command/hosts/list.go b/cli/command/hosts/list.go index 704744759..be675abcb 100644 --- a/cli/command/hosts/list.go +++ b/cli/command/hosts/list.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ type listOptions struct { labels string } -func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewListCommand(curveadm *cli.DingoAdm) *cobra.Command { var options listOptions cmd := &cobra.Command{ @@ -153,7 +154,7 @@ func filter(data string, labels []string) ([]*hosts.HostConfig, error) { return out, nil } -func runList(curveadm *cli.CurveAdm, options listOptions) error { +func runList(curveadm *cli.DingoAdm, options listOptions) error { var hcs []*hosts.HostConfig var err error data := curveadm.Hosts() diff --git a/cli/command/hosts/playbook.go b/cli/command/hosts/playbook.go index 5fe464c68..c4f9667f4 100644 --- a/cli/command/hosts/playbook.go +++ b/cli/command/hosts/playbook.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +57,7 @@ type playbookOptions struct { labels []string } -func checkPlaybookOptions(curveadm *cli.CurveAdm, options playbookOptions) error { +func checkPlaybookOptions(curveadm *cli.DingoAdm, options playbookOptions) error { // TODO: added error code if !utils.PathExist(options.filepath) { return fmt.Errorf("%s: no such file", options.filepath) @@ -64,7 +65,7 @@ func checkPlaybookOptions(curveadm *cli.CurveAdm, options playbookOptions) error return nil } -func NewPlaybookCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewPlaybookCommand(curveadm *cli.DingoAdm) *cobra.Command { var options playbookOptions cmd := &cobra.Command{ @@ -89,7 +90,7 @@ func NewPlaybookCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func execute(curveadm *cli.CurveAdm, options playbookOptions, idx int, hc *hosts.HostConfig) { +func execute(curveadm *cli.DingoAdm, options playbookOptions, idx int, hc *hosts.HostConfig) { defer func() { wg.Done() }() name := hc.GetHost() target := path.Join("/tmp", utils.RandString(8)) @@ -114,7 +115,7 @@ func execute(curveadm *cli.CurveAdm, options playbookOptions, idx int, hc *hosts retC <- result{index: idx, host: name, out: out, err: err} } -func output(curveadm *cli.CurveAdm, ret *result) { +func output(curveadm *cli.DingoAdm, ret *result) { curveadm.WriteOutln("") out, err := ret.out, ret.err curveadm.WriteOutln("%s [%s]", color.YellowString(ret.host), @@ -128,7 +129,7 @@ func output(curveadm *cli.CurveAdm, ret *result) { } } -func receiver(curveadm *cli.CurveAdm, total int) { +func receiver(curveadm *cli.DingoAdm, total int) { curveadm.WriteOutln("TOTAL: %d hosts", total) current := 0 rets := map[int]result{} @@ -145,7 +146,7 @@ func receiver(curveadm *cli.CurveAdm, total int) { } } -func runPlaybook(curveadm *cli.CurveAdm, options playbookOptions) error { +func runPlaybook(curveadm *cli.DingoAdm, options playbookOptions) error { var hcs []*hosts.HostConfig var err error hosts := curveadm.Hosts() diff --git a/cli/command/hosts/show.go b/cli/command/hosts/show.go index 781789e44..c5a976b11 100644 --- a/cli/command/hosts/show.go +++ b/cli/command/hosts/show.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ import ( type showOptions struct{} -func NewShowCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewShowCommand(curveadm *cli.DingoAdm) *cobra.Command { var options showOptions cmd := &cobra.Command{ @@ -48,7 +49,7 @@ func NewShowCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runShow(curveadm *cli.CurveAdm, options showOptions) error { +func runShow(curveadm *cli.DingoAdm, options showOptions) error { hosts := curveadm.Hosts() if len(hosts) == 0 { curveadm.WriteOutln("") diff --git a/cli/command/hosts/ssh.go b/cli/command/hosts/ssh.go index 65517e59f..251b2a709 100644 --- a/cli/command/hosts/ssh.go +++ b/cli/command/hosts/ssh.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,7 @@ type sshOptions struct { become bool } -func NewSSHCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewSSHCommand(curveadm *cli.DingoAdm) *cobra.Command { var options sshOptions cmd := &cobra.Command{ @@ -56,6 +57,6 @@ func NewSSHCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runSSH(curveadm *cli.CurveAdm, options sshOptions) error { +func runSSH(curveadm *cli.DingoAdm, options sshOptions) error { return tools.AttachRemoteHost(curveadm, options.host, options.become) } diff --git a/cli/command/migrate.go b/cli/command/migrate.go index 514c4fa39..f4da05ad8 100644 --- a/cli/command/migrate.go +++ b/cli/command/migrate.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,7 +109,7 @@ type migrateOptions struct { poolsetDiskType string } -func NewMigrateCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewMigrateCommand(curveadm *cli.DingoAdm) *cobra.Command { var options migrateOptions cmd := &cobra.Command{ @@ -130,7 +131,7 @@ func NewMigrateCommand(curveadm *cli.CurveAdm) *cobra.Command { } // NOTE: you can only migrate same role whole host services ervey time -func checkMigrateTopology(curveadm *cli.CurveAdm, data string) error { +func checkMigrateTopology(curveadm *cli.DingoAdm, data string) error { diffs, err := curveadm.DiffTopology(curveadm.ClusterTopologyData(), data) if err != nil { return err @@ -165,7 +166,7 @@ func checkMigrateTopology(curveadm *cli.CurveAdm, data string) error { return nil } -func getMigrates(curveadm *cli.CurveAdm, data string) []*configure.MigrateServer { +func getMigrates(curveadm *cli.DingoAdm, data string) []*configure.MigrateServer { diffs, _ := diffTopology(curveadm, data) dcs2add := diffs[topology.DIFF_ADD] dcs2del := diffs[topology.DIFF_DELETE] @@ -183,7 +184,7 @@ func getMigrates(curveadm *cli.CurveAdm, data string) []*configure.MigrateServer return migrates } -func genMigratePlaybook(curveadm *cli.CurveAdm, +func genMigratePlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options migrateOptions, data string) (*playbook.Playbook, error) { diffs, _ := diffTopology(curveadm, data) dcs2add := diffs[topology.DIFF_ADD] @@ -242,7 +243,7 @@ func genMigratePlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayMigrateTitle(curveadm *cli.CurveAdm, data string) { +func displayMigrateTitle(curveadm *cli.DingoAdm, data string) { migrates := getMigrates(curveadm, data) from := migrates[0].From to := migrates[0].To @@ -252,7 +253,7 @@ func displayMigrateTitle(curveadm *cli.CurveAdm, data string) { curveadm.WriteOutln(color.YellowString(" - Migrate host: from %s to %s", from.GetHost(), to.GetHost())) } -func runMigrate(curveadm *cli.CurveAdm, options migrateOptions) error { +func runMigrate(curveadm *cli.DingoAdm, options migrateOptions) error { // TODO(P0): added prechek for target host // 1) parse cluster topology dcs, err := curveadm.ParseTopology() diff --git a/cli/command/monitor/clean.go b/cli/command/monitor/clean.go index 10afdb4eb..dcdd8d1b3 100644 --- a/cli/command/monitor/clean.go +++ b/cli/command/monitor/clean.go @@ -58,7 +58,7 @@ type cleanOptions struct { only []string } -func NewCleanCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewCleanCommand(curveadm *cli.DingoAdm) *cobra.Command { var options cleanOptions cmd := &cobra.Command{ @@ -80,7 +80,7 @@ func NewCleanCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genCleanPlaybook(curveadm *cli.CurveAdm, +func genCleanPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options cleanOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -105,7 +105,7 @@ func genCleanPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runClean(curveadm *cli.CurveAdm, options cleanOptions) error { +func runClean(curveadm *cli.DingoAdm, options cleanOptions) error { // 1) parse monitor config mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/monitor/cmd.go b/cli/command/monitor/cmd.go index 53a697f4c..c223b1c4e 100644 --- a/cli/command/monitor/cmd.go +++ b/cli/command/monitor/cmd.go @@ -28,7 +28,7 @@ import ( "github.com/spf13/cobra" ) -func NewMonitorCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewMonitorCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "monitor", Short: "Manage monitor", diff --git a/cli/command/monitor/deploy.go b/cli/command/monitor/deploy.go index e7090c7be..30004f061 100644 --- a/cli/command/monitor/deploy.go +++ b/cli/command/monitor/deploy.go @@ -65,7 +65,7 @@ type deployOptions struct { * 4.2) start prometheus container * 4.3) start grafana container */ -func NewDeployCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewDeployCommand(curveadm *cli.DingoAdm) *cobra.Command { var options deployOptions cmd := &cobra.Command{ @@ -84,7 +84,7 @@ func NewDeployCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genDeployPlaybook(curveadm *cli.CurveAdm, +func genDeployPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig) (*playbook.Playbook, error) { steps := MONITOR_DEPLOY_STEPS pb := playbook.NewPlaybook(curveadm) @@ -108,7 +108,7 @@ func genDeployPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func parseTopology(curveadm *cli.CurveAdm) ([]string, []string, []*topology.DeployConfig, error) { +func parseTopology(curveadm *cli.DingoAdm) ([]string, []string, []*topology.DeployConfig, error) { dcs, err := curveadm.ParseTopology() if err != nil || len(dcs) == 0 { return nil, nil, nil, err @@ -130,7 +130,7 @@ func parseTopology(curveadm *cli.CurveAdm) ([]string, []string, []*topology.Depl return hosts, hostIps, dcs, nil } -func runDeploy(curveadm *cli.CurveAdm, options deployOptions) error { +func runDeploy(curveadm *cli.DingoAdm, options deployOptions) error { // 1) parse cluster topology and get services' hosts hosts, hostIps, dcs, err := parseTopology(curveadm) if err != nil { diff --git a/cli/command/monitor/reload.go b/cli/command/monitor/reload.go index 448a71aee..74a43bd29 100644 --- a/cli/command/monitor/reload.go +++ b/cli/command/monitor/reload.go @@ -48,7 +48,7 @@ type reloadOptions struct { host string } -func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewReloadCommand(curveadm *cli.DingoAdm) *cobra.Command { var options reloadOptions cmd := &cobra.Command{ Use: "reload [OPTIONS]", @@ -68,7 +68,7 @@ func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genReloadPlaybook(curveadm *cli.CurveAdm, +func genReloadPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options reloadOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -102,7 +102,7 @@ func genReloadPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runReload(curveadm *cli.CurveAdm, options reloadOptions) error { +func runReload(curveadm *cli.DingoAdm, options reloadOptions) error { // 1) parse monitor configure mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/monitor/restart.go b/cli/command/monitor/restart.go index 616917cb2..b0e893eea 100644 --- a/cli/command/monitor/restart.go +++ b/cli/command/monitor/restart.go @@ -44,7 +44,7 @@ type restartOptions struct { host string } -func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewRestartCommand(curveadm *cli.DingoAdm) *cobra.Command { var options restartOptions cmd := &cobra.Command{ Use: "restart [OPTIONS]", @@ -64,7 +64,7 @@ func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genRestartPlaybook(curveadm *cli.CurveAdm, +func genRestartPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options restartOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -87,7 +87,7 @@ func genRestartPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runRestart(curveadm *cli.CurveAdm, options restartOptions) error { +func runRestart(curveadm *cli.DingoAdm, options restartOptions) error { // 1) parse monitor configure mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/monitor/start.go b/cli/command/monitor/start.go index cd6a93fa1..2a7c2ce04 100644 --- a/cli/command/monitor/start.go +++ b/cli/command/monitor/start.go @@ -44,7 +44,7 @@ type startOptions struct { host string } -func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStartCommand(curveadm *cli.DingoAdm) *cobra.Command { var options startOptions cmd := &cobra.Command{ Use: "start [OPTIONS]", @@ -64,7 +64,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStartPlaybook(curveadm *cli.CurveAdm, +func genStartPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options startOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -87,7 +87,7 @@ func genStartPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStart(curveadm *cli.CurveAdm, options startOptions) error { +func runStart(curveadm *cli.DingoAdm, options startOptions) error { // 1) parse monitor configure mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/monitor/status.go b/cli/command/monitor/status.go index 28d5354dd..d0d8ff962 100644 --- a/cli/command/monitor/status.go +++ b/cli/command/monitor/status.go @@ -48,7 +48,7 @@ type statusOptions struct { verbose bool } -func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStatusCommand(curveadm *cli.DingoAdm) *cobra.Command { var options statusOptions cmd := &cobra.Command{ Use: "status [OPTIONS]", @@ -68,7 +68,7 @@ func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func parseMonitorConfig(curveadm *cli.CurveAdm) ([]*configure.MonitorConfig, error) { +func parseMonitorConfig(curveadm *cli.DingoAdm) ([]*configure.MonitorConfig, error) { if curveadm.ClusterId() == -1 { return nil, errno.ERR_NO_CLUSTER_SPECIFIED } @@ -81,7 +81,7 @@ func parseMonitorConfig(curveadm *cli.CurveAdm) ([]*configure.MonitorConfig, err return configure.ParseMonitorConfig(curveadm, "", monitor.Monitor, hosts, hostIps, dcs) } -func genStatusPlaybook(curveadm *cli.CurveAdm, +func genStatusPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options statusOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -109,7 +109,7 @@ func genStatusPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayStatus(curveadm *cli.CurveAdm, dcs []*configure.MonitorConfig, options statusOptions) { +func displayStatus(curveadm *cli.DingoAdm, dcs []*configure.MonitorConfig, options statusOptions) { statuses := []monitor.MonitorStatus{} value := curveadm.MemStorage().Get(comm.KEY_MONITOR_STATUS) if value != nil { @@ -127,7 +127,7 @@ func displayStatus(curveadm *cli.CurveAdm, dcs []*configure.MonitorConfig, optio curveadm.WriteOut("%s", output) } -func runStatus(curveadm *cli.CurveAdm, options statusOptions) error { +func runStatus(curveadm *cli.DingoAdm, options statusOptions) error { // 1) parse monitor config mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/monitor/stop.go b/cli/command/monitor/stop.go index 37c5fe88c..b7e97ffd1 100644 --- a/cli/command/monitor/stop.go +++ b/cli/command/monitor/stop.go @@ -44,7 +44,7 @@ type stopOptions struct { host string } -func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStopCommand(curveadm *cli.DingoAdm) *cobra.Command { var options stopOptions cmd := &cobra.Command{ Use: "stop [OPTIONS]", @@ -64,7 +64,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStopPlaybook(curveadm *cli.CurveAdm, +func genStopPlaybook(curveadm *cli.DingoAdm, mcs []*configure.MonitorConfig, options stopOptions) (*playbook.Playbook, error) { mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ @@ -87,7 +87,7 @@ func genStopPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStop(curveadm *cli.CurveAdm, options stopOptions) error { +func runStop(curveadm *cli.DingoAdm, options stopOptions) error { // 1) parse monitor config mcs, err := parseMonitorConfig(curveadm) if err != nil { diff --git a/cli/command/pfs/cmd.go b/cli/command/pfs/cmd.go index 26339f277..d3a8ccb75 100644 --- a/cli/command/pfs/cmd.go +++ b/cli/command/pfs/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ import ( "github.com/spf13/cobra" ) -func NewPFSCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewPFSCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "pfs", Short: "Manage pfs", diff --git a/cli/command/pfs/install.go b/cli/command/pfs/install.go index be462d4ff..1bedbb87e 100644 --- a/cli/command/pfs/install.go +++ b/cli/command/pfs/install.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +48,7 @@ type installOptions struct { filename string } -func checkInstallOptions(curveadm *cli.CurveAdm, options installOptions) error { +func checkInstallOptions(curveadm *cli.DingoAdm, options installOptions) error { if !utils.PathExist(options.filename) { return errno.ERR_CLIENT_CONFIGURE_FILE_NOT_EXIST. F("%s: no such file", utils.AbsPath(options.filename)) @@ -55,7 +56,7 @@ func checkInstallOptions(curveadm *cli.CurveAdm, options installOptions) error { return nil } -func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewInstallCommand(curveadm *cli.DingoAdm) *cobra.Command { var options installOptions cmd := &cobra.Command{ @@ -78,7 +79,7 @@ func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genInstallPlaybook(curveadm *cli.CurveAdm, +func genInstallPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options installOptions) (*playbook.Playbook, error) { steps := INSTALL_PFS_PLAYBOOK_STEPS @@ -95,7 +96,7 @@ func genInstallPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runInstall(curveadm *cli.CurveAdm, options installOptions) error { +func runInstall(curveadm *cli.DingoAdm, options installOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/pfs/uninstall.go b/cli/command/pfs/uninstall.go index f051f6dfb..46d34618f 100644 --- a/cli/command/pfs/uninstall.go +++ b/cli/command/pfs/uninstall.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ type uninstallOptions struct { host string } -func NewUninstallCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewUninstallCommand(curveadm *cli.DingoAdm) *cobra.Command { var options uninstallOptions cmd := &cobra.Command{ @@ -61,7 +62,7 @@ func NewUninstallCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genUninstallPlaybook(curveadm *cli.CurveAdm, +func genUninstallPlaybook(curveadm *cli.DingoAdm, v interface{}, options uninstallOptions) (*playbook.Playbook, error) { steps := UNINSTALL_PFS_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) @@ -77,7 +78,7 @@ func genUninstallPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runUninstall(curveadm *cli.CurveAdm, options uninstallOptions) error { +func runUninstall(curveadm *cli.DingoAdm, options uninstallOptions) error { // 1) generate map playbook pb, err := genUninstallPlaybook(curveadm, nil, options) if err != nil { diff --git a/cli/command/playground/cmd.go b/cli/command/playground/cmd.go index 41c06b193..e2d4c83fc 100644 --- a/cli/command/playground/cmd.go +++ b/cli/command/playground/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ import ( "github.com/spf13/cobra" ) -func NewPlaygroundCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewPlaygroundCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "playground", Short: "Manage playground", diff --git a/cli/command/playground/enter.go b/cli/command/playground/enter.go index 699f8f280..f55071940 100644 --- a/cli/command/playground/enter.go +++ b/cli/command/playground/enter.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,7 @@ type enterOptions struct { id string } -func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewEnterCommand(curveadm *cli.DingoAdm) *cobra.Command { var options enterOptions cmd := &cobra.Command{ @@ -51,7 +52,7 @@ func NewEnterCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func runEnter(curveadm *cli.CurveAdm, options enterOptions) error { +func runEnter(curveadm *cli.DingoAdm, options enterOptions) error { // 1) get playground id := options.id playgrounds, err := curveadm.Storage().GetPlaygroundById(id) diff --git a/cli/command/playground/list.go b/cli/command/playground/list.go index 7af1943a3..f0d37decd 100644 --- a/cli/command/playground/list.go +++ b/cli/command/playground/list.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +41,7 @@ var GET_PLAYGROUND_STATUS_PLAYBOOK_STEPS = []int{ playbook.GET_PLAYGROUND_STATUS, } -func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewListCommand(curveadm *cli.DingoAdm) *cobra.Command { var options listOptions cmd := &cobra.Command{ @@ -57,7 +58,7 @@ func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genListPlaybook(curveadm *cli.CurveAdm, +func genListPlaybook(curveadm *cli.DingoAdm, playgrounds []storage.Playground) (*playbook.Playbook, error) { configs := []interface{}{} for _, playground := range playgrounds { @@ -77,7 +78,7 @@ func genListPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayPlaygrounds(curveadm *cli.CurveAdm) { +func displayPlaygrounds(curveadm *cli.DingoAdm) { statuses := []pg.PlaygroundStatus{} value := curveadm.MemStorage().Get(comm.KEY_ALL_PLAYGROUNDS_STATUS) if value != nil { @@ -91,7 +92,7 @@ func displayPlaygrounds(curveadm *cli.CurveAdm) { curveadm.WriteOut(output) } -func runList(curveadm *cli.CurveAdm, options listOptions) error { +func runList(curveadm *cli.DingoAdm, options listOptions) error { // 1) get playgrounds playgrounds, err := curveadm.Storage().GetPlaygrounds("%") if err != nil { diff --git a/cli/command/playground/remove.go b/cli/command/playground/remove.go index dcacdfe35..a27aa4928 100644 --- a/cli/command/playground/remove.go +++ b/cli/command/playground/remove.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +41,7 @@ var REMOVE_PLAYGROUND_PLAYBOOK_STEPS = []int{ playbook.REMOVE_PLAYGROUND, } -func NewRemoveCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewRemoveCommand(curveadm *cli.DingoAdm) *cobra.Command { var options removeOptions cmd := &cobra.Command{ @@ -58,7 +59,7 @@ func NewRemoveCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genRemovePlaybook(curveadm *cli.CurveAdm, +func genRemovePlaybook(curveadm *cli.DingoAdm, playgrounds []storage.Playground) (*playbook.Playbook, error) { configs := []interface{}{} for _, playground := range playgrounds { @@ -75,7 +76,7 @@ func genRemovePlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runRemove(curveadm *cli.CurveAdm, options removeOptions) error { +func runRemove(curveadm *cli.DingoAdm, options removeOptions) error { // 1) get playground id := options.id playgrounds, err := curveadm.Storage().GetPlaygroundById(id) diff --git a/cli/command/playground/run.go b/cli/command/playground/run.go index 4e2c869fb..2646f0c15 100644 --- a/cli/command/playground/run.go +++ b/cli/command/playground/run.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +67,7 @@ type runOptions struct { containerImage string } -func checkRunOptions(curveadm *cli.CurveAdm, options runOptions) error { +func checkRunOptions(curveadm *cli.DingoAdm, options runOptions) error { kind := options.kind mountPoint := options.mountPoint if !supportKind[kind] { @@ -91,7 +92,7 @@ func checkRunOptions(curveadm *cli.CurveAdm, options runOptions) error { return nil } -func NewRunCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewRunCommand(curveadm *cli.DingoAdm) *cobra.Command { var options runOptions cmd := &cobra.Command{ @@ -117,7 +118,7 @@ func NewRunCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genRunPlaybook(curveadm *cli.CurveAdm, +func genRunPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, cc *configure.ClientConfig, options runOptions) (*playbook.Playbook, error) { @@ -142,7 +143,7 @@ func genRunPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runRun(curveadm *cli.CurveAdm, options runOptions) error { +func runRun(curveadm *cli.DingoAdm, options runOptions) error { // 1) print prompt curveadm.WriteOutln(color.GreenString("Start to run playground '%s', it will takes 1~2 minutes\n"), options.name) diff --git a/cli/command/precheck.go b/cli/command/precheck.go index 7f91fab7d..e2395c11a 100644 --- a/cli/command/precheck.go +++ b/cli/command/precheck.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +130,7 @@ func checkPrecheckOptions(options precheckOptions) error { return nil } -func NewPrecheckCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewPrecheckCommand(curveadm *cli.DingoAdm) *cobra.Command { var options precheckOptions cmd := &cobra.Command{ @@ -166,7 +167,7 @@ func skipPrecheckSteps(precheckSteps []int, options precheckOptions) []int { return out } -func genPrecheckPlaybook(curveadm *cli.CurveAdm, +func genPrecheckPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options precheckOptions) (*playbook.Playbook, error) { kind := dcs[0].GetKind() @@ -221,7 +222,7 @@ func genPrecheckPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runPrecheck(curveadm *cli.CurveAdm, options precheckOptions) error { +func runPrecheck(curveadm *cli.DingoAdm, options precheckOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/reload.go b/cli/command/reload.go index 60381b40a..b1baae1ee 100644 --- a/cli/command/reload.go +++ b/cli/command/reload.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +49,7 @@ type reloadOptions struct { host string } -func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewReloadCommand(curveadm *cli.DingoAdm) *cobra.Command { var options reloadOptions cmd := &cobra.Command{ @@ -72,7 +73,7 @@ func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genReloadPlaybook(curveadm *cli.CurveAdm, +func genReloadPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options reloadOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -95,7 +96,7 @@ func genReloadPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runReload(curveadm *cli.CurveAdm, options reloadOptions) error { +func runReload(curveadm *cli.DingoAdm, options reloadOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/restart.go b/cli/command/restart.go index 9e790f1dd..222303299 100644 --- a/cli/command/restart.go +++ b/cli/command/restart.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +50,7 @@ type restartOptions struct { force bool } -func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewRestartCommand(curveadm *cli.DingoAdm) *cobra.Command { var options restartOptions cmd := &cobra.Command{ @@ -74,7 +75,7 @@ func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genRestartPlaybook(curveadm *cli.CurveAdm, +func genRestartPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options restartOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -97,7 +98,7 @@ func genRestartPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runRestart(curveadm *cli.CurveAdm, options restartOptions) error { +func runRestart(curveadm *cli.DingoAdm, options restartOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/scale_out.go b/cli/command/scale_out.go index ae80e97dc..f977da55f 100644 --- a/cli/command/scale_out.go +++ b/cli/command/scale_out.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +122,7 @@ type scaleOutOptions struct { poolsetDiskType string } -func NewScaleOutCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewScaleOutCommand(curveadm *cli.DingoAdm) *cobra.Command { var options scaleOutOptions cmd := &cobra.Command{ @@ -144,7 +145,7 @@ func NewScaleOutCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func readTopology(curveadm *cli.CurveAdm, filename string) (string, error) { +func readTopology(curveadm *cli.DingoAdm, filename string) (string, error) { if !utils.PathExist(filename) { return "", errno.ERR_TOPOLOGY_FILE_NOT_FOUND. F("%s: no such file", utils.AbsPath(filename)) @@ -160,7 +161,7 @@ func readTopology(curveadm *cli.CurveAdm, filename string) (string, error) { return data, nil } -func diffTopology(curveadm *cli.CurveAdm, data string) (map[int][]*topology.DeployConfig, error) { +func diffTopology(curveadm *cli.DingoAdm, data string) (map[int][]*topology.DeployConfig, error) { diffs, err := curveadm.DiffTopology(curveadm.ClusterTopologyData(), data) if err != nil { return nil, err @@ -187,7 +188,7 @@ func getHostNum(dcs []*topology.DeployConfig) int { return num } -func checkScaleOutTopology(curveadm *cli.CurveAdm, data string) error { +func checkScaleOutTopology(curveadm *cli.DingoAdm, data string) error { diffs, err := diffTopology(curveadm, data) if err != nil { return err @@ -223,7 +224,7 @@ func checkScaleOutTopology(curveadm *cli.CurveAdm, data string) error { return nil } -func genScaleOutPrecheckPlaybook(curveadm *cli.CurveAdm, data string) (*playbook.Playbook, error) { +func genScaleOutPrecheckPlaybook(curveadm *cli.DingoAdm, data string) (*playbook.Playbook, error) { dcsAll, _ := curveadm.ParseTopologyData(data) kind := dcsAll[0].GetKind() steps := CURVEFS_PRECHECK_STEPS @@ -283,7 +284,7 @@ func genScaleOutPrecheckPlaybook(curveadm *cli.CurveAdm, data string) (*playbook return pb, nil } -func precheckBeforeScaleOut(curveadm *cli.CurveAdm, options scaleOutOptions, data string) error { +func precheckBeforeScaleOut(curveadm *cli.DingoAdm, options scaleOutOptions, data string) error { // 1) skip precheck if options.insecure { return nil @@ -310,7 +311,7 @@ func precheckBeforeScaleOut(curveadm *cli.CurveAdm, options scaleOutOptions, dat return nil } -func genScaleOutPlaybook(curveadm *cli.CurveAdm, +func genScaleOutPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, data string, options scaleOutOptions) (*playbook.Playbook, error) { @@ -366,7 +367,7 @@ func genScaleOutPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayScaleOutTitle(curveadm *cli.CurveAdm, data string) { +func displayScaleOutTitle(curveadm *cli.DingoAdm, data string) { diffs, _ := diffTopology(curveadm, data) dcs := diffs[topology.DIFF_ADD] curveadm.WriteOutln("") @@ -376,7 +377,7 @@ func displayScaleOutTitle(curveadm *cli.CurveAdm, data string) { dcs[0].GetRole(), len(dcs))) } -func runScaleOut(curveadm *cli.CurveAdm, options scaleOutOptions) error { +func runScaleOut(curveadm *cli.DingoAdm, options scaleOutOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/start.go b/cli/command/start.go index 47b1e5f02..cbf5eaea5 100644 --- a/cli/command/start.go +++ b/cli/command/start.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +50,7 @@ type startOptions struct { force bool } -func checkCommonOptions(curveadm *cli.CurveAdm, id, role, host string) error { +func checkCommonOptions(curveadm *cli.DingoAdm, id, role, host string) error { items := []struct { key string callback func(string) error @@ -71,7 +72,7 @@ func checkCommonOptions(curveadm *cli.CurveAdm, id, role, host string) error { return nil } -func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStartCommand(curveadm *cli.DingoAdm) *cobra.Command { var options startOptions cmd := &cobra.Command{ @@ -96,7 +97,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStartPlaybook(curveadm *cli.CurveAdm, +func genStartPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options startOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -119,7 +120,7 @@ func genStartPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStart(curveadm *cli.CurveAdm, options startOptions) error { +func runStart(curveadm *cli.DingoAdm, options startOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/status.go b/cli/command/status.go index e46fa9c67..e7829d24f 100644 --- a/cli/command/status.go +++ b/cli/command/status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,7 @@ type statusOptions struct { showInstances bool } -func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStatusCommand(curveadm *cli.DingoAdm) *cobra.Command { var options statusOptions cmd := &cobra.Command{ @@ -103,9 +104,9 @@ func getClusterMdsLeader(statuses []task.ServiceStatus) string { return color.RedString("") } -func displayStatus(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options statusOptions) { +func displayStatus(dingoadm *cli.DingoAdm, dcs []*topology.DeployConfig, options statusOptions) { statuses := []task.ServiceStatus{} - value := curveadm.MemStorage().Get(comm.KEY_ALL_SERVICE_STATUS) + value := dingoadm.MemStorage().Get(comm.KEY_ALL_SERVICE_STATUS) if value != nil { m := value.(map[string]task.ServiceStatus) for _, status := range m { @@ -114,16 +115,16 @@ func displayStatus(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options } output := tui.FormatStatus(statuses, options.verbose, options.showInstances) - curveadm.WriteOutln("") - curveadm.WriteOutln("cluster name : %s", curveadm.ClusterName()) - curveadm.WriteOutln("cluster kind : %s", dcs[0].GetKind()) - curveadm.WriteOutln("cluster mds addr : %s", getClusterMdsAddr(dcs)) - curveadm.WriteOutln("cluster mds leader: %s", getClusterMdsLeader(statuses)) - curveadm.WriteOutln("") - curveadm.WriteOut("%s", output) + dingoadm.WriteOutln("") + dingoadm.WriteOutln("cluster name : %s", dingoadm.ClusterName()) + dingoadm.WriteOutln("cluster kind : %s", dcs[0].GetKind()) + dingoadm.WriteOutln("cluster mds addr : %s", getClusterMdsAddr(dcs)) + dingoadm.WriteOutln("cluster mds leader: %s", getClusterMdsLeader(statuses)) + dingoadm.WriteOutln("") + dingoadm.WriteOut("%s", output) } -func genStatusPlaybook(curveadm *cli.CurveAdm, +func genStatusPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options statusOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -152,15 +153,15 @@ func genStatusPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStatus(curveadm *cli.CurveAdm, options statusOptions) error { +func runStatus(dingoadm *cli.DingoAdm, options statusOptions) error { // 1) parse cluster topology - dcs, err := curveadm.ParseTopology() + dcs, err := dingoadm.ParseTopology() if err != nil { return err } // 2) generate get status playbook - pb, err := genStatusPlaybook(curveadm, dcs, options) + pb, err := genStatusPlaybook(dingoadm, dcs, options) if err != nil { return err } @@ -169,6 +170,6 @@ func runStatus(curveadm *cli.CurveAdm, options statusOptions) error { err = pb.Run() // 4) display service status - displayStatus(curveadm, dcs, options) + displayStatus(dingoadm, dcs, options) return err } diff --git a/cli/command/stop.go b/cli/command/stop.go index 0ec39c7e4..367c3540b 100644 --- a/cli/command/stop.go +++ b/cli/command/stop.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +50,7 @@ type stopOptions struct { force bool } -func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStopCommand(curveadm *cli.DingoAdm) *cobra.Command { var options stopOptions cmd := &cobra.Command{ @@ -74,7 +75,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStopPlaybook(curveadm *cli.CurveAdm, +func genStopPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options stopOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -97,7 +98,7 @@ func genStopPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStop(curveadm *cli.CurveAdm, options stopOptions) error { +func runStop(curveadm *cli.DingoAdm, options stopOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/support.go b/cli/command/support.go index d723cd7ef..20c1f8d61 100644 --- a/cli/command/support.go +++ b/cli/command/support.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +54,7 @@ type supportOptions struct { ids []string } -func NewSupportCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewSupportCommand(curveadm *cli.DingoAdm) *cobra.Command { var options supportOptions cmd := &cobra.Command{ @@ -72,7 +73,7 @@ func NewSupportCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func getClients(curveadm *cli.CurveAdm, +func getClients(curveadm *cli.DingoAdm, options supportOptions) ([]storage.Client, error) { out := []storage.Client{} for _, id := range options.ids { @@ -88,7 +89,7 @@ func getClients(curveadm *cli.CurveAdm, return out, nil } -func genSupportPlaybook(curveadm *cli.CurveAdm, +func genSupportPlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options supportOptions) (*playbook.Playbook, error) { clients, err := getClients(curveadm, options) @@ -131,7 +132,7 @@ func genSupportPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runSupport(curveadm *cli.CurveAdm, options supportOptions) error { +func runSupport(curveadm *cli.DingoAdm, options supportOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/command/target/add.go b/cli/command/target/add.go index ec43effdb..eff39ecea 100644 --- a/cli/command/target/add.go +++ b/cli/command/target/add.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +54,7 @@ type addOptions struct { blocksize string } -func checkAddOptions(curveadm *cli.CurveAdm, options addOptions) error { +func checkAddOptions(curveadm *cli.DingoAdm, options addOptions) error { if _, _, err := client.ParseImage(options.image); err != nil { return err } else if _, err = client.ParseSize(options.size); err != nil { @@ -67,7 +68,7 @@ func checkAddOptions(curveadm *cli.CurveAdm, options addOptions) error { return nil } -func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewAddCommand(curveadm *cli.DingoAdm) *cobra.Command { var options addOptions cmd := &cobra.Command{ @@ -94,7 +95,7 @@ func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genAddPlaybook(curveadm *cli.CurveAdm, +func genAddPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options addOptions) (*playbook.Playbook, error) { user, name, _ := client.ParseImage(options.image) @@ -121,7 +122,7 @@ func genAddPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runAdd(curveadm *cli.CurveAdm, options addOptions) error { +func runAdd(curveadm *cli.DingoAdm, options addOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/target/cmd.go b/cli/command/target/cmd.go index bcf021b62..2e6469894 100644 --- a/cli/command/target/cmd.go +++ b/cli/command/target/cmd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ import ( "github.com/spf13/cobra" ) -func NewTargetCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewTargetCommand(curveadm *cli.DingoAdm) *cobra.Command { cmd := &cobra.Command{ Use: "target", Short: "Manage SCSI target of CurveBS", diff --git a/cli/command/target/delete.go b/cli/command/target/delete.go index 6292c8415..5b0c876c7 100644 --- a/cli/command/target/delete.go +++ b/cli/command/target/delete.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +44,7 @@ type deleteOptions struct { tid string } -func NewDeleteCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewDeleteCommand(curveadm *cli.DingoAdm) *cobra.Command { var options deleteOptions cmd := &cobra.Command{ @@ -64,7 +65,7 @@ func NewDeleteCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genDeletePlaybook(curveadm *cli.CurveAdm, options deleteOptions) (*playbook.Playbook, error) { +func genDeletePlaybook(curveadm *cli.DingoAdm, options deleteOptions) (*playbook.Playbook, error) { steps := DELETE_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) for _, step := range steps { @@ -82,7 +83,7 @@ func genDeletePlaybook(curveadm *cli.CurveAdm, options deleteOptions) (*playbook return pb, nil } -func runDelete(curveadm *cli.CurveAdm, options deleteOptions) error { +func runDelete(curveadm *cli.DingoAdm, options deleteOptions) error { // 1) generate list playbook pb, err := genDeletePlaybook(curveadm, options) if err != nil { diff --git a/cli/command/target/list.go b/cli/command/target/list.go index 94624aa51..0887507d6 100644 --- a/cli/command/target/list.go +++ b/cli/command/target/list.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ type listOptions struct { host string } -func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewListCommand(curveadm *cli.DingoAdm) *cobra.Command { var options listOptions cmd := &cobra.Command{ @@ -62,7 +63,7 @@ func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genListPlaybook(curveadm *cli.CurveAdm, options listOptions) (*playbook.Playbook, error) { +func genListPlaybook(curveadm *cli.DingoAdm, options listOptions) (*playbook.Playbook, error) { steps := LIST_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) for _, step := range steps { @@ -79,7 +80,7 @@ func genListPlaybook(curveadm *cli.CurveAdm, options listOptions) (*playbook.Pla return pb, nil } -func displayTargets(curveadm *cli.CurveAdm) { +func displayTargets(curveadm *cli.DingoAdm) { targets := []bs.Target{} value := curveadm.MemStorage().Get(comm.KEY_ALL_TARGETS) if value != nil { @@ -94,7 +95,7 @@ func displayTargets(curveadm *cli.CurveAdm) { curveadm.WriteOut(output) } -func runList(curveadm *cli.CurveAdm, options listOptions) error { +func runList(curveadm *cli.DingoAdm, options listOptions) error { // 1) generate list playbook pb, err := genListPlaybook(curveadm, options) if err != nil { diff --git a/cli/command/target/start.go b/cli/command/target/start.go index c62531d69..9994d4941 100644 --- a/cli/command/target/start.go +++ b/cli/command/target/start.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +47,7 @@ type startOptions struct { filename string } -func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStartCommand(curveadm *cli.DingoAdm) *cobra.Command { var options startOptions cmd := &cobra.Command{ @@ -66,7 +67,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStartPlaybook(curveadm *cli.CurveAdm, +func genStartPlaybook(curveadm *cli.DingoAdm, ccs []*configure.ClientConfig, options startOptions) (*playbook.Playbook, error) { steps := START_PLAYBOOK_STEPS @@ -85,7 +86,7 @@ func genStartPlaybook(curveadm *cli.CurveAdm, return pb, nil } -func runStart(curveadm *cli.CurveAdm, options startOptions) error { +func runStart(curveadm *cli.DingoAdm, options startOptions) error { // 1) parse client configure cc, err := configure.ParseClientConfig(options.filename) if err != nil { diff --git a/cli/command/target/stop.go b/cli/command/target/stop.go index b31f1e8d6..a624ba642 100644 --- a/cli/command/target/stop.go +++ b/cli/command/target/stop.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ type stopOptions struct { host string } -func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewStopCommand(curveadm *cli.DingoAdm) *cobra.Command { var options stopOptions cmd := &cobra.Command{ @@ -61,7 +62,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genStopPlaybook(curveadm *cli.CurveAdm, options stopOptions) (*playbook.Playbook, error) { +func genStopPlaybook(curveadm *cli.DingoAdm, options stopOptions) (*playbook.Playbook, error) { steps := STOP_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) for _, step := range steps { @@ -78,7 +79,7 @@ func genStopPlaybook(curveadm *cli.CurveAdm, options stopOptions) (*playbook.Pla return pb, nil } -func runStop(curveadm *cli.CurveAdm, options stopOptions) error { +func runStop(curveadm *cli.DingoAdm, options stopOptions) error { // 1) generate stop playbook pb, err := genStopPlaybook(curveadm, options) if err != nil { diff --git a/cli/command/upgrade.go b/cli/command/upgrade.go index d02df9250..e8056c21e 100644 --- a/cli/command/upgrade.go +++ b/cli/command/upgrade.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,7 @@ type upgradeOptions struct { force bool } -func NewUpgradeCommand(curveadm *cli.CurveAdm) *cobra.Command { +func NewUpgradeCommand(curveadm *cli.DingoAdm) *cobra.Command { var options upgradeOptions cmd := &cobra.Command{ @@ -80,7 +81,7 @@ func NewUpgradeCommand(curveadm *cli.CurveAdm) *cobra.Command { return cmd } -func genUpgradePlaybook(curveadm *cli.CurveAdm, +func genUpgradePlaybook(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options upgradeOptions) (*playbook.Playbook, error) { dcs = curveadm.FilterDeployConfig(dcs, topology.FilterOption{ @@ -107,7 +108,7 @@ func genUpgradePlaybook(curveadm *cli.CurveAdm, return pb, nil } -func displayTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options upgradeOptions) { +func displayTitle(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options upgradeOptions) { total := len(dcs) if options.force { curveadm.WriteOutln(color.YellowString("Upgrade %d services at once", total)) @@ -117,7 +118,7 @@ func displayTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options curveadm.WriteOutln(color.YellowString("Upgrade services: %s", serviceStats(dcs))) } -func upgradeAtOnce(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options upgradeOptions) error { +func upgradeAtOnce(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options upgradeOptions) error { // 1) display upgrade title displayTitle(curveadm, dcs, options) @@ -145,7 +146,7 @@ func upgradeAtOnce(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options return nil } -func upgradeOneByOne(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options upgradeOptions) error { +func upgradeOneByOne(curveadm *cli.DingoAdm, dcs []*topology.DeployConfig, options upgradeOptions) error { // 1) display upgrade title displayTitle(curveadm, dcs, options) @@ -180,7 +181,7 @@ func upgradeOneByOne(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, optio return nil } -func runUpgrade(curveadm *cli.CurveAdm, options upgradeOptions) error { +func runUpgrade(curveadm *cli.DingoAdm, options upgradeOptions) error { // 1) parse cluster topology dcs, err := curveadm.ParseTopology() if err != nil { diff --git a/cli/curveadm.go b/cli/dingoadm.go similarity index 93% rename from cli/curveadm.go rename to cli/dingoadm.go index 2f0b48372..f6b84919c 100644 --- a/cli/curveadm.go +++ b/cli/dingoadm.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ import ( ) func Execute() { - curveadm, err := cli.NewCurveAdm() + curveadm, err := cli.NewDingoAdm() if err != nil { fmt.Println(err) os.Exit(1) diff --git a/cmd/curveadm/main.go b/cmd/dingoadm/main.go similarity index 95% rename from cmd/curveadm/main.go rename to cmd/dingoadm/main.go index 4585bb285..081706245 100644 --- a/cmd/curveadm/main.go +++ b/cmd/dingoadm/main.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/build/debug.go b/internal/build/debug.go index a12c83e21..4eef94d17 100644 --- a/internal/build/debug.go +++ b/internal/build/debug.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/common/common.go b/internal/common/common.go index 47dc1bd0a..1f369b322 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/client.go b/internal/configure/client.go index 6bfa4d0f7..1eeee03fe 100644 --- a/internal/configure/client.go +++ b/internal/configure/client.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/common/item_set.go b/internal/configure/common/item_set.go index 60aa5c2e2..e6b7a23d8 100644 --- a/internal/configure/common/item_set.go +++ b/internal/configure/common/item_set.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/curveadm/curveadm.go b/internal/configure/dingoadm/dingoadm.go similarity index 98% rename from internal/configure/curveadm/curveadm.go rename to internal/configure/dingoadm/dingoadm.go index 45cd81224..460b16197 100644 --- a/internal/configure/curveadm/curveadm.go +++ b/internal/configure/dingoadm/dingoadm.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ // __SIGN_BY_WINE93__ -package curveadm +package dingoadm import ( "fmt" @@ -111,7 +112,7 @@ func newDefault() *CurveAdmConfig { AutoUpgrade: true, SSHRetries: 3, SSHTimeout: 10, - DBUrl: fmt.Sprintf("sqlite://%s/.curveadm/data/curveadm.db", home), + DBUrl: fmt.Sprintf("sqlite://%s/.dingoadm/data/dingoadm.db", home), } return cfg } diff --git a/internal/configure/format.go b/internal/configure/format.go index 65abb2a3c..6d2b429b5 100644 --- a/internal/configure/format.go +++ b/internal/configure/format.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/hosts/hc_get.go b/internal/configure/hosts/hc_get.go index 57495c4ce..896d0f428 100644 --- a/internal/configure/hosts/hc_get.go +++ b/internal/configure/hosts/hc_get.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +27,7 @@ package hosts import ( comm "github.com/dingodb/dingoadm/internal/configure/common" - "github.com/dingodb/dingoadm/internal/configure/curveadm" + "github.com/dingodb/dingoadm/internal/configure/dingoadm" "github.com/dingodb/dingoadm/internal/utils" "github.com/dingodb/dingoadm/pkg/module" ) @@ -105,7 +106,7 @@ func (hc *HostConfig) GetSSHConfig() *module.SSHConfig { BecomeMethod: "sudo", BecomeFlags: "-iu", BecomeUser: hc.GetBecomeUser(), - ConnectTimeoutSec: curveadm.GlobalCurveAdmConfig.GetSSHTimeout(), - ConnectRetries: curveadm.GlobalCurveAdmConfig.GetSSHRetries(), + ConnectTimeoutSec: dingoadm.GlobalCurveAdmConfig.GetSSHTimeout(), + ConnectRetries: dingoadm.GlobalCurveAdmConfig.GetSSHRetries(), } } diff --git a/internal/configure/hosts/hc_item.go b/internal/configure/hosts/hc_item.go index 1a843a7cf..40c67d578 100644 --- a/internal/configure/hosts/hc_item.go +++ b/internal/configure/hosts/hc_item.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/hosts/hosts.go b/internal/configure/hosts/hosts.go index 06311a20d..446e52f7b 100644 --- a/internal/configure/hosts/hosts.go +++ b/internal/configure/hosts/hosts.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/monitor.go b/internal/configure/monitor.go index a10eb243f..b0edf70ca 100644 --- a/internal/configure/monitor.go +++ b/internal/configure/monitor.go @@ -235,7 +235,7 @@ func parsePrometheusTarget(dcs []*topology.DeployConfig) (string, error) { return string(target), nil } -func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs []string, +func ParseMonitorConfig(curveadm *cli.DingoAdm, filename string, data string, hs []string, hostIps []string, dcs []*topology.DeployConfig) ( []*MonitorConfig, error) { parser := viper.NewWithOptions(viper.KeyDelimiter("::")) @@ -341,7 +341,7 @@ func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs return ret, nil } -func FilterMonitorConfig(curveadm *cli.CurveAdm, mcs []*MonitorConfig, +func FilterMonitorConfig(curveadm *cli.DingoAdm, mcs []*MonitorConfig, options FilterMonitorOption) []*MonitorConfig { ret := []*MonitorConfig{} for _, mc := range mcs { diff --git a/internal/configure/os.go b/internal/configure/os.go index 1693d3df3..3e7e9d79a 100644 --- a/internal/configure/os.go +++ b/internal/configure/os.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/os/os.go b/internal/configure/os/os.go index b02aeef05..acebe43e9 100644 --- a/internal/configure/os/os.go +++ b/internal/configure/os/os.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +26,9 @@ package os const ( - PATH_FSTAB = "/etc/fstab" + PATH_FSTAB = "/etc/fstab" PATH_OS_RELEASE = "/etc/os-release" - MAX_PORT = 65535 + MAX_PORT = 65535 ) func GetFSTabPath() string { return PATH_FSTAB } diff --git a/internal/configure/playground.go b/internal/configure/playground.go index f557a09b8..8cf9d7403 100644 --- a/internal/configure/playground.go +++ b/internal/configure/playground.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/pool.go b/internal/configure/pool.go index 353a863cc..d2a1a5e3e 100644 --- a/internal/configure/pool.go +++ b/internal/configure/pool.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/context.go b/internal/configure/topology/context.go index 675ca0a64..20aee24b5 100644 --- a/internal/configure/topology/context.go +++ b/internal/configure/topology/context.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/dc.go b/internal/configure/topology/dc.go index f1342e508..daacb2be3 100644 --- a/internal/configure/topology/dc.go +++ b/internal/configure/topology/dc.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/dc_get.go b/internal/configure/topology/dc_get.go index 71b1e2981..f17d52d3d 100644 --- a/internal/configure/topology/dc_get.go +++ b/internal/configure/topology/dc_get.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/dc_item.go b/internal/configure/topology/dc_item.go index ba3642f37..184218f7b 100644 --- a/internal/configure/topology/dc_item.go +++ b/internal/configure/topology/dc_item.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/diff.go b/internal/configure/topology/diff.go index 87265e8e8..aaa5a9b3b 100644 --- a/internal/configure/topology/diff.go +++ b/internal/configure/topology/diff.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/topology.go b/internal/configure/topology/topology.go index 2a7973dc8..befbe363c 100644 --- a/internal/configure/topology/topology.go +++ b/internal/configure/topology/topology.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/configure/topology/variables.go b/internal/configure/topology/variables.go index db4734715..2ed8c61b1 100644 --- a/internal/configure/topology/variables.go +++ b/internal/configure/topology/variables.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/errno/errno.go b/internal/errno/errno.go index 92113f967..239c3a746 100644 --- a/internal/errno/errno.go +++ b/internal/errno/errno.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/playbook/config.go b/internal/playbook/config.go index 37a65245f..ad5d0ece7 100644 --- a/internal/playbook/config.go +++ b/internal/playbook/config.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/playbook/configs.go b/internal/playbook/configs.go index f327b3c27..eb1824e08 100644 --- a/internal/playbook/configs.go +++ b/internal/playbook/configs.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/playbook/factory.go b/internal/playbook/factory.go index d6a0f07ed..13072651c 100644 --- a/internal/playbook/factory.go +++ b/internal/playbook/factory.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/playbook/playbook.go b/internal/playbook/playbook.go index 079d8c546..e04b75058 100644 --- a/internal/playbook/playbook.go +++ b/internal/playbook/playbook.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +57,7 @@ type ( } Playbook struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm steps []*PlaybookStep postSteps []*PlaybookStep } @@ -64,7 +65,7 @@ type ( ExecOptions = tasks.ExecOptions ) -func NewPlaybook(curveadm *cli.CurveAdm) *Playbook { +func NewPlaybook(curveadm *cli.DingoAdm) *Playbook { return &Playbook{ curveadm: curveadm, steps: []*PlaybookStep{}, diff --git a/internal/playbook/tasks/monitor.go b/internal/playbook/tasks/monitor.go index 4125e097a..112177cc8 100644 --- a/internal/playbook/tasks/monitor.go +++ b/internal/playbook/tasks/monitor.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/playbook/tasks/tasks.go b/internal/playbook/tasks/tasks.go index aa42d53d6..484446214 100644 --- a/internal/playbook/tasks/tasks.go +++ b/internal/playbook/tasks/tasks.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/storage/sql.go b/internal/storage/sql.go index 0ce916aa1..eaf373789 100644 --- a/internal/storage/sql.go +++ b/internal/storage/sql.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 5060a2437..28ef6573b 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/context/context.go b/internal/task/context/context.go index d4a7bb925..2b8f3cfef 100644 --- a/internal/task/context/context.go +++ b/internal/task/context/context.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/context/register.go b/internal/task/context/register.go index 0c166c062..6d332c0f7 100644 --- a/internal/task/context/register.go +++ b/internal/task/context/register.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/scripts/script.go b/internal/task/scripts/script.go index 92e0fb2e1..4c9f4eae1 100644 --- a/internal/task/scripts/script.go +++ b/internal/task/scripts/script.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/step/common.go b/internal/task/step/common.go index c62b89032..1643cffa8 100644 --- a/internal/task/step/common.go +++ b/internal/task/step/common.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/step/container.go b/internal/task/step/container.go index 981b19034..2976c6a71 100644 --- a/internal/task/step/container.go +++ b/internal/task/step/container.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/step/file.go b/internal/task/step/file.go index faa070068..0fdaf4fb6 100644 --- a/internal/task/step/file.go +++ b/internal/task/step/file.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/step/shell.go b/internal/task/step/shell.go index 4bed45bd0..62f831eb6 100644 --- a/internal/task/step/shell.go +++ b/internal/task/step/shell.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/bs/add_target.go b/internal/task/task/bs/add_target.go index 57777b854..236a398ff 100644 --- a/internal/task/task/bs/add_target.go +++ b/internal/task/task/bs/add_target.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +44,7 @@ type TargetOption struct { Blocksize uint64 } -func NewAddTargetTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewAddTargetTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_TARGET_OPTIONS).(TargetOption) user, volume := options.User, options.Volume hc, err := curveadm.GetHost(options.Host) diff --git a/internal/task/task/bs/balance_leader.go b/internal/task/task/bs/balance_leader.go index 5aa8d5e61..c3e0d251c 100644 --- a/internal/task/task/bs/balance_leader.go +++ b/internal/task/task/bs/balance_leader.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ import ( tui "github.com/dingodb/dingoadm/internal/tui/common" ) -func NewBalanceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewBalanceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/bs/check.go b/internal/task/task/bs/check.go index 361457e11..50168a55c 100644 --- a/internal/task/task/bs/check.go +++ b/internal/task/task/bs/check.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/bs/create_volume.go b/internal/task/task/bs/create_volume.go index 98aa77e19..8bd6c727a 100644 --- a/internal/task/task/bs/create_volume.go +++ b/internal/task/task/bs/create_volume.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +77,7 @@ func checkCreateStatus(out *string) step.LambdaType { } } -func setClientAuxInfo(curveadm *cli.CurveAdm, options MapOptions) step.LambdaType { +func setClientAuxInfo(curveadm *cli.DingoAdm, options MapOptions) step.LambdaType { return func(ctx *context.Context) error { volumeId := curveadm.GetVolumeId(options.Host, options.User, options.Volume) @@ -98,7 +99,7 @@ func setClientAuxInfo(curveadm *cli.CurveAdm, options MapOptions) step.LambdaTyp } } -func NewCreateVolumeTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewCreateVolumeTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/delete_target.go b/internal/task/task/bs/delete_target.go index 96fc5ce86..230995ffc 100644 --- a/internal/task/task/bs/delete_target.go +++ b/internal/task/task/bs/delete_target.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +51,7 @@ func (s *step2CheckTgtdStatus) Execute(ctx *context.Context) error { return nil } -func NewDeleteTargetTask(curveadm *cli.CurveAdm, cc *client.ClientConfig) (*task.Task, error) { +func NewDeleteTargetTask(curveadm *cli.DingoAdm, cc *client.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(common.KEY_TARGET_OPTIONS).(TargetOption) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/detect_release.go b/internal/task/task/bs/detect_release.go index d639dfdf8..47bf32b2a 100644 --- a/internal/task/task/bs/detect_release.go +++ b/internal/task/task/bs/detect_release.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +45,7 @@ type step2ParseOSRelease struct { host string success *bool out *string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2ParseOSRelease) Execute(ctx *context.Context) error { @@ -64,7 +65,7 @@ func (s *step2ParseOSRelease) Execute(ctx *context.Context) error { return errno.ERR_GET_OS_REELASE_FAILED.S(*s.out) } -func NewDetectOSReleaseTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewDetectOSReleaseTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_POLARFS_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/format.go b/internal/task/task/bs/format.go index 8b5f59960..d96bdeedc 100644 --- a/internal/task/task/bs/format.go +++ b/internal/task/task/bs/format.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +62,7 @@ type ( oldUuid *string uuid *string skipAdd bool - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } ) @@ -175,7 +176,7 @@ func device2ContainerName(device string) string { return fmt.Sprintf("curvebs-format-%s", utils.MD5Sum(device)) } -func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { +func NewFormatChunkfilePoolTask(curveadm *cli.DingoAdm, fc *configure.FormatConfig) (*task.Task, error) { host := fc.GetHost() hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/format_status.go b/internal/task/task/bs/format_status.go index 180104f17..1925e0864 100644 --- a/internal/task/task/bs/format_status.go +++ b/internal/task/task/bs/format_status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +113,7 @@ func (s *step2FormatStatus) Execute(ctx *context.Context) error { return nil } -func NewGetFormatStatusTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { +func NewGetFormatStatusTask(curveadm *cli.DingoAdm, fc *configure.FormatConfig) (*task.Task, error) { host := fc.GetHost() hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/format_stop.go b/internal/task/task/bs/format_stop.go index 3f2a07e0b..4f15903e6 100644 --- a/internal/task/task/bs/format_stop.go +++ b/internal/task/task/bs/format_stop.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +44,7 @@ func skipStopFormat(containerId *string) step.LambdaType { type stopContainer struct { containerId *string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *stopContainer) Execute(ctx *context.Context) error { @@ -66,7 +67,7 @@ func (s *stopContainer) Execute(ctx *context.Context) error { return nil } -func NewStopFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { +func NewStopFormatTask(curveadm *cli.DingoAdm, fc *configure.FormatConfig) (*task.Task, error) { host := fc.GetHost() hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/install_polarfs.go b/internal/task/task/bs/install_polarfs.go index 185f6ec25..6dcfeb3c0 100644 --- a/internal/task/task/bs/install_polarfs.go +++ b/internal/task/task/bs/install_polarfs.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +52,7 @@ const ( type step2InstallPackage struct { root string release string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2InstallPackage) Execute(ctx *context.Context) error { @@ -86,7 +87,7 @@ func (s *step2InstallPackage) Execute(ctx *context.Context) error { return nil } -func getRelease(curveadm *cli.CurveAdm) string { +func getRelease(curveadm *cli.DingoAdm) string { v := curveadm.MemStorage().Get(comm.KEY_OS_RELEASE) if v == nil { return comm.OS_RELEASE_UNKNOWN @@ -94,7 +95,7 @@ func getRelease(curveadm *cli.CurveAdm) string { return v.(string) } -func NewInstallPolarFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewInstallPolarFSTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_POLARFS_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/list_targets.go b/internal/task/task/bs/list_targets.go index 90cc1af09..ca89f66a3 100644 --- a/internal/task/task/bs/list_targets.go +++ b/internal/task/task/bs/list_targets.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +112,7 @@ func (s *step2FormatTarget) Execute(ctx *context.Context) error { return nil } -func NewListTargetsTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewListTargetsTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_TARGET_OPTIONS).(TargetOption) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/map.go b/internal/task/task/bs/map.go index bde449961..970c295e6 100644 --- a/internal/task/task/bs/map.go +++ b/internal/task/task/bs/map.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +72,7 @@ func getMapOptions(options MapOptions) string { return strings.Join(mapOptions, " ") } -func NewMapTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewMapTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/start_nebd.go b/internal/task/task/bs/start_nebd.go index 888798a2f..7768a156e 100644 --- a/internal/task/task/bs/start_nebd.go +++ b/internal/task/task/bs/start_nebd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +45,7 @@ const ( type ( step2InsertClient struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm options MapOptions config *configure.ClientConfig containerId *string @@ -146,7 +147,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { return nil } -func NewStartNEBDServiceTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewStartNEBDServiceTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/start_tgtd.go b/internal/task/task/bs/start_tgtd.go index d8d521aab..e36d4e533 100644 --- a/internal/task/task/bs/start_tgtd.go +++ b/internal/task/task/bs/start_tgtd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +58,7 @@ func (s *step2CheckTargetDaemonStatus) Execute(ctx *context.Context) error { F("host=%s", s.host) } -func NewStartTargetDaemonTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewStartTargetDaemonTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_TARGET_OPTIONS).(TargetOption) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/stop_tgtd.go b/internal/task/task/bs/stop_tgtd.go index f18ec26ee..c33af119f 100644 --- a/internal/task/task/bs/stop_tgtd.go +++ b/internal/task/task/bs/stop_tgtd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +42,7 @@ func checkTargetDaemonExist(containerId *string) step.LambdaType { } } -func NewStopTargetDaemonTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewStopTargetDaemonTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_TARGET_OPTIONS).(TargetOption) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/bs/uninstall_polarfs.go b/internal/task/task/bs/uninstall_polarfs.go index af75a2f07..f228ab4ed 100644 --- a/internal/task/task/bs/uninstall_polarfs.go +++ b/internal/task/task/bs/uninstall_polarfs.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ import ( type step2UninstallPackage struct { release string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2UninstallPackage) Execute(ctx *context.Context) error { @@ -67,7 +68,7 @@ func (s *step2UninstallPackage) Execute(ctx *context.Context) error { return nil } -func NewUninstallPolarFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewUninstallPolarFSTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_POLARFS_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/bs/unmap.go b/internal/task/task/bs/unmap.go index da47c829d..7fa01e55f 100644 --- a/internal/task/task/bs/unmap.go +++ b/internal/task/task/bs/unmap.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,13 +50,13 @@ type ( } step2RemoveContainer struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm status *string containerId string } step2DeleteClient struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm volumeId string } ) @@ -130,7 +131,7 @@ func (s *step2DeleteClient) Execute(ctx *context.Context) error { return nil } -func NewUnmapTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewUnmapTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) volumeId := curveadm.GetVolumeId(options.Host, options.User, options.Volume) containerId, err := curveadm.Storage().GetClientContainerId(volumeId) diff --git a/internal/task/task/checker/common.go b/internal/task/task/checker/common.go index 30fbe2dee..9e38dd3fc 100644 --- a/internal/task/task/checker/common.go +++ b/internal/task/task/checker/common.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/checker/date.go b/internal/task/task/checker/date.go index 838c48a50..db0d08e6f 100644 --- a/internal/task/task/checker/date.go +++ b/internal/task/task/checker/date.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +53,7 @@ func step2Pre(start *int64) step.LambdaType { } } -func newIfNil(curveadm *cli.CurveAdm) map[string]Time { +func newIfNil(curveadm *cli.DingoAdm) map[string]Time { m := curveadm.MemStorage().Get(comm.KEY_ALL_HOST_DATE) if m != nil { return m.(map[string]Time) @@ -60,7 +61,7 @@ func newIfNil(curveadm *cli.CurveAdm) map[string]Time { return map[string]Time{} } -func step2Post(curveadm *cli.CurveAdm, dc *topology.DeployConfig, start *int64, out *string) step.LambdaType { +func step2Post(curveadm *cli.DingoAdm, dc *topology.DeployConfig, start *int64, out *string) step.LambdaType { return func(ctx *context.Context) error { if len(*out) == 0 { return errno.ERR_INVALID_DATE_FORMAT. @@ -80,7 +81,7 @@ func step2Post(curveadm *cli.CurveAdm, dc *topology.DeployConfig, start *int64, } } -func NewGetHostDate(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewGetHostDate(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -106,7 +107,7 @@ func NewGetHostDate(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta return t, nil } -func checkDate(curveadm *cli.CurveAdm) step.LambdaType { +func checkDate(curveadm *cli.DingoAdm) step.LambdaType { return func(ctx *context.Context) error { var minT, maxT Time min, max := int64(0), int64(0) @@ -131,7 +132,7 @@ func checkDate(curveadm *cli.CurveAdm) step.LambdaType { } } -func NewCheckDate(curveadm *cli.CurveAdm, c interface{}) (*task.Task, error) { +func NewCheckDate(curveadm *cli.DingoAdm, c interface{}) (*task.Task, error) { t := task.NewTask("Check Host Date ", "", nil) t.AddStep(&step.Lambda{ Lambda: checkDate(curveadm), diff --git a/internal/task/task/checker/kernel.go b/internal/task/task/checker/kernel.go index 498d9a61d..3cc98dae5 100644 --- a/internal/task/task/checker/kernel.go +++ b/internal/task/task/checker/kernel.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +98,7 @@ func checkKernelModule(name string, success *bool, out *string) step.LambdaType } } -func NewCheckKernelVersionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckKernelVersionTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -122,7 +123,7 @@ func NewCheckKernelVersionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig return t, nil } -func NewCheckKernelModuleTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewCheckKernelModuleTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/checker/kernel_test.go b/internal/task/task/checker/kernel_test.go index f28ee6fdf..0e89d28a6 100644 --- a/internal/task/task/checker/kernel_test.go +++ b/internal/task/task/checker/kernel_test.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/checker/network.go b/internal/task/task/checker/network.go index 4bb64bb07..927c2d3a1 100644 --- a/internal/task/task/checker/network.go +++ b/internal/task/task/checker/network.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +78,7 @@ func joinPorts(dc *topology.DeployConfig, addresses []Address) string { return strings.Join(ports, ",") } -func getCheckPortContainerName(curveadm *cli.CurveAdm, dc *topology.DeployConfig) string { +func getCheckPortContainerName(curveadm *cli.DingoAdm, dc *topology.DeployConfig) string { return fmt.Sprintf("%s-%s-%s", CHECK_PORT_CONTAINER_NAME, dc.GetRole(), @@ -88,7 +89,7 @@ type step2CheckPortStatus struct { containerId *string success *bool dc *topology.DeployConfig - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm port int } @@ -125,7 +126,7 @@ func (s *step2CheckPortStatus) Execute(ctx *context.Context) error { return nil } -func NewCheckPortInUseTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckPortInUseTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -193,7 +194,7 @@ func checkReachable(success *bool, out *string) step.LambdaType { } } -func NewCheckDestinationReachableTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckDestinationReachableTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -234,7 +235,7 @@ func getNginxListens(dc *topology.DeployConfig) string { return strings.Join(listens, " ") } -func getHTTPServerContainerName(curveadm *cli.CurveAdm, dc *topology.DeployConfig) string { +func getHTTPServerContainerName(curveadm *cli.DingoAdm, dc *topology.DeployConfig) string { return fmt.Sprintf("%s-%s-%s", HTTP_SERVER_CONTAINER_NAME, dc.GetRole(), @@ -248,7 +249,7 @@ func waitNginxStarted(seconds int) step.LambdaType { } } -func NewStartHTTPServerTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewStartHTTPServerTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -318,7 +319,7 @@ func (s *step2CheckConnectStatus) Execute(ctx *context.Context) error { s.dc.GetRole(), s.dc.GetHost(), s.address.IP, s.address.Port) } -func NewCheckNetworkFirewallTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckNetworkFirewallTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -357,7 +358,7 @@ func NewCheckNetworkFirewallTask(curveadm *cli.CurveAdm, dc *topology.DeployConf type step2StopContainer struct { containerId *string dc *topology.DeployConfig - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2StopContainer) Execute(ctx *context.Context) error { @@ -387,7 +388,7 @@ func (s *step2StopContainer) Execute(ctx *context.Context) error { return nil } -func NewCleanEnvironmentTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCleanEnvironmentTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/checker/network_test.go b/internal/task/task/checker/network_test.go index 2007a47ea..de19a99bf 100644 --- a/internal/task/task/checker/network_test.go +++ b/internal/task/task/checker/network_test.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/checker/permission.go b/internal/task/task/checker/permission.go index 9d8742ac9..84fa311c8 100644 --- a/internal/task/task/checker/permission.go +++ b/internal/task/task/checker/permission.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +112,7 @@ func CheckEngineInfo(host, engine string, success *bool, out *string) step.Lambd } } -func NewCheckPermissionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckPermissionTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/checker/service.go b/internal/task/task/checker/service.go index 9b5cf1eda..eaba7ac7a 100644 --- a/internal/task/task/checker/service.go +++ b/internal/task/task/checker/service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +132,7 @@ func (s *step2CheckClientS3Configure) Execute(ctx *context.Context) error { return nil } -func NewCheckChunkfilePoolTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckChunkfilePoolTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err @@ -148,7 +149,7 @@ func NewCheckChunkfilePoolTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig return t, nil } -func NewCheckS3Task(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckS3Task(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) t := task.NewTask("Check S3", subname, nil) @@ -162,7 +163,7 @@ func NewCheckS3Task(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta return t, nil } -func NewCheckMdsAddressTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewCheckMdsAddressTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { @@ -176,7 +177,7 @@ func NewCheckMdsAddressTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) return t, nil } -func NewClientS3ConfigureTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewClientS3ConfigureTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { t := task.NewTask("Check S3 Configure ", "", nil) t.AddStep(&step2CheckClientS3Configure{ @@ -186,6 +187,6 @@ func NewClientS3ConfigureTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig return t, nil } -func NewCheckDiskUsageTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewCheckDiskUsageTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { return nil, nil } diff --git a/internal/task/task/checker/ssh.go b/internal/task/task/checker/ssh.go index 3dde7adbb..2946aacbd 100644 --- a/internal/task/task/checker/ssh.go +++ b/internal/task/task/checker/ssh.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +65,7 @@ func checkHost(hc *hosts.HostConfig) step.LambdaType { } } -func NewCheckSSHConnectTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCheckSSHConnectTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/checker/topology.go b/internal/task/task/checker/topology.go index 24766a247..c5f998aa4 100644 --- a/internal/task/task/checker/topology.go +++ b/internal/task/task/checker/topology.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,13 +45,13 @@ type ( // check whether host exist step2CheckSSHConfigure struct { dc *topology.DeployConfig - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } // check whether the S3 configure is valid step2CheckS3Configure struct { dc *topology.DeployConfig - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } // check whether directory path is absolute path @@ -73,7 +74,7 @@ type ( // (1) each role requires at least 3 services // (2) each requires at least 3 hosts step2CheckServices struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm dcs []*topology.DeployConfig } ) @@ -259,7 +260,7 @@ func (s *step2CheckServices) Execute(ctx *context.Context) error { return nil } -func NewCheckTopologyTask(curveadm *cli.CurveAdm, null interface{}) (*task.Task, error) { +func NewCheckTopologyTask(curveadm *cli.DingoAdm, null interface{}) (*task.Task, error) { // new task dcs := curveadm.MemStorage().Get(comm.KEY_ALL_DEPLOY_CONFIGS).([]*topology.DeployConfig) subname := fmt.Sprintf("cluster=%s kind=%s", curveadm.ClusterName(), dcs[0].GetKind()) diff --git a/internal/task/task/common/backup_etcd.go b/internal/task/task/common/backup_etcd.go index bb7b061e6..ce535a200 100644 --- a/internal/task/task/common/backup_etcd.go +++ b/internal/task/task/common/backup_etcd.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ func genBackupCommand(dc *topology.DeployConfig) string { return command } -func NewBackupEtcdDataTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewBackupEtcdDataTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/clean_service.go b/internal/task/task/common/clean_service.go index 1a0b198da..760b09cfe 100644 --- a/internal/task/task/common/clean_service.go +++ b/internal/task/task/common/clean_service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +132,7 @@ func getCleanFiles(clean map[string]bool, dc *topology.DeployConfig, recycle boo return files } -func NewCleanServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCleanServiceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/client_status.go b/internal/task/task/common/client_status.go index 77ba1a26f..1c6c183c4 100644 --- a/internal/task/task/common/client_status.go +++ b/internal/task/task/common/client_status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +65,7 @@ type ( } ) -func dumpCfg(curveadm *cli.CurveAdm, id string, cfgPath *string) step.LambdaType { +func dumpCfg(curveadm *cli.DingoAdm, id string, cfgPath *string) step.LambdaType { return func(ctx *context.Context) error { *cfgPath = MISSING_CLIENT_CONFIG cfgs, err := curveadm.Storage().GetClientConfig(id) @@ -136,7 +137,7 @@ func (s *step2FormatClientStatus) Execute(ctx *context.Context) error { return nil } -func NewInitClientStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewInitClientStatusTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { client := v.(storage.Client) t := task.NewTask("Init Client Status", "", nil) @@ -154,7 +155,7 @@ func NewInitClientStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, return t, nil } -func NewGetClientStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewGetClientStatusTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { client := v.(storage.Client) hc, err := curveadm.GetHost(client.Host) if err != nil { diff --git a/internal/task/task/common/collect_client.go b/internal/task/task/common/collect_client.go index 5b7f6bc86..4d14a0884 100644 --- a/internal/task/task/common/collect_client.go +++ b/internal/task/task/common/collect_client.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ import ( "github.com/dingodb/dingoadm/internal/utils" ) -func NewCollectClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewCollectClientTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { client := v.(storage.Client) hc, err := curveadm.GetHost(client.Host) if err != nil { diff --git a/internal/task/task/common/collect_curveadm.go b/internal/task/task/common/collect_curveadm.go index 22ea6110d..4b19a8b15 100644 --- a/internal/task/task/common/collect_curveadm.go +++ b/internal/task/task/common/collect_curveadm.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,7 @@ import ( "github.com/dingodb/dingoadm/internal/utils" ) -func NewCollectCurveAdmTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCollectCurveAdmTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { // NOTE: we think it's not a good idae to collect curveadm's datbase file... // new task kind := dc.GetKind() diff --git a/internal/task/task/common/collect_report.go b/internal/task/task/common/collect_report.go index 11110fa8c..77da1ebd1 100644 --- a/internal/task/task/common/collect_report.go +++ b/internal/task/task/common/collect_report.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +70,7 @@ func (s *step2EncryptFile) Execute(ctx *context.Context) error { return nil } -func NewCollectReportTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCollectReportTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { /* // new task kind := dc.GetKind() diff --git a/internal/task/task/common/collect_service.go b/internal/task/task/common/collect_service.go index 83d7df219..5ebebd6c9 100644 --- a/internal/task/task/common/collect_service.go +++ b/internal/task/task/common/collect_service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ type ( files *[]string containerId string hostDestDir string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } ) @@ -73,7 +74,7 @@ func (s *step2CopyFilesFromContainer) Execute(ctx *context.Context) error { return nil } -func NewCollectServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCollectServiceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.Storage().GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/create_container.go b/internal/task/task/common/create_container.go index 1cf159d04..b6fb62666 100644 --- a/internal/task/task/common/create_container.go +++ b/internal/task/task/common/create_container.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,7 +212,7 @@ func TrimContainerId(containerId *string) step.LambdaType { } } -func NewCreateContainerTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCreateContainerTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/common/create_pool.go b/internal/task/task/common/create_pool.go index 83c693038..dbe887841 100644 --- a/internal/task/task/common/create_pool.go +++ b/internal/task/task/common/create_pool.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,19 +44,19 @@ import ( ) type step2SetClusterPool struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm clusterPool string storage *storage.Storage } -func getPoolset(curveadm *cli.CurveAdm, kind string) configure.Poolset { +func getPoolset(curveadm *cli.DingoAdm, kind string) configure.Poolset { if kind == configure.KIND_CURVEFS || kind == configure.KIND_DINGOFS { return configure.Poolset{} } return curveadm.MemStorage().Get(comm.KEY_POOLSET).(configure.Poolset) } -func getClusterPool(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (configure.CurveClusterTopo, error) { +func getClusterPool(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (configure.CurveClusterTopo, error) { poolset := getPoolset(curveadm, dc.GetKind()) oldPool := configure.CurveClusterTopo{} dcs, err := curveadm.ParseTopology() @@ -95,7 +96,7 @@ func getClusterPool(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (configur return oldPool, err } -func prepare(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (clusterPoolJson, clusterMDSAddrs string, err error) { +func prepare(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (clusterPoolJson, clusterMDSAddrs string, err error) { // 1. get origin cluster pool var clusterPool configure.CurveClusterTopo clusterPool, err = getClusterPool(curveadm, dc) @@ -181,7 +182,7 @@ func (s *step2SetClusterPool) Execute(ctx *context.Context) error { return nil } -func NewCreateTopologyTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewCreateTopologyTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/etcd_auth_enable.go b/internal/task/task/common/etcd_auth_enable.go index 157dfa0a2..9c4b6cdb0 100644 --- a/internal/task/task/common/etcd_auth_enable.go +++ b/internal/task/task/common/etcd_auth_enable.go @@ -44,7 +44,7 @@ func checkEnableEtcdAuthStatus(success *bool, out *string) step.LambdaType { } } -func NewEnableEtcdAuthTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewEnableEtcdAuthTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/init_support.go b/internal/task/task/common/init_support.go index 62dadbc91..ef185ec20 100644 --- a/internal/task/task/common/init_support.go +++ b/internal/task/task/common/init_support.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +34,7 @@ import ( "github.com/dingodb/dingoadm/internal/task/task" ) -func NewInitSupportTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewInitSupportTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { // new task kind := dc.GetKind() subname := fmt.Sprintf("cluster=%s kind=%s", diff --git a/internal/task/task/common/install_client.go b/internal/task/task/common/install_client.go index 10c8a0044..0285b713e 100644 --- a/internal/task/task/common/install_client.go +++ b/internal/task/task/common/install_client.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +63,7 @@ const ( type step2InstallPackage struct { root string release string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2InstallPackage) Execute(ctx *context.Context) error { @@ -122,7 +123,7 @@ func newClientMutate(cc *configure.ClientConfig, delimiter string) step.Mutate { } } -func getRelease(curveadm *cli.CurveAdm) string { +func getRelease(curveadm *cli.DingoAdm) string { v := curveadm.MemStorage().Get(comm.KEY_OS_RELEASE) if v == nil { return comm.OS_RELEASE_UNKNOWN @@ -130,7 +131,7 @@ func getRelease(curveadm *cli.CurveAdm) string { return v.(string) } -func NewInstallClientTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewInstallClientTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/common/pull_image.go b/internal/task/task/common/pull_image.go index f2640985e..a24f4099e 100644 --- a/internal/task/task/common/pull_image.go +++ b/internal/task/task/common/pull_image.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +34,7 @@ import ( "github.com/dingodb/dingoadm/internal/task/task" ) -func NewPullImageTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewPullImageTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/common/restart_service.go b/internal/task/task/common/restart_service.go index f34b59551..06e10d99b 100644 --- a/internal/task/task/common/restart_service.go +++ b/internal/task/task/common/restart_service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,7 @@ func WaitContainerStart(seconds int) step.LambdaType { } } -func NewRestartServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewRestartServiceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/service_status.go b/internal/task/task/common/service_status.go index 61cb4ffc5..d8abd80a1 100644 --- a/internal/task/task/common/service_status.go +++ b/internal/task/task/common/service_status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -218,7 +219,7 @@ func (s *step2FormatServiceStatus) Execute(ctx *context.Context) error { return nil } -func NewInitServiceStatusTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewInitServiceStatusTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { @@ -249,7 +250,7 @@ func TrimContainerStatus(status *string) step.LambdaType { } } -func NewGetServiceStatusTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewGetServiceStatusTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/start_service.go b/internal/task/task/common/start_service.go index 87e92fd37..e8231ad6a 100644 --- a/internal/task/task/common/start_service.go +++ b/internal/task/task/common/start_service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +74,7 @@ func (s *Step2CheckPostStart) Execute(ctx *context.Context) error { return nil } -func NewStartServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewStartServiceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/stop_service.go b/internal/task/task/common/stop_service.go index f027a1f9b..314fb3090 100644 --- a/internal/task/task/common/stop_service.go +++ b/internal/task/task/common/stop_service.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +58,7 @@ func checkContainerId(containerId string) step.LambdaType { } } -func NewStopServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewStopServiceTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { hc, err := curveadm.GetHost(dc.GetHost()) if err != nil { return nil, err diff --git a/internal/task/task/common/sync_config.go b/internal/task/task/common/sync_config.go index a39384078..7d912e39e 100644 --- a/internal/task/task/common/sync_config.go +++ b/internal/task/task/common/sync_config.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +88,7 @@ func newCrontab(uuid string, dc *topology.DeployConfig, reportScriptPath string) return fmt.Sprintf("%s %s\n", period, command) } -func NewSyncConfigTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) { +func NewSyncConfigTask(curveadm *cli.DingoAdm, dc *topology.DeployConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(dc.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if curveadm.IsSkip(dc) { diff --git a/internal/task/task/common/uninstall_client.go b/internal/task/task/common/uninstall_client.go index 4cda47572..94db96876 100644 --- a/internal/task/task/common/uninstall_client.go +++ b/internal/task/task/common/uninstall_client.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ import ( type step2UninstallPackage struct { kind string release string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } func (s *step2UninstallPackage) Execute(ctx *context.Context) error { @@ -69,7 +70,7 @@ func (s *step2UninstallPackage) Execute(ctx *context.Context) error { return nil } -func NewUninstallClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewUninstallClientTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/common/update_topology.go b/internal/task/task/common/update_topology.go index ee637f315..b7212536a 100644 --- a/internal/task/task/common/update_topology.go +++ b/internal/task/task/common/update_topology.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +34,7 @@ import ( "github.com/dingodb/dingoadm/internal/task/task" ) -func updateTopology(curveadm *cli.CurveAdm) step.LambdaType { +func updateTopology(curveadm *cli.DingoAdm) step.LambdaType { return func(ctx *context.Context) error { topology := curveadm.MemStorage().Get(comm.KEY_NEW_TOPOLOGY_DATA).(string) err := curveadm.Storage().SetClusterTopology(curveadm.ClusterId(), topology) @@ -44,7 +45,7 @@ func updateTopology(curveadm *cli.CurveAdm) step.LambdaType { } } -func NewUpdateTopologyTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewUpdateTopologyTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { t := task.NewTask("Update Topology", "", nil) // add step to task diff --git a/internal/task/task/fs/mount.go b/internal/task/task/fs/mount.go index b92d345ce..e1ff47ba6 100644 --- a/internal/task/task/fs/mount.go +++ b/internal/task/task/fs/mount.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +59,7 @@ type ( } step2InsertClient struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm options MountOptions config *configure.ClientConfig containerId *string @@ -318,7 +319,7 @@ func checkStartContainerStatus(success *bool, out *string) step.LambdaType { } } -func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { +func NewMountFSTask(curveadm *cli.DingoAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MOUNT_OPTIONS).(MountOptions) hc, err := curveadm.GetHost(options.Host) if err != nil { diff --git a/internal/task/task/fs/umount.go b/internal/task/task/fs/umount.go index 900387aef..c8eceddce 100644 --- a/internal/task/task/fs/umount.go +++ b/internal/task/task/fs/umount.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,18 +46,18 @@ type ( containerId string status *string mountPoint string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } step2RemoveContainer struct { status *string containerId string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } step2DeleteClient struct { fsId string - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } ) @@ -126,7 +127,7 @@ func (s *step2RemoveContainer) Execute(ctx *context.Context) error { return nil } -func NewUmountFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewUmountFSTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MOUNT_OPTIONS).(MountOptions) fsId := curveadm.GetFilesystemId(options.Host, options.MountPoint) hc, err := curveadm.GetHost(options.Host) diff --git a/internal/task/task/gateway/start.go b/internal/task/task/gateway/start.go index d60897618..06d89c034 100644 --- a/internal/task/task/gateway/start.go +++ b/internal/task/task/gateway/start.go @@ -40,7 +40,7 @@ import ( "github.com/dingodb/dingoadm/internal/utils" ) -func NewStartGatewayTask(curveadm *cli.CurveAdm, gc *configure.GatewayConfig) (*task.Task, error) { +func NewStartGatewayTask(curveadm *cli.DingoAdm, gc *configure.GatewayConfig) (*task.Task, error) { host := curveadm.MemStorage().Get(comm.GATEWAY_HOST).(string) hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/monitor/clean_container.go b/internal/task/task/monitor/clean_container.go index 87f5705f6..4c6063f1b 100644 --- a/internal/task/task/monitor/clean_container.go +++ b/internal/task/task/monitor/clean_container.go @@ -29,7 +29,7 @@ import ( "github.com/dingodb/dingoadm/internal/task/task/common" ) -func NewCleanConfigContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewCleanConfigContainerTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { role := cfg.GetRole() if role != ROLE_MONITOR_CONF { return nil, nil diff --git a/internal/task/task/monitor/clean_service.go b/internal/task/task/monitor/clean_service.go index 4925ef6ae..5c18e1ff4 100644 --- a/internal/task/task/monitor/clean_service.go +++ b/internal/task/task/monitor/clean_service.go @@ -54,7 +54,7 @@ func getCleanFiles(clean map[string]bool, mc *configure.MonitorConfig) []string return files } -func NewCleanMonitorTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewCleanMonitorTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if err != nil { diff --git a/internal/task/task/monitor/create_container.go b/internal/task/task/monitor/create_container.go index e656e702b..af16138fa 100644 --- a/internal/task/task/monitor/create_container.go +++ b/internal/task/task/monitor/create_container.go @@ -111,7 +111,7 @@ func getEnvironments(cfg *configure.MonitorConfig) []string { return []string{} } -func NewCreateContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewCreateContainerTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { host := cfg.GetHost() hc, err := curveadm.GetHost(host) if err != nil { diff --git a/internal/task/task/monitor/pull_image.go b/internal/task/task/monitor/pull_image.go index 669ddbef8..37864fa57 100644 --- a/internal/task/task/monitor/pull_image.go +++ b/internal/task/task/monitor/pull_image.go @@ -31,7 +31,7 @@ import ( "github.com/dingodb/dingoadm/internal/task/task" ) -func NewPullImageTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewPullImageTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { image := cfg.GetImage() host := cfg.GetHost() hc, err := curveadm.GetHost(host) diff --git a/internal/task/task/monitor/restart_service.go b/internal/task/task/monitor/restart_service.go index bf1525b0f..e2ac6de11 100644 --- a/internal/task/task/monitor/restart_service.go +++ b/internal/task/task/monitor/restart_service.go @@ -33,7 +33,7 @@ import ( tui "github.com/dingodb/dingoadm/internal/tui/common" ) -func NewRestartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewRestartServiceTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF}) { diff --git a/internal/task/task/monitor/start_service.go b/internal/task/task/monitor/start_service.go index c9f0214b4..57b807610 100644 --- a/internal/task/task/monitor/start_service.go +++ b/internal/task/task/monitor/start_service.go @@ -43,7 +43,7 @@ func IsSkip(mc *configure.MonitorConfig, roles []string) bool { return false } -func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewStartServiceTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF}) { diff --git a/internal/task/task/monitor/status_service.go b/internal/task/task/monitor/status_service.go index 7f80c6e4d..99135d452 100644 --- a/internal/task/task/monitor/status_service.go +++ b/internal/task/task/monitor/status_service.go @@ -115,7 +115,7 @@ func (s *step2FormatMonitorStatus) Execute(ctx *context.Context) error { return nil } -func NewInitMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewInitMonitorStatusTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF}) { @@ -138,7 +138,7 @@ func NewInitMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConf return t, nil } -func NewGetMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewGetMonitorStatusTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF}) { diff --git a/internal/task/task/monitor/stop_service.go b/internal/task/task/monitor/stop_service.go index ef3feecbd..1e00c5fa9 100644 --- a/internal/task/task/monitor/stop_service.go +++ b/internal/task/task/monitor/stop_service.go @@ -33,7 +33,7 @@ import ( tui "github.com/dingodb/dingoadm/internal/tui/common" ) -func NewStopServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewStopServiceTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF}) { diff --git a/internal/task/task/monitor/sync_config.go b/internal/task/task/monitor/sync_config.go index 09ffa3155..7b3ff1baf 100644 --- a/internal/task/task/monitor/sync_config.go +++ b/internal/task/task/monitor/sync_config.go @@ -54,7 +54,7 @@ func getNodeExporterAddrs(hosts []string, port int) string { return fmt.Sprintf("[%s]", strings.Join(endpoint, ",")) } -func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { +func NewSyncConfigTask(curveadm *cli.DingoAdm, cfg *configure.MonitorConfig) (*task.Task, error) { serviceId := curveadm.GetServiceId(cfg.GetId()) containerId, err := curveadm.GetContainerId(serviceId) if IsSkip(cfg, []string{ROLE_MONITOR_CONF, ROLE_NODE_EXPORTER}) { diff --git a/internal/task/task/playground/create.go b/internal/task/task/playground/create.go index f30ce7120..0d35efee3 100644 --- a/internal/task/task/playground/create.go +++ b/internal/task/task/playground/create.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ type ( } step2InsertPlayGround struct { - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm cfg *configure.PlaygroundConfig } ) @@ -70,7 +71,7 @@ func getMountVolumes(kind string) []step.Volume { } } -func execOptions(curveadm *cli.CurveAdm) module.ExecOptions { +func execOptions(curveadm *cli.DingoAdm) module.ExecOptions { options := curveadm.ExecOptions() options.ExecInLocal = true options.ExecWithSudo = false @@ -92,7 +93,7 @@ func (s *step2InsertPlayGround) Execute(ctx *context.Context) error { return nil } -func NewCreatePlaygroundTask(curveadm *cli.CurveAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { +func NewCreatePlaygroundTask(curveadm *cli.DingoAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { kind := cfg.GetKind() name := cfg.GetName() containerImage := cfg.GetContainIamge() diff --git a/internal/task/task/playground/init.go b/internal/task/task/playground/init.go index bf4b39824..03688e979 100644 --- a/internal/task/task/playground/init.go +++ b/internal/task/task/playground/init.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +102,7 @@ func prepare(dcs []*topology.DeployConfig, poolset configure.Poolset) (string, e return string(bytes), err } -func NewInitPlaygroundTask(curveadm *cli.CurveAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { +func NewInitPlaygroundTask(curveadm *cli.DingoAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { // new task kind := cfg.GetKind() name := cfg.GetName() diff --git a/internal/task/task/playground/list.go b/internal/task/task/playground/list.go index e7a374384..8751c9780 100644 --- a/internal/task/task/playground/list.go +++ b/internal/task/task/playground/list.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +80,7 @@ func (s *step2FormatPlaygroundStatus) Execute(ctx *context.Context) error { return nil } -func NewGetPlaygroundStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewGetPlaygroundStatusTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { // new task playground := v.(storage.Playground) subname := fmt.Sprintf("id=%d name=%s", playground.Id, playground.Name) diff --git a/internal/task/task/playground/remove.go b/internal/task/task/playground/remove.go index 7745bc1b7..76fb5e97d 100644 --- a/internal/task/task/playground/remove.go +++ b/internal/task/task/playground/remove.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,12 +38,12 @@ type ( step2RemoveContainer struct { containerId *string plaground storage.Playground - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } step2DeletePlayground struct { plaground storage.Playground - curveadm *cli.CurveAdm + curveadm *cli.DingoAdm } ) @@ -91,7 +92,7 @@ func (s *step2DeletePlayground) Execute(ctx *context.Context) error { return nil } -func NewRemovePlaygroundTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { +func NewRemovePlaygroundTask(curveadm *cli.DingoAdm, v interface{}) (*task.Task, error) { // new task playground := v.(storage.Playground) subname := fmt.Sprintf("name=%s", playground.Name) diff --git a/internal/task/task/playground/script/script.go b/internal/task/task/playground/script/script.go index dc2058fc7..2ef49a121 100644 --- a/internal/task/task/playground/script/script.go +++ b/internal/task/task/playground/script/script.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/task/playground/start.go b/internal/task/task/playground/start.go index 5f077393d..f473fa2c7 100644 --- a/internal/task/task/playground/start.go +++ b/internal/task/task/playground/start.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +41,7 @@ func wait(seconds int) step.LambdaType { } } -func NewStartPlaygroundTask(curveadm *cli.CurveAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { +func NewStartPlaygroundTask(curveadm *cli.DingoAdm, cfg *configure.PlaygroundConfig) (*task.Task, error) { // new task subname := fmt.Sprintf("kind=%s name=%s", cfg.GetKind(), cfg.GetName()) t := task.NewTask("Start Playground", subname, nil) diff --git a/internal/task/task/task.go b/internal/task/task/task.go index 9a8730beb..bd622fa0e 100644 --- a/internal/task/task/task.go +++ b/internal/task/task/task.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/tasks/monitor.go b/internal/task/tasks/monitor.go index 4125e097a..112177cc8 100644 --- a/internal/task/tasks/monitor.go +++ b/internal/task/tasks/monitor.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/task/tasks/tasks.go b/internal/task/tasks/tasks.go index aa42d53d6..484446214 100644 --- a/internal/task/tasks/tasks.go +++ b/internal/task/tasks/tasks.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tasks/monitor.go b/internal/tasks/monitor.go index 109b6d305..d62114ff0 100644 --- a/internal/tasks/monitor.go +++ b/internal/tasks/monitor.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tasks/tasks.go b/internal/tasks/tasks.go index fcdfeeb77..18270480e 100644 --- a/internal/tasks/tasks.go +++ b/internal/tasks/tasks.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tools/ssh.go b/internal/tools/ssh.go index 931496ded..d887797c1 100644 --- a/internal/tools/ssh.go +++ b/internal/tools/ssh.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +46,7 @@ const ( TEMPLATE_COMMAND_EXEC_CONTAINER_NOATTACH = `{{.sudo}} {{.engine}} exec -t {{.container_id}} /bin/bash -c "{{.command}}"` ) -func prepareOptions(curveadm *cli.CurveAdm, host string, become bool, extra map[string]interface{}) (map[string]interface{}, error) { +func prepareOptions(curveadm *cli.DingoAdm, host string, become bool, extra map[string]interface{}) (map[string]interface{}, error) { options := map[string]interface{}{} hc, err := curveadm.GetHost(host) if err != nil { @@ -77,7 +78,7 @@ func prepareOptions(curveadm *cli.CurveAdm, host string, become bool, extra map[ return options, nil } -func newCommand(curveadm *cli.CurveAdm, text string, options map[string]interface{}) (*exec.Cmd, error) { +func newCommand(curveadm *cli.DingoAdm, text string, options map[string]interface{}) (*exec.Cmd, error) { tmpl := template.Must(template.New(utils.MD5Sum(text)).Parse(text)) buffer := bytes.NewBufferString("") if err := tmpl.Execute(buffer, options); err != nil { @@ -88,7 +89,7 @@ func newCommand(curveadm *cli.CurveAdm, text string, options map[string]interfac return exec.Command(items[0], items[1:]...), nil } -func runCommand(curveadm *cli.CurveAdm, text string, options map[string]interface{}) error { +func runCommand(curveadm *cli.DingoAdm, text string, options map[string]interface{}) error { cmd, err := newCommand(curveadm, text, options) if err != nil { return err @@ -99,7 +100,7 @@ func runCommand(curveadm *cli.CurveAdm, text string, options map[string]interfac return cmd.Run() } -func runCommandOutput(curveadm *cli.CurveAdm, text string, options map[string]interface{}) (string, error) { +func runCommandOutput(curveadm *cli.DingoAdm, text string, options map[string]interface{}) (string, error) { cmd, err := newCommand(curveadm, text, options) if err != nil { return "", err @@ -108,7 +109,7 @@ func runCommandOutput(curveadm *cli.CurveAdm, text string, options map[string]in return string(out), err } -func ssh(curveadm *cli.CurveAdm, options map[string]interface{}) error { +func ssh(curveadm *cli.DingoAdm, options map[string]interface{}) error { err := runCommand(curveadm, TEMPLATE_SSH_ATTACH, options) if err != nil && !strings.HasPrefix(err.Error(), "exit status") { return errno.ERR_CONNECT_REMOTE_HOST_WITH_INTERACT_BY_SSH_FAILED.E(err) @@ -116,17 +117,17 @@ func ssh(curveadm *cli.CurveAdm, options map[string]interface{}) error { return nil } -func scp(curveadm *cli.CurveAdm, options map[string]interface{}) error { +func scp(curveadm *cli.DingoAdm, options map[string]interface{}) error { // TODO: added error code _, err := runCommandOutput(curveadm, TEMPLATE_SCP, options) return err } -func execute(curveadm *cli.CurveAdm, options map[string]interface{}) (string, error) { +func execute(curveadm *cli.DingoAdm, options map[string]interface{}) (string, error) { return runCommandOutput(curveadm, TEMPLATE_SSH_COMMAND, options) } -func AttachRemoteHost(curveadm *cli.CurveAdm, host string, become bool) error { +func AttachRemoteHost(curveadm *cli.DingoAdm, host string, become bool) error { options, err := prepareOptions(curveadm, host, become, map[string]interface{}{"command": "/bin/bash"}) if err != nil { @@ -135,7 +136,7 @@ func AttachRemoteHost(curveadm *cli.CurveAdm, host string, become bool) error { return ssh(curveadm, options) } -func AttachRemoteContainer(curveadm *cli.CurveAdm, host, containerId, home string) error { +func AttachRemoteContainer(curveadm *cli.DingoAdm, host, containerId, home string) error { data := map[string]interface{}{ "sudo": curveadm.Config().GetSudoAlias(), "engine": curveadm.Config().GetEngine(), @@ -157,7 +158,7 @@ func AttachRemoteContainer(curveadm *cli.CurveAdm, host, containerId, home strin return ssh(curveadm, options) } -func AttachLocalContainer(curveadm *cli.CurveAdm, containerId string) error { +func AttachLocalContainer(curveadm *cli.DingoAdm, containerId string) error { data := map[string]interface{}{ "container_id": containerId, "engine": curveadm.Config().GetEngine(), @@ -171,7 +172,7 @@ func AttachLocalContainer(curveadm *cli.CurveAdm, containerId string) error { return runCommand(curveadm, command, map[string]interface{}{}) } -func ExecCmdInRemoteContainer(curveadm *cli.CurveAdm, host, containerId, cmd string) error { +func ExecCmdInRemoteContainer(curveadm *cli.DingoAdm, host, containerId, cmd string) error { data := map[string]interface{}{ "sudo": curveadm.Config().GetSudoAlias(), "engine": curveadm.Config().GetEngine(), @@ -193,7 +194,7 @@ func ExecCmdInRemoteContainer(curveadm *cli.CurveAdm, host, containerId, cmd str return ssh(curveadm, options) } -func Scp(curveadm *cli.CurveAdm, host, source, target string) error { +func Scp(curveadm *cli.DingoAdm, host, source, target string) error { options, err := prepareOptions(curveadm, host, false, map[string]interface{}{ "source": source, @@ -205,7 +206,7 @@ func Scp(curveadm *cli.CurveAdm, host, source, target string) error { return scp(curveadm, options) } -func ExecuteRemoteCommand(curveadm *cli.CurveAdm, host, command string) (string, error) { +func ExecuteRemoteCommand(curveadm *cli.DingoAdm, host, command string) (string, error) { options, err := prepareOptions(curveadm, host, true, map[string]interface{}{"command": command}) if err != nil { diff --git a/internal/tools/upgrade.go b/internal/tools/upgrade.go index 2e180992b..72b532761 100644 --- a/internal/tools/upgrade.go +++ b/internal/tools/upgrade.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tools/upgrade/upgrade.go b/internal/tools/upgrade/upgrade.go index 01c438125..2e469fffc 100644 --- a/internal/tools/upgrade/upgrade.go +++ b/internal/tools/upgrade/upgrade.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tools/upload.go b/internal/tools/upload.go index 348750f0c..243532ff2 100644 --- a/internal/tools/upload.go +++ b/internal/tools/upload.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/audit.go b/internal/tui/audit.go index ca822993a..7b1a7f44a 100644 --- a/internal/tui/audit.go +++ b/internal/tui/audit.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/client/status.go b/internal/tui/client/status.go index 4d385cebc..32c1bd1fc 100644 --- a/internal/tui/client/status.go +++ b/internal/tui/client/status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/clients.go b/internal/tui/clients.go index a88d4cee2..08e389475 100644 --- a/internal/tui/clients.go +++ b/internal/tui/clients.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/clusters.go b/internal/tui/clusters.go index 0ba99d107..79be8c95e 100644 --- a/internal/tui/clusters.go +++ b/internal/tui/clusters.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/common/prompt.go b/internal/tui/common/prompt.go index 8ea5dcc35..5596accc5 100644 --- a/internal/tui/common/prompt.go +++ b/internal/tui/common/prompt.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/common/tui.go b/internal/tui/common/tui.go index 45a18c04f..df00d0ba7 100644 --- a/internal/tui/common/tui.go +++ b/internal/tui/common/tui.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/format/status.go b/internal/tui/format/status.go index e816810ac..f0ed3af8c 100644 --- a/internal/tui/format/status.go +++ b/internal/tui/format/status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/hosts.go b/internal/tui/hosts.go index b95201cca..de7b8e0c1 100644 --- a/internal/tui/hosts.go +++ b/internal/tui/hosts.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/playground.go b/internal/tui/playground.go index 2c048ef07..ecc5ae32e 100644 --- a/internal/tui/playground.go +++ b/internal/tui/playground.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/service/status.go b/internal/tui/service/status.go index cb0ea4710..7e006b47e 100644 --- a/internal/tui/service/status.go +++ b/internal/tui/service/status.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/tui/targets.go b/internal/tui/targets.go index 22ded30b3..d57abdd15 100644 --- a/internal/tui/targets.go +++ b/internal/tui/targets.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/utils/cobra.go b/internal/utils/cobra.go index 6693480fa..fe8978979 100644 --- a/internal/utils/cobra.go +++ b/internal/utils/cobra.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/utils/common.go b/internal/utils/common.go index 056a649a8..4c5ec32a6 100644 --- a/internal/utils/common.go +++ b/internal/utils/common.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/utils/file.go b/internal/utils/file.go index 0ecd12aa3..fb2df7871 100644 --- a/internal/utils/file.go +++ b/internal/utils/file.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/utils/fs.go b/internal/utils/fs.go index 6145f21f4..9a667c754 100644 --- a/internal/utils/fs.go +++ b/internal/utils/fs.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/internal/utils/map.go b/internal/utils/map.go index 0be87594d..e0798fc02 100644 --- a/internal/utils/map.go +++ b/internal/utils/map.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/log/glg/log.go b/pkg/log/glg/log.go index 5846d12b6..b6e25888d 100644 --- a/pkg/log/glg/log.go +++ b/pkg/log/glg/log.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/log/log.go b/pkg/log/log.go index eb67ca580..c0151ef68 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/log/zaplog/log.go b/pkg/log/zaplog/log.go index 76e22b69d..e0361b680 100644 --- a/pkg/log/zaplog/log.go +++ b/pkg/log/zaplog/log.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/module/docker_cli.go b/pkg/module/docker_cli.go index 43974faf8..e41bdd6f4 100644 --- a/pkg/module/docker_cli.go +++ b/pkg/module/docker_cli.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/module/file.go b/pkg/module/file.go index e56466a3d..8f9571350 100644 --- a/pkg/module/file.go +++ b/pkg/module/file.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/module/module.go b/pkg/module/module.go index 55d097207..feb46d30a 100644 --- a/pkg/module/module.go +++ b/pkg/module/module.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/module/shell.go b/pkg/module/shell.go index 9be3379dd..c3f79be70 100644 --- a/pkg/module/shell.go +++ b/pkg/module/shell.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/module/ssh.go b/pkg/module/ssh.go index ddc95f636..f05edf8ed 100644 --- a/pkg/module/ssh.go +++ b/pkg/module/ssh.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/variable/variables.go b/pkg/variable/variables.go index cd703ecb0..8f203cfb1 100644 --- a/pkg/variable/variables.go +++ b/pkg/variable/variables.go @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 NetEase Inc. + * Copyright (c) 2024 dingodb.com Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/scripts/install_dingoadm.sh b/scripts/install_dingoadm.sh index 4edbb4607..b557c2f90 100755 --- a/scripts/install_dingoadm.sh +++ b/scripts/install_dingoadm.sh @@ -8,10 +8,11 @@ g_dingoadm_home="${HOME}/.dingoadm" g_bin_dir="${g_dingoadm_home}/bin" g_db_path="${g_dingoadm_home}/data/dingoadm.db" g_profile="${HOME}/.profile" -g_root_url="https://work.dingodb.top" -g_upgrade="${CURVEADM_UPGRADE}" -g_version="${CURVEADM_VERSION:=$g_latest_version}" -g_download_url="${g_root_url}/dingoadm.tar.gz" +g_internal_url="https://work.dingodb.top" +g_github_url="https://github.com/dingodb/dingoadm/releases/download/latest/dingoadm" +g_upgrade="${DINGOADM_UPGRADE}" +g_version="${DINGOADM_VERSION:=$g_latest_version}" +g_download_url="${g_internal_url}/dingoadm.tar.gz" ############################ BASIC FUNCTIONS msg() { @@ -66,13 +67,38 @@ __EOF__ fi } -install_binray() { +install_binary() { local ret=1 - local tempfile="/tmp/dingoadm-$(date +%s%6N).tar.gz" - curl "${g_download_url}" -skLo "${tempfile}" - if [ $? -eq 0 ]; then - tar -zxvf "${tempfile}" -C "${g_bin_dir}" 1>/dev/null - ret=$? + + # curl "${g_download_url}" -skLo "${tempfile}" # internal + # wget $g_github_url -O "${tempfile}" # github + # if [ $? -eq 0 ]; then + # tar -zxvf "${tempfile}" -C "${g_bin_dir}" 1>/dev/null + # ret=$? + # fi + + local source=$1 + if [ "$source" == "internal" ]; then + echo "Downloading from internal source..." + local tempfile="/tmp/dingoadm-$(date +%s%6N).tar.gz" + # Add your internal download logic here + wget --no-check-certificate "${g_download_url}" -O "${tempfile}" # internal + if [ $? -eq 0 ]; then + tar -zxvf "${tempfile}" -C "${g_bin_dir}" 1>/dev/null + ret=$? + fi + elif [ "$source" == "github" ]; then + echo "Downloading from GitHub..." + local tempfile="/tmp/dingoadm" + # Add your GitHub download logic here + wget $g_github_url -O "${tempfile}" # github + if [ $? -eq 0 ]; then + cp "${tempfile}" "${g_bin_dir}/" + ret=$? + fi + else + echo "Invalid source specified. Please choose 'internal' or 'github'." + exit 1 fi # rm "${tempfile}" @@ -111,23 +137,37 @@ print_upgrade_success() { } install() { + local source=$1 backup setup - install_binray + install_binary "$source" set_profile print_install_success } upgrade() { - install_binray + local source=$1 + install_binary "$source" print_upgrade_success } main() { + local source="github" # Default source + for arg in "$@"; do + case $arg in + --source=*) + source="${arg#*=}" + shift + ;; + *) + # Unknown option + ;; + esac + done if [ "${g_upgrade}" == "true" ]; then - upgrade + upgrade "$source" else - install + install "$source" fi }