Browse Source

update

tags/v1.22.11.1^2
liuzx 3 years ago
parent
commit
ebc00c2bfa
2 changed files with 23 additions and 9 deletions
  1. +1
    -0
      models/cloudbrain_static.go
  2. +22
    -9
      routers/api/v1/repo/cloudbrain_dashboard.go

+ 1
- 0
models/cloudbrain_static.go View File

@@ -45,6 +45,7 @@ type CardTypeAndNum struct {
}
type ResourceOverview struct {
Cluster string `json:"cluster"`
AiCenterName string `json:"aiCenterName"`
AiCenterCode string `json:"aiCenterCode"`
CardTypeAndNum []CardTypeAndNum `json:"cardTypeAndNum"`
}


+ 22
- 9
routers/api/v1/repo/cloudbrain_dashboard.go View File

@@ -1426,11 +1426,11 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
log.Info("GetCanUseCardInfo err: %v", err)
return
}
// ResourceAiCenterRes, err := models.GetResourceAiCenters()
// if err != nil {
// log.Error("Can not get ResourceAiCenterRes.", err)
// return
// }
ResourceAiCenterRes, err := models.GetResourceAiCenters()
if err != nil {
log.Error("Can not get ResourceAiCenterRes.", err)
return
}
resourceOverviews := []models.ResourceOverview{}
resourceOpenIOne := models.ResourceOverview{}
resourceOpenITwo := models.ResourceOverview{}
@@ -1439,8 +1439,9 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
for _, resourceQueue := range resourceQueues {
if resourceQueue.Cluster == models.OpenICluster {
if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainOne {
resourceOpenIOne.Cluster = models.OpenICluster
resourceOpenIOne.AiCenterCode = models.AICenterOfCloudBrainOne
resourceOpenIOne.Cluster = resourceQueue.Cluster
resourceOpenIOne.AiCenterCode = resourceQueue.AiCenterCode
resourceOpenIOne.AiCenterName = resourceQueue.AiCenterName
cardTypeNum := models.CardTypeAndNum{}
cardTypeNum.CardType = resourceQueue.AccCardType
cardTypeNum.Num = resourceQueue.CardsTotalNum
@@ -1448,8 +1449,9 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
resourceOpenIOne.CardTypeAndNum = append(resourceOpenIOne.CardTypeAndNum, cardTypeNum)
}
if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainTwo {
resourceOpenITwo.Cluster = models.OpenICluster
resourceOpenITwo.AiCenterCode = models.AICenterOfCloudBrainTwo
resourceOpenITwo.Cluster = resourceQueue.Cluster
resourceOpenITwo.AiCenterCode = resourceQueue.AiCenterCode
resourceOpenITwo.AiCenterName = resourceQueue.AiCenterName
cardTypeNum := models.CardTypeAndNum{}
cardTypeNum.CardType = resourceQueue.AccCardType
cardTypeNum.Num = resourceQueue.CardsTotalNum
@@ -1470,6 +1472,17 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
resourceOverviews = append(resourceOverviews, resourceOpenIOne)
resourceOverviews = append(resourceOverviews, resourceOpenITwo)
// resourceOverviews = append(resourceOverviews, resourceChengdu)
for _, resourceAiCenterRes := range ResourceAiCenterRes {
if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainOne {
if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainTwo {
test := models.ResourceOverview{}
test.Cluster = models.C2NetCluster
test.AiCenterCode = resourceAiCenterRes.AiCenterCode
test.AiCenterName = resourceAiCenterRes.AiCenterName
resourceOverviews = append(resourceOverviews, test)
}
}
}

ctx.JSON(http.StatusOK, map[string]interface{}{
"resourceOverviews": resourceOverviews,


Loading…
Cancel
Save