From 3cc16100fa60f947d8f1881923eedb005967c268 Mon Sep 17 00:00:00 2001 From: tzwang Date: Wed, 31 Jan 2024 17:45:14 +0800 Subject: [PATCH] added shuguangai cluster resources function Former-commit-id: 3f03d5c3a29e5e12f399e3da7087ab92e5f802e5 --- api/internal/scheduler/service/aiService.go | 2 +- .../scheduler/strategy/test/strategy_test.go | 4 ++-- api/internal/storeLink/shuguangai.go | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/api/internal/scheduler/service/aiService.go b/api/internal/scheduler/service/aiService.go index 29ab4653..2ea57cec 100644 --- a/api/internal/scheduler/service/aiService.go +++ b/api/internal/scheduler/service/aiService.go @@ -19,7 +19,7 @@ var ( "Hanwuji": OCTOPUS, "Suiyan": OCTOPUS, "Sailingsi": OCTOPUS, - "modelarts-CloudBrain2": MODELARTS, + "Modelarts-CloudBrain2": MODELARTS, "ShuguangAi": SHUGUANGAI, } ) diff --git a/api/internal/scheduler/strategy/test/strategy_test.go b/api/internal/scheduler/strategy/test/strategy_test.go index 53f24cb9..6331d136 100644 --- a/api/internal/scheduler/strategy/test/strategy_test.go +++ b/api/internal/scheduler/strategy/test/strategy_test.go @@ -15,7 +15,7 @@ func TestReplication(t *testing.T) { {Name: "test2", Participant_id: 2}, {Name: "test3", Participant_id: 3}, } - res := []*collector.ResourceSpecs{ + rsc := []*collector.ResourceSpecs{ { ParticipantId: 1, Name: "test1", @@ -47,7 +47,7 @@ func TestReplication(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - params := ¶m.Params{Resources: res} + params := ¶m.Params{Resources: rsc} repl := strategy.NewReplicationStrategy(¶m.ReplicationParams{Params: params, Replicas: tt.replica}) schedule, err := repl.Schedule() if err != nil { diff --git a/api/internal/storeLink/shuguangai.go b/api/internal/storeLink/shuguangai.go index ad84315d..3d027d41 100644 --- a/api/internal/storeLink/shuguangai.go +++ b/api/internal/storeLink/shuguangai.go @@ -22,6 +22,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" + "strconv" "strings" ) @@ -173,6 +174,28 @@ func (o *ShuguangAi) QuerySpecs() (interface{}, error) { } func (o *ShuguangAi) GetResourceSpecs() (*collector.ResourceSpecs, error) { + userReq := &hpcAC.GetUserInfoReq{} + userinfo, err := o.svcCtx.ACRpc.GetUserInfo(o.ctx, userReq) + if err != nil { + return nil, err + } + limitReq := &hpcAC.QueueReq{} + _, err = o.svcCtx.ACRpc.QueryUserQuotasLimit(o.ctx, limitReq) + if err != nil { + return nil, err + } + diskReq := &hpcAC.ParaStorQuotaReq{} + _, err = o.svcCtx.ACRpc.ParaStorQuota(o.ctx, diskReq) + if err != nil { + return nil, err + } + + balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64) + _ = &collector.ResourceSpecs{ + ParticipantId: o.participantId, + Name: o.platform, + Balance: balance, + } return nil, nil }