@@ -699,6 +699,84 @@ func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequ
699
699
return nil
700
700
}
701
701
702
+ // ListHosts lists hosts in scheduler.
703
+ 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
778
+ }
779
+
702
780
// DeleteHost releases host in scheduler.
703
781
func (v * V2 ) DeleteHost (ctx context.Context , req * schedulerv2.DeleteHostRequest ) error {
704
782
log := logger .WithHostID (req .GetHostId ())
0 commit comments