@@ -18,6 +18,7 @@ package service
18
18
19
19
import (
20
20
"context"
21
+ "errors"
21
22
"fmt"
22
23
"io"
23
24
"time"
@@ -701,80 +702,87 @@ func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequ
701
702
702
703
// ListHosts lists hosts in scheduler.
703
704
func (v * V2 ) ListHosts (ctx context.Context ) (* schedulerv2.ListHostsResponse , error ) {
704
- hosts := v .resource .HostManager ().LoadAll ()
705
-
706
- resHosts := make ([]* commonv2.Host , len (hosts ))
707
- for i , host := range hosts {
708
- resHosts [i ] = & commonv2.Host {
709
- Id : host .ID ,
710
- Type : uint32 (host .Type ),
711
- Hostname : host .Hostname ,
712
- Ip : host .IP ,
713
- Port : host .Port ,
714
- DownloadPort : host .DownloadPort ,
715
- Os : host .OS ,
716
- Platform : host .Platform ,
717
- PlatformFamily : host .PlatformFamily ,
718
- PlatformVersion : host .PlatformVersion ,
719
- KernelVersion : host .KernelVersion ,
720
- Cpu : & commonv2.CPU {
721
- LogicalCount : host .CPU .LogicalCount ,
722
- PhysicalCount : host .CPU .PhysicalCount ,
723
- Percent : host .CPU .Percent ,
724
- ProcessPercent : host .CPU .ProcessPercent ,
725
- Times : & commonv2.CPUTimes {
726
- User : host .CPU .Times .User ,
727
- System : host .CPU .Times .System ,
728
- Idle : host .CPU .Times .Idle ,
729
- Nice : host .CPU .Times .Nice ,
730
- Iowait : host .CPU .Times .Iowait ,
731
- Irq : host .CPU .Times .Irq ,
732
- Softirq : host .CPU .Times .Softirq ,
733
- Steal : host .CPU .Times .Steal ,
734
- Guest : host .CPU .Times .Guest ,
735
- GuestNice : host .CPU .Times .GuestNice ,
736
- },
737
- },
738
- Memory : & commonv2.Memory {
739
- Total : host .Memory .Total ,
740
- Available : host .Memory .Available ,
741
- Used : host .Memory .Used ,
742
- UsedPercent : host .Memory .UsedPercent ,
743
- ProcessUsedPercent : host .Memory .ProcessUsedPercent ,
744
- Free : host .Memory .Free ,
745
- },
746
- Network : & commonv2.Network {
747
- TcpConnectionCount : host .Network .TCPConnectionCount ,
748
- UploadTcpConnectionCount : host .Network .UploadTCPConnectionCount ,
749
- Location : & host .Network .Location ,
750
- Idc : & host .Network .IDC ,
751
- },
752
- Disk : & commonv2.Disk {
753
- Total : host .Disk .Total ,
754
- Free : host .Disk .Free ,
755
- Used : host .Disk .Used ,
756
- UsedPercent : host .Disk .UsedPercent ,
757
- InodesTotal : host .Disk .InodesTotal ,
758
- InodesUsed : host .Disk .InodesUsed ,
759
- InodesFree : host .Disk .InodesFree ,
760
- InodesUsedPercent : host .Disk .InodesUsedPercent ,
761
- },
762
- Build : & commonv2.Build {
763
- GitVersion : host .Build .GitVersion ,
764
- GitCommit : & host .Build .GitCommit ,
765
- GoVersion : & host .Build .GoVersion ,
766
- Platform : & host .Build .Platform ,
767
- },
768
- SchedulerClusterId : host .SchedulerClusterID ,
769
- DisableShared : host .DisableShared ,
770
- }
771
- }
772
-
773
- resp := & schedulerv2.ListHostsResponse {
774
- Hosts : resHosts ,
775
- }
776
-
777
- return resp , nil
705
+ return nil , errors .New ("not implemented" )
706
+ //hosts := v.resource.HostManager().LoadAll()
707
+ //
708
+ ////resHosts := make([]*commonv2.Host, len(hosts))
709
+ ////for i, host := range hosts {
710
+ //// resHosts[i] = &commonv2.Host{
711
+ //// Id: host.ID,
712
+ //// Type: uint32(host.Type),
713
+ //// Hostname: host.Hostname,
714
+ //// Ip: host.IP,
715
+ //// Port: host.Port,
716
+ //// DownloadPort: host.DownloadPort,
717
+ //// Os: host.OS,
718
+ //// Platform: host.Platform,
719
+ //// PlatformFamily: host.PlatformFamily,
720
+ //// PlatformVersion: host.PlatformVersion,
721
+ //// KernelVersion: host.KernelVersion,
722
+ //// Cpu: &commonv2.CPU{
723
+ //// LogicalCount: host.CPU.LogicalCount,
724
+ //// PhysicalCount: host.CPU.PhysicalCount,
725
+ //// Percent: host.CPU.Percent,
726
+ //// ProcessPercent: host.CPU.ProcessPercent,
727
+ //// Times: &commonv2.CPUTimes{
728
+ //// User: host.CPU.Times.User,
729
+ //// System: host.CPU.Times.System,
730
+ //// Idle: host.CPU.Times.Idle,
731
+ //// Nice: host.CPU.Times.Nice,
732
+ //// Iowait: host.CPU.Times.Iowait,
733
+ //// Irq: host.CPU.Times.Irq,
734
+ //// Softirq: host.CPU.Times.Softirq,
735
+ //// Steal: host.CPU.Times.Steal,
736
+ //// Guest: host.CPU.Times.Guest,
737
+ //// GuestNice: host.CPU.Times.GuestNice,
738
+ //// },
739
+ //// },
740
+ //// Memory: &commonv2.Memory{
741
+ //// Total: host.Memory.Total,
742
+ //// Available: host.Memory.Available,
743
+ //// Used: host.Memory.Used,
744
+ //// UsedPercent: host.Memory.UsedPercent,
745
+ //// ProcessUsedPercent: host.Memory.ProcessUsedPercent,
746
+ //// Free: host.Memory.Free,
747
+ //// },
748
+ //// Network: &commonv2.Network{
749
+ //// TcpConnectionCount: host.Network.TCPConnectionCount,
750
+ //// UploadTcpConnectionCount: host.Network.UploadTCPConnectionCount,
751
+ //// Location: &host.Network.Location,
752
+ //// Idc: &host.Network.IDC,
753
+ //// },
754
+ //// Disk: &commonv2.Disk{
755
+ //// Total: host.Disk.Total,
756
+ //// Free: host.Disk.Free,
757
+ //// Used: host.Disk.Used,
758
+ //// UsedPercent: host.Disk.UsedPercent,
759
+ //// InodesTotal: host.Disk.InodesTotal,
760
+ //// InodesUsed: host.Disk.InodesUsed,
761
+ //// InodesFree: host.Disk.InodesFree,
762
+ //// InodesUsedPercent: host.Disk.InodesUsedPercent,
763
+ //// },
764
+ //// Build: &commonv2.Build{
765
+ //// GitVersion: host.Build.GitVersion,
766
+ //// GitCommit: &host.Build.GitCommit,
767
+ //// GoVersion: &host.Build.GoVersion,
768
+ //// Platform: &host.Build.Platform,
769
+ //// },
770
+ //// SchedulerClusterId: host.SchedulerClusterID,
771
+ //// DisableShared: host.DisableShared,
772
+ //// }
773
+ ////}
774
+ //resHosts := []*commonv2.Host{
775
+ // &commonv2.Host{
776
+ // Id: "我自己添加的",
777
+ // Type: uint32(len(hosts)),
778
+ // },
779
+ //}
780
+ //
781
+ //resp := &schedulerv2.ListHostsResponse{
782
+ // Hosts: resHosts,
783
+ //}
784
+ //
785
+ //return resp, nil
778
786
}
779
787
780
788
// DeleteHost releases host in scheduler.
0 commit comments