diff --git a/cli/command/client/enter.go b/cli/command/client/enter.go index ea4ca3b5a..981045310 100644 --- a/cli/command/client/enter.go +++ b/cli/command/client/enter.go @@ -67,5 +67,5 @@ func runEnter(curveadm *cli.CurveAdm, options enterOptions) error { if client.Kind == topology.KIND_CURVEFS { home = "/curvefs/client" } - return tools.AttachRemoteContainer(curveadm, client.Host, client.ContainerId, home) + return tools.AttachRemoteContainer(curveadm, client.Name, client.ContainerId, home) } diff --git a/cli/command/client/install.go b/cli/command/client/install.go index e82783f13..30c19c79c 100644 --- a/cli/command/client/install.go +++ b/cli/command/client/install.go @@ -44,7 +44,7 @@ var ( type installOptions struct { kind string - host string + name string filename string } @@ -77,7 +77,7 @@ func NewInstallCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "local", "Specify install target host") + flags.StringVar(&options.name, "name", "local", "Specify install target name") flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file") return cmd @@ -93,7 +93,7 @@ func genInstallPlaybook(curveadm *cli.CurveAdm, Type: step, Configs: ccs, Options: map[string]interface{}{ - comm.KEY_CLIENT_HOST: options.host, + comm.KEY_CLIENT_NAME: options.name, }, }) } @@ -129,6 +129,6 @@ func runInstall(curveadm *cli.CurveAdm, options installOptions) error { // 4) print success prompt curveadm.WriteOutln("") curveadm.WriteOutln(color.GreenString("Install %s to %s success ^_^"), - options.kind, options.host) + options.kind, options.name) return nil } diff --git a/cli/command/client/map.go b/cli/command/client/map.go index 9cb0b3c53..42aa7d7e5 100644 --- a/cli/command/client/map.go +++ b/cli/command/client/map.go @@ -41,10 +41,10 @@ import ( const ( MAP_EXAMPLE = `Examples: - $ curveadm map user:/volume --host machine1 --create # Map volume which created by automatic - $ curveadm map user:/volume --host machine1 --size=10GiB --create # Map volume which size is 10GiB and created by automatic - $ curveadm map user:/volume --host machine1 --create --poolset ssd # Map volume created by automatic in poolset 'ssd' - $ curveadm map user:/volume --host machine1 -c /path/to/client.yaml # Map volume with specified configure file` + $ curveadm map user:/volume --name machine1 --create # Map volume which created by automatic + $ curveadm map user:/volume --name machine1 --size=10GiB --create # Map volume which size is 10GiB and created by automatic + $ curveadm map user:/volume --name machine1 --create --poolset ssd # Map volume created by automatic in poolset 'ssd' + $ curveadm map user:/volume --name machine1 -c /path/to/client.yaml # Map volume with specified configure file` ) var ( @@ -60,7 +60,7 @@ var ( type mapOptions struct { image string - host string + name string size string create bool filename string @@ -68,7 +68,7 @@ type mapOptions struct { poolset string } -func ParseImage(image string) (user, name string, err error) { +func ParseImage(image string) (user, volumeName string, err error) { items := strings.Split(image, ":") if len(items) != 2 || len(items[0]) == 0 || len(items[1]) == 0 { err = errno.ERR_INVALID_VOLUME_FORMAT. @@ -76,16 +76,16 @@ func ParseImage(image string) (user, name string, err error) { return } - user, name = items[0], items[1] + user, volumeName = items[0], items[1] if user == "root" { err = errno.ERR_ROOT_VOLUME_USER_NOT_ALLOWED. F("volume user: %s", user) - } else if !strings.HasPrefix(name, "/") { + } else if !strings.HasPrefix(volumeName, "/") { err = errno.ERR_VOLUME_NAME_MUST_START_WITH_SLASH_PREFIX. - F("volume name: %s", name) - } else if strings.Contains(name, "_") { + F("volume name: %s", volumeName) + } else if strings.Contains(volumeName, "_") { err = errno.ERR_VOLUME_NAME_CAN_NOT_CONTAIN_UNDERSCORE. - F("volume name: %s", name) + F("volume name: %s", volumeName) } return } @@ -156,7 +156,7 @@ func NewMapCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "localhost", "Specify target host") + flags.StringVar(&options.name, "name", "localhost", "Specify target name") flags.BoolVar(&options.create, "create", false, "Create volume iff not exist") flags.BoolVar(&options.noExclusive, "no-exclusive", false, "Map volume non exclusive") flags.StringVar(&options.size, "size", "10GiB", "Specify volume size") @@ -168,7 +168,7 @@ func NewMapCommand(curveadm *cli.CurveAdm) *cobra.Command { func genMapPlaybook(curveadm *cli.CurveAdm, ccs []*configure.ClientConfig, options mapOptions) (*playbook.Playbook, error) { - user, name, _ := ParseImage(options.image) + user, volumeName, _ := ParseImage(options.image) size, _ := ParseSize(options.size) steps := MAP_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) @@ -181,15 +181,15 @@ func genMapPlaybook(curveadm *cli.CurveAdm, Configs: ccs, Options: map[string]interface{}{ comm.KEY_MAP_OPTIONS: bs.MapOptions{ - Host: options.host, + Name: options.name, User: user, - Volume: name, + Volume: volumeName, Size: size, Create: options.create, NoExclusive: options.noExclusive, Poolset: options.poolset, }, - comm.KEY_CLIENT_HOST: options.host, // for checker + comm.KEY_CLIENT_NAME: options.name, // for checker comm.KEY_CHECK_KERNEL_MODULE_NAME: comm.KERNERL_MODULE_NBD, }, }) @@ -223,6 +223,6 @@ func runMap(curveadm *cli.CurveAdm, options mapOptions) error { // 4) print success prompt curveadm.WriteOutln("") curveadm.WriteOutln(color.GreenString("Map %s to %s nbd device success ^_^"), - options.image, options.host) + options.image, options.name) return nil } diff --git a/cli/command/client/mount.go b/cli/command/client/mount.go index 83cccc862..9d83af396 100644 --- a/cli/command/client/mount.go +++ b/cli/command/client/mount.go @@ -39,8 +39,8 @@ import ( const ( MOUNT_EXAMPLE = `Examples: - $ curveadm mount /s3_001 /path/to/mount --host machine -c client.yaml [--fstype s3] # Mount a s3 CurveFS '/s3_001' to '/path/to/mount' - $ curveadm mount /volume_001 /path/to/mount --host machine -c client.yaml --fstype volume # Mount a volume CurveFS '/volume_001' to '/path/to/mount'` + $ curveadm mount /s3_001 /path/to/mount --name machine -c client.yaml [--fstype s3] # Mount a s3 CurveFS '/s3_001' to '/path/to/mount' + $ curveadm mount /volume_001 /path/to/mount --name machine -c client.yaml --fstype volume # Mount a volume CurveFS '/volume_001' to '/path/to/mount'` ) var ( @@ -53,7 +53,7 @@ var ( ) type mountOptions struct { - host string + name string mountFSName string mountFSType string mountPoint string @@ -91,7 +91,7 @@ func NewMountCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "localhost", "Specify target host") + flags.StringVar(&options.name, "name", "localhost", "Specify target name") flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file") flags.StringVar(&options.mountFSType, "fstype", "s3", "Specify fs data backend") flags.BoolVarP(&options.insecure, "insecure", "k", false, "Mount without precheck") @@ -115,12 +115,12 @@ func genMountPlaybook(curveadm *cli.CurveAdm, Configs: ccs, Options: map[string]interface{}{ comm.KEY_MOUNT_OPTIONS: fs.MountOptions{ - Host: options.host, + Name: options.name, MountFSName: options.mountFSName, MountFSType: options.mountFSType, MountPoint: utils.TrimSuffixRepeat(options.mountPoint, "/"), }, - comm.KEY_CLIENT_HOST: options.host, // for checker + comm.KEY_CLIENT_NAME: options.name, // for checker comm.KEY_CHECK_KERNEL_MODULE_NAME: comm.KERNERL_MODULE_FUSE, }, ExecOptions: playbook.ExecOptions{ @@ -156,6 +156,6 @@ func runMount(curveadm *cli.CurveAdm, options mountOptions) error { // 4) print success prompt curveadm.WriteOutln("") curveadm.WriteOutln(color.GreenString("Mount %s to %s (%s) success ^_^"), - options.mountFSName, options.mountPoint, options.host) + options.mountFSName, options.mountPoint, options.name) return nil } diff --git a/cli/command/client/umount.go b/cli/command/client/umount.go index 86cae9f2b..995a67565 100644 --- a/cli/command/client/umount.go +++ b/cli/command/client/umount.go @@ -43,7 +43,7 @@ var ( ) type umountOptions struct { - host string + name string mountPoint string } @@ -74,7 +74,7 @@ func NewUmountCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "localhost", "Specify target host") + flags.StringVar(&options.name, "name", "localhost", "Specify target name") return cmd } @@ -90,7 +90,7 @@ func genUnmountPlaybook(curveadm *cli.CurveAdm, Configs: nil, Options: map[string]interface{}{ comm.KEY_MOUNT_OPTIONS: fs.MountOptions{ - Host: options.host, + Name: options.name, MountPoint: utils.TrimSuffixRepeat(options.mountPoint, "/"), }, }, diff --git a/cli/command/client/uninstall.go b/cli/command/client/uninstall.go index bcdb1f449..ec2b78821 100644 --- a/cli/command/client/uninstall.go +++ b/cli/command/client/uninstall.go @@ -42,7 +42,7 @@ var ( type uninstallOptions struct { kind string - host string + name string } func checkUninstallOptions(curveadm *cli.CurveAdm, options uninstallOptions) error { @@ -72,7 +72,7 @@ func NewUninstallCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "local", "Specify uninstall target host") + flags.StringVar(&options.name, "name", "local", "Specify uninstall target name") return cmd } @@ -86,7 +86,7 @@ func genUninstallPlaybook(curveadm *cli.CurveAdm, Type: step, Configs: nil, Options: map[string]interface{}{ - comm.KEY_CLIENT_HOST: options.host, + comm.KEY_CLIENT_NAME: options.name, comm.KEY_CLIENT_KIND: options.kind, }, }) @@ -110,6 +110,6 @@ func runUninstall(curveadm *cli.CurveAdm, options uninstallOptions) error { // 4) print success prompt curveadm.WriteOutln("") curveadm.WriteOutln(color.GreenString("UnInstall %s %s success ^_^"), - options.host, options.kind) + options.name, options.kind) return nil } diff --git a/cli/command/client/unmap.go b/cli/command/client/unmap.go index e5e70b092..76b09ee69 100644 --- a/cli/command/client/unmap.go +++ b/cli/command/client/unmap.go @@ -34,7 +34,7 @@ import ( const ( UNMAP_EXAMPLE = `Examples: - $ curveadm unmap user:volume --host machine1 # Unmap volume` + $ curveadm unmap user:volume --name machine1 # Unmap volume` ) var ( @@ -44,7 +44,7 @@ var ( ) type unmapOptions struct { - host string + name string image string } @@ -73,7 +73,7 @@ func NewUnmapCommand(curveadm *cli.CurveAdm) *cobra.Command { } flags := cmd.Flags() - flags.StringVar(&options.host, "host", "localhost", "Specify target host") + flags.StringVar(&options.name, "name", "localhost", "Specify target name") return cmd } @@ -81,7 +81,7 @@ func NewUnmapCommand(curveadm *cli.CurveAdm) *cobra.Command { func genUnmapPlaybook(curveadm *cli.CurveAdm, ccs []*configure.ClientConfig, options unmapOptions) (*playbook.Playbook, error) { - user, name, _ := ParseImage(options.image) + user, volumeName, _ := ParseImage(options.image) steps := UNMAP_PLAYBOOK_STEPS pb := playbook.NewPlaybook(curveadm) for _, step := range steps { @@ -90,9 +90,9 @@ func genUnmapPlaybook(curveadm *cli.CurveAdm, Configs: nil, Options: map[string]interface{}{ comm.KEY_MAP_OPTIONS: bs.MapOptions{ - Host: options.host, + Name: options.name, User: user, - Volume: name, + Volume: volumeName, }, }, }) diff --git a/cli/command/disks/commit.go b/cli/command/disks/commit.go index aec4127cf..35ea15fb2 100644 --- a/cli/command/disks/commit.go +++ b/cli/command/disks/commit.go @@ -39,7 +39,7 @@ import ( ) const ( - HOST_DEVICE_SEP = ":" + NAME_DEVICE_SEP = ":" COMMIT_EXAMPLE = `Examples: $ curveadm disks commit /path/to/disks.yaml # Commit disks` ) @@ -103,9 +103,9 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, serviceMountDevice := 0 // 0: false, 1: true var newDiskRecords, diskRecordDeleteList []storage.Disk for _, dc := range dcs { - for _, host := range dc.GetHost() { + for _, name := range dc.GetName() { device := dc.GetDevice() - key := strings.Join([]string{host, device}, HOST_DEVICE_SEP) + key := strings.Join([]string{name, device}, NAME_DEVICE_SEP) newDiskMap[key] = true if dc.GetServiceMount() { serviceMountDevice = 1 @@ -114,7 +114,7 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, diskUri := comm.DISK_DEFAULT_NULL_URI diskChunkserverId := comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID for _, dr := range oldDiskRecords { - if dr.Host == host && device == dr.Device { + if dr.Name == name && device == dr.Device { diskSize = dr.Size diskUri = dr.URI diskChunkserverId = dr.ChunkServerID @@ -123,7 +123,7 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, } newDiskRecords = append( newDiskRecords, storage.Disk{ - Host: host, + Name: name, Device: device, Size: diskSize, URI: diskUri, @@ -137,7 +137,7 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, } for _, dr := range oldDiskRecords { - key := strings.Join([]string{dr.Host, dr.Device}, HOST_DEVICE_SEP) + key := strings.Join([]string{dr.Name, dr.Device}, NAME_DEVICE_SEP) if _, ok := newDiskMap[key]; !ok { diskRecordDeleteList = append(diskRecordDeleteList, dr) } @@ -148,7 +148,7 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, func writeDiskRecord(dr storage.Disk, curveadm *cli.CurveAdm) error { if err := curveadm.Storage().SetDisk( - dr.Host, + dr.Name, dr.Device, dr.MountPoint, dr.ContainerImage, @@ -195,10 +195,10 @@ func syncDiskRecords(data string, dcs []*disks.DiskConfig, if dr.ChunkServerID != comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID { return errno.ERR_DELETE_SERVICE_BINDING_DISK. F("The disk[%s:%s] is used by service[%s:%s]", - dr.Host, dr.Device, topology.ROLE_CHUNKSERVER, dr.ChunkServerID) + dr.Name, dr.Device, topology.ROLE_CHUNKSERVER, dr.ChunkServerID) } - if err := curveadm.Storage().DeleteDisk(dr.Host, dr.Device); err != nil { + if err := curveadm.Storage().DeleteDisk(dr.Name, dr.Device); err != nil { return errno.ERR_UPDATE_DISK_FAILED.E(err) } } diff --git a/cli/command/disks/list.go b/cli/command/disks/list.go index 53b199ea3..49de3bd89 100644 --- a/cli/command/disks/list.go +++ b/cli/command/disks/list.go @@ -62,7 +62,7 @@ func runList(curveadm *cli.CurveAdm, options listOptions) error { if options.host == "*" { diskRecords = curveadm.DiskRecords() } else { - if diskRecords, err = curveadm.Storage().GetDisk(common.DISK_FILTER_HOST, + if diskRecords, err = curveadm.Storage().GetDisk(common.DISK_FILTER_NAME, options.host); err != nil { return err } diff --git a/cli/command/format.go b/cli/command/format.go index fb907bbbf..fa365d33b 100644 --- a/cli/command/format.go +++ b/cli/command/format.go @@ -229,7 +229,7 @@ func runFormat(curveadm *cli.CurveAdm, options formatOptions) error { containerImage = dr.ContainerImage } disk := fmt.Sprintf("%s:%s:%d", dr.Device, dr.MountPoint, dr.FormatPercent) - fc, err := configure.NewFormatConfig(containerImage, dr.Host, disk) + fc, err := configure.NewFormatConfig(containerImage, dr.Name, disk) if err != nil { return err } @@ -299,7 +299,7 @@ func Format(curveadm *cli.CurveAdm, status bool) (string, error) { containerImage = dr.ContainerImage } disk := fmt.Sprintf("%s:%s:%d", dr.Device, dr.MountPoint, dr.FormatPercent) - fc, err := configure.NewFormatConfig(containerImage, dr.Host, disk) + fc, err := configure.NewFormatConfig(containerImage, dr.Name, disk) if err != nil { return output, err } diff --git a/cli/command/monitor/clean.go b/cli/command/monitor/clean.go index 97bdbe4a8..9d32d4ee2 100644 --- a/cli/command/monitor/clean.go +++ b/cli/command/monitor/clean.go @@ -54,7 +54,7 @@ var ( type cleanOptions struct { id string role string - host string + name string only []string } @@ -75,7 +75,7 @@ func NewCleanCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify monitor service id") flags.StringVar(&options.role, "role", "*", "Specify monitor service role") - flags.StringVar(&options.host, "host", "*", "Specify monitor service host") + flags.StringVar(&options.name, "name", "*", "Specify monitor service name") flags.StringSliceVarP(&options.only, "only", "o", CLEAN_ITEMS, "Specify clean item") return cmd } @@ -86,7 +86,7 @@ func genCleanPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -119,7 +119,7 @@ func runClean(curveadm *cli.CurveAdm, options cleanOptions) error { } // 3) confirm by user - if pass := tui.ConfirmYes(tui.PromptCleanService(options.role, options.host, options.only)); !pass { + if pass := tui.ConfirmYes(tui.PromptCleanService(options.role, options.name, options.only)); !pass { curveadm.WriteOut(tui.PromptCancelOpetation("clean monitor service")) return errno.ERR_CANCEL_OPERATION } diff --git a/cli/command/monitor/reload.go b/cli/command/monitor/reload.go index 9378238a8..303f2dce4 100644 --- a/cli/command/monitor/reload.go +++ b/cli/command/monitor/reload.go @@ -46,7 +46,7 @@ var ( type reloadOptions struct { id string role string - host string + name string } func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { @@ -64,7 +64,7 @@ func NewReloadCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify monitor service id") flags.StringVar(&options.role, "role", "*", "Specify monitor service role") - flags.StringVar(&options.host, "host", "*", "Specify monitor service host") + flags.StringVar(&options.name, "name", "*", "Specify monitor service name") return cmd } @@ -75,7 +75,7 @@ func genReloadPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -117,7 +117,7 @@ func runReload(curveadm *cli.CurveAdm, options reloadOptions) error { } // 3) confirm by user - if pass := tui.ConfirmYes(tui.PromptReloadService(options.id, options.role, options.host)); !pass { + if pass := tui.ConfirmYes(tui.PromptReloadService(options.id, options.role, options.name)); !pass { curveadm.WriteOut(tui.PromptCancelOpetation("reload monitor service")) return errno.ERR_CANCEL_OPERATION } diff --git a/cli/command/monitor/restart.go b/cli/command/monitor/restart.go index b9c76c55b..c3c3471ce 100644 --- a/cli/command/monitor/restart.go +++ b/cli/command/monitor/restart.go @@ -41,7 +41,7 @@ var ( type restartOptions struct { id string role string - host string + name string } func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { @@ -59,7 +59,7 @@ func NewRestartCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify monitor service id") flags.StringVar(&options.role, "role", "*", "Specify monitor service role") - flags.StringVar(&options.host, "host", "*", "Specify monitor service host") + flags.StringVar(&options.name, "name", "*", "Specify monitor service name") return cmd } @@ -70,7 +70,7 @@ func genRestartPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -101,7 +101,7 @@ func runRestart(curveadm *cli.CurveAdm, options restartOptions) error { } // 3) confirm by user - if pass := tui.ConfirmYes(tui.PromptRestartService(options.id, options.role, options.host)); !pass { + if pass := tui.ConfirmYes(tui.PromptRestartService(options.id, options.role, options.name)); !pass { curveadm.WriteOut(tui.PromptCancelOpetation("restart monitor service")) return errno.ERR_CANCEL_OPERATION } diff --git a/cli/command/monitor/start.go b/cli/command/monitor/start.go index b97b7a25f..3830fbcfd 100644 --- a/cli/command/monitor/start.go +++ b/cli/command/monitor/start.go @@ -41,7 +41,7 @@ var ( type startOptions struct { id string role string - host string + name string } func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { @@ -59,7 +59,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify monitor service id") flags.StringVar(&options.role, "role", "*", "Specify monitor service role") - flags.StringVar(&options.host, "host", "*", "Specify monitor service host") + flags.StringVar(&options.name, "name", "*", "Specify monitor service name") return cmd } @@ -70,7 +70,7 @@ func genStartPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -101,7 +101,7 @@ func runStart(curveadm *cli.CurveAdm, options startOptions) error { } // 3) confirm by user - if pass := tui.ConfirmYes(tui.PromptStartService(options.id, options.role, options.host)); !pass { + if pass := tui.ConfirmYes(tui.PromptStartService(options.id, options.role, options.name)); !pass { curveadm.WriteOut(tui.PromptCancelOpetation("start monitor service")) return errno.ERR_CANCEL_OPERATION } diff --git a/cli/command/monitor/status.go b/cli/command/monitor/status.go index 38ce55d58..15dff4642 100644 --- a/cli/command/monitor/status.go +++ b/cli/command/monitor/status.go @@ -44,7 +44,7 @@ var ( type statusOptions struct { id string role string - host string + name string verbose bool } @@ -63,7 +63,7 @@ func NewStatusCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify monitor service id") flags.StringVar(&options.role, "role", "*", "Specify monitor service role") - flags.StringVar(&options.host, "host", "*", "Specify monitor service host") + flags.StringVar(&options.name, "name", "*", "Specify monitor service name") flags.BoolVarP(&options.verbose, "verbose", "v", false, "Verbose output for status") return cmd } @@ -87,7 +87,7 @@ func genStatusPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -145,6 +145,7 @@ func runStatus(curveadm *cli.CurveAdm, options statusOptions) error { // 4) display service status displayStatus(curveadm, mcs, options) + return err } diff --git a/cli/command/monitor/stop.go b/cli/command/monitor/stop.go index 60661ce3a..5ee6ca869 100644 --- a/cli/command/monitor/stop.go +++ b/cli/command/monitor/stop.go @@ -41,7 +41,7 @@ var ( type stopOptions struct { id string role string - host string + name string } func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { @@ -59,7 +59,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { flags := cmd.Flags() flags.StringVar(&options.id, "id", "*", "Specify service id") flags.StringVar(&options.role, "role", "*", "Specify service role") - flags.StringVar(&options.host, "host", "*", "Specify service host") + flags.StringVar(&options.name, "name", "*", "Specify service name") return cmd } @@ -70,7 +70,7 @@ func genStopPlaybook(curveadm *cli.CurveAdm, mcs = configure.FilterMonitorConfig(curveadm, mcs, configure.FilterMonitorOption{ Id: options.id, Role: options.role, - Host: options.host, + Name: options.name, }) if len(mcs) == 0 { return nil, errno.ERR_NO_SERVICES_MATCHED @@ -101,7 +101,7 @@ func runStop(curveadm *cli.CurveAdm, options stopOptions) error { } // 3) confirm by user - pass := tui.ConfirmYes(tui.PromptStopService(options.id, options.role, options.host)) + pass := tui.ConfirmYes(tui.PromptStopService(options.id, options.role, options.name)) if !pass { curveadm.WriteOut(tui.PromptCancelOpetation("stop monitor service")) return errno.ERR_CANCEL_OPERATION diff --git a/cli/command/target/add.go b/cli/command/target/add.go index af5fcd649..fc7a248fd 100644 --- a/cli/command/target/add.go +++ b/cli/command/target/add.go @@ -97,7 +97,7 @@ func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command { func genAddPlaybook(curveadm *cli.CurveAdm, ccs []*configure.ClientConfig, options addOptions) (*playbook.Playbook, error) { - user, name, _ := client.ParseImage(options.image) + user, volumeName, _ := client.ParseImage(options.image) size, _ := client.ParseSize(options.size) blocksize, _ := client.ParseBlockSize(options.blocksize) steps := ADD_PLAYBOOK_STEPS @@ -110,7 +110,7 @@ func genAddPlaybook(curveadm *cli.CurveAdm, comm.KEY_TARGET_OPTIONS: bs.TargetOption{ Host: options.host, User: user, - Volume: name, + Volume: volumeName, Size: size, Blocksize: blocksize, Create: options.create, diff --git a/cli/command/website/clean.go b/cli/command/website/clean.go index 405b30da7..ce1021058 100644 --- a/cli/command/website/clean.go +++ b/cli/command/website/clean.go @@ -110,7 +110,7 @@ func runClean(curveadm *cli.CurveAdm, options cleanOptions) error { } // 3) confirm by user - if pass := tui.ConfirmYes(tui.PromptCleanService(configure.ROLE_WEBSITE, wcs[0].GetHost(), options.only)); !pass { + if pass := tui.ConfirmYes(tui.PromptCleanService(configure.ROLE_WEBSITE, wcs[0].GetName(), options.only)); !pass { curveadm.WriteOut(tui.PromptCancelOpetation("clean website service")) return errno.ERR_CANCEL_OPERATION } diff --git a/internal/common/common.go b/internal/common/common.go index df2b68c5b..c217bdf48 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -56,10 +56,11 @@ const ( DISK_DEFAULT_NULL_CHUNKSERVER_ID = DISK_DEFAULT_NULL_SIZE DISK_FILTER_ALL = "all" DISK_FILTER_HOST = "host" + DISK_FILTER_NAME = "name" DISK_FILTER_DEVICE = "device" DISK_FILTER_MOUNT = "mount" DISK_FILTER_SERVICE = "service" - DISK_EXCLUDE_HOST = "exclude" + DISK_EXCLUDE_NAME = "exclude" DISK_SERVICE_MOUNT_DEVICE = "service_mount_device" DISK_FORMAT_PERCENT = "format_percent" @@ -96,7 +97,7 @@ const ( CLEANED_CONTAINER_ID = "-" // client - KEY_CLIENT_HOST = "CLIENT_HOST" + KEY_CLIENT_NAME = "CLIENT_NAME" KEY_CLIENT_KIND = "CLIENT_KIND" KEY_ALL_CLIENT_STATUS = "ALL_CLIENT_STATUS" KEY_MAP_OPTIONS = "MAP_OPTIONS" diff --git a/internal/configure/disks/dc_get.go b/internal/configure/disks/dc_get.go index bf6b57b10..d1b7339c9 100644 --- a/internal/configure/disks/dc_get.go +++ b/internal/configure/disks/dc_get.go @@ -71,10 +71,20 @@ func (dc *DiskConfig) getStrSlice(i *comm.Item) []string { return v.([]string) } +func (dc *DiskConfig) getName() []string { + res := dc.GetHost() + if len(res) == 0 { + res = dc.getStrSlice(CONFIG_GLOBAL_NAME) + } + + return res +} + func (dc *DiskConfig) GetContainerImage() string { return dc.getString(CONFIG_GLOBAL_CONTAINER_IMAGE) } func (dc *DiskConfig) GetFormatPercent() int { return dc.getInt(CONFIG_GLOBAL_FORMAT_PERCENT) } func (dc *DiskConfig) GetServiceMount() bool { return dc.getBool(CONFIG_GLOBAL_SERVICE_MOUNT_DEVICE) } func (dc *DiskConfig) GetHost() []string { return dc.getStrSlice(CONFIG_GLOBAL_HOST) } +func (dc *DiskConfig) GetName() []string { return dc.getName() } func (dc *DiskConfig) GetDevice() string { return dc.getString(CONFIG_DISK_DEVICE) } func (dc *DiskConfig) GetMountPoint() string { return dc.getString(CONFIG_DISK_MOUNT_POINT) } -func (dc *DiskConfig) GetHostExclude() []string { return dc.getStrSlice(CONFIG_DISK_HOST_EXCLUDE) } +func (dc *DiskConfig) GetNameExclude() []string { return dc.getStrSlice(CONFIG_DISK_NAME_EXCLUDE) } diff --git a/internal/configure/disks/dc_item.go b/internal/configure/disks/dc_item.go index cfe30c36a..182322343 100644 --- a/internal/configure/disks/dc_item.go +++ b/internal/configure/disks/dc_item.go @@ -62,6 +62,13 @@ var ( nil, ) + CONFIG_GLOBAL_NAME = itemset.Insert( + common.DISK_FILTER_NAME, + comm.REQUIRE_STRING_SLICE, + false, + nil, + ) + CONFIG_DISK_DEVICE = itemset.Insert( common.DISK_FILTER_DEVICE, comm.REQUIRE_STRING, @@ -76,8 +83,8 @@ var ( nil, ) - CONFIG_DISK_HOST_EXCLUDE = itemset.Insert( - common.DISK_EXCLUDE_HOST, + CONFIG_DISK_NAME_EXCLUDE = itemset.Insert( + common.DISK_EXCLUDE_NAME, comm.REQUIRE_STRING_SLICE, false, nil, diff --git a/internal/configure/disks/disk_test.go b/internal/configure/disks/disk_test.go index a8ea8067e..f727579f0 100644 --- a/internal/configure/disks/disk_test.go +++ b/internal/configure/disks/disk_test.go @@ -125,10 +125,10 @@ func TestDiskConfigNormal(t *testing.T) { assert.Equal(disks[1].GetFormatPercent(), 95) assert.True(disks[0].GetServiceMount()) assert.False(disks[1].GetServiceMount()) - assert.Equal(len(disks[3].GetHost()), 2) - assert.Equal(len(disks[4].GetHostExclude()), 1) - assert.IsType([]string{}, disks[3].GetHost()) - assert.IsType([]string{}, disks[4].GetHostExclude()) + assert.Equal(len(disks[3].GetName()), 2) + assert.Equal(len(disks[4].GetNameExclude()), 1) + assert.IsType([]string{}, disks[3].GetName()) + assert.IsType([]string{}, disks[4].GetNameExclude()) } func TestDiskConfigInvalidFormatPercent(t *testing.T) { diff --git a/internal/configure/disks/disks.go b/internal/configure/disks/disks.go index 8a46ba63d..b20b12299 100644 --- a/internal/configure/disks/disks.go +++ b/internal/configure/disks/disks.go @@ -68,35 +68,35 @@ func newIfNil(config map[string]interface{}) map[string]interface{} { } func mergeFinalHost(dc *DiskConfig) error { - hostExclude := dc.GetHostExclude() - if len(hostExclude) > 0 { - diskHost := []string{} - hosts := dc.GetHost() - hostMap := utils.Slice2Map(hosts) - hostExcludeMap := utils.Slice2Map(hostExclude) - for _, h := range hosts { - if _, ok := hostExcludeMap[h]; !ok { - diskHost = append(diskHost, h) + nameExclude := dc.GetNameExclude() + if len(nameExclude) > 0 { + diskName := []string{} + names := dc.GetName() + nameMap := utils.Slice2Map(names) + nameExcludeMap := utils.Slice2Map(nameExclude) + for _, n := range names { + if _, ok := nameExcludeMap[n]; !ok { + diskName = append(diskName, n) } } - // check if the host to be excluded is the member of global host list - for _, h := range hostExclude { - if _, ok := hostMap[h]; !ok { + // check if the name to be excluded is the member of global name list + for _, h := range nameExclude { + if _, ok := nameMap[h]; !ok { return errno.ERR_NAME_NOT_FOUND. - F("no such host: %s", h) + F("no such name: %s", h) } } - dc.config[common.DISK_FILTER_HOST] = diskHost + dc.config[common.DISK_FILTER_NAME] = diskName } return nil } func checkDupHost(dc *DiskConfig) error { existHost := map[string]bool{} - for _, h := range dc.GetHost() { + for _, h := range dc.GetName() { if _, ok := existHost[h]; ok { return errno.ERR_DUPLICATE_NAME. - F("duplicated host: %s", h) + F("duplicated name: %s", h) } existHost[h] = true } @@ -121,7 +121,7 @@ func GenDiskURI(proto, uri string) string { func returnInvalidDiskUriError(disk storage.Disk) error { return errno.ERR_INVALID_DISK_URI. - F("The URI[%s] of disk[%s:%s] is invalid", disk.Host, disk.Device, disk.URI) + F("The URI[%s] of disk[%s:%s] is invalid", disk.Name, disk.Device, disk.URI) } func GetDiskId(disk storage.Disk) (diskId, diskUriProto string, err error) { @@ -160,9 +160,9 @@ func (dc *DiskConfig) Build() error { return err } - if len(dc.GetHost()) == 0 { + if len(dc.GetName()) == 0 { return errno.ERR_NAME_FIELD_MISSING. - F("disks[%d].host = []", dc.sequence) + F("disks[%d].name = []", dc.sequence) } else if dc.GetDevice() == "" { return errno.ERR_DEVICE_FIELD_MISSING. F("disks[%d].device = nil", dc.sequence) diff --git a/internal/configure/format.go b/internal/configure/format.go index 7dc7f9140..e5dcebbf3 100644 --- a/internal/configure/format.go +++ b/internal/configure/format.go @@ -35,7 +35,7 @@ const ( ) /* - * host: + * name: * - machine1 * - machine2 * - machine3 @@ -47,7 +47,7 @@ const ( type ( FormatConfig struct { ContainerIamge string - Host string + Name string Device string MountPoint string FormtPercent int @@ -57,12 +57,12 @@ type ( Format struct { ContainerImage string `mapstructure:"container_image"` - Hosts []string `mapstructure:"host"` + Names []string `mapstructure:"name"` Disks []string `mapstructure:"disk"` } ) -func NewFormatConfig(containerImage, host, disk string) (*FormatConfig, error) { +func NewFormatConfig(containerImage, name, disk string) (*FormatConfig, error) { items := strings.Split(disk, ":") if len(items) != 3 { return nil, errno.ERR_INVALID_DISK_FORMAT.S(disk) @@ -88,7 +88,7 @@ func NewFormatConfig(containerImage, host, disk string) (*FormatConfig, error) { return &FormatConfig{ ContainerIamge: containerImage, - Host: host, + Name: name, Device: device, MountPoint: mountPoint, FormtPercent: formatPercent, @@ -121,9 +121,9 @@ func ParseFormat(filename string) ([]*FormatConfig, error) { } fcs := []*FormatConfig{} - for _, host := range format.Hosts { + for _, name := range format.Names { for _, disk := range format.Disks { - fc, err := NewFormatConfig(containerImage, host, disk) + fc, err := NewFormatConfig(containerImage, name, disk) if err != nil { return nil, err } @@ -135,7 +135,7 @@ func ParseFormat(filename string) ([]*FormatConfig, error) { } func (fc *FormatConfig) GetContainerImage() string { return fc.ContainerIamge } -func (fc *FormatConfig) GetHost() string { return fc.Host } +func (fc *FormatConfig) GetName() string { return fc.Name } func (fc *FormatConfig) GetDevice() string { return fc.Device } func (fc *FormatConfig) GetMountPoint() string { return fc.MountPoint } func (fc *FormatConfig) GetFormatPercent() int { return fc.FormtPercent } diff --git a/internal/configure/monitor.go b/internal/configure/monitor.go index 6950d91fc..10284aa1e 100644 --- a/internal/configure/monitor.go +++ b/internal/configure/monitor.go @@ -43,6 +43,7 @@ const ( ROLE_MONITOR_CONF = "monitor_conf" KEY_HOST = "host" + KEY_NAME = "name" KEY_LISTEN_PORT = "listen_port" KEY_RETENTION_TIME = "retention.time" KEY_RETENTION_SIZE = "retention.size" @@ -58,6 +59,7 @@ const ( type monitor struct { Host string `mapstructure:"host"` + Name string `mapstructure:"name"` Container string `mapstructure:"container_image"` NodeExporter map[string]interface{} `mapstructure:"node_exporter"` Prometheus map[string]interface{} `mapstructure:"prometheus"` @@ -68,7 +70,7 @@ type MonitorConfig struct { kind string id string // role_host role string - host string + name string config map[string]interface{} } @@ -80,7 +82,7 @@ type serviceTarget struct { type FilterMonitorOption struct { Id string Role string - Host string + Name string } func (m *MonitorConfig) getString(key string) string { @@ -119,8 +121,8 @@ func (m *MonitorConfig) GetRole() string { return m.role } -func (m *MonitorConfig) GetHost() string { - return m.host +func (m *MonitorConfig) GetName() string { + return m.name } func (m *MonitorConfig) GetNodeIps() []string { @@ -197,6 +199,32 @@ func getHost(c *monitor, role string) string { return h } +func getName(c *monitor, role string) string { + if h := getHost(c, role); h != "" { + return h + } + + n := c.Name + switch role { + case ROLE_NODE_EXPORTER: + if _, ok := c.NodeExporter[KEY_NAME]; ok { + return c.NodeExporter[KEY_NAME].(string) + } + c.NodeExporter[KEY_NAME] = n + case ROLE_PROMETHEUS: + if _, ok := c.Prometheus[KEY_NAME]; ok { + return c.Prometheus[KEY_NAME].(string) + } + c.Prometheus[KEY_NAME] = n + case ROLE_GRAFANA: + if _, ok := c.Grafana[KEY_NAME]; ok { + return c.Grafana[KEY_NAME].(string) + } + c.Grafana[KEY_NAME] = n + } + return n +} + func parsePrometheusTarget(dcs []*topology.DeployConfig) (string, error) { targets := []serviceTarget{} tMap := make(map[string]serviceTarget) @@ -235,7 +263,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.CurveAdm, filename string, data string, ns []string, hostIps []string, dcs []*topology.DeployConfig) ( []*MonitorConfig, error) { parser := viper.NewWithOptions(viper.KeyDelimiter("::")) @@ -286,7 +314,7 @@ func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs } ret := []*MonitorConfig{} for _, role := range roles { - host := getHost(&config, role) + name := getName(&config, role) switch role { case ROLE_PROMETHEUS: target, err := parsePrometheusTarget(dcs) @@ -300,9 +328,9 @@ func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs config.Prometheus[KEY_PROMETHEUS_TARGET] = target ret = append(ret, &MonitorConfig{ kind: mkind, - id: fmt.Sprintf("%s_%s", role, host), + id: fmt.Sprintf("%s_%s", role, name), role: role, - host: host, + name: name, config: config.Prometheus, }) case ROLE_GRAFANA: @@ -312,26 +340,26 @@ func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs } ret = append(ret, &MonitorConfig{ kind: mkind, - id: fmt.Sprintf("%s_%s", role, host), + id: fmt.Sprintf("%s_%s", role, name), role: role, - host: host, + name: name, config: config.Grafana, }, &MonitorConfig{ kind: mkind, - id: fmt.Sprintf("%s_%s", ROLE_MONITOR_CONF, host), + id: fmt.Sprintf("%s_%s", ROLE_MONITOR_CONF, name), role: ROLE_MONITOR_CONF, - host: host, + name: name, config: map[string]interface{}{ KEY_CONTAINER_IMAGE: mconfImage, }, }) case ROLE_NODE_EXPORTER: - for _, h := range hs { + for _, n := range ns { ret = append(ret, &MonitorConfig{ kind: mkind, - id: fmt.Sprintf("%s_%s", role, h), + id: fmt.Sprintf("%s_%s", role, n), role: role, - host: h, + name: n, config: config.NodeExporter, }) } @@ -346,11 +374,11 @@ func FilterMonitorConfig(curveadm *cli.CurveAdm, mcs []*MonitorConfig, for _, mc := range mcs { mcId := mc.GetId() role := mc.GetRole() - host := mc.GetHost() + name := mc.GetName() serviceId := curveadm.GetServiceId(mcId) if (options.Id == "*" || options.Id == serviceId) && (options.Role == "*" || options.Role == role) && - (options.Host == "*" || options.Host == host) { + (options.Name == "*" || options.Name == name) { ret = append(ret, mc) } } diff --git a/internal/configure/topology/topology.go b/internal/configure/topology/topology.go index f3dc9da7a..5f73c2196 100644 --- a/internal/configure/topology/topology.go +++ b/internal/configure/topology/topology.go @@ -26,7 +26,6 @@ package topology import ( "bytes" - "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/utils" "github.com/spf13/viper" diff --git a/internal/configure/website.go b/internal/configure/website.go index add94ac20..359a23716 100644 --- a/internal/configure/website.go +++ b/internal/configure/website.go @@ -38,6 +38,7 @@ const ( type website struct { Kind string `mapstructure:"kind"` Host string `mapstructure:"host"` + Name string `mapstructure:"name"` Config map[string]interface{} `mapstructure:"config"` } @@ -45,7 +46,7 @@ type WebsiteConfig struct { kind string id string // role_host role string - host string + name string config map[string]interface{} } @@ -69,8 +70,8 @@ func (w *WebsiteConfig) GetImage() string { return w.getString(KEY_CONTAINER_IMAGE) } -func (w *WebsiteConfig) GetHost() string { - return w.host +func (w *WebsiteConfig) GetName() string { + return w.name } func (w *WebsiteConfig) GetRole() string { @@ -118,11 +119,14 @@ func ParseWebsiteConfig(filename string) ([]*WebsiteConfig, error) { ret := []*WebsiteConfig{} k := config.Kind - h := config.Host + n := config.Name + if config.Host != "" || n == "" { + n = config.Host + } ret = append(ret, &WebsiteConfig{ kind: k, - host: h, - id: fmt.Sprintf("%s_%s", ROLE_WEBSITE, h), + name: n, + id: fmt.Sprintf("%s_%s", ROLE_WEBSITE, n), role: ROLE_WEBSITE, config: config.Config, }) diff --git a/internal/storage/sql.go b/internal/storage/sql.go index c126ecb5b..0ff81d098 100644 --- a/internal/storage/sql.go +++ b/internal/storage/sql.go @@ -65,7 +65,7 @@ var ( CREATE_DISK_TABLE = ` CREATE TABLE IF NOT EXISTS disk ( id INTEGER PRIMARY KEY AUTOINCREMENT, - host TEXT NOT NULL, + name TEXT NOT NULL, device TEXT NOT NULL, size TEXT NOT NULL, uri TEXT NOT NULL, @@ -111,7 +111,7 @@ var ( CREATE TABLE IF NOT EXISTS clients ( id TEXT PRIMARY KEY, kind TEXT NOT NULL, - host TEXT NOT NULL, + name TEXT NOT NULL, container_id TEXT NOT NULL, aux_info TEXT NOT NULL ) @@ -177,7 +177,7 @@ var ( // disk INSERT_DISK = `INSERT INTO disk( - host, + name, device, size, uri, @@ -194,27 +194,27 @@ var ( lastmodified_time = datetime('now','localtime') WHERE id = ?` SET_DISK_URI = `UPDATE disk SET uri = ?, - lastmodified_time = datetime('now','localtime') WHERE host = ? AND device = ?` + lastmodified_time = datetime('now','localtime') WHERE name = ? AND device = ?` SET_DISK_SIZE = `UPDATE disk SET size = ?, - lastmodified_time = datetime('now','localtime') WHERE host = ? AND device = ?` + lastmodified_time = datetime('now','localtime') WHERE name = ? AND device = ?` SET_DISK_CHUNKSERVER_ID = `UPDATE disk SET chunkserver_id = ?, - lastmodified_time = datetime('now','localtime') WHERE host = ? AND disk_format_mount_point = ?` + lastmodified_time = datetime('now','localtime') WHERE name = ? AND disk_format_mount_point = ?` SELECT_DISK_ALL = `SELECT * FROM disk` - SELECT_DISK_BY_HOST = `SELECT * FROM disk where host = ?` + SELECT_DISK_BY_NAME = `SELECT * FROM disk where name = ?` SELECT_DISK_BY_CHUNKSERVER_ID = `SELECT * FROM disk where chunkserver_id = ?` - SELECT_DISK_BY_DEVICE_PATH = `SELECT * from disk WHERE host = ? AND device = ?` + SELECT_DISK_BY_DEVICE_PATH = `SELECT * from disk WHERE name = ? AND device = ?` - SELECT_DISK_BY_MOUNTPOINT = `SELECT * from disk WHERE host = ? AND disk_format_mount_point = ?` + SELECT_DISK_BY_MOUNTPOINT = `SELECT * from disk WHERE name = ? AND disk_format_mount_point = ?` - DELETE_DISK_HOST = `DELETE from disk WHERE host = ?` + DELETE_DISK_NAME = `DELETE from disk WHERE name = ?` - DELETE_DISK_HOST_DEVICE = `DELETE from disk WHERE host = ? AND device = ?` + DELETE_DISK_NAME_DEVICE = `DELETE from disk WHERE name = ? AND device = ?` // cluster INSERT_CLUSTER = `INSERT INTO clusters(uuid, name, description, topology, pool, create_time) @@ -250,7 +250,7 @@ var ( SET_CONTAINER_ID = `UPDATE containers SET container_id = ? WHERE id = ?` // client - INSERT_CLIENT = `INSERT INTO clients(id, kind, host, container_id, aux_info) VALUES(?, ?, ?, ?, ?)` + INSERT_CLIENT = `INSERT INTO clients(id, kind, name, container_id, aux_info) VALUES(?, ?, ?, ?, ?)` SELECT_CLIENTS = `SELECT * FROM clients` diff --git a/internal/storage/storage.go b/internal/storage/storage.go index ab4591155..0d8bd3f6e 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -53,7 +53,7 @@ type Disks struct { type Disk struct { Id int - Host string + Name string Device string Size string URI string @@ -85,7 +85,7 @@ type Service struct { type Client struct { Id string Kind string - Host string + Name string ContainerId string AuxInfo string } @@ -354,11 +354,11 @@ func (s *Storage) UpdateDiskChunkServerID(host, mountPoint, chunkserverId string return s.execSQL(SET_DISK_CHUNKSERVER_ID, chunkserverId, host, mountPoint) } -func (s *Storage) DeleteDisk(host, device string) error { +func (s *Storage) DeleteDisk(name, device string) error { if len(device) > 0 { - return s.execSQL(DELETE_DISK_HOST_DEVICE, host, device) + return s.execSQL(DELETE_DISK_NAME_DEVICE, name, device) } else { - return s.execSQL(DELETE_DISK_HOST, host) + return s.execSQL(DELETE_DISK_NAME, name) } } @@ -382,7 +382,7 @@ func (s *Storage) CleanDiskChunkServerId(serviceId string) error { for _, disk := range diskRecords { if err := s.UpdateDiskChunkServerID( - disk.Host, + disk.Name, disk.MountPoint, comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID, ); err != nil { @@ -397,8 +397,8 @@ func (s *Storage) GetDisk(filter string, args ...interface{}) ([]Disk, error) { switch filter { case comm.DISK_FILTER_ALL: query = SELECT_DISK_ALL - case comm.DISK_FILTER_HOST: - query = SELECT_DISK_BY_HOST + case comm.DISK_FILTER_NAME: + query = SELECT_DISK_BY_NAME case comm.DISK_FILTER_DEVICE: query = SELECT_DISK_BY_DEVICE_PATH case comm.DISK_FILTER_MOUNT: @@ -422,7 +422,7 @@ func (s *Storage) GetDisk(filter string, args ...interface{}) ([]Disk, error) { for rows.Next() { err = rows.Scan(&disk.Id, - &disk.Host, + &disk.Name, &disk.Device, &disk.Size, &disk.URI, @@ -546,8 +546,8 @@ func (s *Storage) SetContainId(serviceId, containerId string) error { } // client -func (s *Storage) InsertClient(id, kind, host, containerId, auxInfo string) error { - return s.execSQL(INSERT_CLIENT, id, kind, host, containerId, auxInfo) +func (s *Storage) InsertClient(id, kind, name, containerId, auxInfo string) error { + return s.execSQL(INSERT_CLIENT, id, kind, name, containerId, auxInfo) } func (s *Storage) getClients(query string, args ...interface{}) ([]Client, error) { @@ -562,7 +562,7 @@ func (s *Storage) getClients(query string, args ...interface{}) ([]Client, error clients := []Client{} var client Client for rows.Next() { - err = rows.Scan(&client.Id, &client.Kind, &client.Host, &client.ContainerId, &client.AuxInfo) + err = rows.Scan(&client.Id, &client.Kind, &client.Name, &client.ContainerId, &client.AuxInfo) if err != nil { return nil, err } diff --git a/internal/task/task/bs/create_volume.go b/internal/task/task/bs/create_volume.go index 829abb85e..53de6e422 100644 --- a/internal/task/task/bs/create_volume.go +++ b/internal/task/task/bs/create_volume.go @@ -68,7 +68,7 @@ func checkCreateStatus(out *string) step.LambdaType { func NewCreateVolumeTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } diff --git a/internal/task/task/bs/format.go b/internal/task/task/bs/format.go index 0049477e8..350eca59f 100644 --- a/internal/task/task/bs/format.go +++ b/internal/task/task/bs/format.go @@ -225,8 +225,8 @@ func device2ContainerName(device string) string { } func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { - host := fc.GetHost() - hc, err := curveadm.GetHost(host) + name := fc.GetName() + hc, err := curveadm.GetHost(name) if err != nil { return nil, err } @@ -235,8 +235,8 @@ func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConf device := fc.GetDevice() mountPoint := fc.GetMountPoint() usagePercent := fc.GetFormatPercent() - subname := fmt.Sprintf("host=%s device=%s mountPoint=%s usage=%d%%", - fc.GetHost(), device, mountPoint, usagePercent) + subname := fmt.Sprintf("name=%s device=%s mountPoint=%s usage=%d%%", + fc.GetName(), device, mountPoint, usagePercent) t := task.NewTask("Start Format Chunkfile Pool", subname, hc.GetSSHConfig()) // add step to task @@ -292,12 +292,12 @@ func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConf ExecOptions: curveadm.ExecOptions(), }) - // "ServiceMountDevice=false" means write disk UUID into /etc/fstab for host mounting. + // "ServiceMountDevice=false" means write disk UUID into /etc/fstab for name mounting. // "ServiceMountDevice=true" means not to update /etc/fstab, the disk UUID will be wrote // into the config of service(chunkserver) container for disk automatic mounting. if !fc.ServiceMountDevice { t.AddStep(&step2EditFSTab{ - host: host, + host: name, device: device, oldUUID: &oldUUID, mountPoint: mountPoint, @@ -308,7 +308,7 @@ func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConf // update disk size and uri(diskId) when use disk records commited by disks yaml if fc.FromDiskRecord { t.AddStep(&step2UpdateDiskSizeUri{ - host: host, + host: name, device: device, curveadm: curveadm, }) diff --git a/internal/task/task/bs/format_clean.go b/internal/task/task/bs/format_clean.go index 2bff89e86..d59eafb06 100644 --- a/internal/task/task/bs/format_clean.go +++ b/internal/task/task/bs/format_clean.go @@ -67,7 +67,7 @@ func (s *step2FormatClean) Execute(ctx *context.Context) error { } func NewCleanFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { - hc, err := curveadm.GetHost(fc.GetHost()) + hc, err := curveadm.GetHost(fc.GetName()) if err != nil { return nil, err } @@ -77,7 +77,7 @@ func NewCleanFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*ta mountPoint := fc.GetMountPoint() containerName := device2ContainerName(device) subname := fmt.Sprintf("host=%s device=%s mountPoint=%s containerName=%s", - fc.GetHost(), device, mountPoint, containerName) + fc.GetName(), device, mountPoint, containerName) t := task.NewTask("Clean Format Container", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/bs/format_status.go b/internal/task/task/bs/format_status.go index 68b3a3265..372dda9ba 100644 --- a/internal/task/task/bs/format_status.go +++ b/internal/task/task/bs/format_status.go @@ -73,7 +73,7 @@ func setFormatStatus(memStorage *utils.SafeMap, id string, status FormatStatus) */ func (s *step2FormatStatus) Execute(ctx *context.Context) error { config := s.config - host := config.GetHost() + host := config.GetName() device := config.GetDevice() mountPoint := config.GetMountPoint() @@ -113,7 +113,7 @@ func (s *step2FormatStatus) Execute(ctx *context.Context) error { } func NewGetFormatStatusTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { - host := fc.GetHost() + host := fc.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err @@ -121,7 +121,7 @@ func NewGetFormatStatusTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) // new task device := fc.GetDevice() - subname := fmt.Sprintf("host=%s device=%s", fc.GetHost(), fc.GetDevice()) + subname := fmt.Sprintf("host=%s device=%s", fc.GetName(), fc.GetDevice()) t := task.NewTask("Get Format Status", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/bs/format_stop.go b/internal/task/task/bs/format_stop.go index aff2902a4..145d8373e 100644 --- a/internal/task/task/bs/format_stop.go +++ b/internal/task/task/bs/format_stop.go @@ -67,7 +67,7 @@ func (s *stopContainer) Execute(ctx *context.Context) error { } func NewStopFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*task.Task, error) { - host := fc.GetHost() + host := fc.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err @@ -78,7 +78,7 @@ func NewStopFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*tas mountPoint := fc.GetMountPoint() containerName := device2ContainerName(device) subname := fmt.Sprintf("host=%s device=%s mountPoint=%s containerName=%s", - fc.GetHost(), device, mountPoint, containerName) + fc.GetName(), device, mountPoint, containerName) t := task.NewTask("Stop Format Chunkfile Pool", subname, hc.GetSSHConfig()) var oldContainerId string diff --git a/internal/task/task/bs/map.go b/internal/task/task/bs/map.go index adcb0c00c..a48376275 100644 --- a/internal/task/task/bs/map.go +++ b/internal/task/task/bs/map.go @@ -44,7 +44,7 @@ const ( type ( MapOptions struct { - Host string + Name string User string Volume string Create bool @@ -73,7 +73,7 @@ func getMapOptions(options MapOptions) string { func NewMapTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } diff --git a/internal/task/task/bs/start_nebd.go b/internal/task/task/bs/start_nebd.go index d7fdcaccd..c5511ccd8 100644 --- a/internal/task/task/bs/start_nebd.go +++ b/internal/task/task/bs/start_nebd.go @@ -119,7 +119,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { config := s.config curveadm := s.curveadm options := s.options - volumeId := curveadm.GetVolumeId(options.Host, options.User, options.Volume) + volumeId := curveadm.GetVolumeId(options.Name, options.User, options.Volume) auxInfo := &AuxInfo{ User: options.User, @@ -131,7 +131,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { } err = curveadm.Storage().InsertClient(volumeId, config.GetKind(), - options.Host, *s.containerId, string(bytes)) + options.Name, *s.containerId, string(bytes)) if err != nil { return errno.ERR_INSERT_CLIENT_FAILED.E(err) } @@ -140,7 +140,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { func NewStartNEBDServiceTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } @@ -162,7 +162,7 @@ func NewStartNEBDServiceTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) ExecOptions: curveadm.ExecOptions(), }) t.AddStep(&step.Lambda{ - Lambda: checker.CheckEngineInfo(options.Host, curveadm.ExecOptions().ExecWithEngine, &success, &out), + Lambda: checker.CheckEngineInfo(options.Name, curveadm.ExecOptions().ExecWithEngine, &success, &out), }) t.AddStep(&step.ListContainers{ ShowAll: true, diff --git a/internal/task/task/bs/unmap.go b/internal/task/task/bs/unmap.go index 33a596373..d0729fb95 100644 --- a/internal/task/task/bs/unmap.go +++ b/internal/task/task/bs/unmap.go @@ -126,12 +126,12 @@ func (s *step2DeleteClient) Execute(ctx *context.Context) error { func NewUnmapTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MAP_OPTIONS).(MapOptions) - volumeId := curveadm.GetVolumeId(options.Host, options.User, options.Volume) + volumeId := curveadm.GetVolumeId(options.Name, options.User, options.Volume) containerId, err := curveadm.Storage().GetClientContainerId(volumeId) if err != nil { return nil, errno.ERR_GET_CLIENT_CONTAINER_ID_FAILED.E(err) } - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } diff --git a/internal/task/task/checker/date.go b/internal/task/task/checker/date.go index 41a4900aa..f9dcaf487 100644 --- a/internal/task/task/checker/date.go +++ b/internal/task/task/checker/date.go @@ -87,7 +87,7 @@ func NewGetHostDate(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta } subname := fmt.Sprintf("host=%s start=%d", dc.GetHost(), time.Now().Unix()) - t := task.NewTask("Get Host Date ", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Name Date ", subname, hc.GetSSHConfig()) var start int64 var out string @@ -132,7 +132,7 @@ func checkDate(curveadm *cli.CurveAdm) step.LambdaType { } func NewCheckDate(curveadm *cli.CurveAdm, c interface{}) (*task.Task, error) { - t := task.NewTask("Check Host Date ", "", nil) + t := task.NewTask("Check Name 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 7a3c4b36e..ebb9eac30 100644 --- a/internal/task/task/checker/kernel.go +++ b/internal/task/task/checker/kernel.go @@ -123,7 +123,7 @@ func NewCheckKernelVersionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig } func NewCheckKernelModuleTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { - host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) + host := curveadm.MemStorage().Get(comm.KEY_CLIENT_NAME).(string) hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/checker/service.go b/internal/task/task/checker/service.go index 4a9a3af35..d5c7e840c 100644 --- a/internal/task/task/checker/service.go +++ b/internal/task/task/checker/service.go @@ -200,7 +200,7 @@ func NewCheckS3Task(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta } func NewCheckMdsAddressTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { - host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) + host := curveadm.MemStorage().Get(comm.KEY_CLIENT_NAME).(string) hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/common/client_status.go b/internal/task/task/common/client_status.go index 4f7d3a989..ddb2193c4 100644 --- a/internal/task/task/common/client_status.go +++ b/internal/task/task/common/client_status.go @@ -45,7 +45,7 @@ type ( ClientStatus struct { Id string - Host string + Name string Kind string ContainerId string Status string @@ -77,7 +77,7 @@ func (s *step2FormatClientStatus) Execute(ctx *context.Context) error { id := client.Id setClientStatus(s.memStorage, id, ClientStatus{ Id: client.Id, - Host: client.Host, + Name: client.Name, Kind: client.Kind, ContainerId: s.containerId, Status: status, @@ -88,7 +88,7 @@ func (s *step2FormatClientStatus) Execute(ctx *context.Context) error { func NewGetClientStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { client := v.(storage.Client) - hc, err := curveadm.GetHost(client.Host) + hc, err := curveadm.GetHost(client.Name) if err != nil { return nil, err } diff --git a/internal/task/task/common/collect_client.go b/internal/task/task/common/collect_client.go index 5dfbd0dc3..2b2752401 100644 --- a/internal/task/task/common/collect_client.go +++ b/internal/task/task/common/collect_client.go @@ -38,7 +38,7 @@ import ( func NewCollectClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { client := v.(storage.Client) - hc, err := curveadm.GetHost(client.Host) + hc, err := curveadm.GetHost(client.Name) if err != nil { return nil, err } diff --git a/internal/task/task/common/install_client.go b/internal/task/task/common/install_client.go index dcb691b12..a4252f280 100644 --- a/internal/task/task/common/install_client.go +++ b/internal/task/task/common/install_client.go @@ -131,7 +131,7 @@ func getRelease(curveadm *cli.CurveAdm) string { } func NewInstallClientTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { - host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) + host := curveadm.MemStorage().Get(comm.KEY_CLIENT_NAME).(string) hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/common/uninstall_client.go b/internal/task/task/common/uninstall_client.go index ce939832d..bdd0f63c8 100644 --- a/internal/task/task/common/uninstall_client.go +++ b/internal/task/task/common/uninstall_client.go @@ -70,7 +70,7 @@ func (s *step2UninstallPackage) Execute(ctx *context.Context) error { } func NewUninstallClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { - host := curveadm.MemStorage().Get(comm.KEY_CLIENT_HOST).(string) + host := curveadm.MemStorage().Get(comm.KEY_CLIENT_NAME).(string) hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/fs/mount.go b/internal/task/task/fs/mount.go index 26091cb9a..56a7e7510 100644 --- a/internal/task/task/fs/mount.go +++ b/internal/task/task/fs/mount.go @@ -61,7 +61,7 @@ const ( type ( MountOptions struct { - Host string + Name string MountFSName string MountFSType string MountPoint string @@ -277,7 +277,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { config := s.config curveadm := s.curveadm options := s.options - fsId := curveadm.GetFilesystemId(options.Host, options.MountPoint) + fsId := curveadm.GetFilesystemId(options.Name, options.MountPoint) auxInfo := &AuxInfo{ FSName: options.MountFSName, @@ -289,7 +289,7 @@ func (s *step2InsertClient) Execute(ctx *context.Context) error { } err = curveadm.Storage().InsertClient(fsId, config.GetKind(), - options.Host, *s.containerId, string(bytes)) + options.Name, *s.containerId, string(bytes)) if err != nil { return errno.ERR_INSERT_CLIENT_FAILED.E(err) } @@ -309,7 +309,7 @@ func checkStartContainerStatus(success *bool, out *string) step.LambdaType { func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MOUNT_OPTIONS).(MountOptions) - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } @@ -337,7 +337,7 @@ func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.T ExecOptions: curveadm.ExecOptions(), }) t.AddStep(&step.Lambda{ - Lambda: checker.CheckEngineInfo(options.Host, curveadm.ExecOptions().ExecWithEngine, &success, &out), + Lambda: checker.CheckEngineInfo(options.Name, curveadm.ExecOptions().ExecWithEngine, &success, &out), }) t.AddStep(&step.ListContainers{ ShowAll: true, diff --git a/internal/task/task/fs/umount.go b/internal/task/task/fs/umount.go index ea4e55f9a..25db70fb3 100644 --- a/internal/task/task/fs/umount.go +++ b/internal/task/task/fs/umount.go @@ -116,19 +116,19 @@ func (s *step2RemoveContainer) Execute(ctx *context.Context) error { func NewUmountFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { options := curveadm.MemStorage().Get(comm.KEY_MOUNT_OPTIONS).(MountOptions) - fsId := curveadm.GetFilesystemId(options.Host, options.MountPoint) + fsId := curveadm.GetFilesystemId(options.Name, options.MountPoint) containerId, err := curveadm.Storage().GetClientContainerId(fsId) if err != nil { return nil, errno.ERR_GET_CLIENT_CONTAINER_ID_FAILED.E(err) } - hc, err := curveadm.GetHost(options.Host) + hc, err := curveadm.GetHost(options.Name) if err != nil { return nil, err } // new task mountPoint := options.MountPoint - subname := fmt.Sprintf("host=%s mountPoint=%s", options.Host, mountPoint) + subname := fmt.Sprintf("host=%s mountPoint=%s", options.Name, mountPoint) t := task.NewTask("Umount FileSystem", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/monitor/clean_container.go b/internal/task/task/monitor/clean_container.go index 1756be472..8efe8da9d 100644 --- a/internal/task/task/monitor/clean_container.go +++ b/internal/task/task/monitor/clean_container.go @@ -34,7 +34,7 @@ func NewCleanConfigContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorC if role != ROLE_MONITOR_CONF { return nil, nil } - host := cfg.GetHost() + host := cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/monitor/clean_service.go b/internal/task/task/monitor/clean_service.go index 2e7d02fa8..54807a49e 100644 --- a/internal/task/task/monitor/clean_service.go +++ b/internal/task/task/monitor/clean_service.go @@ -64,7 +64,7 @@ func NewCleanMonitorTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( (len(containerId) == 0 || containerId == comm.CLEANED_CONTAINER_ID) { return nil, nil } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } @@ -72,7 +72,7 @@ func NewCleanMonitorTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( // new task only := curveadm.MemStorage().Get(comm.KEY_CLEAN_ITEMS).([]string) subname := fmt.Sprintf("host=%s role=%s containerId=%s clean=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) t := task.NewTask("Clean Monitor", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/monitor/create_container.go b/internal/task/task/monitor/create_container.go index ac8ae9821..5c129b42a 100644 --- a/internal/task/task/monitor/create_container.go +++ b/internal/task/task/monitor/create_container.go @@ -112,7 +112,7 @@ func getEnvironments(cfg *configure.MonitorConfig) []string { } func NewCreateContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { - host := cfg.GetHost() + host := cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/monitor/pull_image.go b/internal/task/task/monitor/pull_image.go index 80883e43d..5e4ceee16 100644 --- a/internal/task/task/monitor/pull_image.go +++ b/internal/task/task/monitor/pull_image.go @@ -33,7 +33,7 @@ import ( func NewPullImageTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*task.Task, error) { image := cfg.GetImage() - host := cfg.GetHost() + host := cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/monitor/restart_service.go b/internal/task/task/monitor/restart_service.go index 25be8d924..248daf266 100644 --- a/internal/task/task/monitor/restart_service.go +++ b/internal/task/task/monitor/restart_service.go @@ -41,20 +41,20 @@ func NewRestartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) } else if err != nil { return nil, err } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Restart Monitor Service", subname, hc.GetSSHConfig()) // add step to task var out string var success bool - host, role := cfg.GetHost(), cfg.GetRole() + host, role := cfg.GetName(), cfg.GetRole() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, diff --git a/internal/task/task/monitor/start_service.go b/internal/task/task/monitor/start_service.go index 7391e1aaf..304456763 100644 --- a/internal/task/task/monitor/start_service.go +++ b/internal/task/task/monitor/start_service.go @@ -51,20 +51,20 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( } else if err != nil { return nil, err } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Start Service", subname, hc.GetSSHConfig()) // add step to task var out string var success bool - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, @@ -83,7 +83,7 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( Lambda: common.WaitContainerStart(3), }) t.AddStep(&common.Step2CheckPostStart{ - Host: cfg.GetHost(), + Host: cfg.GetName(), Role: cfg.GetRole(), ContainerId: containerId, Success: &success, diff --git a/internal/task/task/monitor/status_service.go b/internal/task/task/monitor/status_service.go index 9c9c36323..d85f9670c 100644 --- a/internal/task/task/monitor/status_service.go +++ b/internal/task/task/monitor/status_service.go @@ -53,10 +53,11 @@ type step2FormatMonitorStatus struct { memStorage *utils.SafeMap } +// todo type MonitorStatus struct { Id string Role string - Host string + Name string ContainerId string Ports string Status string @@ -83,7 +84,7 @@ func (s *step2InitMonitorStatus) Execute(ctx *context.Context) error { setMonitorStatus(s.memStorage, id, MonitorStatus{ Id: id, Role: mc.GetRole(), - Host: mc.GetHost(), + Name: mc.GetName(), ContainerId: tui.TrimContainerId(s.containerId), Status: comm.SERVICE_STATUS_UNKNOWN, DataDir: mc.GetDataDir(), @@ -105,7 +106,7 @@ func (s *step2FormatMonitorStatus) Execute(ctx *context.Context) error { setMonitorStatus(s.memStorage, id, MonitorStatus{ Id: id, Role: mc.GetRole(), - Host: mc.GetHost(), + Name: mc.GetName(), ContainerId: tui.TrimContainerId(s.containerId), Ports: *s.ports, Status: status, @@ -125,7 +126,7 @@ func NewInitMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConf } subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Init Monitor Status", subname, nil) t.AddStep(&step2InitMonitorStatus{ @@ -146,14 +147,14 @@ func NewGetMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfi } else if err != nil { return nil, err } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Get Monitor Status", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/monitor/stop_service.go b/internal/task/task/monitor/stop_service.go index 126a5801d..24ccfca54 100644 --- a/internal/task/task/monitor/stop_service.go +++ b/internal/task/task/monitor/stop_service.go @@ -41,19 +41,19 @@ func NewStopServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (* } else if err != nil { return nil, err } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Stop Service", subname, hc.GetSSHConfig()) // add step to task var out string - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, diff --git a/internal/task/task/monitor/sync_config.go b/internal/task/task/monitor/sync_config.go index a82d85892..5ba1ca441 100644 --- a/internal/task/task/monitor/sync_config.go +++ b/internal/task/task/monitor/sync_config.go @@ -63,7 +63,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*t return nil, err } - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err @@ -71,7 +71,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*t // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Sync Config", subname, hc.GetSSHConfig()) // add step to task var out string @@ -83,7 +83,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*t ExecOptions: curveadm.ExecOptions(), }) t.AddStep(&step.Lambda{ - Lambda: common.CheckContainerExist(cfg.GetHost(), cfg.GetRole(), containerId, &out), + Lambda: common.CheckContainerExist(cfg.GetName(), cfg.GetRole(), containerId, &out), }) if role == ROLE_PROMETHEUS { t.AddStep(&step.CreateAndUploadDir{ // prepare prometheus conf path @@ -108,7 +108,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*t ExecOptions: curveadm.ExecOptions(), }) } else if role == ROLE_GRAFANA { - serviceId = curveadm.GetServiceId(fmt.Sprintf("%s_%s", ROLE_MONITOR_CONF, cfg.GetHost())) + serviceId = curveadm.GetServiceId(fmt.Sprintf("%s_%s", ROLE_MONITOR_CONF, cfg.GetName())) confContainerId, err := curveadm.GetContainerId(serviceId) if err != nil { return nil, err diff --git a/internal/task/task/website/clean_service.go b/internal/task/task/website/clean_service.go index 682225488..e44411feb 100644 --- a/internal/task/task/website/clean_service.go +++ b/internal/task/task/website/clean_service.go @@ -53,7 +53,7 @@ func NewCleanWebsiteTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) ( serviceId := curveadm.GetWebsiteServiceId(cfg.GetId()) containerId, _ := curveadm.GetContainerId(serviceId) - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } @@ -61,7 +61,7 @@ func NewCleanWebsiteTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) ( // new task only := curveadm.MemStorage().Get(comm.KEY_CLEAN_ITEMS).([]string) subname := fmt.Sprintf("host=%s role=%s containerId=%s clean=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) t := task.NewTask("Clean Website", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/website/create_container.go b/internal/task/task/website/create_container.go index 4b79ec846..4d87a3936 100644 --- a/internal/task/task/website/create_container.go +++ b/internal/task/task/website/create_container.go @@ -46,7 +46,7 @@ func getMountVolumes(cfg *configure.WebsiteConfig) []step.Volume { } func NewCreateContainerTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (*task.Task, error) { - host := cfg.GetHost() + host := cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/website/pull_image.go b/internal/task/task/website/pull_image.go index d9a4ac35d..519d15c43 100644 --- a/internal/task/task/website/pull_image.go +++ b/internal/task/task/website/pull_image.go @@ -33,7 +33,7 @@ import ( func NewPullImageTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (*task.Task, error) { image := cfg.GetImage() - host := cfg.GetHost() + host := cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err diff --git a/internal/task/task/website/restart_service.go b/internal/task/task/website/restart_service.go index c714bd5e2..66cf5511b 100644 --- a/internal/task/task/website/restart_service.go +++ b/internal/task/task/website/restart_service.go @@ -37,20 +37,20 @@ func NewRestartServiceTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) serviceId := curveadm.GetWebsiteServiceId(cfg.GetId()) containerId, _ := curveadm.GetContainerId(serviceId) - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Restart Website Service", subname, hc.GetSSHConfig()) // add step to task var out string var success bool - host, role := cfg.GetHost(), cfg.GetRole() + host, role := cfg.GetName(), cfg.GetRole() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, diff --git a/internal/task/task/website/start_service.go b/internal/task/task/website/start_service.go index 2c25ba316..aa67e9ac9 100644 --- a/internal/task/task/website/start_service.go +++ b/internal/task/task/website/start_service.go @@ -37,20 +37,20 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) ( serviceId := curveadm.GetWebsiteServiceId(cfg.GetId()) containerId, _ := curveadm.GetContainerId(serviceId) - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Start Website", subname, hc.GetSSHConfig()) // add step to task var out string var success bool - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, @@ -69,7 +69,7 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) ( Lambda: common.WaitContainerStart(3), }) t.AddStep(&common.Step2CheckPostStart{ - Host: cfg.GetHost(), + Host: cfg.GetName(), Role: cfg.GetRole(), ContainerId: containerId, Success: &success, diff --git a/internal/task/task/website/status_service.go b/internal/task/task/website/status_service.go index ff7d38326..a18807d9c 100644 --- a/internal/task/task/website/status_service.go +++ b/internal/task/task/website/status_service.go @@ -53,10 +53,11 @@ type step2FormatWebsiteStatus struct { memStorage *utils.SafeMap } +// todo type WebsiteStatus struct { Id string Role string - Host string + Name string ContainerId string Ports string Status string @@ -84,7 +85,7 @@ func (s *step2InitWebsiteStatus) Execute(ctx *context.Context) error { setWebsiteStatus(s.memStorage, id, WebsiteStatus{ Id: id, Role: wc.GetRole(), - Host: wc.GetHost(), + Name: wc.GetName(), ContainerId: tui.TrimContainerId(s.containerId), Status: comm.SERVICE_STATUS_UNKNOWN, DataDir: wc.GetDataDir(), @@ -107,7 +108,7 @@ func (s *step2FormatWebsiteStatus) Execute(ctx *context.Context) error { setWebsiteStatus(s.memStorage, id, WebsiteStatus{ Id: id, Role: wc.GetRole(), - Host: wc.GetHost(), + Name: wc.GetName(), ContainerId: tui.TrimContainerId(s.containerId), Ports: *s.ports, Status: status, @@ -126,7 +127,7 @@ func NewInitWebsiteStatusTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConf } subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Init Website Status", subname, nil) t.AddStep(&step2InitWebsiteStatus{ @@ -145,14 +146,14 @@ func NewGetWebsiteStatusTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfi if err != nil { return nil, err } - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Get Website Status", subname, hc.GetSSHConfig()) // add step to task diff --git a/internal/task/task/website/stop_service.go b/internal/task/task/website/stop_service.go index a6300b2dc..e7f9b9236 100644 --- a/internal/task/task/website/stop_service.go +++ b/internal/task/task/website/stop_service.go @@ -37,19 +37,19 @@ func NewStopServiceTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (* serviceId := curveadm.GetWebsiteServiceId(cfg.GetId()) containerId, _ := curveadm.GetContainerId(serviceId) - hc, err := curveadm.GetHost(cfg.GetHost()) + hc, err := curveadm.GetHost(cfg.GetName()) if err != nil { return nil, err } // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Stop Website", subname, hc.GetSSHConfig()) // add step to task var out string - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() t.AddStep(&step.ListContainers{ ShowAll: true, Format: `"{{.ID}}"`, diff --git a/internal/task/task/website/sync_config.go b/internal/task/task/website/sync_config.go index ea837f40b..3e13e2730 100644 --- a/internal/task/task/website/sync_config.go +++ b/internal/task/task/website/sync_config.go @@ -61,7 +61,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (*t serviceId := curveadm.GetWebsiteServiceId(cfg.GetId()) containerId, _ := curveadm.GetContainerId(serviceId) - role, host := cfg.GetRole(), cfg.GetHost() + role, host := cfg.GetRole(), cfg.GetName() hc, err := curveadm.GetHost(host) if err != nil { return nil, err @@ -69,7 +69,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (*t // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", - cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) + cfg.GetName(), cfg.GetRole(), tui.TrimContainerId(containerId)) t := task.NewTask("Sync Config", subname, hc.GetSSHConfig()) // add step to task var out string @@ -81,7 +81,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.WebsiteConfig) (*t ExecOptions: curveadm.ExecOptions(), }) t.AddStep(&step.Lambda{ - Lambda: common.CheckContainerExist(cfg.GetHost(), cfg.GetRole(), containerId, &out), + Lambda: common.CheckContainerExist(cfg.GetName(), cfg.GetRole(), containerId, &out), }) if role == configure.ROLE_WEBSITE { t.AddStep(&step.SyncFile{ // sync service config diff --git a/internal/tui/client/status.go b/internal/tui/client/status.go index b61ed0c31..fc888d052 100644 --- a/internal/tui/client/status.go +++ b/internal/tui/client/status.go @@ -43,7 +43,7 @@ func sortStatues(statuses []task.ClientStatus) { sort.Slice(statuses, func(i, j int) bool { s1, s2 := statuses[i], statuses[j] if s1.Kind == s2.Kind { - return s1.Host < s2.Host + return s1.Name < s2.Name } return s1.Kind < s2.Kind }) @@ -56,7 +56,7 @@ func FormatStatus(statuses []task.ClientStatus, verbose bool) string { title := []string{ "Id", "Kind", - "Host", + "Name", "Container Id", "Status", "Aux Info", @@ -71,7 +71,7 @@ func FormatStatus(statuses []task.ClientStatus, verbose bool) string { lines = append(lines, []interface{}{ status.Id, status.Kind, - status.Host, + status.Name, tui.TrimContainerId(status.ContainerId), tui.DecorateMessage{Message: status.Status, Decorate: statusDecorate}, status.AuxInfo, diff --git a/internal/tui/common/prompt.go b/internal/tui/common/prompt.go index 52e8b1588..8235c6fc2 100644 --- a/internal/tui/common/prompt.go +++ b/internal/tui/common/prompt.go @@ -140,47 +140,47 @@ func PromptMigrate() string { return prompt.Build() } -func PromptStartService(id, role, host string) string { +func PromptStartService(id, role, name string) string { prompt := NewPrompt(color.YellowString(PROMPT_COMMON_WARNING) + DEFAULT_CONFIRM_PROMPT) prompt.data["warning"] = "WARNING: service items which matched will start" prompt.data["id"] = id prompt.data["role"] = role - prompt.data["host"] = host + prompt.data["name"] = name return prompt.Build() } -func PromptStopService(id, role, host string) string { +func PromptStopService(id, role, name string) string { prompt := NewPrompt(color.YellowString(PROMPT_COMMON_WARNING) + DEFAULT_CONFIRM_PROMPT) prompt.data["warning"] = "WARNING: stop service may cause client IO be hang" prompt.data["id"] = id prompt.data["role"] = role - prompt.data["host"] = host + prompt.data["name"] = name return prompt.Build() } -func PromptRestartService(id, role, host string) string { +func PromptRestartService(id, role, name string) string { prompt := NewPrompt(color.YellowString(PROMPT_COMMON_WARNING) + DEFAULT_CONFIRM_PROMPT) prompt.data["warning"] = "WARNING: service items which matched will restart" prompt.data["id"] = id prompt.data["role"] = role - prompt.data["host"] = host + prompt.data["name"] = name return prompt.Build() } -func PromptReloadService(id, role, host string) string { +func PromptReloadService(id, role, name string) string { prompt := NewPrompt(color.YellowString(PROMPT_COMMON_WARNING) + DEFAULT_CONFIRM_PROMPT) prompt.data["warning"] = "WARNING: service items which matched will reload" prompt.data["id"] = id prompt.data["role"] = role - prompt.data["host"] = host + prompt.data["name"] = name return prompt.Build() } -func PromptCleanService(role, host string, items []string) string { +func PromptCleanService(role, name string, items []string) string { prompt := NewPrompt(color.YellowString(PROMPT_CLEAN_SERVICE) + DEFAULT_CONFIRM_PROMPT) prompt.data["warning"] = "WARNING: service items which matched will be cleaned up" prompt.data["role"] = role - prompt.data["host"] = host + prompt.data["name"] = name prompt.data["items"] = strings.Join(items, ",") return prompt.Build() } diff --git a/internal/tui/disks.go b/internal/tui/disks.go index f8815ec93..5ef7a8fdb 100644 --- a/internal/tui/disks.go +++ b/internal/tui/disks.go @@ -32,17 +32,17 @@ import ( func SortDiskRecords(diskRecords []storage.Disk) { sort.Slice(diskRecords, func(i, j int) bool { d1, d2 := diskRecords[i], diskRecords[j] - if d1.Host == d2.Host { + if d1.Name == d2.Name { return d1.Device < d2.Device } - return d1.Host < d2.Host + return d1.Name < d2.Name }) } func FormatDisks(diskRecords []storage.Disk) string { lines := [][]interface{}{} title := []string{ - "Host", + "Name", "Device Path", "Device Size", "Device URI", @@ -56,7 +56,7 @@ func FormatDisks(diskRecords []storage.Disk) string { SortDiskRecords(diskRecords) for _, dr := range diskRecords { lines = append(lines, []interface{}{ - dr.Host, + dr.Name, dr.Device, dr.Size, dr.URI, diff --git a/internal/tui/format/status.go b/internal/tui/format/status.go index e628e01ee..6d0ad1b33 100644 --- a/internal/tui/format/status.go +++ b/internal/tui/format/status.go @@ -43,7 +43,7 @@ func FormatStatus(statuses []bs.FormatStatus) string { lines := [][]interface{}{} // title - title := []string{"Host", "Device", "MountPoint", "Formatted", "Status"} + title := []string{"Name", "Device", "MountPoint", "Formatted", "Status"} first, second := tui.FormatTitle(title) lines = append(lines, first) lines = append(lines, second) diff --git a/internal/tui/service/status.go b/internal/tui/service/status.go index 0b16c4c8f..6d1fb9dce 100644 --- a/internal/tui/service/status.go +++ b/internal/tui/service/status.go @@ -213,7 +213,7 @@ func FormatStatus(statuses []task.ServiceStatus, verbose, expand bool) string { title := []string{ "Id", "Role", - "Host", + "Name", "Instances", "Container Id", "Status", @@ -260,7 +260,7 @@ func sortMonitorStatues(statuses []monitor.MonitorStatus) { sort.Slice(statuses, func(i, j int) bool { s1, s2 := statuses[i], statuses[j] if s1.Role == s2.Role { - return s1.Host < s2.Host + return s1.Name < s2.Name } return MONITOT_ROLE_SCORE[s1.Role] < ROLE_SCORE[s2.Role] }) @@ -273,7 +273,7 @@ func FormatMonitorStatus(statuses []monitor.MonitorStatus, verbose bool) string title := []string{ "Id", "Role", - "Host", + "Name", "Container Id", "Status", "Ports", @@ -289,7 +289,7 @@ func FormatMonitorStatus(statuses []monitor.MonitorStatus, verbose bool) string lines = append(lines, []interface{}{ status.Id, status.Role, - status.Host, + status.Name, status.ContainerId, tui.DecorateMessage{Message: status.Status, Decorate: statusDecorate}, utils.Choose(len(status.Ports) == 0, "-", status.Ports), @@ -315,7 +315,7 @@ func FormatWebsiteStatus(statuses []website.WebsiteStatus, verbose bool) string title := []string{ "Id", "Role", - "Host", + "Name", "Container Id", "Status", "Ports", @@ -331,7 +331,7 @@ func FormatWebsiteStatus(statuses []website.WebsiteStatus, verbose bool) string lines = append(lines, []interface{}{ status.Id, status.Role, - status.Host, + status.Name, status.ContainerId, tui.DecorateMessage{Message: status.Status, Decorate: statusDecorate}, utils.Choose(len(status.Ports) == 0, "-", status.Ports), diff --git a/internal/tui/targets.go b/internal/tui/targets.go index 2bda6a389..419d3eb7e 100644 --- a/internal/tui/targets.go +++ b/internal/tui/targets.go @@ -39,7 +39,7 @@ func sortTargets(targets []step.Target) { func FormatTargets(targets []step.Target) string { lines := [][]interface{}{} - title := []string{"Tid", "Host", "Target Name", "Store", "Portal"} + title := []string{"Tid", "Name", "Target Name", "Store", "Portal"} first, second := tuicommon.FormatTitle(title) lines = append(lines, first) lines = append(lines, second) diff --git a/pkg/module/ssh.go b/pkg/module/ssh.go index 8f2d47f79..d7114a8ea 100644 --- a/pkg/module/ssh.go +++ b/pkg/module/ssh.go @@ -55,7 +55,7 @@ type ( ) func askIsHostTrusted(host string, key ssh.PublicKey) bool { - // format := "Unknown Host: %s \\nFingerprint: %s \\nWould you likt to add it?[y/N]: " + // format := "Unknown Name: %s \\nFingerprint: %s \\nWould you likt to add it?[y/N]: " // prompt := fmt.Sprintf(format, host, ssh.FingerprintSHA256(key)) // return tui.ConfirmYes(prompt) return true @@ -65,7 +65,7 @@ func VerifyHost(host string, remote net.Addr, key ssh.PublicKey) error { hostFound, err := goph.CheckKnownHost(host, remote, key, "") /* - * Host in known hosts but key mismatch! + * Name in known hosts but key mismatch! * Maybe because of MAN IN THE MIDDLE ATTACK! */ if hostFound && err != nil {